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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 SkRect rect = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize,
kHalfSquareSize }; | 103 SkRect rect = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize,
kHalfSquareSize }; |
104 rect.offset(gBlurOffsets[i]); | 104 rect.offset(gBlurOffsets[i]); |
105 rect.offset(x, y); | 105 rect.offset(x, y); |
106 canvas->drawRect(rect, paint); | 106 canvas->drawRect(rect, paint); |
107 } | 107 } |
108 | 108 |
109 canvas->restore(); | 109 canvas->restore(); |
110 } | 110 } |
111 | 111 |
112 SkMaskFilter* createBlur() { | 112 SkMaskFilter* createBlur() { |
113 static const SkScalar kBlurRadius = 25.0f; | 113 static const SkScalar kBlurSigma = SkFloatToScalar(14.93375f); |
114 | 114 |
115 return SkBlurMaskFilter::Create(kBlurRadius, | 115 return SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle, |
116 SkBlurMaskFilter::kNormal_BlurStyle, | 116 kBlurSigma, |
117 SkBlurMaskFilter::kHighQuality_BlurFlag)
; | 117 SkBlurMaskFilter::kHighQuality_BlurFlag)
; |
118 } | 118 } |
119 | 119 |
120 // This draws 4 blurred shadows around a single square (centered at x, y). | 120 // This draws 4 blurred shadows around a single square (centered at x, y). |
121 // Each blur is offset +/- half the square's side in x & y from the original | 121 // Each blur is offset +/- half the square's side in x & y from the original |
122 // (so each blurred rect is centered at one of the corners of the original). | 122 // (so each blurred rect is centered at one of the corners of the original). |
123 // For each blur a large outer clip is centered around the blurred rect | 123 // For each blur a large outer clip is centered around the blurred rect |
124 // while a difference clip stays at the location of the original rect. | 124 // while a difference clip stays at the location of the original rect. |
125 // Each blurred rect is drawn with a draw looper where the original (non- | 125 // Each blurred rect is drawn with a draw looper where the original (non- |
126 // blurred rect) is offset to reside outside of the large outer clip (so | 126 // blurred rect) is offset to reside outside of the large outer clip (so |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 { -kHalfSquareSize, -kHalfSquareSize } | 241 { -kHalfSquareSize, -kHalfSquareSize } |
242 }; | 242 }; |
243 | 243 |
244 const SkColor MegaLooperGM::gColors[4] = { | 244 const SkColor MegaLooperGM::gColors[4] = { |
245 SK_ColorGREEN, SK_ColorYELLOW, SK_ColorBLUE, SK_ColorRED | 245 SK_ColorGREEN, SK_ColorYELLOW, SK_ColorBLUE, SK_ColorRED |
246 }; | 246 }; |
247 | 247 |
248 DEF_GM( return new MegaLooperGM(MegaLooperGM::k0x0_Type); ) | 248 DEF_GM( return new MegaLooperGM(MegaLooperGM::k0x0_Type); ) |
249 DEF_GM( return new MegaLooperGM(MegaLooperGM::k4x1_Type); ) | 249 DEF_GM( return new MegaLooperGM(MegaLooperGM::k4x1_Type); ) |
250 DEF_GM( return new MegaLooperGM(MegaLooperGM::k1x4_Type); ) | 250 DEF_GM( return new MegaLooperGM(MegaLooperGM::k1x4_Type); ) |
OLD | NEW |