Chromium Code Reviews| 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..467f032a2bd8043d986dea95555ff5a8db4949ee 100644 |
| --- a/gm/imageblurtiled.cpp |
| +++ b/gm/imageresizetiled.cpp |
| @@ -6,23 +6,24 @@ |
| */ |
| #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: |
|
robertphillips
2014/02/19 19:42:01
SK_OVERRIDE on next 3?
Stephen White
2014/02/19 20:32:44
Done.
|
| virtual SkString onShortName() { |
| - return SkString("imageblurtiled"); |
| + return SkString("imageresizetiled"); |
| } |
| virtual SkISize onISize() { |
| @@ -31,15 +32,20 @@ protected: |
| virtual void onDraw(SkCanvas* canvas) { |
| SkPaint paint; |
|
robertphillips
2014/02/19 19:42:01
over length line.
Stephen White
2014/02/19 20:32:44
Done.
|
| - paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref(); |
| - const SkScalar tile_size = SkIntToScalar(128); |
| + paint.setImageFilter(new SkResizeImageFilter(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone_FilterLevel))->unref(); |
| + 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) { |
| + SkRect layerBounds = SkRect::MakeWH(WIDTH, HEIGHT); |
| + 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->saveLayer(NULL, &paint); |
| + canvas->translate(layerBounds.x(), layerBounds.y()); |
| + canvas->scale(SkScalarInvert(RESIZE_FACTOR), |
| + SkScalarInvert(RESIZE_FACTOR)); |
| + canvas->translate(-layerBounds.x(), -layerBounds.y()); |
| + canvas->saveLayer(&layerBounds, &paint); |
| const char* str[] = { |
| "The quick", |
| "brown fox", |
| @@ -62,15 +68,12 @@ protected: |
| } |
| private: |
| - SkScalar fSigmaX; |
| - SkScalar fSigmaY; |
| - |
| typedef GM INHERITED; |
| }; |
| ////////////////////////////////////////////////////////////////////////////// |
|
robertphillips
2014/02/19 19:42:01
DEF_GM?
Stephen White
2014/02/19 20:32:44
Done.
|
| -static GM* MyFactory1(void*) { return new ImageBlurTiledGM(3.0f, 3.0f); } |
| +static GM* MyFactory1(void*) { return new ImageResizeTiledGM(); } |
| static GMRegistry reg1(MyFactory1); |
| } |