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

Unified Diff: gm/tileimagefilter.cpp

Issue 112803004: Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated to ToT Created 6 years, 12 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 | « gm/offsetimagefilter.cpp ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/tileimagefilter.cpp
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index 48d65ca0730b904f404dec533979367c62b14035..2d6160fe8212e506a0f7054702d4afb4b70b6e78 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -31,7 +31,7 @@ protected:
fBitmap.allocPixels();
SkBitmapDevice device(fBitmap);
SkCanvas canvas(&device);
- canvas.clear(0x00000000);
+ canvas.clear(0xFF000000);
SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(0xD000D000);
@@ -67,16 +67,6 @@ protected:
return make_isize(WIDTH, HEIGHT);
}
- void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint,
- SkScalar x, SkScalar y) {
- canvas->save();
- canvas->translate(x, y);
- canvas->clipRect(SkRect::MakeXYWH(0, 0,
- SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())));
- canvas->drawBitmap(bitmap, 0, 0, &paint);
- canvas->restore();
- }
-
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
make_bitmap();
@@ -95,13 +85,16 @@ protected:
SkIntToScalar(bitmap->height()/(i+1)));
SkRect dstRect = SkRect::MakeXYWH(SkIntToScalar(i * 8),
SkIntToScalar(i * 4),
- SkIntToScalar(bitmap->width() - i * 4),
- SkIntToScalar(bitmap->height()) - i * 8);
+ SkIntToScalar(bitmap->width() - i * 12),
+ SkIntToScalar(bitmap->height()) - i * 12);
SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*bitmap)));
SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(
SkTileImageFilter, (srcRect, dstRect, tileInput)));
+ canvas->save();
+ canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
paint.setImageFilter(filter);
- drawClippedBitmap(canvas, *bitmap, paint, SkIntToScalar(x), SkIntToScalar(y));
+ canvas->drawBitmap(fBitmap, 0, 0, &paint);
+ canvas->restore();
x += bitmap->width() + MARGIN;
if (x + bitmap->width() > WIDTH) {
x = 0;
« no previous file with comments | « gm/offsetimagefilter.cpp ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698