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

Side by Side Diff: gm/rectangletexture.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/recordopts.cpp ('k') | gm/rrect.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 2016 Google Inc. 2 * Copyright 2016 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 // This test only works with the GPU backend. 8 // This test only works with the GPU backend.
9 9
10 #include "gm.h" 10 #include "gm.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return nullptr; 120 return nullptr;
121 } 121 }
122 122
123 void onDraw(SkCanvas* canvas) override { 123 void onDraw(SkCanvas* canvas) override {
124 GrContext *context = canvas->getGrContext(); 124 GrContext *context = canvas->getGrContext();
125 if (!context) { 125 if (!context) {
126 skiagm::GM::DrawGpuOnlyMessage(canvas); 126 skiagm::GM::DrawGpuOnlyMessage(canvas);
127 return; 127 return;
128 } 128 }
129 129
130 static const int kWidth = 50; 130 constexpr int kWidth = 50;
131 static const int kHeight = 50; 131 constexpr int kHeight = 50;
132 static const SkScalar kPad = 5.f; 132 constexpr SkScalar kPad = 5.f;
133 133
134 SkPMColor pixels[kWidth * kHeight]; 134 SkPMColor pixels[kWidth * kHeight];
135 this->fillPixels(kWidth, kHeight, pixels); 135 this->fillPixels(kWidth, kHeight, pixels);
136 sk_sp<SkImage> rectImg(this->createRectangleTextureImg(context, kWidth, kHeight, pixels)); 136 sk_sp<SkImage> rectImg(this->createRectangleTextureImg(context, kWidth, kHeight, pixels));
137 137
138 if (!rectImg) { 138 if (!rectImg) {
139 SkPaint paint; 139 SkPaint paint;
140 paint.setAntiAlias(true); 140 paint.setAntiAlias(true);
141 static const char* kMsg = "Could not create rectangle texture image. "; 141 const char* kMsg = "Could not create rectangle texture image.";
142 canvas->drawText(kMsg, strlen(kMsg), 10, 100, paint); 142 canvas->drawText(kMsg, strlen(kMsg), 10, 100, paint);
143 return; 143 return;
144 } 144 }
145 145
146 static const SkFilterQuality kQualities[] = { 146 constexpr SkFilterQuality kQualities[] = {
147 kNone_SkFilterQuality, 147 kNone_SkFilterQuality,
148 kLow_SkFilterQuality, 148 kLow_SkFilterQuality,
149 kMedium_SkFilterQuality, 149 kMedium_SkFilterQuality,
150 kHigh_SkFilterQuality, 150 kHigh_SkFilterQuality,
151 }; 151 };
152 152
153 static const SkScalar kScales[] = { 1.0f, 1.2f, 0.75f }; 153 constexpr SkScalar kScales[] = { 1.0f, 1.2f, 0.75f };
154 154
155 canvas->translate(kPad, kPad); 155 canvas->translate(kPad, kPad);
156 for (auto s : kScales) { 156 for (auto s : kScales) {
157 canvas->save(); 157 canvas->save();
158 canvas->scale(s, s); 158 canvas->scale(s, s);
159 for (auto q : kQualities) { 159 for (auto q : kQualities) {
160 SkPaint plainPaint; 160 SkPaint plainPaint;
161 plainPaint.setFilterQuality(q); 161 plainPaint.setFilterQuality(q);
162 canvas->drawImage(rectImg.get(), 0, 0, &plainPaint); 162 canvas->drawImage(rectImg.get(), 0, 0, &plainPaint);
163 canvas->translate(kWidth + kPad, 0); 163 canvas->translate(kWidth + kPad, 0);
(...skipping 18 matching lines...) Expand all
182 } 182 }
183 183
184 private: 184 private:
185 typedef GM INHERITED; 185 typedef GM INHERITED;
186 }; 186 };
187 187
188 DEF_GM(return new RectangleTexture;) 188 DEF_GM(return new RectangleTexture;)
189 } 189 }
190 190
191 #endif 191 #endif
OLDNEW
« no previous file with comments | « gm/recordopts.cpp ('k') | gm/rrect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698