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

Side by Side Diff: gm/xfermodes3.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/xfermodes2.cpp ('k') | gm/yuvtorgbeffect.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 "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 30 matching lines...) Expand all
41 canvas->drawPaint(bgPaint); 41 canvas->drawPaint(bgPaint);
42 } 42 }
43 43
44 void onDraw(SkCanvas* canvas) override { 44 void onDraw(SkCanvas* canvas) override {
45 canvas->translate(SkIntToScalar(10), SkIntToScalar(20)); 45 canvas->translate(SkIntToScalar(10), SkIntToScalar(20));
46 46
47 SkPaint labelP; 47 SkPaint labelP;
48 labelP.setAntiAlias(true); 48 labelP.setAntiAlias(true);
49 sk_tool_utils::set_portable_typeface(&labelP); 49 sk_tool_utils::set_portable_typeface(&labelP);
50 50
51 static const SkColor kSolidColors[] = { 51 constexpr SkColor kSolidColors[] = {
52 SK_ColorTRANSPARENT, 52 SK_ColorTRANSPARENT,
53 SK_ColorBLUE, 53 SK_ColorBLUE,
54 0x80808000 54 0x80808000
55 }; 55 };
56 56
57 static const SkColor kBmpAlphas[] = { 57 constexpr SkColor kBmpAlphas[] = {
58 0xff, 58 0xff,
59 0x80, 59 0x80,
60 }; 60 };
61 61
62 auto tempSurface(this->possiblyCreateTempSurface(canvas, kSize, kSize)); 62 auto tempSurface(this->possiblyCreateTempSurface(canvas, kSize, kSize));
63 63
64 int test = 0; 64 int test = 0;
65 int x = 0, y = 0; 65 int x = 0, y = 0;
66 static const struct { SkPaint::Style fStyle; SkScalar fWidth; } kStrokes [] = { 66 constexpr struct { SkPaint::Style fStyle; SkScalar fWidth; } kStrokes[] = {
67 {SkPaint::kFill_Style, 0}, 67 {SkPaint::kFill_Style, 0},
68 {SkPaint::kStroke_Style, SkIntToScalar(kSize) / 2}, 68 {SkPaint::kStroke_Style, SkIntToScalar(kSize) / 2},
69 }; 69 };
70 for (size_t s = 0; s < SK_ARRAY_COUNT(kStrokes); ++s) { 70 for (size_t s = 0; s < SK_ARRAY_COUNT(kStrokes); ++s) {
71 for (size_t m = 0; m <= SkXfermode::kLastMode; ++m) { 71 for (size_t m = 0; m <= SkXfermode::kLastMode; ++m) {
72 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m); 72 SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(m);
73 canvas->drawText(SkXfermode::ModeName(mode), 73 canvas->drawText(SkXfermode::ModeName(mode),
74 strlen(SkXfermode::ModeName(mode)), 74 strlen(SkXfermode::ModeName(mode)),
75 SkIntToScalar(x), 75 SkIntToScalar(x),
76 SkIntToScalar(y + kSize + 3) + labelP.getTextSi ze(), 76 SkIntToScalar(y + kSize + 3) + labelP.getTextSi ze(),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); 167 r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
168 SkPaint borderPaint; 168 SkPaint borderPaint;
169 borderPaint.setStyle(SkPaint::kStroke_Style); 169 borderPaint.setStyle(SkPaint::kStroke_Style);
170 canvas->drawRect(r, borderPaint); 170 canvas->drawRect(r, borderPaint);
171 171
172 canvas->restore(); 172 canvas->restore();
173 } 173 }
174 174
175 void onOnceBeforeDraw() override { 175 void onOnceBeforeDraw() override {
176 static const uint32_t kCheckData[] = { 176 const uint32_t kCheckData[] = {
177 SkPackARGB32(0xFF, 0x42, 0x41, 0x42), 177 SkPackARGB32(0xFF, 0x42, 0x41, 0x42),
178 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), 178 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
179 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6), 179 SkPackARGB32(0xFF, 0xD6, 0xD3, 0xD6),
180 SkPackARGB32(0xFF, 0x42, 0x41, 0x42) 180 SkPackARGB32(0xFF, 0x42, 0x41, 0x42)
181 }; 181 };
182 SkBitmap bg; 182 SkBitmap bg;
183 bg.allocN32Pixels(2, 2, true); 183 bg.allocN32Pixels(2, 2, true);
184 SkAutoLockPixels bgAlp(bg); 184 SkAutoLockPixels bgAlp(bg);
185 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData)); 185 memcpy(bg.getPixels(), kCheckData, sizeof(kCheckData));
186 186
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 sk_sp<SkShader> fBmpShader; 221 sk_sp<SkShader> fBmpShader;
222 222
223 typedef GM INHERITED; 223 typedef GM INHERITED;
224 }; 224 };
225 225
226 ////////////////////////////////////////////////////////////////////////////// 226 //////////////////////////////////////////////////////////////////////////////
227 227
228 DEF_GM(return new Xfermodes3GM;) 228 DEF_GM(return new Xfermodes3GM;)
229 229
230 } 230 }
OLDNEW
« no previous file with comments | « gm/xfermodes2.cpp ('k') | gm/yuvtorgbeffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698