| OLD | NEW |
| 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" |
| 11 #include "SkValidateImageFilter.h" |
| 11 #include "SkXfermodeImageFilter.h" | 12 #include "SkXfermodeImageFilter.h" |
| 12 #include "SkBitmapSource.h" | 13 #include "SkBitmapSource.h" |
| 13 | 14 |
| 14 #define WIDTH 600 | 15 #define WIDTH 600 |
| 15 #define HEIGHT 600 | 16 #define HEIGHT 600 |
| 16 #define MARGIN 12 | 17 #define MARGIN 12 |
| 17 | 18 |
| 18 namespace skiagm { | 19 namespace skiagm { |
| 19 | 20 |
| 20 class XfermodeImageFilterGM : public GM { | 21 class XfermodeImageFilterGM : public GM { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mod
e, background)); | 137 SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mod
e, background)); |
| 137 paint.setImageFilter(filter); | 138 paint.setImageFilter(filter); |
| 138 drawClippedBitmap(canvas, fBitmap, paint, x, y); | 139 drawClippedBitmap(canvas, fBitmap, paint, x, y); |
| 139 x += fBitmap.width() + MARGIN; | 140 x += fBitmap.width() + MARGIN; |
| 140 if (x + fBitmap.width() > WIDTH) { | 141 if (x + fBitmap.width() > WIDTH) { |
| 141 x = 0; | 142 x = 0; |
| 142 y += fBitmap.height() + MARGIN; | 143 y += fBitmap.height() + MARGIN; |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 // Test arithmetic mode as image filter | 146 // Test arithmetic mode as image filter |
| 146 SkAutoTUnref<SkXfermode> mode(SkArithmeticMode::Create(0, SK_Scalar1, SK
_Scalar1, 0)); | 147 SkAutoTUnref<SkXfermode> mode(SkArithmeticMode::Create(0, SK_Scalar1, SK
_Scalar1, 0, false)); |
| 147 SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mode, b
ackground)); | 148 SkAutoTUnref<SkImageFilter> xferFilter(SkXfermodeImageFilter::Create(mod
e, background)); |
| 149 SkAutoTUnref<SkImageFilter> filter(SkValidateImageFilter::Create(xferFil
ter)); |
| 148 paint.setImageFilter(filter); | 150 paint.setImageFilter(filter); |
| 149 drawClippedBitmap(canvas, fBitmap, paint, x, y); | 151 drawClippedBitmap(canvas, fBitmap, paint, x, y); |
| 150 x += fBitmap.width() + MARGIN; | 152 x += fBitmap.width() + MARGIN; |
| 151 if (x + fBitmap.width() > WIDTH) { | 153 if (x + fBitmap.width() > WIDTH) { |
| 152 x = 0; | 154 x = 0; |
| 153 y += fBitmap.height() + MARGIN; | 155 y += fBitmap.height() + MARGIN; |
| 154 } | 156 } |
| 155 // Test NULL mode | 157 // Test NULL mode |
| 156 filter.reset(SkXfermodeImageFilter::Create(NULL, background)); | 158 filter.reset(SkXfermodeImageFilter::Create(NULL, background)); |
| 157 paint.setImageFilter(filter); | 159 paint.setImageFilter(filter); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 private: | 219 private: |
| 218 SkBitmap fBitmap, fCheckerboard; | 220 SkBitmap fBitmap, fCheckerboard; |
| 219 typedef GM INHERITED; | 221 typedef GM INHERITED; |
| 220 }; | 222 }; |
| 221 | 223 |
| 222 ////////////////////////////////////////////////////////////////////////////// | 224 ////////////////////////////////////////////////////////////////////////////// |
| 223 | 225 |
| 224 DEF_GM( return new XfermodeImageFilterGM; ); | 226 DEF_GM( return new XfermodeImageFilterGM; ); |
| 225 | 227 |
| 226 } | 228 } |
| OLD | NEW |