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 24 matching lines...) Expand all Loading... |
35 fName.appendf("-WH-%ix%i-unevenCorners", width, height); | 35 fName.appendf("-WH-%ix%i-unevenCorners", width, height); |
36 SkVector radii[4]; | 36 SkVector radii[4]; |
37 radii[0].set(SkIntToScalar(30), SkIntToScalar(30)); | 37 radii[0].set(SkIntToScalar(30), SkIntToScalar(30)); |
38 radii[1].set(SkIntToScalar(10), SkIntToScalar(10)); | 38 radii[1].set(SkIntToScalar(10), SkIntToScalar(10)); |
39 radii[2].set(SkIntToScalar(30), SkIntToScalar(30)); | 39 radii[2].set(SkIntToScalar(30), SkIntToScalar(30)); |
40 radii[3].set(SkIntToScalar(10), SkIntToScalar(10)); | 40 radii[3].set(SkIntToScalar(10), SkIntToScalar(10)); |
41 SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); | 41 SkRect r = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); |
42 fRRect.setRectRadii(r, radii); | 42 fRRect.setRectRadii(r, radii); |
43 } | 43 } |
44 | 44 |
45 SkString onShortName() SK_OVERRIDE { | 45 SkString onShortName() override { |
46 return fName; | 46 return fName; |
47 } | 47 } |
48 | 48 |
49 SkISize onISize() SK_OVERRIDE { | 49 SkISize onISize() override { |
50 return SkISize::Make(SkScalarCeilToInt(fRRect.rect().width()), | 50 return SkISize::Make(SkScalarCeilToInt(fRRect.rect().width()), |
51 SkScalarCeilToInt(fRRect.rect().height())); | 51 SkScalarCeilToInt(fRRect.rect().height())); |
52 } | 52 } |
53 | 53 |
54 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 54 void onDraw(SkCanvas* canvas) override { |
55 SkLayerDrawLooper::Builder looperBuilder; | 55 SkLayerDrawLooper::Builder looperBuilder; |
56 { | 56 { |
57 SkLayerDrawLooper::LayerInfo info; | 57 SkLayerDrawLooper::LayerInfo info; |
58 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit | 58 info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit |
59 | SkLayerDrawLooper::kColorFilter_Bit; | 59 | SkLayerDrawLooper::kColorFilter_Bit; |
60 info.fColorMode = SkXfermode::kSrc_Mode; | 60 info.fColorMode = SkXfermode::kSrc_Mode; |
61 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); | 61 info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); |
62 info.fPostTranslate = false; | 62 info.fPostTranslate = false; |
63 SkPaint* paint = looperBuilder.addLayerOnTop(info); | 63 SkPaint* paint = looperBuilder.addLayerOnTop(info); |
64 SkMaskFilter* maskFilter = SkBlurMaskFilter::Create( | 64 SkMaskFilter* maskFilter = SkBlurMaskFilter::Create( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 // Simpler blurred RR test cases where all the radii are the same. | 121 // Simpler blurred RR test cases where all the radii are the same. |
122 class SimpleBlurRoundRectGM : public skiagm::GM { | 122 class SimpleBlurRoundRectGM : public skiagm::GM { |
123 public: | 123 public: |
124 SimpleBlurRoundRectGM() | 124 SimpleBlurRoundRectGM() |
125 : fName("simpleblurroundrect") { | 125 : fName("simpleblurroundrect") { |
126 } | 126 } |
127 | 127 |
128 protected: | 128 protected: |
129 | 129 |
130 SkString onShortName() SK_OVERRIDE { | 130 SkString onShortName() override { |
131 return fName; | 131 return fName; |
132 } | 132 } |
133 | 133 |
134 SkISize onISize() SK_OVERRIDE { | 134 SkISize onISize() override { |
135 return SkISize::Make(1000, 500); | 135 return SkISize::Make(1000, 500); |
136 } | 136 } |
137 | 137 |
138 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 138 void onDraw(SkCanvas* canvas) override { |
139 canvas->scale(1.5f, 1.5f); | 139 canvas->scale(1.5f, 1.5f); |
140 canvas->translate(50,50); | 140 canvas->translate(50,50); |
141 | 141 |
142 const float blurRadii[] = { 1,5,10,20 }; | 142 const float blurRadii[] = { 1,5,10,20 }; |
143 const int cornerRadii[] = { 1,5,10,20 }; | 143 const int cornerRadii[] = { 1,5,10,20 }; |
144 const SkRect r = SkRect::MakeWH(SkIntToScalar(25), SkIntToScalar(25)); | 144 const SkRect r = SkRect::MakeWH(SkIntToScalar(25), SkIntToScalar(25)); |
145 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { | 145 for (size_t i = 0; i < SK_ARRAY_COUNT(blurRadii); ++i) { |
146 SkAutoCanvasRestore autoRestore(canvas, true); | 146 SkAutoCanvasRestore autoRestore(canvas, true); |
147 canvas->translate(0, (r.height() + SkIntToScalar(50)) * i); | 147 canvas->translate(0, (r.height() + SkIntToScalar(50)) * i); |
148 for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) { | 148 for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // TODO(scroggo): Disabled in an attempt to rememdy | 180 // TODO(scroggo): Disabled in an attempt to rememdy |
181 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: | 181 // https://code.google.com/p/skia/issues/detail?id=1801 ('Win7 Test bots all fai
ling GenerateGMs: |
182 // ran wrong number of tests') | 182 // ran wrong number of tests') |
183 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) | 183 //DEF_GM(return new BlurRoundRectGM(600, 5514, 6);) |
184 | 184 |
185 // Rounded rect with two opposite corners with large radii, the other two | 185 // Rounded rect with two opposite corners with large radii, the other two |
186 // small. | 186 // small. |
187 DEF_GM(return new BlurRoundRectGM(100, 100);) | 187 DEF_GM(return new BlurRoundRectGM(100, 100);) |
188 | 188 |
189 DEF_GM(return new SimpleBlurRoundRectGM();) | 189 DEF_GM(return new SimpleBlurRoundRectGM();) |
OLD | NEW |