Chromium Code Reviews| Index: gm/imageblurtiled2.cpp |
| diff --git a/gm/imageblurtiled2.cpp b/gm/imageblurtiled2.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..82d148d795562d2e5c020555e1535d87c998c488 |
| --- /dev/null |
| +++ b/gm/imageblurtiled2.cpp |
| @@ -0,0 +1,62 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "gm.h" |
| +#include "SkDropShadowImageFilter.h" |
| +#include "SkPictureRecorder.h" |
| + |
| +#define TILE 128 |
| +#define WIDTH 200 |
| +#define HEIGHT 400 |
| +#define DX 4 |
| +#define DY 4 |
| +#define SIGMA 3 |
| +#define OFFSET (WIDTH + 10) |
| + |
| +// This GM is a regression test for http://skbug.com/2957 and http://crbug.com/415468. |
|
robertphillips
2014/09/23 16:36:38
// It draws a clipped rect in a layer which, in tu
|
| +struct ImageBlurTiled2GM : public skiagm::GM { |
|
robertphillips
2014/09/23 16:36:38
SK_OVERRIDE on these two ?
|
| + virtual SkString onShortName() { return SkString("imageblurtiled2"); } |
|
Stephen White
2014/09/23 16:03:51
Nit: this GM should probably be renamed dropshadow
mtklein
2014/09/23 17:43:13
Very good idea. Done.
|
| + virtual SkISize onISize() { |
| + return SkISize::Make(WIDTH + OFFSET + DX + 3 * SIGMA, HEIGHT + DY + 3 * SIGMA); |
| + } |
| + |
|
robertphillips
2014/09/23 16:36:38
Just make this "const SkPicture* create_picture();
|
| + void drawInto(SkCanvas* canvas) const { |
| + SkPaint layerPaint; |
| + layerPaint.setImageFilter( |
| + SkDropShadowImageFilter::Create(OFFSET, DX, DY, SIGMA, SK_ColorBLACK))->unref(); |
| + |
| + SkPaint green; |
| + green.setColor(SK_ColorGREEN); |
| + |
| + canvas->saveLayer(NULL, &layerPaint); |
| + canvas->clipRect(SkRect::MakeWH(WIDTH, HEIGHT)); |
| + canvas->drawRect(SkRect::MakeWH(WIDTH, HEIGHT), green); |
| + canvas->restore(); |
| + } |
| + |
|
robertphillips
2014/09/23 16:36:38
SK_OVERRIDE ?
|
| + virtual void onDraw(SkCanvas* canvas) { |
| + SkPictureRecorder recorder; |
| + const SkTileGridFactory::TileGridInfo info = { { TILE, TILE }, {0, 0}, {0, 0} }; |
| + SkTileGridFactory factory(info); |
| + |
| + this->drawInto(recorder.beginRecording(WIDTH + OFFSET, HEIGHT, &factory)); |
| + SkAutoTUnref<const SkPicture> pic(recorder.endRecording()); |
| + |
| + SkRect bounds = { 0, 0, 0, 0 }; |
| + SkAssertResult(canvas->getClipBounds(&bounds)); |
| + |
| + for (SkScalar y = bounds.top() ; y < bounds.bottom(); y += TILE) { |
|
robertphillips
2014/09/23 16:36:38
indent here?
|
| + for (SkScalar x = bounds.left(); x < bounds.right() ; x += TILE) { |
| + canvas->save(); |
| + canvas->clipRect(SkRect::MakeXYWH(x, y, TILE, TILE)); |
| + canvas->drawPicture(pic); |
| + canvas->restore(); |
| + } |
| + } |
| + } |
|
robertphillips
2014/09/23 16:36:38
private:
typedef GM INHERITED;
?
|
| +}; |
|
robertphillips
2014/09/23 16:36:38
virtual uint32_t onGetFlags() const SK_OVERRIDE {
|
| +DEF_GM(return new ImageBlurTiled2GM); |