Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: gm/megalooper.cpp

Issue 2300623005: Replace a lot of 'static const' with 'constexpr' or 'const'. (Closed)
Patch Set: small msvc concession Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/linepaths.cpp ('k') | gm/mixedtextblobs.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 case k1x4_Type: // fall through 61 case k1x4_Type: // fall through
62 default: 62 default:
63 draw1x4(canvas, SkIntToScalar(x), SkIntToScalar(y)); 63 draw1x4(canvas, SkIntToScalar(x), SkIntToScalar(y));
64 break; 64 break;
65 } 65 }
66 } 66 }
67 } 67 }
68 } 68 }
69 69
70 private: 70 private:
71 static const int kWidth = 800; 71 static constexpr int kWidth = 800;
72 static const int kHeight = 800; 72 static constexpr int kHeight = 800;
73 static const int kHalfOuterClipSize = 100; 73 static constexpr int kHalfOuterClipSize = 100;
74 static const int kHalfSquareSize = 50; 74 static constexpr int kHalfSquareSize = 50;
75 static const int kOffsetToOutsideClip = kHalfSquareSize + kHalfOuterClipSize + 1; 75 static constexpr int kOffsetToOutsideClip = kHalfSquareSize + kHalfOuterClip Size + 1;
76 76
77 static const SkPoint gBlurOffsets[4]; 77 static const SkPoint gBlurOffsets[4];
78 static const SkColor gColors[4]; 78 static const SkColor gColors[4];
79 Type fType; 79 Type fType;
80 80
81 // Just draw a blurred rect at each of the four corners of a square (centere d at x,y). 81 // Just draw a blurred rect at each of the four corners of a square (centere d at x,y).
82 // Use two clips to define a rectori where we want pixels to appear. 82 // Use two clips to define a rectori where we want pixels to appear.
83 void draw0x0(SkCanvas* canvas, SkScalar x, SkScalar y) { 83 void draw0x0(SkCanvas* canvas, SkScalar x, SkScalar y) {
84 SkRect innerClip = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize , kHalfSquareSize }; 84 SkRect innerClip = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize , kHalfSquareSize };
85 innerClip.offset(x, y); 85 innerClip.offset(x, y);
(...skipping 18 matching lines...) Expand all
104 SkRect rect = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize, kHalfSquareSize }; 104 SkRect rect = { -kHalfSquareSize, -kHalfSquareSize, kHalfSquareSize, kHalfSquareSize };
105 rect.offset(gBlurOffsets[i]); 105 rect.offset(gBlurOffsets[i]);
106 rect.offset(x, y); 106 rect.offset(x, y);
107 canvas->drawRect(rect, paint); 107 canvas->drawRect(rect, paint);
108 } 108 }
109 109
110 canvas->restore(); 110 canvas->restore();
111 } 111 }
112 112
113 static sk_sp<SkMaskFilter> MakeBlur() { 113 static sk_sp<SkMaskFilter> MakeBlur() {
114 static const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIn tToScalar(25)); 114 const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScal ar(25));
115 115
116 return SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kBlurSigma, 116 return SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 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.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 { -kHalfSquareSize, -kHalfSquareSize } 238 { -kHalfSquareSize, -kHalfSquareSize }
239 }; 239 };
240 240
241 const SkColor MegaLooperGM::gColors[4] = { 241 const SkColor MegaLooperGM::gColors[4] = {
242 SK_ColorGREEN, SK_ColorYELLOW, SK_ColorBLUE, SK_ColorRED 242 SK_ColorGREEN, SK_ColorYELLOW, SK_ColorBLUE, SK_ColorRED
243 }; 243 };
244 244
245 DEF_GM( return new MegaLooperGM(MegaLooperGM::k0x0_Type); ) 245 DEF_GM( return new MegaLooperGM(MegaLooperGM::k0x0_Type); )
246 DEF_GM( return new MegaLooperGM(MegaLooperGM::k4x1_Type); ) 246 DEF_GM( return new MegaLooperGM(MegaLooperGM::k4x1_Type); )
247 DEF_GM( return new MegaLooperGM(MegaLooperGM::k1x4_Type); ) 247 DEF_GM( return new MegaLooperGM(MegaLooperGM::k1x4_Type); )
OLDNEW
« no previous file with comments | « gm/linepaths.cpp ('k') | gm/mixedtextblobs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698