| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_
Mode)); | 176 SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_
Mode)); |
| 177 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S
kIntToScalar(100))); | 177 SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), S
kIntToScalar(100))); |
| 178 SkAutoTUnref<SkImageFilter> blend(new SkXfermodeImageFilter(mode, bl
ur, NULL, &cropRect)); | 178 SkAutoTUnref<SkImageFilter> blend(new SkXfermodeImageFilter(mode, bl
ur, NULL, &cropRect)); |
| 179 | 179 |
| 180 SkPaint paint; | 180 SkPaint paint; |
| 181 paint.setImageFilter(blend); | 181 paint.setImageFilter(blend); |
| 182 drawClippedBitmap(canvas, fBitmap, paint); | 182 drawClippedBitmap(canvas, fBitmap, paint); |
| 183 canvas->translate(SkIntToScalar(100), 0); | 183 canvas->translate(SkIntToScalar(100), 0); |
| 184 } | 184 } |
| 185 { |
| 186 // Test that crop offsets are absolute, not relative to the parent's
crop rect. |
| 187 SkAutoTUnref<SkColorFilter> cf1(SkColorFilter::CreateModeFilter(SK_C
olorBLUE, |
| 188 SkXf
ermode::kSrcIn_Mode)); |
| 189 SkAutoTUnref<SkColorFilter> cf2(SkColorFilter::CreateModeFilter(SK_C
olorGREEN, |
| 190 SkXf
ermode::kSrcIn_Mode)); |
| 191 SkImageFilter::CropRect outerRect(SkRect::MakeXYWH(SkIntToScalar(10)
, SkIntToScalar(10), |
| 192 SkIntToScalar(80)
, SkIntToScalar(80))); |
| 193 SkImageFilter::CropRect innerRect(SkRect::MakeXYWH(SkIntToScalar(20)
, SkIntToScalar(20), |
| 194 SkIntToScalar(60)
, SkIntToScalar(60))); |
| 195 SkAutoTUnref<SkImageFilter> color1(SkColorFilterImageFilter::Create(
cf1, NULL, &outerRect)); |
| 196 SkAutoTUnref<SkImageFilter> color2(SkColorFilterImageFilter::Create(
cf2, color1, &innerRect)); |
| 197 |
| 198 SkPaint paint; |
| 199 paint.setImageFilter(color2); |
| 200 paint.setColor(0xFFFF0000); |
| 201 canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), paint); |
| 202 canvas->translate(SkIntToScalar(100), 0); |
| 203 } |
| 185 } | 204 } |
| 186 | 205 |
| 187 private: | 206 private: |
| 188 typedef GM INHERITED; | 207 typedef GM INHERITED; |
| 189 SkBitmap fBitmap; | 208 SkBitmap fBitmap; |
| 190 bool fInitialized; | 209 bool fInitialized; |
| 191 }; | 210 }; |
| 192 | 211 |
| 193 /////////////////////////////////////////////////////////////////////////////// | 212 /////////////////////////////////////////////////////////////////////////////// |
| 194 | 213 |
| 195 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } | 214 static skiagm::GM* MyFactory(void*) { return new ImageFiltersGraphGM; } |
| 196 static skiagm::GMRegistry reg(MyFactory); | 215 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |