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

Unified Diff: gm/offsetimagefilter.cpp

Issue 1201333002: add more tests (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 4c8242a4b22741cdd09fa64e46f2cd1292e1f20f..bb2eae19d534d5f948789c8b05af2904639e679c 100644
--- a/gm/offsetimagefilter.cpp
+++ b/gm/offsetimagefilter.cpp
@@ -114,7 +114,7 @@ protected:
return SkString("simple-offsetimagefilter");
}
- SkISize onISize() override { return SkISize::Make(140, 60); }
+ SkISize onISize() override { return SkISize::Make(640, 200); }
void doDraw(SkCanvas* canvas, const SkRect& r, SkImageFilter* imgf,
const SkRect* clipR = NULL) {
@@ -155,33 +155,55 @@ protected:
}
void onDraw(SkCanvas* canvas) override {
- const SkRect r = SkRect::MakeWH(10, 10);
+ const SkRect r = SkRect::MakeWH(40, 40);
SkImageFilter::CropRect cr0(r);
- SkImageFilter::CropRect cr1(SkRect::MakeWH(5, 5));
- const SkRect r2 = SkRect::MakeXYWH(10, 0, 10, 10);
+ SkImageFilter::CropRect cr1(SkRect::MakeWH(20, 20));
+ const SkRect r2 = SkRect::MakeXYWH(40, 0, 40, 40);
SkImageFilter::CropRect cr2(r2);
- canvas->translate(20, 20);
- this->doDraw(canvas, r, NULL);
+ canvas->translate(40, 40);
- canvas->translate(20, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5));
+ canvas->save();
robertphillips 2015/06/24 16:23:53 // 0,0: rect draw - no offset ?
+ this->doDraw(canvas, r, NULL);
robertphillips 2015/06/24 16:23:53 // 1,0: offset rect draw ?
- canvas->translate(20, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr0));
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20));
robertphillips 2015/06/24 16:23:53 // 2,0: offset rect draw with crop rect - 3/4 of t
- canvas->translate(20, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5), &r);
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, NULL, &cr0));
- canvas->translate(20, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr1));
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20), &r);
- SkRect clipR = SkRect::MakeXYWH(10, 10, 10, 10);
- canvas->translate(20, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, NULL), &clipR);
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, NULL, &cr1));
- canvas->translate(20, 0);
- this->doDraw(canvas, r, SkOffsetImageFilter::Create(10, 0, NULL, &cr2), NULL);
+ SkRect clipR = SkRect::MakeXYWH(40, 40, 40, 40);
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, NULL, NULL), &clipR);
+ canvas->restore();
+
+ // 2nd row
+ canvas->translate(0, 80);
+
+ /*
+ * combos of clip and crop rects that align with src and dst
+ */
+
+ // crop==clip==src
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr0), &r);
+
+ // crop==src, clip==dst
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr0), &r2);
+
+ // crop==dst, clip==src
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr2), &r);
+
+ // crop==clip==dst
+ canvas->translate(100, 0);
+ this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr2), &r2);
}
private:
« 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