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

Side by Side Diff: gm/xfermodeimagefilter.cpp

Issue 1588633002: Fix SkXfermodeImageFilter GPU fast path for differing sizes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix formatting Created 4 years, 11 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"
11 #include "SkImage.h" 11 #include "SkImage.h"
12 #include "SkImageSource.h" 12 #include "SkImageSource.h"
13 #include "SkOffsetImageFilter.h" 13 #include "SkOffsetImageFilter.h"
14 #include "SkXfermodeImageFilter.h" 14 #include "SkXfermodeImageFilter.h"
15 15
16 #define WIDTH 600 16 #define WIDTH 600
17 #define HEIGHT 600 17 #define HEIGHT 700
18 #define MARGIN 12 18 #define MARGIN 12
19 19
20 namespace skiagm { 20 namespace skiagm {
21 21
22 class XfermodeImageFilterGM : public GM { 22 class XfermodeImageFilterGM : public GM {
23 public: 23 public:
24 XfermodeImageFilterGM(){ 24 XfermodeImageFilterGM(){
25 this->setBGColor(0xFF000000); 25 this->setBGColor(0xFF000000);
26 } 26 }
27 27
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 filter.reset(SkXfermodeImageFilter::Create( 162 filter.reset(SkXfermodeImageFilter::Create(
163 mode, offsetBackground, offsetForeground, &r ect)); 163 mode, offsetBackground, offsetForeground, &r ect));
164 paint.setImageFilter(filter); 164 paint.setImageFilter(filter);
165 DrawClippedPaint(canvas, clipRect, paint, x, y); 165 DrawClippedPaint(canvas, clipRect, paint, x, y);
166 x += fBitmap.width() + MARGIN; 166 x += fBitmap.width() + MARGIN;
167 if (x + fBitmap.width() > WIDTH) { 167 if (x + fBitmap.width() > WIDTH) {
168 x = 0; 168 x = 0;
169 y += fBitmap.height() + MARGIN; 169 y += fBitmap.height() + MARGIN;
170 } 170 }
171 } 171 }
172 // Test small bg, large fg with Screen (uses shader blend)
173 mode.reset(SkXfermode::Create(SkXfermode::kScreen_Mode));
174 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(10, 10, 60, 60));
175 SkAutoTUnref<SkImageFilter> cropped(
176 SkOffsetImageFilter::Create(0, 0, foreground, &cropRect));
177 filter.reset(SkXfermodeImageFilter::Create(mode, cropped, background));
178 paint.setImageFilter(filter);
179 DrawClippedPaint(canvas, clipRect, paint, x, y);
180 x += fBitmap.width() + MARGIN;
181 if (x + fBitmap.width() > WIDTH) {
182 x = 0;
183 y += fBitmap.height() + MARGIN;
184 }
185 // Test small fg, large bg with Screen (uses shader blend)
186 filter.reset(SkXfermodeImageFilter::Create(mode, background, cropped));
187 paint.setImageFilter(filter);
188 DrawClippedPaint(canvas, clipRect, paint, x, y);
189 x += fBitmap.width() + MARGIN;
190 if (x + fBitmap.width() > WIDTH) {
191 x = 0;
192 y += fBitmap.height() + MARGIN;
193 }
172 } 194 }
173 195
174 private: 196 private:
175 static void DrawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, cons t SkPaint& paint, 197 static void DrawClippedBitmap(SkCanvas* canvas, const SkBitmap& bitmap, cons t SkPaint& paint,
176 int x, int y) { 198 int x, int y) {
177 canvas->save(); 199 canvas->save();
178 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 200 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
179 canvas->clipRect(SkRect::MakeWH( 201 canvas->clipRect(SkRect::MakeWH(
180 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()))); 202 SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height())));
181 canvas->drawBitmap(bitmap, 0, 0, &paint); 203 canvas->drawBitmap(bitmap, 0, 0, &paint);
(...skipping 13 matching lines...) Expand all
195 SkAutoTUnref<SkImage> fCheckerboard; 217 SkAutoTUnref<SkImage> fCheckerboard;
196 218
197 typedef GM INHERITED; 219 typedef GM INHERITED;
198 }; 220 };
199 221
200 ////////////////////////////////////////////////////////////////////////////// 222 //////////////////////////////////////////////////////////////////////////////
201 223
202 DEF_GM( return new XfermodeImageFilterGM; ); 224 DEF_GM( return new XfermodeImageFilterGM; );
203 225
204 } 226 }
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