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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkBitmapSource.h" 9 #include "SkBitmapSource.h"
10 #include "SkOffsetImageFilter.h" 10 #include "SkOffsetImageFilter.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 class SimpleOffsetImageFilterGM : public skiagm::GM { 108 class SimpleOffsetImageFilterGM : public skiagm::GM {
109 public: 109 public:
110 SimpleOffsetImageFilterGM() {} 110 SimpleOffsetImageFilterGM() {}
111 111
112 protected: 112 protected:
113 SkString onShortName() override { 113 SkString onShortName() override {
114 return SkString("simple-offsetimagefilter"); 114 return SkString("simple-offsetimagefilter");
115 } 115 }
116 116
117 SkISize onISize() override { return SkISize::Make(140, 60); } 117 SkISize onISize() override { return SkISize::Make(640, 200); }
118 118
119 void doDraw(SkCanvas* canvas, const SkRect& r, SkImageFilter* imgf, 119 void doDraw(SkCanvas* canvas, const SkRect& r, SkImageFilter* imgf,
120 const SkRect* clipR = NULL) { 120 const SkRect* clipR = NULL) {
121 SkPaint p; 121 SkPaint p;
122 122
123 if (clipR) { 123 if (clipR) {
124 p.setColor(0xFF00FF00); 124 p.setColor(0xFF00FF00);
125 p.setStyle(SkPaint::kStroke_Style); 125 p.setStyle(SkPaint::kStroke_Style);
126 canvas->drawRect(clipR->makeInset(SK_ScalarHalf, SK_ScalarHalf), p); 126 canvas->drawRect(clipR->makeInset(SK_ScalarHalf, SK_ScalarHalf), p);
127 p.setStyle(SkPaint::kFill_Style); 127 p.setStyle(SkPaint::kFill_Style);
(...skipping 20 matching lines...) Expand all
148 } 148 }
149 p.setColor(0x66FF0000); 149 p.setColor(0x66FF0000);
150 canvas->drawRect(r, p); 150 canvas->drawRect(r, p);
151 151
152 if (clipR) { 152 if (clipR) {
153 canvas->restore(); 153 canvas->restore();
154 } 154 }
155 } 155 }
156 156
157 void onDraw(SkCanvas* canvas) override { 157 void onDraw(SkCanvas* canvas) override {
158 const SkRect r = SkRect::MakeWH(10, 10); 158 const SkRect r = SkRect::MakeWH(40, 40);
159 SkImageFilter::CropRect cr0(r); 159 SkImageFilter::CropRect cr0(r);
160 SkImageFilter::CropRect cr1(SkRect::MakeWH(5, 5)); 160 SkImageFilter::CropRect cr1(SkRect::MakeWH(20, 20));
161 const SkRect r2 = SkRect::MakeXYWH(10, 0, 10, 10); 161 const SkRect r2 = SkRect::MakeXYWH(40, 0, 40, 40);
162 SkImageFilter::CropRect cr2(r2); 162 SkImageFilter::CropRect cr2(r2);
163 163
164 canvas->translate(20, 20); 164 canvas->translate(40, 40);
165
166 canvas->save();
robertphillips 2015/06/24 16:23:53 // 0,0: rect draw - no offset ?
165 this->doDraw(canvas, r, NULL); 167 this->doDraw(canvas, r, NULL);
166 168
robertphillips 2015/06/24 16:23:53 // 1,0: offset rect draw ?
167 canvas->translate(20, 0); 169 canvas->translate(100, 0);
168 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5)); 170 this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20));
169 171
robertphillips 2015/06/24 16:23:53 // 2,0: offset rect draw with crop rect - 3/4 of t
170 canvas->translate(20, 0); 172 canvas->translate(100, 0);
171 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr0)); 173 this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, NULL, &cr0)) ;
172 174
173 canvas->translate(20, 0); 175 canvas->translate(100, 0);
174 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5), &r); 176 this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20), &r);
175 177
176 canvas->translate(20, 0); 178 canvas->translate(100, 0);
177 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, &cr1)); 179 this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, NULL, &cr1)) ;
178 180
179 SkRect clipR = SkRect::MakeXYWH(10, 10, 10, 10); 181 SkRect clipR = SkRect::MakeXYWH(40, 40, 40, 40);
180 canvas->translate(20, 0); 182 canvas->translate(100, 0);
181 this->doDraw(canvas, r, SkOffsetImageFilter::Create(5, 5, NULL, NULL), & clipR); 183 this->doDraw(canvas, r, SkOffsetImageFilter::Create(20, 20, NULL, NULL), &clipR);
182 184 canvas->restore();
183 canvas->translate(20, 0); 185
184 this->doDraw(canvas, r, SkOffsetImageFilter::Create(10, 0, NULL, &cr2), NULL); 186 // 2nd row
187 canvas->translate(0, 80);
188
189 /*
190 * combos of clip and crop rects that align with src and dst
191 */
192
193 // crop==clip==src
194 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr0), &r);
195
196 // crop==src, clip==dst
197 canvas->translate(100, 0);
198 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr0), &r2);
199
200 // crop==dst, clip==src
201 canvas->translate(100, 0);
202 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr2), &r);
203
204 // crop==clip==dst
205 canvas->translate(100, 0);
206 this->doDraw(canvas, r, SkOffsetImageFilter::Create(40, 0, NULL, &cr2), &r2);
185 } 207 }
186 208
187 private: 209 private:
188 typedef skiagm::GM INHERITED; 210 typedef skiagm::GM INHERITED;
189 }; 211 };
190 DEF_GM( return new SimpleOffsetImageFilterGM; ) 212 DEF_GM( return new SimpleOffsetImageFilterGM; )
OLDNEW
« 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