Index: gm/imagefilterscropped.cpp |
diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp |
index 4c6ef623561a450834afb2600f1b9f37d50f09b0..745e8984dbdc2b7947770f7bd955f6a4a61fd7ed 100644 |
--- a/gm/imagefilterscropped.cpp |
+++ b/gm/imagefilterscropped.cpp |
@@ -63,6 +63,29 @@ |
paint.setImageFilter(imf); |
canvas->drawBitmap(bm, 0, 0, &paint); |
+} |
+ |
+static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { |
+ SkPaint paint; |
+ |
+ SkIRect bounds; |
+ r.roundOut(&bounds); |
+ |
+ SkBitmap bm; |
+ bm.allocN32Pixels(bounds.width(), bounds.height()); |
+ bm.eraseColor(SK_ColorRED); |
+ SkCanvas c(bm); |
+ |
+ SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44); |
+ paint.setColor(SK_ColorGREEN); |
+ c.drawRect(SkRect::Make(cropRect), paint); |
+ |
+ paint.setImageFilter(imf); |
+ SkPoint loc = { r.fLeft, r.fTop }; |
+ canvas->getTotalMatrix().mapPoints(&loc, 1); |
+ canvas->drawSprite(bm, |
+ SkScalarRoundToInt(loc.fX), SkScalarRoundToInt(loc.fY), |
+ &paint); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -112,7 +135,7 @@ |
virtual void onDraw(SkCanvas* canvas) override { |
void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { |
- draw_bitmap, draw_path, draw_paint, draw_text |
+ draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text |
}; |
SkAutoTUnref<SkColorFilter> cf( |