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

Side by Side Diff: bench/PicturePlaybackBench.cpp

Issue 1379923005: Remove const from `const int loops`. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: n too Created 5 years, 2 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 | « bench/PictureOverheadBench.cpp ('k') | bench/PremulAndUnpremulAlphaOpsBench.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 2011 Google Inc. 2 * Copyright 2011 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 #include "Benchmark.h" 7 #include "Benchmark.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 19 matching lines...) Expand all
30 enum { 30 enum {
31 PICTURE_WIDTH = 1000, 31 PICTURE_WIDTH = 1000,
32 PICTURE_HEIGHT = 4000, 32 PICTURE_HEIGHT = 4000,
33 TEXT_SIZE = 10 33 TEXT_SIZE = 10
34 }; 34 };
35 protected: 35 protected:
36 virtual const char* onGetName() { 36 virtual const char* onGetName() {
37 return fName.c_str(); 37 return fName.c_str();
38 } 38 }
39 39
40 virtual void onDraw(const int loops, SkCanvas* canvas) { 40 virtual void onDraw(int loops, SkCanvas* canvas) {
41 41
42 SkPictureRecorder recorder; 42 SkPictureRecorder recorder;
43 SkCanvas* pCanvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGH T, nullptr, 0); 43 SkCanvas* pCanvas = recorder.beginRecording(PICTURE_WIDTH, PICTURE_HEIGH T, nullptr, 0);
44 this->recordCanvas(pCanvas); 44 this->recordCanvas(pCanvas);
45 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 45 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
46 46
47 const SkPoint translateDelta = getTranslateDelta(loops); 47 const SkPoint translateDelta = getTranslateDelta(loops);
48 48
49 for (int i = 0; i < loops; i++) { 49 for (int i = 0; i < loops; i++) {
50 picture->playback(canvas); 50 picture->playback(canvas);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 w = rand.nextRangeScalar(0, 128), 178 w = rand.nextRangeScalar(0, 128),
179 h = rand.nextRangeScalar(0, 128); 179 h = rand.nextRangeScalar(0, 128);
180 SkPaint paint; 180 SkPaint paint;
181 paint.setColor(rand.nextU()); 181 paint.setColor(rand.nextU());
182 paint.setAlpha(0xFF); 182 paint.setAlpha(0xFF);
183 canvas->drawRect(SkRect::MakeXYWH(x,y,w,h), paint); 183 canvas->drawRect(SkRect::MakeXYWH(x,y,w,h), paint);
184 } 184 }
185 fPic.reset(recorder.endRecording()); 185 fPic.reset(recorder.endRecording());
186 } 186 }
187 187
188 void onDraw(const int loops, SkCanvas* canvas) override { 188 void onDraw(int loops, SkCanvas* canvas) override {
189 for (int i = 0; i < loops; i++) { 189 for (int i = 0; i < loops; i++) {
190 // This inner loop guarantees we make the same choices for all bench variants. 190 // This inner loop guarantees we make the same choices for all bench variants.
191 SkRandom rand; 191 SkRandom rand;
192 for (int j = 0; j < 10; j++) { 192 for (int j = 0; j < 10; j++) {
193 SkScalar x = 0, y = 0; 193 SkScalar x = 0, y = 0;
194 switch (fMode) { 194 switch (fMode) {
195 case kTiled: x = SkScalar(256 * rand.nextULessThan(4)); 195 case kTiled: x = SkScalar(256 * rand.nextULessThan(4));
196 y = SkScalar(256 * rand.nextULessThan(4)); 196 y = SkScalar(256 * rand.nextULessThan(4));
197 break; 197 break;
198 case kRandom: x = rand.nextRangeScalar(0, 768); 198 case kRandom: x = rand.nextRangeScalar(0, 768);
(...skipping 11 matching lines...) Expand all
210 BBH fBBH; 210 BBH fBBH;
211 Mode fMode; 211 Mode fMode;
212 SkString fName; 212 SkString fName;
213 SkAutoTUnref<SkPicture> fPic; 213 SkAutoTUnref<SkPicture> fPic;
214 }; 214 };
215 215
216 DEF_BENCH( return new TiledPlaybackBench(kNone, kRandom); ) 216 DEF_BENCH( return new TiledPlaybackBench(kNone, kRandom); )
217 DEF_BENCH( return new TiledPlaybackBench(kNone, kTiled ); ) 217 DEF_BENCH( return new TiledPlaybackBench(kNone, kTiled ); )
218 DEF_BENCH( return new TiledPlaybackBench(kRTree, kRandom); ) 218 DEF_BENCH( return new TiledPlaybackBench(kRTree, kRandom); )
219 DEF_BENCH( return new TiledPlaybackBench(kRTree, kTiled ); ) 219 DEF_BENCH( return new TiledPlaybackBench(kRTree, kTiled ); )
OLDNEW
« no previous file with comments | « bench/PictureOverheadBench.cpp ('k') | bench/PremulAndUnpremulAlphaOpsBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698