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

Unified Diff: gm/imagefiltersbase.cpp

Issue 1529803004: Revert of remove drawSprite from canvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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/dropshadowimagefilter.cpp ('k') | gm/imagefilterscropped.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefiltersbase.cpp
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp
index fbe4681da4276af5aa3a9616649dda78f4e033c1..0101a9c2a042816f2237874ccf1a15da4ea7f2b4 100644
--- a/gm/imagefiltersbase.cpp
+++ b/gm/imagefiltersbase.cpp
@@ -165,6 +165,26 @@
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 @@
draw_paint,
draw_line, draw_rect, draw_path, draw_text,
draw_bitmap,
+ draw_sprite
};
SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED,
« no previous file with comments | « gm/dropshadowimagefilter.cpp ('k') | gm/imagefilterscropped.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698