| 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" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkShader.h" | 12 #include "SkShader.h" |
| 13 | 13 |
| 14 #include "SkBlurImageFilter.h" | 14 #include "SkBlurImageFilter.h" |
| 15 #include "SkColorFilterImageFilter.h" | 15 #include "SkColorFilterImageFilter.h" |
| 16 #include "SkDropShadowImageFilter.h" |
| 16 #include "SkTestImageFilters.h" | 17 #include "SkTestImageFilters.h" |
| 17 | 18 |
| 18 class FailImageFilter : public SkImageFilter { | 19 class FailImageFilter : public SkImageFilter { |
| 19 public: | 20 public: |
| 20 FailImageFilter() : INHERITED(0) {} | 21 FailImageFilter() : INHERITED(0) {} |
| 21 | 22 |
| 22 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) | 23 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter) |
| 23 protected: | 24 protected: |
| 24 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, | 25 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, |
| 25 SkBitmap* result, SkIPoint* offset) { | 26 SkBitmap* result, SkIPoint* offset) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 class ImageFiltersBaseGM : public skiagm::GM { | 150 class ImageFiltersBaseGM : public skiagm::GM { |
| 150 public: | 151 public: |
| 151 ImageFiltersBaseGM () {} | 152 ImageFiltersBaseGM () {} |
| 152 | 153 |
| 153 protected: | 154 protected: |
| 154 | 155 |
| 155 virtual SkString onShortName() { | 156 virtual SkString onShortName() { |
| 156 return SkString("imagefiltersbase"); | 157 return SkString("imagefiltersbase"); |
| 157 } | 158 } |
| 158 | 159 |
| 159 virtual SkISize onISize() { return SkISize::Make(700, 460); } | 160 virtual SkISize onISize() { return SkISize::Make(700, 500); } |
| 160 | 161 |
| 161 void draw_frame(SkCanvas* canvas, const SkRect& r) { | 162 void draw_frame(SkCanvas* canvas, const SkRect& r) { |
| 162 SkPaint paint; | 163 SkPaint paint; |
| 163 paint.setStyle(SkPaint::kStroke_Style); | 164 paint.setStyle(SkPaint::kStroke_Style); |
| 164 paint.setColor(SK_ColorRED); | 165 paint.setColor(SK_ColorRED); |
| 165 canvas->drawRect(r, paint); | 166 canvas->drawRect(r, paint); |
| 166 } | 167 } |
| 167 | 168 |
| 168 virtual uint32_t onGetFlags() const { | 169 virtual uint32_t onGetFlags() const { |
| 169 // Because of the use of drawSprite, this test is excluded | 170 // Because of the use of drawSprite, this test is excluded |
| (...skipping 12 matching lines...) Expand all Loading... |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED, | 185 SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorRED, |
| 185 SkXfermode::kSrcIn_Mode); | 186 SkXfermode::kSrcIn_Mode); |
| 186 SkImageFilter* filters[] = { | 187 SkImageFilter* filters[] = { |
| 187 NULL, | 188 NULL, |
| 188 new IdentityImageFilter, | 189 new IdentityImageFilter, |
| 189 new FailImageFilter, | 190 new FailImageFilter, |
| 190 SkColorFilterImageFilter::Create(cf), | 191 SkColorFilterImageFilter::Create(cf), |
| 191 new SkBlurImageFilter(12.0f, 0.0f), | 192 new SkBlurImageFilter(12.0f, 0.0f), |
| 193 new SkDropShadowImageFilter(10.0f, 5.0f, 3.0f, SK_ColorBLUE), |
| 192 }; | 194 }; |
| 193 cf->unref(); | 195 cf->unref(); |
| 194 | 196 |
| 195 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); | 197 SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64)); |
| 196 SkScalar MARGIN = SkIntToScalar(16); | 198 SkScalar MARGIN = SkIntToScalar(16); |
| 197 SkScalar DX = r.width() + MARGIN; | 199 SkScalar DX = r.width() + MARGIN; |
| 198 SkScalar DY = r.height() + MARGIN; | 200 SkScalar DY = r.height() + MARGIN; |
| 199 | 201 |
| 200 canvas->translate(MARGIN, MARGIN); | 202 canvas->translate(MARGIN, MARGIN); |
| 201 for (size_t i = 0; i < SK_ARRAY_COUNT(drawProc); ++i) { | 203 for (size_t i = 0; i < SK_ARRAY_COUNT(drawProc); ++i) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 216 } | 218 } |
| 217 | 219 |
| 218 private: | 220 private: |
| 219 typedef GM INHERITED; | 221 typedef GM INHERITED; |
| 220 }; | 222 }; |
| 221 | 223 |
| 222 /////////////////////////////////////////////////////////////////////////////// | 224 /////////////////////////////////////////////////////////////////////////////// |
| 223 | 225 |
| 224 static skiagm::GM* MyFactory(void*) { return new ImageFiltersBaseGM; } | 226 static skiagm::GM* MyFactory(void*) { return new ImageFiltersBaseGM; } |
| 225 static skiagm::GMRegistry reg(MyFactory); | 227 static skiagm::GMRegistry reg(MyFactory); |
| OLD | NEW |