aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/hairlines.cpp
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-12-10 14:23:40 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-10 14:23:40 -0800
commitbd528cdb51c4a64c2daead66f152b4034cebf752 (patch)
tree1591b9853e3f971dd9990ac8afdfbdf3c880fc47 /gm/hairlines.cpp
parentb2fe5407df616e00e41d380393673136d8f9f1e7 (diff)
fix for chrome bug with sub pixel hairlines
Diffstat (limited to 'gm/hairlines.cpp')
-rw-r--r--gm/hairlines.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/gm/hairlines.cpp b/gm/hairlines.cpp
index e017d8b22d..df67412dfe 100644
--- a/gm/hairlines.cpp
+++ b/gm/hairlines.cpp
@@ -22,7 +22,7 @@ protected:
return SkString("hairlines");
}
- virtual SkISize onISize() { return SkISize::Make(800, 600); }
+ virtual SkISize onISize() { return SkISize::Make(1250, 1250); }
virtual void onOnceBeforeDraw() SK_OVERRIDE {
{
@@ -166,6 +166,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 };
+ static const SkScalar kWidths[] = { 0, 0.5f, 1.5f };
enum {
kMargin = 5,
@@ -180,32 +181,34 @@ protected:
for (int p = 0; p < fPaths.count(); ++p) {
for (size_t a = 0; a < SK_ARRAY_COUNT(kAlphaValue); ++a) {
for (int aa = 0; aa < 2; ++aa) {
- const SkRect& bounds = fPaths[p].getBounds();
+ for (size_t w = 0; w < SK_ARRAY_COUNT(kWidths); w++) {
+ const SkRect& bounds = fPaths[p].getBounds();
+
+ if (x + bounds.width() > wrapX) {
+ canvas->restore();
+ canvas->translate(0, maxH + SkIntToScalar(kMargin));
+ canvas->save();
+ maxH = 0;
+ x = SkIntToScalar(kMargin);
+ }
+
+ SkPaint paint;
+ paint.setARGB(kAlphaValue[a], 0, 0, 0);
+ paint.setAntiAlias(SkToBool(aa));
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(kWidths[w]);
- if (x + bounds.width() > wrapX) {
- canvas->restore();
- canvas->translate(0, maxH + SkIntToScalar(kMargin));
canvas->save();
- maxH = 0;
- x = SkIntToScalar(kMargin);
- }
-
- SkPaint paint;
- paint.setARGB(kAlphaValue[a], 0, 0, 0);
- paint.setAntiAlias(SkToBool(aa));
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(0);
-
- canvas->save();
- canvas->translate(-bounds.fLeft, -bounds.fTop);
- canvas->drawPath(fPaths[p], paint);
- canvas->restore();
+ canvas->translate(-bounds.fLeft, -bounds.fTop);
+ canvas->drawPath(fPaths[p], paint);
+ canvas->restore();
- maxH = SkMaxScalar(maxH, bounds.height());
+ maxH = SkMaxScalar(maxH, bounds.height());
- SkScalar dx = bounds.width() + SkIntToScalar(kMargin);
- x += dx;
- canvas->translate(dx, 0);
+ SkScalar dx = bounds.width() + SkIntToScalar(kMargin);
+ x += dx;
+ canvas->translate(dx, 0);
+ }
}
}
}