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

Side by Side Diff: gm/xfermodeimagefilter.cpp

Issue 1842033005: Image filters: fix crop rect application in SkXfermodeImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix formatting. 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/effects/SkXfermodeImageFilter.cpp » ('j') | 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 "gm.h" 8 #include "gm.h"
9 #include "sk_tool_utils.h" 9 #include "sk_tool_utils.h"
10 #include "SkArithmeticMode.h" 10 #include "SkArithmeticMode.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 y += fBitmap.height() + MARGIN; 176 y += fBitmap.height() + MARGIN;
177 } 177 }
178 // Test small fg, large bg with Screen (uses shader blend) 178 // Test small fg, large bg with Screen (uses shader blend)
179 paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropp ed, nullptr)); 179 paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropp ed, nullptr));
180 DrawClippedPaint(canvas, clipRect, paint, x, y); 180 DrawClippedPaint(canvas, clipRect, paint, x, y);
181 x += fBitmap.width() + MARGIN; 181 x += fBitmap.width() + MARGIN;
182 if (x + fBitmap.width() > WIDTH) { 182 if (x + fBitmap.width() > WIDTH) {
183 x = 0; 183 x = 0;
184 y += fBitmap.height() + MARGIN; 184 y += fBitmap.height() + MARGIN;
185 } 185 }
186 // Test small fg, large bg with SrcIn with a crop that forces it to full size.
187 // This tests that SkXfermodeImageFilter correctly applies the compositi ng mode to
188 // the region outside the foreground.
189 mode = SkXfermode::Make(SkXfermode::kSrcIn_Mode);
190 SkImageFilter::CropRect cropRectFull(SkRect::MakeXYWH(0, 0, 80, 80));
191 paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropp ed, &cropRectFull));
192 DrawClippedPaint(canvas, clipRect, paint, x, y);
193 x += fBitmap.width() + MARGIN;
194 if (x + fBitmap.width() > WIDTH) {
195 x = 0;
196 y += fBitmap.height() + MARGIN;
197 }
186 } 198 }
187 199
188 private: 200 private:
189 static void DrawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, cons t SkPaint& paint, 201 static void DrawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, cons t SkPaint& paint,
190 int x, int y) { 202 int x, int y) {
191 canvas->save(); 203 canvas->save();
192 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 204 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
193 canvas->clipRect(SkRect::MakeWH( 205 canvas->clipRect(SkRect::MakeWH(
194 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); 206 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())));
195 canvas->drawBitmap(bitmap, 0, 0, &paint); 207 canvas->drawBitmap(bitmap, 0, 0, &paint);
(...skipping 13 matching lines...) Expand all
209 sk_sp<SkImage> fCheckerboard; 221 sk_sp<SkImage> fCheckerboard;
210 222
211 typedef GM INHERITED; 223 typedef GM INHERITED;
212 }; 224 };
213 225
214 ////////////////////////////////////////////////////////////////////////////// 226 //////////////////////////////////////////////////////////////////////////////
215 227
216 DEF_GM( return new XfermodeImageFilterGM; ); 228 DEF_GM( return new XfermodeImageFilterGM; );
217 229
218 } 230 }
OLDNEW
« no previous file with comments | « no previous file | src/effects/SkXfermodeImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698