Dilate approximated text bounds to squelch recent assertion failure.
authormtklein <mtklein@chromium.org>
Mon, 20 Oct 2014 20:44:24 +0000 (13:44 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 20 Oct 2014 20:44:24 +0000 (13:44 -0700)
This is once again an issue related to logo fonts, so I don't
see any easy way to add a regression test for this.

BUG=424824

Review URL: https://codereview.chromium.org/665103002

src/core/SkRecordDraw.cpp
tests/RecordDrawTest.cpp

index 0c3347ec55c790a95f129dbf485ae91d70cc8ad6..12579e9b658b3a0529d28efbb36295bcb3be1a39 100644 (file)
@@ -473,8 +473,10 @@ private:
 #ifdef SK_DEBUG
         SkRect correct = *rect;
 #endif
-        const SkScalar yPad = 2.0f * paint.getTextSize(),  // In practice, this seems to be enough.
-                       xPad = 4.0f * yPad;                 // Hack for very wide Github logo font.
+        // crbug.com/373785 ~~> xPad = 4x yPad
+        // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x
+        const SkScalar yPad = 2.5f * paint.getTextSize(),
+                       xPad = 4.0f * yPad;
         rect->outset(xPad, yPad);
 #ifdef SK_DEBUG
         SkPaint::FontMetrics metrics;
index 51313de9a9f5438de426f647f717bb0b76e99bf7..0dfd86a8dd19ac8fa3674b1e8af9d641d60a0f6f 100644 (file)
@@ -166,8 +166,8 @@ DEF_TEST(RecordDraw_TextBounds, r) {
     // We can make these next assertions confidently because SkRecordFillBounds
     // builds its bounds by overestimating font metrics in a platform-independent way.
     // If that changes, these tests will need to be more flexible.
-    REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[0].bounds, SkRect::MakeLTRB(-86,  6, 116, 54)));
-    REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[1].bounds, SkRect::MakeLTRB(-56, 26, 156, 94)));
+    REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[0].bounds, SkRect::MakeLTRB(-110,  0, 140, 60)));
+    REPORTER_ASSERT(r, sloppy_rect_eq(bbh.fEntries[1].bounds, SkRect::MakeLTRB(-80, 20, 180, 100)));
 }
 
 // Base test to ensure start/stop range is respected