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

Side by Side Diff: bench/MatrixBench.cpp

Issue 1232463006: Fix up -Winconsistent-missing-override (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: llvm_coverage_build Created 5 years, 5 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/Matrix44Bench.cpp ('k') | bench/MutexBench.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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkMatrix.h" 9 #include "SkMatrix.h"
10 #include "SkMatrixUtils.h" 10 #include "SkMatrixUtils.h"
11 #include "SkRandom.h" 11 #include "SkRandom.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 13
14 class MatrixBench : public Benchmark { 14 class MatrixBench : public Benchmark {
15 SkString fName; 15 SkString fName;
16 public: 16 public:
17 MatrixBench(const char name[]) { 17 MatrixBench(const char name[]) {
18 fName.printf("matrix_%s", name); 18 fName.printf("matrix_%s", name);
19 } 19 }
20 20
21 bool isSuitableFor(Backend backend) override { 21 bool isSuitableFor(Backend backend) override {
22 return backend == kNonRendering_Backend; 22 return backend == kNonRendering_Backend;
23 } 23 }
24 24
25 virtual void performTest() = 0; 25 virtual void performTest() = 0;
26 26
27 protected: 27 protected:
28 virtual int mulLoopCount() const { return 1; } 28 virtual int mulLoopCount() const { return 1; }
29 29
30 virtual const char* onGetName() { 30 const char* onGetName() override {
31 return fName.c_str(); 31 return fName.c_str();
32 } 32 }
33 33
34 virtual void onDraw(const int loops, SkCanvas*) { 34 void onDraw(const int loops, SkCanvas*) override {
35 for (int i = 0; i < loops; i++) { 35 for (int i = 0; i < loops; i++) {
36 this->performTest(); 36 this->performTest();
37 } 37 }
38 } 38 }
39 39
40 private: 40 private:
41 typedef Benchmark INHERITED; 41 typedef Benchmark INHERITED;
42 }; 42 };
43 43
44 44
45 class EqualsMatrixBench : public MatrixBench { 45 class EqualsMatrixBench : public MatrixBench {
46 public: 46 public:
47 EqualsMatrixBench() : INHERITED("equals") {} 47 EqualsMatrixBench() : INHERITED("equals") {}
48 protected: 48 protected:
49 virtual void performTest() { 49 void performTest() override {
50 SkMatrix m0, m1, m2; 50 SkMatrix m0, m1, m2;
51 51
52 m0.reset(); 52 m0.reset();
53 m1.reset(); 53 m1.reset();
54 m2.reset(); 54 m2.reset();
55 55
56 // xor into a volatile prevents these comparisons from being optimized a way. 56 // xor into a volatile prevents these comparisons from being optimized a way.
57 volatile bool junk = false; 57 volatile bool junk = false;
58 junk ^= (m0 == m1); 58 junk ^= (m0 == m1);
59 junk ^= (m1 == m2); 59 junk ^= (m1 == m2);
60 junk ^= (m2 == m0); 60 junk ^= (m2 == m0);
61 } 61 }
62 private: 62 private:
63 typedef MatrixBench INHERITED; 63 typedef MatrixBench INHERITED;
64 }; 64 };
65 65
66 class ScaleMatrixBench : public MatrixBench { 66 class ScaleMatrixBench : public MatrixBench {
67 public: 67 public:
68 ScaleMatrixBench() : INHERITED("scale") { 68 ScaleMatrixBench() : INHERITED("scale") {
69 fSX = fSY = 1.5f; 69 fSX = fSY = 1.5f;
70 fM0.reset(); 70 fM0.reset();
71 fM1.setScale(fSX, fSY); 71 fM1.setScale(fSX, fSY);
72 fM2.setTranslate(fSX, fSY); 72 fM2.setTranslate(fSX, fSY);
73 } 73 }
74 protected: 74 protected:
75 virtual void performTest() { 75 void performTest() override {
76 SkMatrix m; 76 SkMatrix m;
77 m = fM0; m.preScale(fSX, fSY); 77 m = fM0; m.preScale(fSX, fSY);
78 m = fM1; m.preScale(fSX, fSY); 78 m = fM1; m.preScale(fSX, fSY);
79 m = fM2; m.preScale(fSX, fSY); 79 m = fM2; m.preScale(fSX, fSY);
80 } 80 }
81 private: 81 private:
82 SkMatrix fM0, fM1, fM2; 82 SkMatrix fM0, fM1, fM2;
83 SkScalar fSX, fSY; 83 SkScalar fSX, fSY;
84 typedef MatrixBench INHERITED; 84 typedef MatrixBench INHERITED;
85 }; 85 };
(...skipping 19 matching lines...) Expand all
105 fArray[4] = (float) fRnd.nextS(); 105 fArray[4] = (float) fRnd.nextS();
106 fArray[5] = (float) fRnd.nextS(); 106 fArray[5] = (float) fRnd.nextS();
107 fArray[6] = (float) fRnd.nextS(); 107 fArray[6] = (float) fRnd.nextS();
108 fArray[7] = (float) fRnd.nextS(); 108 fArray[7] = (float) fRnd.nextS();
109 fArray[8] = (float) fRnd.nextS(); 109 fArray[8] = (float) fRnd.nextS();
110 } 110 }
111 protected: 111 protected:
112 // Putting random generation of the matrix inside performTest() 112 // Putting random generation of the matrix inside performTest()
113 // would help us avoid anomalous runs, but takes up 25% or 113 // would help us avoid anomalous runs, but takes up 25% or
114 // more of the function time. 114 // more of the function time.
115 virtual void performTest() { 115 void performTest() override {
116 fMatrix.setAll(fArray[0], fArray[1], fArray[2], 116 fMatrix.setAll(fArray[0], fArray[1], fArray[2],
117 fArray[3], fArray[4], fArray[5], 117 fArray[3], fArray[4], fArray[5],
118 fArray[6], fArray[7], fArray[8]); 118 fArray[6], fArray[7], fArray[8]);
119 // xoring into a volatile prevents the compiler from optimizing these aw ay 119 // xoring into a volatile prevents the compiler from optimizing these aw ay
120 volatile int junk = 0; 120 volatile int junk = 0;
121 junk ^= (fMatrix.getType()); 121 junk ^= (fMatrix.getType());
122 fMatrix.dirtyMatrixTypeCache(); 122 fMatrix.dirtyMatrixTypeCache();
123 junk ^= (fMatrix.getType()); 123 junk ^= (fMatrix.getType());
124 fMatrix.dirtyMatrixTypeCache(); 124 fMatrix.dirtyMatrixTypeCache();
125 junk ^= (fMatrix.getType()); 125 junk ^= (fMatrix.getType());
(...skipping 13 matching lines...) Expand all
139 float fArray[9]; 139 float fArray[9];
140 SkRandom fRnd; 140 SkRandom fRnd;
141 typedef MatrixBench INHERITED; 141 typedef MatrixBench INHERITED;
142 }; 142 };
143 143
144 class DecomposeMatrixBench : public MatrixBench { 144 class DecomposeMatrixBench : public MatrixBench {
145 public: 145 public:
146 DecomposeMatrixBench() : INHERITED("decompose") {} 146 DecomposeMatrixBench() : INHERITED("decompose") {}
147 147
148 protected: 148 protected:
149 virtual void onPreDraw() { 149 void onPreDraw() override {
150 for (int i = 0; i < 10; ++i) { 150 for (int i = 0; i < 10; ++i) {
151 SkScalar rot0 = (fRandom.nextBool()) ? fRandom.nextRangeF(-180, 180) : 0.0f; 151 SkScalar rot0 = (fRandom.nextBool()) ? fRandom.nextRangeF(-180, 180) : 0.0f;
152 SkScalar sx = fRandom.nextRangeF(-3000.f, 3000.f); 152 SkScalar sx = fRandom.nextRangeF(-3000.f, 3000.f);
153 SkScalar sy = (fRandom.nextBool()) ? fRandom.nextRangeF(-3000.f, 300 0.f) : sx; 153 SkScalar sy = (fRandom.nextBool()) ? fRandom.nextRangeF(-3000.f, 300 0.f) : sx;
154 SkScalar rot1 = fRandom.nextRangeF(-180, 180); 154 SkScalar rot1 = fRandom.nextRangeF(-180, 180);
155 fMatrix[i].setRotate(rot0); 155 fMatrix[i].setRotate(rot0);
156 fMatrix[i].postScale(sx, sy); 156 fMatrix[i].postScale(sx, sy);
157 fMatrix[i].postRotate(rot1); 157 fMatrix[i].postRotate(rot1);
158 } 158 }
159 } 159 }
160 virtual void performTest() { 160 void performTest() override {
161 SkPoint rotation1, scale, rotation2; 161 SkPoint rotation1, scale, rotation2;
162 for (int i = 0; i < 10; ++i) { 162 for (int i = 0; i < 10; ++i) {
163 (void) SkDecomposeUpper2x2(fMatrix[i], &rotation1, &scale, &rotation 2); 163 (void) SkDecomposeUpper2x2(fMatrix[i], &rotation1, &scale, &rotation 2);
164 } 164 }
165 } 165 }
166 private: 166 private:
167 SkMatrix fMatrix[10]; 167 SkMatrix fMatrix[10];
168 SkRandom fRandom; 168 SkRandom fRandom;
169 typedef MatrixBench INHERITED; 169 typedef MatrixBench INHERITED;
170 }; 170 };
(...skipping 23 matching lines...) Expand all
194 } 194 }
195 } 195 }
196 enum Flag { 196 enum Flag {
197 kScale_Flag = 0x01, 197 kScale_Flag = 0x01,
198 kTranslate_Flag = 0x02, 198 kTranslate_Flag = 0x02,
199 kRotate_Flag = 0x04, 199 kRotate_Flag = 0x04,
200 kPerspective_Flag = 0x08, 200 kPerspective_Flag = 0x08,
201 kUncachedTypeMask_Flag = 0x10, 201 kUncachedTypeMask_Flag = 0x10,
202 }; 202 };
203 protected: 203 protected:
204 virtual void performTest() { 204 void performTest() override {
205 if (fFlags & kUncachedTypeMask_Flag) { 205 if (fFlags & kUncachedTypeMask_Flag) {
206 // This will invalidate the typemask without 206 // This will invalidate the typemask without
207 // changing the matrix. 207 // changing the matrix.
208 fMatrix.setPerspX(fMatrix.getPerspX()); 208 fMatrix.setPerspX(fMatrix.getPerspX());
209 } 209 }
210 SkMatrix inv; 210 SkMatrix inv;
211 bool invertible = fMatrix.invert(&inv); 211 bool invertible = fMatrix.invert(&inv);
212 SkASSERT(invertible); 212 SkASSERT(invertible);
213 SkRect transformedRect; 213 SkRect transformedRect;
214 // an arbitrary, small, non-zero rect to transform 214 // an arbitrary, small, non-zero rect to transform
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 for (int i = 0; i < 1000000; ++i) { 292 for (int i = 0; i < 1000000; ++i) {
293 fM.mapPoints(fDst, fSrc, N); 293 fM.mapPoints(fDst, fSrc, N);
294 } 294 }
295 } 295 }
296 }; 296 };
297 DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I()); ) 297 DEF_BENCH( return new MapPointsMatrixBench("mappoints_identity", SkMatrix::I()); )
298 DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); ) 298 DEF_BENCH( return new MapPointsMatrixBench("mappoints_trans", make_trans()); )
299 DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); ) 299 DEF_BENCH( return new MapPointsMatrixBench("mappoints_scale", make_scale()); )
300 DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); ) 300 DEF_BENCH( return new MapPointsMatrixBench("mappoints_affine", make_afine()); )
301 301
OLDNEW
« no previous file with comments | « bench/Matrix44Bench.cpp ('k') | bench/MutexBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698