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

Side by Side Diff: gm/xfermodeimagefilter.cpp

Issue 108563002: Fix Windows compiler warnings/errors (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« 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 "gm.h" 8 #include "gm.h"
9 #include "SkArithmeticMode.h" 9 #include "SkArithmeticMode.h"
10 #include "SkOffsetImageFilter.h" 10 #include "SkOffsetImageFilter.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // Test offsets on SrcMode (uses fixed-function blend) 171 // Test offsets on SrcMode (uses fixed-function blend)
172 SkAutoTUnref<SkImageFilter> foreground(SkNEW_ARGS(SkBitmapSource, (fBitm ap))); 172 SkAutoTUnref<SkImageFilter> foreground(SkNEW_ARGS(SkBitmapSource, (fBitm ap)));
173 SkAutoTUnref<SkImageFilter> offsetForeground(SkNEW_ARGS(SkOffsetImageFil ter, 173 SkAutoTUnref<SkImageFilter> offsetForeground(SkNEW_ARGS(SkOffsetImageFil ter,
174 (SkIntToScalar(4), SkIntToScalar(-4), foreground))); 174 (SkIntToScalar(4), SkIntToScalar(-4), foreground)));
175 SkAutoTUnref<SkImageFilter> offsetBackground(SkNEW_ARGS(SkOffsetImageFil ter, 175 SkAutoTUnref<SkImageFilter> offsetBackground(SkNEW_ARGS(SkOffsetImageFil ter,
176 (SkIntToScalar(4), SkIntToScalar(4), background))); 176 (SkIntToScalar(4), SkIntToScalar(4), background)));
177 mode.reset(SkXfermode::Create(SkXfermode::kSrcOver_Mode)); 177 mode.reset(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
178 filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, 178 filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
179 (mode, offsetBackground, offsetForeground))); 179 (mode, offsetBackground, offsetForeground)));
180 paint.setImageFilter(filter); 180 paint.setImageFilter(filter);
181 drawClippedPaint(canvas, clipRect, paint, x, y); 181 drawClippedPaint(canvas, clipRect, paint,
182 SkIntToScalar(x), SkIntToScalar(y));
182 x += fBitmap.width() + MARGIN; 183 x += fBitmap.width() + MARGIN;
183 if (x + fBitmap.width() > WIDTH) { 184 if (x + fBitmap.width() > WIDTH) {
184 x = 0; 185 x = 0;
185 y += fBitmap.height() + MARGIN; 186 y += fBitmap.height() + MARGIN;
186 } 187 }
187 // Test offsets on Darken (uses shader blend) 188 // Test offsets on Darken (uses shader blend)
188 mode.reset(SkXfermode::Create(SkXfermode::kDarken_Mode)); 189 mode.reset(SkXfermode::Create(SkXfermode::kDarken_Mode));
189 filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, (mode, offsetBackground, offsetForeground))); 190 filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, (mode, offsetBackground, offsetForeground)));
190 paint.setImageFilter(filter); 191 paint.setImageFilter(filter);
191 drawClippedPaint(canvas, clipRect, paint, x, y); 192 drawClippedPaint(canvas, clipRect, paint,
193 SkIntToScalar(x), SkIntToScalar(y));
192 x += fBitmap.width() + MARGIN; 194 x += fBitmap.width() + MARGIN;
193 if (x + fBitmap.width() > WIDTH) { 195 if (x + fBitmap.width() > WIDTH) {
194 x = 0; 196 x = 0;
195 y += fBitmap.height() + MARGIN; 197 y += fBitmap.height() + MARGIN;
196 } 198 }
197 // Test cropping 199 // Test cropping
198 static const size_t nbSamples = 3; 200 static const size_t nbSamples = 3;
199 SkXfermode::Mode sampledModes[nbSamples] = {SkXfermode::kOverlay_Mode, 201 SkXfermode::Mode sampledModes[nbSamples] = {SkXfermode::kOverlay_Mode,
200 SkXfermode::kSrcOver_Mode, 202 SkXfermode::kSrcOver_Mode,
201 SkXfermode::kPlus_Mode}; 203 SkXfermode::kPlus_Mode};
202 int offsets[nbSamples][4] = {{ 10, 10, -16, -16}, 204 int offsets[nbSamples][4] = {{ 10, 10, -16, -16},
203 { 10, 10, 10, 10}, 205 { 10, 10, 10, 10},
204 {-10, -10, -6, -6}}; 206 {-10, -10, -6, -6}};
205 for (size_t i = 0; i < nbSamples; ++i) { 207 for (size_t i = 0; i < nbSamples; ++i) {
206 SkIRect cropRect = SkIRect::MakeXYWH(offsets[i][0], 208 SkIRect cropRect = SkIRect::MakeXYWH(offsets[i][0],
207 offsets[i][1], 209 offsets[i][1],
208 fBitmap.width() + offsets[i][2 ], 210 fBitmap.width() + offsets[i][2 ],
209 fBitmap.height() + offsets[i][3 ]); 211 fBitmap.height() + offsets[i][3 ]);
210 SkImageFilter::CropRect rect(SkRect::Make(cropRect)); 212 SkImageFilter::CropRect rect(SkRect::Make(cropRect));
211 mode.reset(SkXfermode::Create(sampledModes[i])); 213 mode.reset(SkXfermode::Create(sampledModes[i]));
212 filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, 214 filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
213 (mode, offsetBackground, offsetForeground, & rect))); 215 (mode, offsetBackground, offsetForeground, & rect)));
214 paint.setImageFilter(filter); 216 paint.setImageFilter(filter);
215 drawClippedPaint(canvas, clipRect, paint, x, y); 217 drawClippedPaint(canvas, clipRect, paint,
218 SkIntToScalar(x), SkIntToScalar(y));
216 x += fBitmap.width() + MARGIN; 219 x += fBitmap.width() + MARGIN;
217 if (x + fBitmap.width() > WIDTH) { 220 if (x + fBitmap.width() > WIDTH) {
218 x = 0; 221 x = 0;
219 y += fBitmap.height() + MARGIN; 222 y += fBitmap.height() + MARGIN;
220 } 223 }
221 } 224 }
222 } 225 }
223 private: 226 private:
224 typedef GM INHERITED; 227 typedef GM INHERITED;
225 SkBitmap fBitmap, fCheckerboard; 228 SkBitmap fBitmap, fCheckerboard;
226 bool fInitialized; 229 bool fInitialized;
227 }; 230 };
228 231
229 ////////////////////////////////////////////////////////////////////////////// 232 //////////////////////////////////////////////////////////////////////////////
230 233
231 static GM* MyFactory(void*) { return new XfermodeImageFilterGM; } 234 static GM* MyFactory(void*) { return new XfermodeImageFilterGM; }
232 static GMRegistry reg(MyFactory); 235 static GMRegistry reg(MyFactory);
233 236
234 } 237 }
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