aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/imagefiltersbase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gm/imagefiltersbase.cpp')
-rw-r--r--gm/imagefiltersbase.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp
index fbe4681da4..0101a9c2a0 100644
--- a/gm/imagefiltersbase.cpp
+++ b/gm/imagefiltersbase.cpp
@@ -165,6 +165,26 @@ static void draw_bitmap(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
canvas->drawBitmap(bm, 0, 0, &paint);
}
+static void draw_sprite(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) {
+ SkPaint paint;
+ paint.setImageFilter(imf);
+
+ SkIRect bounds;
+ r.roundOut(&bounds);
+
+ SkBitmap bm;
+ bm.allocN32Pixels(bounds.width(), bounds.height());
+ bm.eraseColor(SK_ColorTRANSPARENT);
+ SkCanvas c(bm);
+ draw_path(&c, r, nullptr);
+
+ SkPoint loc = { r.fLeft, r.fTop };
+ canvas->getTotalMatrix().mapPoints(&loc, 1);
+ canvas->drawSprite(bm,
+ SkScalarRoundToInt(loc.fX), SkScalarRoundToInt(loc.fY),
+ &paint);
+}
+
///////////////////////////////////////////////////////////////////////////////
class ImageFiltersBaseGM : public skiagm::GM {
@@ -190,6 +210,7 @@ protected:
draw_paint,
draw_line, draw_rect, draw_path, draw_text,
draw_bitmap,
+ draw_sprite
};
SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED,