aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/tileimagefilter.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-03 21:48:22 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-03 21:48:22 +0000
commit6776b82d466fa93ccffd251fdf556fe058395444 (patch)
treeeec73f3d3613a5a9dffd40c8f899c73f283749b0 /gm/tileimagefilter.cpp
parent927138977fa256a6719baf74221882555b24008f (diff)
Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent's crop rect. This is required by SVG semantics, and is more sane anyway.
To do this, this patch changes the "offset/loc" parameter in filterImage() / onFilterImage() from an inout-param to an out-param only, so that the calling filter can know how much the input filter wants its result offset (and doesn't include the original primitive position). This offset can then be applied to the current filter's crop rect. (I've renamed the parameter "offset" in all cases to make this clear.) This makes the call sites in SkCanvas/SkGpuDevice responsible for applying the resulting offset to the primitive's position, which is actually a fairly small change. This change also fixes SkTileImageFilter and SkOffsetImageFilter to correctly handle an input offset, which they weren't before. This required modifying the GM's, since they assumed the broken behaviour. NOTE: this will require rebaselining the imagefiltersgraph test, since it has a new test case. NOTE: this will "break" the Blink layout tests css3/filters/effect-reference-subregion-chained-hw.html and css3/filters/effect-reference-subregion-hw.html, but it actually makes them give correct results. It should be suppressed on the skia roll, and I'll rebaseline it. R=reed@google.com Review URL: https://codereview.chromium.org/112803004 git-svn-id: http://skia.googlecode.com/svn/trunk@12895 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/tileimagefilter.cpp')
-rw-r--r--gm/tileimagefilter.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index 48d65ca073..2d6160fe82 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;