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

Unified Diff: gm/imagefilters.cpp

Issue 1503143002: add gm to exercise large sigmas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix int-float conversion 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imagefilters.cpp
diff --git a/gm/imagefilters.cpp b/gm/imagefilters.cpp
index 1998014bbf097331396547caeee5a99a0328138d..af2c776ce186e77d8e72b6bb4a0d9d81d984da5e 100644
--- a/gm/imagefilters.cpp
+++ b/gm/imagefilters.cpp
@@ -6,8 +6,11 @@
*/
#include "gm.h"
-#include "SkImageFilter.h"
+#include "SkBlurImageFilter.h"
#include "SkColorMatrixFilter.h"
+#include "SkImage.h"
+#include "SkImageFilter.h"
+#include "SkSurface.h"
/**
* Test drawing a primitive w/ an imagefilter (in this case, just matrix w/ identity) to see
@@ -62,3 +65,41 @@ DEF_SIMPLE_GM(imagefilters_xfermodes, canvas, 480, 480) {
canvas->translate(0, 240);
}
}
+
+static SkImage* make_image(SkCanvas* canvas) {
+ const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
+ SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
+ if (!surface) {
+ surface.reset(SkSurface::NewRaster(info));
+ }
+ surface->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), SkPaint());
+ return surface->newImageSnapshot();
+}
+
+// Compare blurs when we're tightly clipped (fast) and not as tightly (slower)
+//
+// Expect the two to draw the same (modulo the extra border of pixels when the clip is larger)
+//
+DEF_SIMPLE_GM(fast_slow_blurimagefilter, canvas, 620, 260) {
+ SkAutoTUnref<SkImage> image(make_image(canvas));
+ const SkRect r = SkRect::MakeIWH(image->width(), image->height());
+
+ canvas->translate(10, 10);
+ for (SkScalar sigma = 8; sigma <= 128; sigma *= 2) {
+ SkPaint paint;
+ paint.setImageFilter(SkBlurImageFilter::Create(sigma, sigma))->unref();
+
+ canvas->save();
+ // we outset the clip by 1, to fall out of the fast-case in drawImage
+ // i.e. the clip is larger than the image
+ for (SkScalar outset = 0; outset <= 1; ++outset) {
+ canvas->save();
+ canvas->clipRect(r.makeOutset(outset, outset));
+ canvas->drawImage(image, 0, 0, &paint);
+ canvas->restore();
+ canvas->translate(0, r.height() + 20);
+ }
+ canvas->restore();
+ canvas->translate(r.width() + 20, 0);
+ }
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698