| Index: gm/imagealphathreshold.cpp
|
| diff --git a/gm/imagealphathreshold.cpp b/gm/imagealphathreshold.cpp
|
| index fdd93bd2105cc1ffa5a02e2fc455be26e4e90ed5..2b65202c1067856228984d1507203aca5f97c344 100644
|
| --- a/gm/imagealphathreshold.cpp
|
| +++ b/gm/imagealphathreshold.cpp
|
| @@ -27,7 +27,7 @@ void draw_rects(SkCanvas* canvas) {
|
| canvas->drawRect(SkRect::MakeXYWH(WIDTH / 2, HEIGHT / 2, WIDTH / 2, HEIGHT / 2), rectPaint);
|
| }
|
|
|
| -SkPaint create_filter_paint() {
|
| +SkPaint create_filter_paint(SkImageFilter::CropRect* cropRect = nullptr) {
|
| SkIRect rects[2];
|
| rects[0] = SkIRect::MakeXYWH(0, 150, WIDTH, HEIGHT - 300);
|
| rects[1] = SkIRect::MakeXYWH(150, 0, WIDTH - 300, HEIGHT);
|
| @@ -35,7 +35,7 @@ SkPaint create_filter_paint() {
|
| region.setRects(rects, 2);
|
|
|
| SkPaint paint;
|
| - paint.setImageFilter(SkAlphaThresholdFilter::Make(region, 0.2f, 0.7f, nullptr));
|
| + paint.setImageFilter(SkAlphaThresholdFilter::Make(region, 0.2f, 0.7f, nullptr, cropRect));
|
| return paint;
|
| }
|
|
|
| @@ -45,13 +45,17 @@ namespace skiagm {
|
|
|
| class ImageAlphaThresholdGM : public GM {
|
| public:
|
| - ImageAlphaThresholdGM() {
|
| + ImageAlphaThresholdGM(bool useCropRect) : fUseCropRect(true) {
|
| this->setBGColor(0xFFFFFFFF);
|
| }
|
|
|
| protected:
|
|
|
| SkString onShortName() override {
|
| + if (fUseCropRect) {
|
| + return SkString("imagealphathreshold_crop");
|
| + }
|
| +
|
| return SkString("imagealphathreshold");
|
| }
|
|
|
| @@ -67,7 +71,10 @@ protected:
|
|
|
| canvas->concat(matrix);
|
|
|
| - SkPaint paint = create_filter_paint();
|
| + SkRect r = SkRect::MakeLTRB(100, 100, WIDTH - 100, HEIGHT - 100);
|
| + SkImageFilter::CropRect cropRect(r);
|
| +
|
| + SkPaint paint = create_filter_paint(fUseCropRect ? &cropRect : nullptr);
|
| canvas->saveLayer(nullptr, &paint);
|
| draw_rects(canvas);
|
|
|
| @@ -75,9 +82,12 @@ protected:
|
| }
|
|
|
| private:
|
| + bool fUseCropRect;
|
| +
|
| typedef GM INHERITED;
|
| };
|
|
|
| +
|
| class ImageAlphaThresholdSurfaceGM : public GM {
|
| public:
|
| ImageAlphaThresholdSurfaceGM() {
|
| @@ -113,7 +123,8 @@ private:
|
|
|
| //////////////////////////////////////////////////////////////////////////////
|
|
|
| -DEF_GM(return new ImageAlphaThresholdGM();)
|
| +DEF_GM(return new ImageAlphaThresholdGM(true);)
|
| +DEF_GM(return new ImageAlphaThresholdGM(false);)
|
| DEF_GM(return new ImageAlphaThresholdSurfaceGM();)
|
|
|
| }
|
|
|