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

Unified Diff: gm/offsetimagefilter.cpp

Issue 1204723002: add simple test for offsetimagefilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/offsetimagefilter.cpp
diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp
index 258403ee79d2572902fb42946649f1cf0387b51f..6519f0a45a95924c20105ed96592574f39e64ad6 100644
--- a/gm/offsetimagefilter.cpp
+++ b/gm/offsetimagefilter.cpp
@@ -105,3 +105,66 @@ DEF_GM( return new OffsetImageFilterGM; )
//////////////////////////////////////////////////////////////////////////////
+class SimpleOffsetImageFilterGM : public skiagm::GM {
+public:
+ SimpleOffsetImageFilterGM() {}
+
+protected:
+ SkString onShortName() override {
+ return SkString("simple-offsetimagefilter");
+ }
+
+ SkISize onISize() override { return SkISize::Make(140, 60); }
+
+ void doDraw(SkCanvas* canvas, const SkRect& r, SkImageFilter* imgf,
+ const SkRect* clipR = NULL) {
+ SkPaint p;
+
+ if (clipR) {
+ p.setColor(0xFF00FF00);
+ p.setStyle(SkPaint::kStroke_Style);
+ canvas->drawRect(clipR->makeInset(SK_ScalarHalf, SK_ScalarHalf), p);
+ p.setStyle(SkPaint::kFill_Style);
+ }
+
+ p.setImageFilter(imgf);
+ p.setColor(SK_ColorRED);
+ canvas->drawRect(r, p);
+
+ if (clipR) {
+ canvas->save();
+ canvas->clipRect(*clipR);
+ }
+ p.setImageFilter(NULL);
+ p.setColor(0x660000FF);
+ canvas->drawRect(r, p);
+ if (clipR) {
+ canvas->restore();
+ }
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ const SkRect r = SkRect::MakeWH(10, 10);
+ SkImageFilter::CropRect cr0(r);
+ SkImageFilter::CropRect cr1(SkRect::MakeWH(5, 5));
+
+ canvas->translate(20, 20);
+ this->doDraw(canvas, r, NULL);
+
+ canvas->translate(20, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5));
+
+ canvas->translate(20, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr0));
+
+ canvas->translate(20, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5), &r);
+
+ canvas->translate(20, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr1));
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new SimpleOffsetImageFilterGM; )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698