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

Side by Side Diff: gm/bigblurs.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/beziers.cpp ('k') | gm/bigrrectaaeffect.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 14 matching lines...) Expand all
25 protected: 25 protected:
26 SkString onShortName() override { 26 SkString onShortName() override {
27 return SkString("bigblurs"); 27 return SkString("bigblurs");
28 } 28 }
29 29
30 SkISize onISize() override { 30 SkISize onISize() override {
31 return SkISize::Make(kWidth, kHeight); 31 return SkISize::Make(kWidth, kHeight);
32 } 32 }
33 33
34 void onDraw(SkCanvas* canvas) override { 34 void onDraw(SkCanvas* canvas) override {
35 static const int kBig = 65536; 35 constexpr int kBig = 65536;
36 static const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToS calar(4)); 36 const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4 ));
37 37
38 const SkRect bigRect = SkRect::MakeWH(SkIntToScalar(kBig), SkIntToScalar (kBig)); 38 const SkRect bigRect = SkRect::MakeWH(SkIntToScalar(kBig), SkIntToScalar (kBig));
39 SkRect insetRect = bigRect; 39 SkRect insetRect = bigRect;
40 insetRect.inset(20, 20); 40 insetRect.inset(20, 20);
41 41
42 SkPath rectori; 42 SkPath rectori;
43 43
44 rectori.addRect(bigRect); 44 rectori.addRect(bigRect);
45 rectori.addRect(insetRect, SkPath::kCCW_Direction); 45 rectori.addRect(insetRect, SkPath::kCCW_Direction);
46 46
47 // The blur extends 3*kSigma out from the big rect. 47 // The blur extends 3*kSigma out from the big rect.
48 // Offset the close-up windows so we get the entire blur 48 // Offset the close-up windows so we get the entire blur
49 static const SkScalar kLeftTopPad = 3*kSigma; // use on left & up of big rect 49 const SkScalar kLeftTopPad = 3*kSigma; // use on left & up of big rec t
50 static const SkScalar kRightBotPad = kCloseUpSize-3*kSigma; // use on ri ght and bot sides 50 const SkScalar kRightBotPad = kCloseUpSize-3*kSigma; // use on right and bot sides
51 51
52 // UL hand corners of the rendered closeups 52 // UL hand corners of the rendered closeups
53 const SkPoint origins[] = { 53 const SkPoint origins[] = {
54 { -kLeftTopPad, -kLeftTopPad }, // UL 54 { -kLeftTopPad, -kLeftTopPad }, // UL
55 { kBig-kRightBotPad, -kLeftTopPad }, // UR 55 { kBig-kRightBotPad, -kLeftTopPad }, // UR
56 { kBig-kRightBotPad, kBig-kRightBotPad }, // LR 56 { kBig-kRightBotPad, kBig-kRightBotPad }, // LR
57 { -kLeftTopPad, kBig-kRightBotPad }, // LL 57 { -kLeftTopPad, kBig-kRightBotPad }, // LL
58 { kBig/2-kCloseUpSize/2, kBig/2-kCloseUpSize/2 }, // center 58 { kBig/2-kCloseUpSize/2, kBig/2-kCloseUpSize/2 }, // center
59 }; 59 };
60 60
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 desiredX += kCloseUpSize; 96 desiredX += kCloseUpSize;
97 } 97 }
98 98
99 desiredX = 0; 99 desiredX = 0;
100 desiredY += kCloseUpSize; 100 desiredY += kCloseUpSize;
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 private: 105 private:
106 static const int kCloseUpSize = 64; 106 static constexpr int kCloseUpSize = 64;
107 static const int kWidth = 5 * kCloseUpSize; 107 static constexpr int kWidth = 5 * kCloseUpSize;
108 static const int kHeight = 2 * (kLastEnum_SkBlurStyle + 1) * kCloseUpSize; 108 static constexpr int kHeight = 2 * (kLastEnum_SkBlurStyle + 1) * kCloseUpSiz e;
109 109
110 typedef GM INHERITED; 110 typedef GM INHERITED;
111 }; 111 };
112 112
113 DEF_GM(return new BigBlursGM;) 113 DEF_GM(return new BigBlursGM;)
114 } 114 }
OLDNEW
« no previous file with comments | « gm/beziers.cpp ('k') | gm/bigrrectaaeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698