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

Side by Side Diff: bench/RectBench.cpp

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms Created 7 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 | Annotate | Revision Log
« no previous file with comments | « bench/RTreeBench.cpp ('k') | bench/RectoriBench.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 #include "SkShader.h" 13 #include "SkShader.h"
14 14
15 class RectBench : public SkBenchmark { 15 class RectBench : public SkBenchmark {
16 public: 16 public:
17 int fShift, fStroke; 17 int fShift, fStroke;
18 enum { 18 enum {
19 W = 640, 19 W = 640,
20 H = 480, 20 H = 480,
21 N = SkBENCHLOOP(300) 21 N = SkBENCHLOOP(300)
22 }; 22 };
23 SkRect fRects[N]; 23 SkRect fRects[N];
24 SkColor fColors[N]; 24 SkColor fColors[N];
25 25
26 RectBench(void* param, int shift, int stroke = 0) 26 RectBench(void* param, int shift, int stroke = 0)
27 : INHERITED(param) 27 : INHERITED(param)
28 , fShift(shift) 28 , fShift(shift)
29 , fStroke(stroke) { 29 , fStroke(stroke) {
30 SkMWCRandom rand; 30 SkRandom rand;
31 const SkScalar offset = SK_Scalar1/3; 31 const SkScalar offset = SK_Scalar1/3;
32 for (int i = 0; i < N; i++) { 32 for (int i = 0; i < N; i++) {
33 int x = rand.nextU() % W; 33 int x = rand.nextU() % W;
34 int y = rand.nextU() % H; 34 int y = rand.nextU() % H;
35 int w = rand.nextU() % W; 35 int w = rand.nextU() % W;
36 int h = rand.nextU() % H; 36 int h = rand.nextU() % H;
37 w >>= shift; 37 w >>= shift;
38 h >>= shift; 38 h >>= shift;
39 x -= w/2; 39 x -= w/2;
40 y -= h/2; 40 y -= h/2;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 virtual void onDraw(SkCanvas* canvas) { 239 virtual void onDraw(SkCanvas* canvas) {
240 SkScalar gSizes[] = { 240 SkScalar gSizes[] = {
241 SkIntToScalar(13), SkIntToScalar(24) 241 SkIntToScalar(13), SkIntToScalar(24)
242 }; 242 };
243 size_t sizes = SK_ARRAY_COUNT(gSizes); 243 size_t sizes = SK_ARRAY_COUNT(gSizes);
244 244
245 if (this->hasStrokeWidth()) { 245 if (this->hasStrokeWidth()) {
246 gSizes[0] = this->getStrokeWidth(); 246 gSizes[0] = this->getStrokeWidth();
247 sizes = 1; 247 sizes = 1;
248 } 248 }
249 SkMWCRandom rand; 249 SkRandom rand;
250 SkColor color = 0xFF000000; 250 SkColor color = 0xFF000000;
251 U8CPU alpha = 0xFF; 251 U8CPU alpha = 0xFF;
252 SkPaint paint; 252 SkPaint paint;
253 paint.setStrokeCap(SkPaint::kRound_Cap); 253 paint.setStrokeCap(SkPaint::kRound_Cap);
254 if (_type == KMaskShader) { 254 if (_type == KMaskShader) {
255 SkBitmap srcBM; 255 SkBitmap srcBM;
256 srcBM.setConfig(SkBitmap::kARGB_8888_Config, 10, 1); 256 srcBM.setConfig(SkBitmap::kARGB_8888_Config, 10, 1);
257 srcBM.allocPixels(); 257 srcBM.allocPixels();
258 srcBM.eraseColor(0xFF00FF00); 258 srcBM.eraseColor(0xFF00FF00);
259 259
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 BlitMaskBench::kMaskBlack, "maskblack") 325 BlitMaskBench::kMaskBlack, "maskblack")
326 ); ) 326 ); )
327 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench, 327 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,
328 (p, SkCanvas::kPoints_PointMode, 328 (p, SkCanvas::kPoints_PointMode,
329 BlitMaskBench::kMaskColor, "maskcolor") 329 BlitMaskBench::kMaskColor, "maskcolor")
330 ); ) 330 ); )
331 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench, 331 DEF_BENCH( return SkNEW_ARGS(BlitMaskBench,
332 (p, SkCanvas::kPoints_PointMode, 332 (p, SkCanvas::kPoints_PointMode,
333 BlitMaskBench::KMaskShader, "maskshader") 333 BlitMaskBench::KMaskShader, "maskshader")
334 ); ) 334 ); )
OLDNEW
« no previous file with comments | « bench/RTreeBench.cpp ('k') | bench/RectoriBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698