| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
| 10 #include "SkDropShadowImageFilter.h" | 10 #include "SkDropShadowImageFilter.h" |
| 11 #include "SkImageSource.h" | 11 #include "SkImageSource.h" |
| 12 #include "SkOffsetImageFilter.h" | 12 #include "SkOffsetImageFilter.h" |
| 13 #include "SkPictureImageFilter.h" | 13 #include "SkPictureImageFilter.h" |
| 14 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
| 15 #include "SkRandom.h" | 15 #include "SkRandom.h" |
| 16 #include "SkSurface.h" | 16 #include "SkSurface.h" |
| 17 #include "SkTileImageFilter.h" |
| 17 | 18 |
| 18 namespace skiagm { | 19 namespace skiagm { |
| 19 | 20 |
| 20 // Each method of this type must draw its geometry inside 'r' using 'p' | 21 // Each method of this type must draw its geometry inside 'r' using 'p' |
| 21 typedef void(*drawMth)(SkCanvas* canvas, const SkRect& r, const SkPaint& p); | 22 typedef void(*drawMth)(SkCanvas* canvas, const SkRect& r, const SkPaint& p); |
| 22 | 23 |
| 23 static void draw_rect(SkCanvas* canvas, const SkRect& r, const SkPaint& p) { | 24 static void draw_rect(SkCanvas* canvas, const SkRect& r, const SkPaint& p) { |
| 24 canvas->drawRect(r, p); | 25 canvas->drawRect(r, p); |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 SkMatrix rot; | 104 SkMatrix rot; |
| 104 rot.setRotate(-33.3f); | 105 rot.setRotate(-33.3f); |
| 105 | 106 |
| 106 SkAutoTUnref<SkImageFilter> rotMIF( | 107 SkAutoTUnref<SkImageFilter> rotMIF( |
| 107 SkImageFilter::CreateMatrixFilter(rot, kLow_SkFilterQuality, source)
); | 108 SkImageFilter::CreateMatrixFilter(rot, kLow_SkFilterQuality, source)
); |
| 108 | 109 |
| 109 add_paint(rotMIF, paints); | 110 add_paint(rotMIF, paints); |
| 110 } | 111 } |
| 111 | 112 |
| 112 { | 113 { |
| 114 SkRect src = SkRect::MakeXYWH(20, 20, 10, 10); |
| 115 SkRect dst = SkRect::MakeXYWH(30, 30, 30, 30); |
| 116 SkAutoTUnref<SkImageFilter> tileIF( |
| 117 SkTileImageFilter::Create(src, dst, nullptr)); |
| 118 |
| 119 add_paint(tileIF, paints); |
| 120 } |
| 121 |
| 122 { |
| 113 static const SkDropShadowImageFilter::ShadowMode kBoth = | 123 static const SkDropShadowImageFilter::ShadowMode kBoth = |
| 114 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode
; | 124 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode
; |
| 115 | 125 |
| 116 SkAutoTUnref<SkImageFilter> dsif( | 126 SkAutoTUnref<SkImageFilter> dsif( |
| 117 SkDropShadowImageFilter::Create(10.0f, 10.0f, | 127 SkDropShadowImageFilter::Create(10.0f, 10.0f, |
| 118 3.0f, 3.0f, | 128 3.0f, 3.0f, |
| 119 SK_ColorRED, kBoth, | 129 SK_ColorRED, kBoth, |
| 120 source, nullptr)); | 130 source, nullptr)); |
| 121 | 131 |
| 122 add_paint(dsif, paints); | 132 add_paint(dsif, paints); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 150 // and image filter | 160 // and image filter |
| 151 class ImageFilterFastBoundGM : public GM { | 161 class ImageFilterFastBoundGM : public GM { |
| 152 public: | 162 public: |
| 153 ImageFilterFastBoundGM() { | 163 ImageFilterFastBoundGM() { |
| 154 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); | 164 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); |
| 155 } | 165 } |
| 156 | 166 |
| 157 protected: | 167 protected: |
| 158 static const int kTileWidth = 100; | 168 static const int kTileWidth = 100; |
| 159 static const int kTileHeight = 100; | 169 static const int kTileHeight = 100; |
| 160 static const int kNumVertTiles = 6; | 170 static const int kNumVertTiles = 7; |
| 161 static const int kNumXtraCols = 2; | 171 static const int kNumXtraCols = 2; |
| 162 | 172 |
| 163 SkString onShortName() override{ return SkString("filterfastbounds"); } | 173 SkString onShortName() override{ return SkString("filterfastbounds"); } |
| 164 | 174 |
| 165 SkISize onISize() override{ | 175 SkISize onISize() override{ |
| 166 return SkISize::Make((SK_ARRAY_COUNT(gDrawMthds) + kNumXtraCols) * kTile
Width, | 176 return SkISize::Make((SK_ARRAY_COUNT(gDrawMthds) + kNumXtraCols) * kTile
Width, |
| 167 kNumVertTiles * kTileHeight); | 177 kNumVertTiles * kTileHeight); |
| 168 } | 178 } |
| 169 | 179 |
| 170 static void draw_geom_with_paint(drawMth draw, const SkIPoint& off, | 180 static void draw_geom_with_paint(drawMth draw, const SkIPoint& off, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 327 } |
| 318 | 328 |
| 319 private: | 329 private: |
| 320 typedef GM INHERITED; | 330 typedef GM INHERITED; |
| 321 }; | 331 }; |
| 322 | 332 |
| 323 ////////////////////////////////////////////////////////////////////////////// | 333 ////////////////////////////////////////////////////////////////////////////// |
| 324 | 334 |
| 325 DEF_GM(return new ImageFilterFastBoundGM;) | 335 DEF_GM(return new ImageFilterFastBoundGM;) |
| 326 } | 336 } |
| OLD | NEW |