diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-04 19:05:25 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-04 19:05:25 +0000 |
commit | e09244d463695cd9d2b089794ca18f59f1e4a621 (patch) | |
tree | cea059927b5908df4fc8f98aa2af4163cc3769cb /gm/offsetimagefilter.cpp | |
parent | 707bd60203ba6d89aaa3061efdba09cefd5b5575 (diff) |
Apply the CTM to the offset in the slow SkOffsetImageFilter path.
This was being done in the fast path, but not the slow path.
Since I had to rebaseline the offsetimagefilter GM anyway (to accomodate
the new test case), I added a red border around the intersection
of the (transformed) crop rect and clip rect in each sample, beyond
which no pixels should be drawn.
Chrome bug: https://code.google.com/p/chromium/issues/detail?id=346362
BUG=skia:
R=sugoi@google.com
Review URL: https://codereview.chromium.org/186643003
git-svn-id: http://skia.googlecode.com/svn/trunk@13656 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/offsetimagefilter.cpp')
-rw-r--r-- | gm/offsetimagefilter.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp index 0425311b0a..52d6de9503 100644 --- a/gm/offsetimagefilter.cpp +++ b/gm/offsetimagefilter.cpp @@ -9,7 +9,7 @@ #include "SkOffsetImageFilter.h" #include "SkBitmapSource.h" -#define WIDTH 400 +#define WIDTH 600 #define HEIGHT 100 #define MARGIN 12 @@ -63,14 +63,26 @@ protected: return make_isize(WIDTH, HEIGHT); } - void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint, - SkScalar x, SkScalar y) { + void drawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, const SkPaint& paint, SkScalar scale, const SkIRect& cropRect) { canvas->save(); - canvas->translate(x, y); - canvas->clipRect(SkRect::MakeXYWH(0, 0, - SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); + SkRect clipRect = SkRect::MakeWH( + SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())); + canvas->clipRect(clipRect); + canvas->scale(scale, scale); canvas->drawBitmap(bitmap, 0, 0, &paint); canvas->restore(); + SkPaint strokePaint; + strokePaint.setStyle(SkPaint::kStroke_Style); + strokePaint.setColor(SK_ColorRED); + + // Draw a boundary rect around the intersection of the clip rect + // and crop rect. + SkMatrix scaleMatrix; + scaleMatrix.setScale(scale, scale); + SkRect cropRectFloat; + scaleMatrix.mapRect(&cropRectFloat, SkRect::Make(cropRect)); + clipRect.intersect(cropRectFloat); + canvas->drawRect(clipRect, strokePaint); } virtual void onDraw(SkCanvas* canvas) { @@ -82,7 +94,6 @@ protected: canvas->clear(0x00000000); SkPaint paint; - int x = 0, y = 0; for (int i = 0; i < 4; i++) { SkBitmap* bitmap = (i & 0x01) ? &fCheckerboard : &fBitmap; SkIRect cropRect = SkIRect::MakeXYWH(i * 12, @@ -96,13 +107,16 @@ protected: SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS( SkOffsetImageFilter, (dx, dy, tileInput, &rect))); paint.setImageFilter(filter); - drawClippedBitmap(canvas, *bitmap, paint, SkIntToScalar(x), SkIntToScalar(y)); - x += bitmap->width() + MARGIN; - if (x + bitmap->width() > WIDTH) { - x = 0; - y += bitmap->height() + MARGIN; - } + drawClippedBitmap(canvas, *bitmap, paint, SK_Scalar1, cropRect); + canvas->translate(SkIntToScalar(bitmap->width() + MARGIN), 0); } + + SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100); + SkImageFilter::CropRect rect(SkRect::Make(cropRect)); + SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS( + SkOffsetImageFilter, (SkIntToScalar(-5), SkIntToScalar(-10), NULL, &rect))); + paint.setImageFilter(filter); + drawClippedBitmap(canvas, fBitmap, paint, SkIntToScalar(2), cropRect); } private: typedef GM INHERITED; |