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

Unified Diff: gm/imageresizetiled.cpp

Issue 168283006: Fix CTM application in SkResizeImagefilter; implement bounds traversals. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Simplify imageresizetiled GM a tad (layerBounds are useless) Created 6 years, 10 months 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/imagefiltersscaled.cpp ('k') | gyp/gmslides.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/imageresizetiled.cpp
diff --git a/gm/imageblurtiled.cpp b/gm/imageresizetiled.cpp
similarity index 62%
copy from gm/imageblurtiled.cpp
copy to gm/imageresizetiled.cpp
index 96df4367b43d0667b1af7de143b9cef078ff2c6c..a54c811cca05321c81df646a4220cc5ad16311a6 100644
--- a/gm/imageblurtiled.cpp
+++ b/gm/imageresizetiled.cpp
@@ -6,39 +6,44 @@
*/
#include "gm.h"
-#include "SkBlurImageFilter.h"
+#include "SkResizeImageFilter.h"
#include "SkRandom.h"
#define WIDTH 640
#define HEIGHT 480
+#define RESIZE_FACTOR SkIntToScalar(2)
+
namespace skiagm {
-class ImageBlurTiledGM : public GM {
+class ImageResizeTiledGM : public GM {
public:
- ImageBlurTiledGM(SkScalar sigmaX, SkScalar sigmaY)
- : fSigmaX(sigmaX), fSigmaY(sigmaY) {
+ ImageResizeTiledGM() {
}
protected:
- virtual SkString onShortName() {
- return SkString("imageblurtiled");
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("imageresizetiled");
}
- virtual SkISize onISize() {
+ virtual SkISize onISize() SK_OVERRIDE {
return make_isize(WIDTH, HEIGHT);
}
- virtual void onDraw(SkCanvas* canvas) {
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
- paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref();
- const SkScalar tile_size = SkIntToScalar(128);
+ SkAutoTUnref<SkImageFilter> imageFilter(
+ new SkResizeImageFilter(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone_FilterLevel));
+ paint.setImageFilter(imageFilter.get());
+ const SkScalar tile_size = SkIntToScalar(100);
SkRect bounds;
canvas->getClipBounds(&bounds);
- for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tile_size) {
- for (SkScalar x = bounds.left(); x < bounds.right(); x += tile_size) {
+ for (SkScalar y = 0; y < HEIGHT; y += tile_size) {
+ for (SkScalar x = 0; x < WIDTH; x += tile_size) {
canvas->save();
canvas->clipRect(SkRect::MakeXYWH(x, y, tile_size, tile_size));
+ canvas->scale(SkScalarInvert(RESIZE_FACTOR),
+ SkScalarInvert(RESIZE_FACTOR));
canvas->saveLayer(NULL, &paint);
const char* str[] = {
"The quick",
@@ -62,15 +67,11 @@ protected:
}
private:
- SkScalar fSigmaX;
- SkScalar fSigmaY;
-
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
-static GM* MyFactory1(void*) { return new ImageBlurTiledGM(3.0f, 3.0f); }
-static GMRegistry reg1(MyFactory1);
+DEF_GM(return new ImageResizeTiledGM(); )
}
« no previous file with comments | « gm/imagefiltersscaled.cpp ('k') | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698