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

Side by Side Diff: bench/InterpBench.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/ImageFilterDAGBench.cpp ('k') | bench/LightingBench.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 #include "Benchmark.h" 1 #include "Benchmark.h"
2 #include "SkColorPriv.h" 2 #include "SkColorPriv.h"
3 #include "SkMatrix.h" 3 #include "SkMatrix.h"
4 #include "SkPaint.h" 4 #include "SkPaint.h"
5 #include "SkRandom.h" 5 #include "SkRandom.h"
6 #include "SkString.h" 6 #include "SkString.h"
7 7
8 #define TILE(x, width) (((x) & 0xFFFF) * width >> 16) 8 #define TILE(x, width) (((x) & 0xFFFF) * width >> 16)
9 9
10 class InterpBench : public Benchmark { 10 class InterpBench : public Benchmark {
11 enum { 11 enum {
12 kBuffer = 128, 12 kBuffer = 128,
13 kLoop = 20000 13 kLoop = 20000
14 }; 14 };
15 SkString fName; 15 SkString fName;
16 int16_t fDst[kBuffer]; 16 int16_t fDst[kBuffer];
17 float fFx, fDx; 17 float fFx, fDx;
18 public: 18 public:
19 InterpBench(const char name[]) { 19 InterpBench(const char name[]) {
20 fName.printf("interp_%s", name); 20 fName.printf("interp_%s", name);
21 fFx = 3.3f; 21 fFx = 3.3f;
22 fDx = 0.1257f; 22 fDx = 0.1257f;
23 } 23 }
24 24
25 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 25 bool isSuitableFor(Backend backend) SK_OVERRIDE {
26 return backend == kNonRendering_Backend; 26 return backend == kNonRendering_Backend;
27 } 27 }
28 28
29 virtual void performTest(int16_t dst[], float x, float dx, int count) = 0; 29 virtual void performTest(int16_t dst[], float x, float dx, int count) = 0;
30 30
31 protected: 31 protected:
32 virtual int mulLoopCount() const { return 1; } 32 virtual int mulLoopCount() const { return 1; }
33 33
34 virtual const char* onGetName() { 34 virtual const char* onGetName() {
35 return fName.c_str(); 35 return fName.c_str();
36 } 36 }
37 37
38 virtual void onDraw(const int loops, SkCanvas*) { 38 virtual void onDraw(const int loops, SkCanvas*) {
39 int n = loops * this->mulLoopCount(); 39 int n = loops * this->mulLoopCount();
40 for (int i = 0; i < n; i++) { 40 for (int i = 0; i < n; i++) {
41 this->performTest(fDst, fFx, fDx, kBuffer); 41 this->performTest(fDst, fFx, fDx, kBuffer);
42 } 42 }
43 } 43 }
44 44
45 private: 45 private:
46 typedef Benchmark INHERITED; 46 typedef Benchmark INHERITED;
47 }; 47 };
48 48
49 class Fixed16D16Interp : public InterpBench { 49 class Fixed16D16Interp : public InterpBench {
50 public: 50 public:
51 Fixed16D16Interp() : INHERITED("16.16") {} 51 Fixed16D16Interp() : INHERITED("16.16") {}
52 52
53 protected: 53 protected:
54 virtual void performTest(int16_t dst[], float fx, float dx, int count) SK_OV ERRIDE { 54 void performTest(int16_t dst[], float fx, float dx, int count) SK_OVERRIDE {
55 SkFixed curr = SkFloatToFixed(fx); 55 SkFixed curr = SkFloatToFixed(fx);
56 SkFixed step = SkFloatToFixed(dx); 56 SkFixed step = SkFloatToFixed(dx);
57 for (int i = 0; i < count; i += 4) { 57 for (int i = 0; i < count; i += 4) {
58 dst[i + 0] = TILE(curr, count); curr += step; 58 dst[i + 0] = TILE(curr, count); curr += step;
59 dst[i + 1] = TILE(curr, count); curr += step; 59 dst[i + 1] = TILE(curr, count); curr += step;
60 dst[i + 2] = TILE(curr, count); curr += step; 60 dst[i + 2] = TILE(curr, count); curr += step;
61 dst[i + 3] = TILE(curr, count); curr += step; 61 dst[i + 3] = TILE(curr, count); curr += step;
62 } 62 }
63 } 63 }
64 private: 64 private:
65 typedef InterpBench INHERITED; 65 typedef InterpBench INHERITED;
66 }; 66 };
67 67
68 class Fixed32D32Interp : public InterpBench { 68 class Fixed32D32Interp : public InterpBench {
69 public: 69 public:
70 Fixed32D32Interp() : INHERITED("32.32") {} 70 Fixed32D32Interp() : INHERITED("32.32") {}
71 71
72 protected: 72 protected:
73 virtual void performTest(int16_t dst[], float fx, float dx, int count) SK_OV ERRIDE { 73 void performTest(int16_t dst[], float fx, float dx, int count) SK_OVERRIDE {
74 int64_t curr = (int64_t)(fx * 65536 * 655536); 74 int64_t curr = (int64_t)(fx * 65536 * 655536);
75 int64_t step = (int64_t)(dx * 65536 * 655536); 75 int64_t step = (int64_t)(dx * 65536 * 655536);
76 SkFixed tmp; 76 SkFixed tmp;
77 for (int i = 0; i < count; i += 4) { 77 for (int i = 0; i < count; i += 4) {
78 tmp = (SkFixed)(curr >> 16); 78 tmp = (SkFixed)(curr >> 16);
79 dst[i + 0] = TILE(tmp, count); 79 dst[i + 0] = TILE(tmp, count);
80 curr += step; 80 curr += step;
81 81
82 tmp = (SkFixed)(curr >> 16); 82 tmp = (SkFixed)(curr >> 16);
83 dst[i + 1] = TILE(tmp, count); 83 dst[i + 1] = TILE(tmp, count);
(...skipping 10 matching lines...) Expand all
94 } 94 }
95 private: 95 private:
96 typedef InterpBench INHERITED; 96 typedef InterpBench INHERITED;
97 }; 97 };
98 98
99 class Fixed16D48Interp : public InterpBench { 99 class Fixed16D48Interp : public InterpBench {
100 public: 100 public:
101 Fixed16D48Interp() : INHERITED("16.48") {} 101 Fixed16D48Interp() : INHERITED("16.48") {}
102 102
103 protected: 103 protected:
104 virtual void performTest(int16_t dst[], float fx, float dx, int count) SK_OV ERRIDE { 104 void performTest(int16_t dst[], float fx, float dx, int count) SK_OVERRIDE {
105 int64_t curr = (int64_t)(fx * 65536 * 655536 * 65536); 105 int64_t curr = (int64_t)(fx * 65536 * 655536 * 65536);
106 int64_t step = (int64_t)(dx * 65536 * 655536 * 65536); 106 int64_t step = (int64_t)(dx * 65536 * 655536 * 65536);
107 SkFixed tmp; 107 SkFixed tmp;
108 for (int i = 0; i < count; i += 4) { 108 for (int i = 0; i < count; i += 4) {
109 tmp = (SkFixed) (curr >> 32); dst[i + 0] = TILE(tmp, count); curr += step; 109 tmp = (SkFixed) (curr >> 32); dst[i + 0] = TILE(tmp, count); curr += step;
110 tmp = (SkFixed) (curr >> 32); dst[i + 1] = TILE(tmp, count); curr += step; 110 tmp = (SkFixed) (curr >> 32); dst[i + 1] = TILE(tmp, count); curr += step;
111 tmp = (SkFixed) (curr >> 32); dst[i + 2] = TILE(tmp, count); curr += step; 111 tmp = (SkFixed) (curr >> 32); dst[i + 2] = TILE(tmp, count); curr += step;
112 tmp = (SkFixed) (curr >> 32); dst[i + 3] = TILE(tmp, count); curr += step; 112 tmp = (SkFixed) (curr >> 32); dst[i + 3] = TILE(tmp, count); curr += step;
113 } 113 }
114 } 114 }
115 private: 115 private:
116 typedef InterpBench INHERITED; 116 typedef InterpBench INHERITED;
117 }; 117 };
118 118
119 class FloatInterp : public InterpBench { 119 class FloatInterp : public InterpBench {
120 public: 120 public:
121 FloatInterp() : INHERITED("float") {} 121 FloatInterp() : INHERITED("float") {}
122 122
123 protected: 123 protected:
124 virtual void performTest(int16_t dst[], float fx, float dx, int count) SK_OV ERRIDE { 124 void performTest(int16_t dst[], float fx, float dx, int count) SK_OVERRIDE {
125 SkFixed tmp; 125 SkFixed tmp;
126 for (int i = 0; i < count; i += 4) { 126 for (int i = 0; i < count; i += 4) {
127 tmp = SkFloatToFixed(fx); dst[i + 0] = TILE(tmp, count); fx += dx; 127 tmp = SkFloatToFixed(fx); dst[i + 0] = TILE(tmp, count); fx += dx;
128 tmp = SkFloatToFixed(fx); dst[i + 1] = TILE(tmp, count); fx += dx; 128 tmp = SkFloatToFixed(fx); dst[i + 1] = TILE(tmp, count); fx += dx;
129 tmp = SkFloatToFixed(fx); dst[i + 2] = TILE(tmp, count); fx += dx; 129 tmp = SkFloatToFixed(fx); dst[i + 2] = TILE(tmp, count); fx += dx;
130 tmp = SkFloatToFixed(fx); dst[i + 3] = TILE(tmp, count); fx += dx; 130 tmp = SkFloatToFixed(fx); dst[i + 3] = TILE(tmp, count); fx += dx;
131 } 131 }
132 } 132 }
133 private: 133 private:
134 typedef InterpBench INHERITED; 134 typedef InterpBench INHERITED;
135 }; 135 };
136 136
137 class DoubleInterp : public InterpBench { 137 class DoubleInterp : public InterpBench {
138 public: 138 public:
139 DoubleInterp() : INHERITED("double") {} 139 DoubleInterp() : INHERITED("double") {}
140 140
141 protected: 141 protected:
142 virtual void performTest(int16_t dst[], float fx, float dx, int count) SK_OV ERRIDE { 142 void performTest(int16_t dst[], float fx, float dx, int count) SK_OVERRIDE {
143 double ffx = fx; 143 double ffx = fx;
144 double ddx = dx; 144 double ddx = dx;
145 SkFixed tmp; 145 SkFixed tmp;
146 for (int i = 0; i < count; i += 4) { 146 for (int i = 0; i < count; i += 4) {
147 tmp = SkDoubleToFixed(ffx); dst[i + 0] = TILE(tmp, count); ffx += dd x; 147 tmp = SkDoubleToFixed(ffx); dst[i + 0] = TILE(tmp, count); ffx += dd x;
148 tmp = SkDoubleToFixed(ffx); dst[i + 1] = TILE(tmp, count); ffx += dd x; 148 tmp = SkDoubleToFixed(ffx); dst[i + 1] = TILE(tmp, count); ffx += dd x;
149 tmp = SkDoubleToFixed(ffx); dst[i + 2] = TILE(tmp, count); ffx += dd x; 149 tmp = SkDoubleToFixed(ffx); dst[i + 2] = TILE(tmp, count); ffx += dd x;
150 tmp = SkDoubleToFixed(ffx); dst[i + 3] = TILE(tmp, count); ffx += dd x; 150 tmp = SkDoubleToFixed(ffx); dst[i + 3] = TILE(tmp, count); ffx += dd x;
151 } 151 }
152 } 152 }
153 private: 153 private:
154 typedef InterpBench INHERITED; 154 typedef InterpBench INHERITED;
155 }; 155 };
156 156
157 /////////////////////////////////////////////////////////////////////////////// 157 ///////////////////////////////////////////////////////////////////////////////
158 158
159 DEF_BENCH( return new Fixed16D16Interp(); ) 159 DEF_BENCH( return new Fixed16D16Interp(); )
160 DEF_BENCH( return new Fixed32D32Interp(); ) 160 DEF_BENCH( return new Fixed32D32Interp(); )
161 DEF_BENCH( return new Fixed16D48Interp(); ) 161 DEF_BENCH( return new Fixed16D48Interp(); )
162 DEF_BENCH( return new FloatInterp(); ) 162 DEF_BENCH( return new FloatInterp(); )
163 DEF_BENCH( return new DoubleInterp(); ) 163 DEF_BENCH( return new DoubleInterp(); )
OLDNEW
« no previous file with comments | « bench/ImageFilterDAGBench.cpp ('k') | bench/LightingBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698