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

Side by Side Diff: bench/PatchBench.cpp

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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/MutexBench.cpp ('k') | bench/PatchGridBench.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 2014 Google Inc. 2 * Copyright 2014 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 "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW, 75 SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW,
76 }; 76 };
77 const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f } }; 77 const SkPoint pts[] = { { 200.f / 4.f, 0.f }, { 3.f * 200.f / 4, 200.f } };
78 78
79 return SkGradientShader::CreateLinear(pts, colors, NULL, 79 return SkGradientShader::CreateLinear(pts, colors, NULL,
80 SK_ARRAY_COUNT(colors), 80 SK_ARRAY_COUNT(colors),
81 SkShader::kMirror_TileMode); 81 SkShader::kMirror_TileMode);
82 } 82 }
83 83
84 protected: 84 protected:
85 virtual const char* onGetName() SK_OVERRIDE { 85 const char* onGetName() SK_OVERRIDE {
86 SkString vertexMode; 86 SkString vertexMode;
87 switch (fVertexMode) { 87 switch (fVertexMode) {
88 case kNone_VertexMode: 88 case kNone_VertexMode:
89 vertexMode.set("meshlines"); 89 vertexMode.set("meshlines");
90 break; 90 break;
91 case kColors_VertexMode: 91 case kColors_VertexMode:
92 vertexMode.set("colors"); 92 vertexMode.set("colors");
93 break; 93 break;
94 case kTexCoords_VertexMode: 94 case kTexCoords_VertexMode:
95 vertexMode.set("texs"); 95 vertexMode.set("texs");
96 break; 96 break;
97 case kBoth_VertexMode: 97 case kBoth_VertexMode:
98 vertexMode.set("colors_texs"); 98 vertexMode.set("colors_texs");
99 break; 99 break;
100 default: 100 default:
101 break; 101 break;
102 } 102 }
103 SkString type; 103 SkString type;
104 this->appendName(&type); 104 this->appendName(&type);
105 fName.printf("patch_%s_%s_[%f,%f]", type.c_str(), vertexMode.c_str(), 105 fName.printf("patch_%s_%s_[%f,%f]", type.c_str(), vertexMode.c_str(),
106 fScale.x(), fScale.y()); 106 fScale.x(), fScale.y());
107 return fName.c_str(); 107 return fName.c_str();
108 } 108 }
109 109
110 virtual void onPreDraw() SK_OVERRIDE { 110 void onPreDraw() SK_OVERRIDE {
111 this->setCubics(); 111 this->setCubics();
112 this->setColors(); 112 this->setColors();
113 this->setTexCoords(); 113 this->setTexCoords();
114 this->setupPaint(&fPaint); 114 this->setupPaint(&fPaint);
115 switch (fVertexMode) { 115 switch (fVertexMode) {
116 case kTexCoords_VertexMode: 116 case kTexCoords_VertexMode:
117 case kBoth_VertexMode: 117 case kBoth_VertexMode:
118 fPaint.setShader(this->createShader())->unref(); 118 fPaint.setShader(this->createShader())->unref();
119 break; 119 break;
120 default: 120 default:
121 fPaint.setShader(NULL); 121 fPaint.setShader(NULL);
122 break; 122 break;
123 } 123 }
124 } 124 }
125 125
126 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 126 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
127 canvas->scale(fScale.x(), fScale.y()); 127 canvas->scale(fScale.x(), fScale.y());
128 for (int i = 0; i < loops; i++) { 128 for (int i = 0; i < loops; i++) {
129 switch (fVertexMode) { 129 switch (fVertexMode) {
130 case kNone_VertexMode: 130 case kNone_VertexMode:
131 canvas->drawPatch(fCubics, NULL, NULL, NULL, fPaint); 131 canvas->drawPatch(fCubics, NULL, NULL, NULL, fPaint);
132 break; 132 break;
133 case kColors_VertexMode: 133 case kColors_VertexMode:
134 canvas->drawPatch(fCubics, fColors, NULL, NULL, fPaint); 134 canvas->drawPatch(fCubics, fColors, NULL, NULL, fPaint);
135 break; 135 break;
136 case kTexCoords_VertexMode: 136 case kTexCoords_VertexMode:
(...skipping 17 matching lines...) Expand all
154 VertexMode fVertexMode; 154 VertexMode fVertexMode;
155 155
156 typedef Benchmark INHERITED; 156 typedef Benchmark INHERITED;
157 }; 157 };
158 158
159 class SquarePatchBench : public PatchBench { 159 class SquarePatchBench : public PatchBench {
160 public: 160 public:
161 SquarePatchBench(SkPoint scale, VertexMode vertexMode) 161 SquarePatchBench(SkPoint scale, VertexMode vertexMode)
162 : INHERITED(scale, vertexMode) { } 162 : INHERITED(scale, vertexMode) { }
163 163
164 virtual void appendName(SkString* name) SK_OVERRIDE { 164 void appendName(SkString* name) SK_OVERRIDE {
165 name->append("square"); 165 name->append("square");
166 } 166 }
167 167
168 virtual void setCubics() SK_OVERRIDE { 168 void setCubics() SK_OVERRIDE {
169 const SkPoint points[SkPatchUtils::kNumCtrlPts] = { 169 const SkPoint points[SkPatchUtils::kNumCtrlPts] = {
170 //top points 170 //top points
171 {100,100},{150,100},{250,100}, {300,100}, 171 {100,100},{150,100},{250,100}, {300,100},
172 //right points 172 //right points
173 {300, 150},{300,250}, 173 {300, 150},{300,250},
174 //bottom points 174 //bottom points
175 {300,300},{250,300},{150,300},{100,300}, 175 {300,300},{250,300},{150,300},{100,300},
176 //left points 176 //left points
177 {100,250},{100,150} 177 {100,250},{100,150}
178 }; 178 };
179 memcpy(fCubics, points, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint)); 179 memcpy(fCubics, points, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint));
180 } 180 }
181 private: 181 private:
182 typedef PatchBench INHERITED; 182 typedef PatchBench INHERITED;
183 }; 183 };
184 184
185 class LODDiffPatchBench : public PatchBench { 185 class LODDiffPatchBench : public PatchBench {
186 public: 186 public:
187 LODDiffPatchBench(SkPoint scale, VertexMode vertexMode) 187 LODDiffPatchBench(SkPoint scale, VertexMode vertexMode)
188 : INHERITED(scale, vertexMode) { } 188 : INHERITED(scale, vertexMode) { }
189 189
190 virtual void appendName(SkString* name) SK_OVERRIDE { 190 void appendName(SkString* name) SK_OVERRIDE {
191 name->append("LOD_Diff"); 191 name->append("LOD_Diff");
192 } 192 }
193 193
194 virtual void setCubics() SK_OVERRIDE { 194 void setCubics() SK_OVERRIDE {
195 const SkPoint points[SkPatchUtils::kNumCtrlPts] = { 195 const SkPoint points[SkPatchUtils::kNumCtrlPts] = {
196 //top points 196 //top points
197 {100,175},{150,100},{250,100}, {300,0}, 197 {100,175},{150,100},{250,100}, {300,0},
198 //right points 198 //right points
199 {300, 150},{300,250}, 199 {300, 150},{300,250},
200 //bottom points 200 //bottom points
201 {300,400},{250,300},{150,300},{100,225}, 201 {300,400},{250,300},{150,300},{100,225},
202 //left points 202 //left points
203 {100,215},{100,185} 203 {100,215},{100,185}
204 }; 204 };
205 memcpy(fCubics, points, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint)); 205 memcpy(fCubics, points, SkPatchUtils::kNumCtrlPts * sizeof(SkPoint));
206 } 206 }
207 private: 207 private:
208 typedef PatchBench INHERITED; 208 typedef PatchBench INHERITED;
209 }; 209 };
210 210
211 class LoopPatchBench : public PatchBench { 211 class LoopPatchBench : public PatchBench {
212 public: 212 public:
213 LoopPatchBench(SkPoint scale, VertexMode vertexMode) 213 LoopPatchBench(SkPoint scale, VertexMode vertexMode)
214 : INHERITED(scale, vertexMode) { } 214 : INHERITED(scale, vertexMode) { }
215 215
216 virtual void appendName(SkString* name) SK_OVERRIDE { 216 void appendName(SkString* name) SK_OVERRIDE {
217 name->append("loop"); 217 name->append("loop");
218 } 218 }
219 219
220 virtual void setCubics() SK_OVERRIDE { 220 void setCubics() SK_OVERRIDE {
221 const SkPoint points[SkPatchUtils::kNumCtrlPts] = { 221 const SkPoint points[SkPatchUtils::kNumCtrlPts] = {
222 //top points 222 //top points
223 {100,100},{300,200},{100,200}, {300,100}, 223 {100,100},{300,200},{100,200}, {300,100},
224 //right points 224 //right points
225 {380, 400},{380,0}, 225 {380, 400},{380,0},
226 //bottom points 226 //bottom points
227 {300,300},{250,250},{30,200},{100,300}, 227 {300,300},{250,250},{30,200},{100,300},
228 //left points 228 //left points
229 {140,325},{150,150} 229 {140,325},{150,150}
230 }; 230 };
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 DEF_BENCH( return new LoopPatchBench(SkVector::Make(1.0f, 1.0f), 316 DEF_BENCH( return new LoopPatchBench(SkVector::Make(1.0f, 1.0f),
317 PatchBench::kBoth_VertexMode); ) 317 PatchBench::kBoth_VertexMode); )
318 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), 318 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f),
319 PatchBench::kNone_VertexMode); ) 319 PatchBench::kNone_VertexMode); )
320 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), 320 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f),
321 PatchBench::kColors_VertexMode); ) 321 PatchBench::kColors_VertexMode); )
322 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), 322 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f),
323 PatchBench::kTexCoords_VertexMode); ) 323 PatchBench::kTexCoords_VertexMode); )
324 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f), 324 DEF_BENCH( return new LoopPatchBench(SkVector::Make(3.0f, 3.0f),
325 PatchBench::kBoth_VertexMode); ) 325 PatchBench::kBoth_VertexMode); )
OLDNEW
« no previous file with comments | « bench/MutexBench.cpp ('k') | bench/PatchGridBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698