aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/imagealphathreshold.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-12 11:02:25 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-12 11:02:25 -0700
commitaf9b8c804643952d5ff3deed62f1355319b72f72 (patch)
treec62ac7137c52816b7f012d5174f92885f2c5b217 /gm/imagealphathreshold.cpp
parent0a74c9d86c7a2fb32184c109170d1946a2cff02d (diff)
Switch AlphaThresholdFilter over to new onFilterImage interface
This CL also alters the raster path in two ways: it now respects the sRGB/linear distinction of its input it now respects the clip TBR=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1879643003 Review URL: https://codereview.chromium.org/1879643003
Diffstat (limited to 'gm/imagealphathreshold.cpp')
-rw-r--r--gm/imagealphathreshold.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/gm/imagealphathreshold.cpp b/gm/imagealphathreshold.cpp
index fdd93bd210..2b65202c10 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();)
}