Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: gm/hairlines.cpp

Issue 796573002: fix for chrome bug with sub pixel hairlines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/hairlines.cpp
diff --git a/gm/hairlines.cpp b/gm/hairlines.cpp
index e017d8b22d6916beae28c5ba94c8f0548baea59c..df67412dfe772699abca111d262eb510b4fd3c45 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);
+ }
}
}
}
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698