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

Side by Side Diff: gm/convexpolyclip.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/convex_all_line_paths.cpp ('k') | gm/convexpolyeffect.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 2014 Google Inc. 2 * Copyright 2014 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 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 rect.inset(wScalar / 8, hScalar / 8); 53 rect.inset(wScalar / 8, hScalar / 8);
54 mat.preTranslate(6 * wScalar, 6 * hScalar); 54 mat.preTranslate(6 * wScalar, 6 * hScalar);
55 mat.postScale(SK_Scalar1 / 3, SK_Scalar1 / 3); 55 mat.postScale(SK_Scalar1 / 3, SK_Scalar1 / 3);
56 } 56 }
57 57
58 paint.setAntiAlias(true); 58 paint.setAntiAlias(true);
59 sk_tool_utils::set_portable_typeface(&paint); 59 sk_tool_utils::set_portable_typeface(&paint);
60 paint.setTextSize(wScalar / 2.2f); 60 paint.setTextSize(wScalar / 2.2f);
61 paint.setShader(0); 61 paint.setShader(0);
62 paint.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY)); 62 paint.setColor(sk_tool_utils::color_to_565(SK_ColorLTGRAY));
63 static const char kTxt[] = "Skia"; 63 constexpr char kTxt[] = "Skia";
64 SkPoint texPos = { wScalar / 17, hScalar / 2 + paint.getTextSize() / 2.5f }; 64 SkPoint texPos = { wScalar / 17, hScalar / 2 + paint.getTextSize() / 2.5f };
65 canvas.drawText(kTxt, SK_ARRAY_COUNT(kTxt)-1, texPos.fX, texPos.fY, paint); 65 canvas.drawText(kTxt, SK_ARRAY_COUNT(kTxt)-1, texPos.fX, texPos.fY, paint);
66 paint.setColor(SK_ColorBLACK); 66 paint.setColor(SK_ColorBLACK);
67 paint.setStyle(SkPaint::kStroke_Style); 67 paint.setStyle(SkPaint::kStroke_Style);
68 paint.setStrokeWidth(SK_Scalar1); 68 paint.setStrokeWidth(SK_Scalar1);
69 canvas.drawText(kTxt, SK_ARRAY_COUNT(kTxt)-1, texPos.fX, texPos.fY, paint); 69 canvas.drawText(kTxt, SK_ARRAY_COUNT(kTxt)-1, texPos.fX, texPos.fY, paint);
70 return bmp; 70 return bmp;
71 } 71 }
72 72
73 namespace skiagm { 73 namespace skiagm {
(...skipping 22 matching lines...) Expand all
96 96
97 void onOnceBeforeDraw() override { 97 void onOnceBeforeDraw() override {
98 SkPath tri; 98 SkPath tri;
99 tri.moveTo(5.f, 5.f); 99 tri.moveTo(5.f, 5.f);
100 tri.lineTo(100.f, 20.f); 100 tri.lineTo(100.f, 20.f);
101 tri.lineTo(15.f, 100.f); 101 tri.lineTo(15.f, 100.f);
102 102
103 fClips.addToTail()->setPath(tri); 103 fClips.addToTail()->setPath(tri);
104 104
105 SkPath hexagon; 105 SkPath hexagon;
106 static const SkScalar kRadius = 45.f; 106 constexpr SkScalar kRadius = 45.f;
107 const SkPoint center = { kRadius, kRadius }; 107 const SkPoint center = { kRadius, kRadius };
108 for (int i = 0; i < 6; ++i) { 108 for (int i = 0; i < 6; ++i) {
109 SkScalar angle = 2 * SK_ScalarPI * i / 6; 109 SkScalar angle = 2 * SK_ScalarPI * i / 6;
110 SkPoint point; 110 SkPoint point;
111 point.fY = SkScalarSinCos(angle, &point.fX); 111 point.fY = SkScalarSinCos(angle, &point.fX);
112 point.scale(kRadius); 112 point.scale(kRadius);
113 point = center + point; 113 point = center + point;
114 if (0 == i) { 114 if (0 == i) {
115 hexagon.moveTo(point); 115 hexagon.moveTo(point);
116 } else { 116 } else {
(...skipping 15 matching lines...) Expand all
132 SkMatrix rotM; 132 SkMatrix rotM;
133 rotM.setRotate(23.f, rect.centerX(), rect.centerY()); 133 rotM.setRotate(23.f, rect.centerX(), rect.centerY());
134 rotRect.transform(rotM); 134 rotRect.transform(rotM);
135 fClips.addToTail()->setPath(rotRect); 135 fClips.addToTail()->setPath(rotRect);
136 136
137 fBmp = make_bmp(100, 100); 137 fBmp = make_bmp(100, 100);
138 } 138 }
139 139
140 void onDraw(SkCanvas* canvas) override { 140 void onDraw(SkCanvas* canvas) override {
141 SkScalar y = 0; 141 SkScalar y = 0;
142 static const SkScalar kMargin = 10.f; 142 constexpr SkScalar kMargin = 10.f;
143 143
144 SkPaint bgPaint; 144 SkPaint bgPaint;
145 bgPaint.setAlpha(0x15); 145 bgPaint.setAlpha(0x15);
146 SkISize size = canvas->getDeviceSize(); 146 SkISize size = canvas->getDeviceSize();
147 canvas->drawBitmapRect(fBmp, SkRect::MakeIWH(size.fWidth, size.fHeight), &bgPaint); 147 canvas->drawBitmapRect(fBmp, SkRect::MakeIWH(size.fWidth, size.fHeight), &bgPaint);
148 148
149 static const char kTxt[] = "Clip Me!"; 149 constexpr char kTxt[] = "Clip Me!";
150 SkPaint txtPaint; 150 SkPaint txtPaint;
151 txtPaint.setTextSize(23.f); 151 txtPaint.setTextSize(23.f);
152 txtPaint.setAntiAlias(true); 152 txtPaint.setAntiAlias(true);
153 sk_tool_utils::set_portable_typeface(&txtPaint); 153 sk_tool_utils::set_portable_typeface(&txtPaint);
154 txtPaint.setColor(sk_tool_utils::color_to_565(SK_ColorDKGRAY)); 154 txtPaint.setColor(sk_tool_utils::color_to_565(SK_ColorDKGRAY));
155 SkScalar textW = txtPaint.measureText(kTxt, SK_ARRAY_COUNT(kTxt)-1); 155 SkScalar textW = txtPaint.measureText(kTxt, SK_ARRAY_COUNT(kTxt)-1);
156 156
157 SkScalar startX = 0; 157 SkScalar startX = 0;
158 int testLayers = kBench_Mode != this->getMode(); 158 int testLayers = kBench_Mode != this->getMode();
159 for (int doLayer = 0; doLayer <= testLayers; ++doLayer) { 159 for (int doLayer = 0; doLayer <= testLayers; ++doLayer) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 292
293 typedef SkTLList<Clip, 1> ClipList; 293 typedef SkTLList<Clip, 1> ClipList;
294 ClipList fClips; 294 ClipList fClips;
295 SkBitmap fBmp; 295 SkBitmap fBmp;
296 296
297 typedef GM INHERITED; 297 typedef GM INHERITED;
298 }; 298 };
299 299
300 DEF_GM(return new ConvexPolyClip;) 300 DEF_GM(return new ConvexPolyClip;)
301 } 301 }
OLDNEW
« no previous file with comments | « gm/convex_all_line_paths.cpp ('k') | gm/convexpolyeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698