OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 protected: | 24 protected: |
25 SkString onShortName() override { | 25 SkString onShortName() override { |
26 return SkString("blurquickreject"); | 26 return SkString("blurquickreject"); |
27 } | 27 } |
28 | 28 |
29 SkISize onISize() override { | 29 SkISize onISize() override { |
30 return SkISize::Make(kWidth, kHeight); | 30 return SkISize::Make(kWidth, kHeight); |
31 } | 31 } |
32 | 32 |
33 void onDraw(SkCanvas* canvas) override { | 33 void onDraw(SkCanvas* canvas) override { |
34 static const SkScalar kBlurRadius = SkIntToScalar(20); | 34 constexpr SkScalar kBlurRadius = SkIntToScalar(20); |
35 static const SkScalar kBoxSize = SkIntToScalar(100); | 35 constexpr SkScalar kBoxSize = SkIntToScalar(100); |
36 | 36 |
37 SkRect clipRect = SkRect::MakeXYWH(0, 0, kBoxSize, kBoxSize); | 37 SkRect clipRect = SkRect::MakeXYWH(0, 0, kBoxSize, kBoxSize); |
38 SkRect blurRects[] = { | 38 SkRect blurRects[] = { |
39 { -kBoxSize - (kBlurRadius+1), 0, -(kBlurRadius+1), kBoxSize }, | 39 { -kBoxSize - (kBlurRadius+1), 0, -(kBlurRadius+1), kBoxSize }, |
40 { 0, -kBoxSize - (kBlurRadius+1), kBoxSize, -(kBlurRadius+1) }, | 40 { 0, -kBoxSize - (kBlurRadius+1), kBoxSize, -(kBlurRadius+1) }, |
41 { kBoxSize+kBlurRadius+1, 0, 2*kBoxSize+kBlurRadius+1, kBoxSize }, | 41 { kBoxSize+kBlurRadius+1, 0, 2*kBoxSize+kBlurRadius+1, kBoxSize }, |
42 { 0, kBoxSize+kBlurRadius+1, kBoxSize, 2*kBoxSize+kBlurRadius+1 } | 42 { 0, kBoxSize+kBlurRadius+1, kBoxSize, 2*kBoxSize+kBlurRadius+1 } |
43 }; | 43 }; |
44 SkColor colors[] = { | 44 SkColor colors[] = { |
45 SK_ColorRED, | 45 SK_ColorRED, |
(...skipping 20 matching lines...) Expand all Loading... |
66 canvas->clipRect(clipRect); | 66 canvas->clipRect(clipRect); |
67 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRects); ++i) { | 67 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRects); ++i) { |
68 blurPaint.setColor(colors[i]); | 68 blurPaint.setColor(colors[i]); |
69 canvas->drawRect(blurRects[i], blurPaint); | 69 canvas->drawRect(blurRects[i], blurPaint); |
70 canvas->drawRect(blurRects[i], hairlinePaint); | 70 canvas->drawRect(blurRects[i], hairlinePaint); |
71 } | 71 } |
72 canvas->restore(); | 72 canvas->restore(); |
73 } | 73 } |
74 | 74 |
75 private: | 75 private: |
76 static const int kWidth = 300; | 76 static constexpr int kWidth = 300; |
77 static const int kHeight = 300; | 77 static constexpr int kHeight = 300; |
78 | 78 |
79 typedef GM INHERITED; | 79 typedef GM INHERITED; |
80 }; | 80 }; |
81 | 81 |
82 DEF_GM( return new BlurQuickRejectGM(); ) | 82 DEF_GM( return new BlurQuickRejectGM(); ) |
OLD | NEW |