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

Unified Diff: gm/imagescalealigned.cpp

Issue 1527633002: SkBitmapProcState rounding bias (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: simplified expr Created 5 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 | « no previous file | src/core/SkBitmapProcState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagescalealigned.cpp
diff --git a/gm/imagescalealigned.cpp b/gm/imagescalealigned.cpp
index fbcdafbd85a0dedc75849fd58aa449a9e93e5c22..c9e697cbadf88245514232808065b84fb15c7107 100644
--- a/gm/imagescalealigned.cpp
+++ b/gm/imagescalealigned.cpp
@@ -34,39 +34,29 @@ protected:
}
SkISize onISize() override {
- return SkISize::Make(550, 300);
+ return SkISize::Make(580, 780);
}
void onDraw(SkCanvas* canvas) override {
struct {
SkPoint offset;
- SkScalar scale;
+ SkVector scale;
} cfgs[] = {
- { { 10, 10 }, 1 },
- { { 140.5f, 10 }, 1 },
- { { 10, 80.5f }, 1 },
- { { 140.5f, 80.5f }, 1 },
-
- { { 280.49f, 10.49f }, 1 },
- { { 410.51f, 10.49f }, 1 },
- { { 280.49f, 80.51f }, 1 },
- { { 410.51f, 80.51f }, 1 },
-
- { { 10, 170 }, 1.1f },
- { { 140.5f, 170 }, 1.1f },
- { { 10, 240.5f }, 1.1f },
- { { 140.5f, 240.5f }, 1.1f },
-
- { { 280.49f, 170.49f }, 1.1f },
- { { 410.51f, 170.49f }, 1.1f },
- { { 280.49f, 240.51f }, 1.1f },
- { { 410.51f, 240.51f }, 1.1f },
+ {{ 10, 10 }, { 1, 1 }},
+ {{ 300.5f, 10 }, { 1, 1 }},
+ {{ 10, 200.5f }, { 1, 1 }},
+ {{ 300.5f, 200.5f }, { 1, 1 }},
+
+ {{ 10.5f, 400.5f }, { 1, 1 }},
+ {{ 550.5f, 400.5f }, { -1, 1 }},
+ {{ 10.5f, 750.5f }, { 1, -1 }},
+ {{ 550.5f, 750.5f }, { -1, -1 }},
};
for (size_t i = 0; i < SK_ARRAY_COUNT(cfgs); ++i) {
SkAutoCanvasRestore acr(canvas, true);
canvas->translate(cfgs[i].offset.x(), cfgs[i].offset.y());
- canvas->scale(cfgs[i].scale, cfgs[i].scale);
+ canvas->scale(cfgs[i].scale.x(), cfgs[i].scale.y());
drawSets(canvas);
}
}
@@ -88,6 +78,11 @@ private:
SkPaint paint;
paint.setAntiAlias(true);
+ const SkRect border = SkRect::MakeIWH(kSegLen, kSegLen).makeInset(.5f, .5f);
+ paint.setColor(SK_ColorBLUE);
+ paint.setStyle(SkPaint::kStroke_Style);
+ surface->getCanvas()->drawRect(border, paint);
+
paint.setColor(SK_ColorBLACK);
surface->getCanvas()->drawLine(start.x(), start.y(), end.x(), end.y(), paint);
surface->getCanvas()->drawPoint(start.x(), start.y(), color);
@@ -116,12 +111,12 @@ private:
for (size_t k = 0; k < SK_ARRAY_COUNT(filters); ++k) {
paint.setFilterQuality(filters[k]);
lastPt = drawSet(canvas, set, paint);
- canvas->translate((kSegLen / 2) * set.fVector.y(),
- (kSegLen / 2) * set.fVector.x());
+ canvas->translate((kSegLen + 4) * set.fVector.y(),
+ (kSegLen + 4) * set.fVector.x());
}
}
canvas->translate(lastPt.x() + kSegLen,
- - SkIntToScalar(kSegLen) / 2 * SK_ARRAY_COUNT(filters) * SK_ARRAY_COUNT(AAs));
+ - SkIntToScalar(kSegLen + 4) * SK_ARRAY_COUNT(filters) * SK_ARRAY_COUNT(AAs));
}
}
@@ -143,8 +138,8 @@ private:
return pt;
}
- static const unsigned kSegLen = 9;
- static const unsigned kStretchFactor = 2;
+ static const unsigned kSegLen = 15;
+ static const unsigned kStretchFactor = 4;
SkSTArray<2, ImageSet> fSets;
typedef GM INHERITED;
« no previous file with comments | « no previous file | src/core/SkBitmapProcState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698