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

Unified Diff: gm/imagealphathreshold.cpp

Issue 1879643003: Switch AlphaThresholdFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix serialize-8888 config (deserialize crop rect) Created 4 years, 8 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 | « no previous file | include/core/SkImageFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();)
}
« no previous file with comments | « no previous file | include/core/SkImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698