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

Side by Side Diff: bench/RegionBench.cpp

Issue 23876006: Refactoring: get rid of the SkBenchmark void* parameter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: sync to head 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/RefCntBench.cpp ('k') | bench/RegionContainBench.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 "SkRandom.h" 9 #include "SkRandom.h"
10 #include "SkRegion.h" 10 #include "SkRegion.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 }; 81 };
82 82
83 SkIRect randrect(SkRandom& rand) { 83 SkIRect randrect(SkRandom& rand) {
84 int x = rand.nextU() % W; 84 int x = rand.nextU() % W;
85 int y = rand.nextU() % H; 85 int y = rand.nextU() % H;
86 int w = rand.nextU() % W; 86 int w = rand.nextU() % W;
87 int h = rand.nextU() % H; 87 int h = rand.nextU() % H;
88 return SkIRect::MakeXYWH(x, y, w >> 1, h >> 1); 88 return SkIRect::MakeXYWH(x, y, w >> 1, h >> 1);
89 } 89 }
90 90
91 RegionBench(void* param, int count, Proc proc, const char name[]) : INHERITE D(param) { 91 RegionBench(int count, Proc proc, const char name[]) {
92 fProc = proc; 92 fProc = proc;
93 fName.printf("region_%s_%d", name, count); 93 fName.printf("region_%s_%d", name, count);
94 94
95 SkRandom rand; 95 SkRandom rand;
96 for (int i = 0; i < count; i++) { 96 for (int i = 0; i < count; i++) {
97 fA.op(randrect(rand), SkRegion::kXOR_Op); 97 fA.op(randrect(rand), SkRegion::kXOR_Op);
98 fB.op(randrect(rand), SkRegion::kXOR_Op); 98 fB.op(randrect(rand), SkRegion::kXOR_Op);
99 } 99 }
100 fIsRendering = false; 100 fIsRendering = false;
101 } 101 }
102 102
103 protected: 103 protected:
104 virtual const char* onGetName() { return fName.c_str(); } 104 virtual const char* onGetName() { return fName.c_str(); }
105 105
106 virtual void onDraw(SkCanvas* canvas) { 106 virtual void onDraw(SkCanvas* canvas) {
107 Proc proc = fProc; 107 Proc proc = fProc;
108 for (int i = 0; i < this->getLoops(); ++i) { 108 for (int i = 0; i < this->getLoops(); ++i) {
109 proc(fA, fB); 109 proc(fA, fB);
110 } 110 }
111 } 111 }
112 112
113 private: 113 private:
114 typedef SkBenchmark INHERITED; 114 typedef SkBenchmark INHERITED;
115 }; 115 };
116 116
117 #define SMALL 16 117 #define SMALL 16
118 118
119 static SkBenchmark* gF0(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, uni on_proc, "union")); } 119 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, union_proc, "union")); )
120 static SkBenchmark* gF1(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, sec t_proc, "intersect")); } 120 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sect_proc, "intersect")); )
121 static SkBenchmark* gF2(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, dif f_proc, "difference")); } 121 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diff_proc, "difference")); )
122 static SkBenchmark* gF3(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, dif frect_proc, "differencerect")); } 122 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrect_proc, "differencerect ")); )
123 static SkBenchmark* gF4(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, dif frectbig_proc, "differencerectbig")); } 123 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, diffrectbig_proc, "differencer ectbig")); )
124 static SkBenchmark* gF5(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, con tainsrect_proc, "containsrect")); } 124 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsrect_proc, "containsre ct")); )
125 static SkBenchmark* gF6(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, sec tsrgn_proc, "intersectsrgn")); } 125 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrgn_proc, "intersectsrgn" )); )
126 static SkBenchmark* gF7(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, sec tsrect_proc, "intersectsrect")); } 126 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, sectsrect_proc, "intersectsrec t")); )
127 static SkBenchmark* gF8(void* p) { return SkNEW_ARGS(RegionBench, (p, SMALL, con tainsxy_proc, "containsxy")); } 127 DEF_BENCH( return SkNEW_ARGS(RegionBench, (SMALL, containsxy_proc, "containsxy") ); )
128
129 static BenchRegistry gR0(gF0);
130 static BenchRegistry gR1(gF1);
131 static BenchRegistry gR2(gF2);
132 static BenchRegistry gR3(gF3);
133 static BenchRegistry gR4(gF4);
134 static BenchRegistry gR5(gF5);
135 static BenchRegistry gR6(gF6);
136 static BenchRegistry gR7(gF7);
137 static BenchRegistry gR8(gF8);
OLDNEW
« no previous file with comments | « bench/RefCntBench.cpp ('k') | bench/RegionContainBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698