OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorFilter.h" | 10 #include "SkColorFilter.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return kSkipScaledReplay_Flag; | 126 return kSkipScaledReplay_Flag; |
127 } | 127 } |
128 | 128 |
129 virtual void onDraw(SkCanvas* canvas) { | 129 virtual void onDraw(SkCanvas* canvas) { |
130 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { | 130 void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = { |
131 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text | 131 draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text |
132 }; | 132 }; |
133 | 133 |
134 SkAutoTUnref<SkColorFilter> cf( | 134 SkAutoTUnref<SkColorFilter> cf( |
135 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod
e)); | 135 SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mod
e)); |
| 136 #ifdef SK_CROP_RECT_IS_INT |
136 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44); | 137 SkIRect cropRect = SkIRect::MakeXYWH(10, 10, 44, 44); |
137 SkIRect bogusRect = SkIRect::MakeXYWH(-100, -100, 10, 10); | 138 SkIRect bogusRect = SkIRect::MakeXYWH(-100, -100, 10, 10); |
| 139 #else |
| 140 SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10,
44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge); |
| 141 SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -
100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge); |
| 142 #endif |
138 | 143 |
139 SkAutoTUnref<SkImageFilter> offset(new SkOffsetImageFilter( | 144 SkAutoTUnref<SkImageFilter> offset(new SkOffsetImageFilter( |
140 SkIntToScalar(-10), SkIntToScalar(-10))); | 145 SkIntToScalar(-10), SkIntToScalar(-10))); |
141 | 146 |
142 SkAutoTUnref<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf
.get(), offset.get())); | 147 SkAutoTUnref<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf
.get(), offset.get())); |
143 | 148 |
144 SkImageFilter* filters[] = { | 149 SkImageFilter* filters[] = { |
145 NULL, | 150 NULL, |
146 SkColorFilterImageFilter::Create(cf.get(), NULL, &cropRect), | 151 SkColorFilterImageFilter::Create(cf.get(), NULL, &cropRect), |
147 new SkBlurImageFilter(1.0f, 1.0f, NULL, &cropRect), | 152 new SkBlurImageFilter(1.0f, 1.0f, NULL, &cropRect), |
(...skipping 27 matching lines...) Expand all Loading... |
175 } | 180 } |
176 | 181 |
177 private: | 182 private: |
178 typedef GM INHERITED; | 183 typedef GM INHERITED; |
179 }; | 184 }; |
180 | 185 |
181 /////////////////////////////////////////////////////////////////////////////// | 186 /////////////////////////////////////////////////////////////////////////////// |
182 | 187 |
183 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; } | 188 static skiagm::GM* MyFactory(void*) { return new ImageFiltersCroppedGM; } |
184 static skiagm::GMRegistry reg(MyFactory); | 189 static skiagm::GMRegistry reg(MyFactory); |
OLD | NEW |