summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/skia/src/core/SkBBoxRecord.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/src/core/SkBBoxRecord.cpp')
-rw-r--r--chromium/third_party/skia/src/core/SkBBoxRecord.cpp54
1 files changed, 37 insertions, 17 deletions
diff --git a/chromium/third_party/skia/src/core/SkBBoxRecord.cpp b/chromium/third_party/skia/src/core/SkBBoxRecord.cpp
index cdb70bb7301..a40ea8ba0d2 100644
--- a/chromium/third_party/skia/src/core/SkBBoxRecord.cpp
+++ b/chromium/third_party/skia/src/core/SkBBoxRecord.cpp
@@ -26,6 +26,13 @@ void SkBBoxRecord::drawRect(const SkRect& rect, const SkPaint& paint) {
}
}
+void SkBBoxRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
+ const SkPaint& paint) {
+ if (this->transformBounds(outer.rect(), &paint)) {
+ this->INHERITED::onDrawDRRect(outer, inner, paint);
+ }
+}
+
void SkBBoxRecord::drawPath(const SkPath& path, const SkPaint& paint) {
if (path.isInverseFillType()) {
// If path is inverse filled, use the current clip bounds as the
@@ -43,7 +50,7 @@ void SkBBoxRecord::drawPath(const SkPath& path, const SkPaint& paint) {
void SkBBoxRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) {
SkRect bbox;
- bbox.set(pts, count);
+ bbox.set(pts, SkToInt(count));
// Small min width value, just to ensure hairline point bounding boxes aren't empty.
// Even though we know hairline primitives are drawn one pixel wide, we do not use a
// minimum of 1 because the playback scale factor is unknown at record time. Later
@@ -77,8 +84,8 @@ void SkBBoxRecord::clear(SkColor color) {
INHERITED::clear(color);
}
-void SkBBoxRecord::drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
- const SkPaint& paint) {
+void SkBBoxRecord::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
+ const SkPaint& paint) {
SkRect bbox;
paint.measureText(text, byteLength, &bbox);
SkPaint::FontMetrics metrics;
@@ -121,7 +128,7 @@ void SkBBoxRecord::drawText(const void* text, size_t byteLength, SkScalar x, SkS
bbox.fTop += y;
bbox.fBottom += y;
if (this->transformBounds(bbox, &paint)) {
- INHERITED::drawText(text, byteLength, x, y, paint);
+ INHERITED::onDrawText(text, byteLength, x, y, paint);
}
}
@@ -158,8 +165,20 @@ void SkBBoxRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
}
}
-void SkBBoxRecord::drawPosText(const void* text, size_t byteLength,
- const SkPoint pos[], const SkPaint& paint) {
+// Hack to work-around https://code.google.com/p/chromium/issues/detail?id=373785
+// This logic assums that 'pad' is enough to add to the left and right to account for
+// big glyphs. For the font in question (a logo font) the glyphs is much wider than just
+// the pointsize (approx 3x wider).
+// As a temp work-around, we scale-up pad.
+// A more correct fix might be to add fontmetrics.fMaxX, but we don't have that value in hand
+// at the moment, and (possibly) the value in the font may not be accurate (but who knows).
+//
+static SkScalar hack_373785_amend_pad(SkScalar pad) {
+ return pad * 4;
+}
+
+void SkBBoxRecord::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
+ const SkPaint& paint) {
SkRect bbox;
bbox.set(pos, paint.countText(text, byteLength));
SkPaint::FontMetrics metrics;
@@ -169,16 +188,17 @@ void SkBBoxRecord::drawPosText(const void* text, size_t byteLength,
// pad on left and right by half of max vertical glyph extents
SkScalar pad = (metrics.fTop - metrics.fBottom) / 2;
+ pad = hack_373785_amend_pad(pad);
bbox.fLeft += pad;
bbox.fRight -= pad;
if (this->transformBounds(bbox, &paint)) {
- INHERITED::drawPosText(text, byteLength, pos, paint);
+ INHERITED::onDrawPosText(text, byteLength, pos, paint);
}
}
-void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
- SkScalar constY, const SkPaint& paint) {
+void SkBBoxRecord::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
+ SkScalar constY, const SkPaint& paint) {
size_t numChars = paint.countText(text, byteLength);
if (numChars == 0) {
return;
@@ -205,6 +225,7 @@ void SkBBoxRecord::drawPosTextH(const void* text, size_t byteLength, const SkSca
}
// pad horizontally by max glyph height
+ pad = hack_373785_amend_pad(pad);
bbox.fLeft += pad;
bbox.fRight -= pad;
@@ -228,9 +249,8 @@ void SkBBoxRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
INHERITED::drawSprite(bitmap, left, top, paint);
}
-void SkBBoxRecord::drawTextOnPath(const void* text, size_t byteLength,
- const SkPath& path, const SkMatrix* matrix,
- const SkPaint& paint) {
+void SkBBoxRecord::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
+ const SkMatrix* matrix, const SkPaint& paint) {
SkRect bbox = path.getBounds();
SkPaint::FontMetrics metrics;
paint.getFontMetrics(&metrics);
@@ -243,7 +263,7 @@ void SkBBoxRecord::drawTextOnPath(const void* text, size_t byteLength,
bbox.fBottom -= pad;
if (this->transformBounds(bbox, &paint)) {
- INHERITED::drawTextOnPath(text, byteLength, path, matrix, paint);
+ INHERITED::onDrawTextOnPath(text, byteLength, path, matrix, paint);
}
}
@@ -260,10 +280,10 @@ void SkBBoxRecord::drawVertices(VertexMode mode, int vertexCount,
}
}
-void SkBBoxRecord::drawPicture(SkPicture& picture) {
- if (picture.width() > 0 && picture.height() > 0 &&
- this->transformBounds(SkRect::MakeWH(picture.width(), picture.height()), NULL)) {
- INHERITED::drawPicture(picture);
+void SkBBoxRecord::onDrawPicture(const SkPicture* picture) {
+ if (picture->width() > 0 && picture->height() > 0 &&
+ this->transformBounds(SkRect::MakeWH(picture->width(), picture->height()), NULL)) {
+ this->INHERITED::onDrawPicture(picture);
}
}