| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 9 |
| 10 #include "SkArithmeticMode.h" | 10 #include "SkArithmeticMode.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 drawClippedBitmap(canvas, fBitmap, paint); | 187 drawClippedBitmap(canvas, fBitmap, paint); |
| 188 canvas->translate(SkIntToScalar(100), 0); | 188 canvas->translate(SkIntToScalar(100), 0); |
| 189 } | 189 } |
| 190 { | 190 { |
| 191 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create( | 191 SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create( |
| 192 SkIntToScalar(10), SkIntToScalar(10))); | 192 SkIntToScalar(10), SkIntToScalar(10))); |
| 193 | 193 |
| 194 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_
Mode)); | 194 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_
Mode)); |
| 195 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S
kIntToScalar(100))); | 195 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S
kIntToScalar(100))); |
| 196 SkAutoTUnref<SkImageFilter> blend( | 196 SkAutoTUnref<SkImageFilter> blend( |
| 197 SkXfermodeImageFilter::Create(mode, blur, NULL, &cropRect)); | 197 SkXfermodeImageFilter::Create(mode, blur, nullptr, &cropRect)); |
| 198 | 198 |
| 199 SkPaint paint; | 199 SkPaint paint; |
| 200 paint.setImageFilter(blend); | 200 paint.setImageFilter(blend); |
| 201 drawClippedBitmap(canvas, fBitmap, paint); | 201 drawClippedBitmap(canvas, fBitmap, paint); |
| 202 canvas->translate(SkIntToScalar(100), 0); | 202 canvas->translate(SkIntToScalar(100), 0); |
| 203 } | 203 } |
| 204 { | 204 { |
| 205 // Test that crop offsets are absolute, not relative to the parent's
crop rect. | 205 // Test that crop offsets are absolute, not relative to the parent's
crop rect. |
| 206 SkAutoTUnref<SkColorFilter> cf1(SkColorFilter::CreateModeFilter(SK_C
olorBLUE, | 206 SkAutoTUnref<SkColorFilter> cf1(SkColorFilter::CreateModeFilter(SK_C
olorBLUE, |
| 207 SkXf
ermode::kSrcIn_Mode)); | 207 SkXf
ermode::kSrcIn_Mode)); |
| 208 SkAutoTUnref<SkColorFilter> cf2(SkColorFilter::CreateModeFilter(SK_C
olorGREEN, | 208 SkAutoTUnref<SkColorFilter> cf2(SkColorFilter::CreateModeFilter(SK_C
olorGREEN, |
| 209 SkXf
ermode::kSrcIn_Mode)); | 209 SkXf
ermode::kSrcIn_Mode)); |
| 210 SkImageFilter::CropRect outerRect(SkRect::MakeXYWH(SkIntToScalar(10)
, SkIntToScalar(10), | 210 SkImageFilter::CropRect outerRect(SkRect::MakeXYWH(SkIntToScalar(10)
, SkIntToScalar(10), |
| 211 SkIntToScalar(80)
, SkIntToScalar(80))); | 211 SkIntToScalar(80)
, SkIntToScalar(80))); |
| 212 SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20)
, SkIntToScalar(20), | 212 SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20)
, SkIntToScalar(20), |
| 213 SkIntToScalar(60)
, SkIntToScalar(60))); | 213 SkIntToScalar(60)
, SkIntToScalar(60))); |
| 214 SkAutoTUnref<SkImageFilter> color1(SkColorFilterImageFilter::Create(
cf1, NULL, &outerRect)); | 214 SkAutoTUnref<SkImageFilter> color1(SkColorFilterImageFilter::Create(
cf1, nullptr, &outerRect)); |
| 215 SkAutoTUnref<SkImageFilter> color2(SkColorFilterImageFilter::Create(
cf2, color1, &innerRect)); | 215 SkAutoTUnref<SkImageFilter> color2(SkColorFilterImageFilter::Create(
cf2, color1, &innerRect)); |
| 216 | 216 |
| 217 SkPaint paint; | 217 SkPaint paint; |
| 218 paint.setImageFilter(color2); | 218 paint.setImageFilter(color2); |
| 219 paint.setColor(SK_ColorRED); | 219 paint.setColor(SK_ColorRED); |
| 220 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint); | 220 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint); |
| 221 canvas->translate(SkIntToScalar(100), 0); | 221 canvas->translate(SkIntToScalar(100), 0); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 private: | 225 private: |
| 226 typedef GM INHERITED; | 226 typedef GM INHERITED; |
| 227 SkBitmap fBitmap; | 227 SkBitmap fBitmap; |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 /////////////////////////////////////////////////////////////////////////////// | 230 /////////////////////////////////////////////////////////////////////////////// |
| 231 | 231 |
| 232 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 232 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |
| 233 static skiagm::GMRegistry reg(MyFactory); | 233 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |