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

Unified Diff: gm/imagefiltersclipped.cpp

Issue 1245983002: Run noise shader separately in imagefiltersclipped (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 5 years, 5 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefiltersclipped.cpp
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index cc636aa276453415319b48427fc9e55783fd9bbb..28f3e0bde97a2d0d26959b952d7bf9966bd43e55 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -59,6 +59,25 @@ protected:
canvas.drawCircle(x, y, radius, paint);
}
+ static void draw_clipped_filter(SkCanvas* canvas, SkImageFilter* filter, size_t i,
+ const SkRect& primBounds, const SkRect& clipBounds) {
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ paint.setImageFilter(filter);
+ paint.setAntiAlias(true);
+ canvas->save();
+ canvas->clipRect(clipBounds);
+ if (5 == i) {
+ canvas->translate(SkIntToScalar(16), SkIntToScalar(-32));
+ } else if (6 == i) {
+ canvas->scale(SkScalarInvert(RESIZE_FACTOR_X),
+ SkScalarInvert(RESIZE_FACTOR_Y));
+ }
+ canvas->drawCircle(primBounds.centerX(), primBounds.centerY(),
+ primBounds.width() * 2 / 5, paint);
+ canvas->restore();
+ }
+
void onDraw(SkCanvas* canvas) override {
if (!fInitialized) {
fCheckerboard.allocN32Pixels(64, 64);
@@ -91,7 +110,6 @@ protected:
SkErodeImageFilter::Create(2, 2, checkerboard.get()),
SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
- SkRectShaderImageFilter::Create(noise),
};
SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
@@ -99,33 +117,31 @@ protected:
SkRect bounds = r;
bounds.outset(margin, margin);
+ canvas->save();
for (int xOffset = 0; xOffset < 80; xOffset += 16) {
canvas->save();
bounds.fLeft = SkIntToScalar(xOffset);
for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
- SkPaint paint;
- paint.setColor(SK_ColorWHITE);
- paint.setImageFilter(filters[i]);
- paint.setAntiAlias(true);
- canvas->save();
- canvas->clipRect(bounds);
- if (5 == i) {
- canvas->translate(SkIntToScalar(16), SkIntToScalar(-32));
- } else if (6 == i) {
- canvas->scale(SkScalarInvert(RESIZE_FACTOR_X),
- SkScalarInvert(RESIZE_FACTOR_Y));
- }
- canvas->drawCircle(r.centerX(), r.centerY(), r.width() * 2 / 5, paint);
- canvas->restore();
+ draw_clipped_filter(canvas, filters[i], i, r, bounds);
canvas->translate(r.width() + margin, 0);
}
canvas->restore();
canvas->translate(0, r.height() + margin);
}
+ canvas->restore();
for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
SkSafeUnref(filters[i]);
}
+
+ SkImageFilter* rectFilter = SkRectShaderImageFilter::Create(noise);
+ canvas->translate(SK_ARRAY_COUNT(filters)*(r.width() + margin), 0);
+ for (int xOffset = 0; xOffset < 80; xOffset += 16) {
+ bounds.fLeft = SkIntToScalar(xOffset);
+ draw_clipped_filter(canvas, rectFilter, 0, r, bounds);
+ canvas->translate(0, r.height() + margin);
+ }
+ SkSafeUnref(rectFilter);
}
private:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698