| 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" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, const SkPaint& p) { | 71 static void draw_bitmap(SkCanvas* canvas, const SkRect& r, const SkPaint& p) { |
| 72 SkBitmap bm; | 72 SkBitmap bm; |
| 73 | 73 |
| 74 bm.allocN32Pixels(64, 64); | 74 bm.allocN32Pixels(64, 64); |
| 75 SkCanvas temp(bm); | 75 SkCanvas temp(bm); |
| 76 temp.clear(SK_ColorMAGENTA); | 76 temp.clear(SK_ColorMAGENTA); |
| 77 | 77 |
| 78 canvas->drawBitmapRect(bm, r, &p); | 78 canvas->drawBitmapRect(bm, r, &p); |
| 79 } | 79 } |
| 80 | 80 |
| 81 static const drawMth gDrawMthds[] = { | 81 constexpr drawMth gDrawMthds[] = { |
| 82 draw_rect, draw_oval, draw_rrect, draw_drrect, draw_path, draw_points, draw_
bitmap | 82 draw_rect, draw_oval, draw_rrect, draw_drrect, draw_path, draw_points, draw_
bitmap |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 static void add_paint(SkTArray<SkPaint>* paints, sk_sp<SkImageFilter> filter) { | 85 static void add_paint(SkTArray<SkPaint>* paints, sk_sp<SkImageFilter> filter) { |
| 86 SkPaint& p = paints->push_back(); | 86 SkPaint& p = paints->push_back(); |
| 87 p.setImageFilter(std::move(filter)); | 87 p.setImageFilter(std::move(filter)); |
| 88 SkASSERT(p.canComputeFastBounds()); | 88 SkASSERT(p.canComputeFastBounds()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Create a selection of imagefilter-based paints to test | 91 // Create a selection of imagefilter-based paints to test |
| (...skipping 20 matching lines...) Expand all Loading... |
| 112 | 112 |
| 113 { | 113 { |
| 114 SkRect src = SkRect::MakeXYWH(20, 20, 10, 10); | 114 SkRect src = SkRect::MakeXYWH(20, 20, 10, 10); |
| 115 SkRect dst = SkRect::MakeXYWH(30, 30, 30, 30); | 115 SkRect dst = SkRect::MakeXYWH(30, 30, 30, 30); |
| 116 sk_sp<SkImageFilter> tileIF(SkTileImageFilter::Make(src, dst, nullptr)); | 116 sk_sp<SkImageFilter> tileIF(SkTileImageFilter::Make(src, dst, nullptr)); |
| 117 | 117 |
| 118 add_paint(paints, std::move(tileIF)); | 118 add_paint(paints, std::move(tileIF)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 { | 121 { |
| 122 static const SkDropShadowImageFilter::ShadowMode kBoth = | 122 constexpr SkDropShadowImageFilter::ShadowMode kBoth = |
| 123 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode
; | 123 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode
; |
| 124 | 124 |
| 125 sk_sp<SkImageFilter> dsif(SkDropShadowImageFilter::Make(10.0f, 10.0f, | 125 sk_sp<SkImageFilter> dsif(SkDropShadowImageFilter::Make(10.0f, 10.0f, |
| 126 3.0f, 3.0f, | 126 3.0f, 3.0f, |
| 127 SK_ColorRED, kBo
th, | 127 SK_ColorRED, kBo
th, |
| 128 source)); | 128 source)); |
| 129 | 129 |
| 130 add_paint(paints, std::move(dsif)); | 130 add_paint(paints, std::move(dsif)); |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 147 | 147 |
| 148 // This GM visualizes the fast bounds for various combinations of geometry | 148 // This GM visualizes the fast bounds for various combinations of geometry |
| 149 // and image filter | 149 // and image filter |
| 150 class ImageFilterFastBoundGM : public GM { | 150 class ImageFilterFastBoundGM : public GM { |
| 151 public: | 151 public: |
| 152 ImageFilterFastBoundGM() { | 152 ImageFilterFastBoundGM() { |
| 153 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); | 153 this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); |
| 154 } | 154 } |
| 155 | 155 |
| 156 protected: | 156 protected: |
| 157 static const int kTileWidth = 100; | 157 static constexpr int kTileWidth = 100; |
| 158 static const int kTileHeight = 100; | 158 static constexpr int kTileHeight = 100; |
| 159 static const int kNumVertTiles = 7; | 159 static constexpr int kNumVertTiles = 7; |
| 160 static const int kNumXtraCols = 2; | 160 static constexpr int kNumXtraCols = 2; |
| 161 | 161 |
| 162 SkString onShortName() override{ return SkString("filterfastbounds"); } | 162 SkString onShortName() override{ return SkString("filterfastbounds"); } |
| 163 | 163 |
| 164 SkISize onISize() override{ | 164 SkISize onISize() override{ |
| 165 return SkISize::Make((SK_ARRAY_COUNT(gDrawMthds) + kNumXtraCols) * kTile
Width, | 165 return SkISize::Make((SK_ARRAY_COUNT(gDrawMthds) + kNumXtraCols) * kTile
Width, |
| 166 kNumVertTiles * kTileHeight); | 166 kNumVertTiles * kTileHeight); |
| 167 } | 167 } |
| 168 | 168 |
| 169 static void draw_geom_with_paint(drawMth draw, const SkIPoint& off, | 169 static void draw_geom_with_paint(drawMth draw, const SkIPoint& off, |
| 170 SkCanvas* canvas, const SkPaint& p) { | 170 SkCanvas* canvas, const SkPaint& p) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } | 313 } |
| 314 | 314 |
| 315 private: | 315 private: |
| 316 typedef GM INHERITED; | 316 typedef GM INHERITED; |
| 317 }; | 317 }; |
| 318 | 318 |
| 319 ////////////////////////////////////////////////////////////////////////////// | 319 ////////////////////////////////////////////////////////////////////////////// |
| 320 | 320 |
| 321 DEF_GM(return new ImageFilterFastBoundGM;) | 321 DEF_GM(return new ImageFilterFastBoundGM;) |
| 322 } | 322 } |
| OLD | NEW |