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

Side by Side Diff: bench/ETCBitmapBench.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/DisplacementBench.cpp ('k') | bench/FSRectBench.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 7
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "Resources.h" 9 #include "Resources.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 typedef Benchmark INHERITED; 115 typedef Benchmark INHERITED;
116 }; 116 };
117 117
118 // This is the rendering benchmark. Prior to rendering the data, create a 118 // This is the rendering benchmark. Prior to rendering the data, create a
119 // bitmap using the etc1 data. 119 // bitmap using the etc1 data.
120 class ETCBitmapBench : public ETCBitmapBenchBase { 120 class ETCBitmapBench : public ETCBitmapBenchBase {
121 public: 121 public:
122 ETCBitmapBench(bool decompress, Backend backend) 122 ETCBitmapBench(bool decompress, Backend backend)
123 : fDecompress(decompress), fBackend(backend) { } 123 : fDecompress(decompress), fBackend(backend) { }
124 124
125 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { 125 bool isSuitableFor(Backend backend) SK_OVERRIDE {
126 return backend == this->fBackend; 126 return backend == this->fBackend;
127 } 127 }
128 128
129 protected: 129 protected:
130 virtual const char* onGetName() SK_OVERRIDE { 130 const char* onGetName() SK_OVERRIDE {
131 if (kGPU_Backend == this->fBackend) { 131 if (kGPU_Backend == this->fBackend) {
132 if (this->fDecompress) { 132 if (this->fDecompress) {
133 return "etc1bitmap_render_gpu_decompressed"; 133 return "etc1bitmap_render_gpu_decompressed";
134 } else { 134 } else {
135 return "etc1bitmap_render_gpu_compressed"; 135 return "etc1bitmap_render_gpu_compressed";
136 } 136 }
137 } else { 137 } else {
138 SkASSERT(kRaster_Backend == this->fBackend); 138 SkASSERT(kRaster_Backend == this->fBackend);
139 if (this->fDecompress) { 139 if (this->fDecompress) {
140 return "etc1bitmap_render_raster_decompressed"; 140 return "etc1bitmap_render_raster_decompressed";
141 } else { 141 } else {
142 return "etc1bitmap_render_raster_compressed"; 142 return "etc1bitmap_render_raster_compressed";
143 } 143 }
144 } 144 }
145 } 145 }
146 146
147 virtual void onPreDraw() SK_OVERRIDE { 147 void onPreDraw() SK_OVERRIDE {
148 if (NULL == fPKMData) { 148 if (NULL == fPKMData) {
149 SkDebugf("Failed to load PKM data!\n"); 149 SkDebugf("Failed to load PKM data!\n");
150 return; 150 return;
151 } 151 }
152 152
153 // Install pixel ref 153 // Install pixel ref
154 if (!SkInstallDiscardablePixelRef(fPKMData, &(this->fBitmap))) { 154 if (!SkInstallDiscardablePixelRef(fPKMData, &(this->fBitmap))) {
155 SkDebugf("Could not install discardable pixel ref.\n"); 155 SkDebugf("Could not install discardable pixel ref.\n");
156 return; 156 return;
157 } 157 }
158 158
159 // Decompress it if necessary 159 // Decompress it if necessary
160 if (this->fDecompress) { 160 if (this->fDecompress) {
161 this->fBitmap.lockPixels(); 161 this->fBitmap.lockPixels();
162 } 162 }
163 } 163 }
164 164
165 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 165 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
166 for (int i = 0; i < loops; ++i) { 166 for (int i = 0; i < loops; ++i) {
167 canvas->drawBitmap(this->fBitmap, 0, 0, NULL); 167 canvas->drawBitmap(this->fBitmap, 0, 0, NULL);
168 } 168 }
169 } 169 }
170 170
171 protected: 171 protected:
172 SkBitmap fBitmap; 172 SkBitmap fBitmap;
173 bool decompress() const { return fDecompress; } 173 bool decompress() const { return fDecompress; }
174 Backend backend() const { return fBackend; } 174 Backend backend() const { return fBackend; }
175 private: 175 private:
176 const bool fDecompress; 176 const bool fDecompress;
177 const Backend fBackend; 177 const Backend fBackend;
178 typedef ETCBitmapBenchBase INHERITED; 178 typedef ETCBitmapBenchBase INHERITED;
179 }; 179 };
180 180
181 // This benchmark is identical to the previous benchmark, but it explicitly forc es 181 // This benchmark is identical to the previous benchmark, but it explicitly forc es
182 // an upload to the GPU before each draw call. We do this by notifying the bitma p 182 // an upload to the GPU before each draw call. We do this by notifying the bitma p
183 // that the pixels have changed (even though they haven't). 183 // that the pixels have changed (even though they haven't).
184 class ETCBitmapUploadBench : public ETCBitmapBench { 184 class ETCBitmapUploadBench : public ETCBitmapBench {
185 public: 185 public:
186 ETCBitmapUploadBench(bool decompress, Backend backend) 186 ETCBitmapUploadBench(bool decompress, Backend backend)
187 : ETCBitmapBench(decompress, backend) { } 187 : ETCBitmapBench(decompress, backend) { }
188 188
189 protected: 189 protected:
190 virtual const char* onGetName() SK_OVERRIDE { 190 const char* onGetName() SK_OVERRIDE {
191 if (kGPU_Backend == this->backend()) { 191 if (kGPU_Backend == this->backend()) {
192 if (this->decompress()) { 192 if (this->decompress()) {
193 return "etc1bitmap_upload_gpu_decompressed"; 193 return "etc1bitmap_upload_gpu_decompressed";
194 } else { 194 } else {
195 return "etc1bitmap_upload_gpu_compressed"; 195 return "etc1bitmap_upload_gpu_compressed";
196 } 196 }
197 } else { 197 } else {
198 SkASSERT(kRaster_Backend == this->backend()); 198 SkASSERT(kRaster_Backend == this->backend());
199 if (this->decompress()) { 199 if (this->decompress()) {
200 return "etc1bitmap_upload_raster_decompressed"; 200 return "etc1bitmap_upload_raster_decompressed";
201 } else { 201 } else {
202 return "etc1bitmap_upload_raster_compressed"; 202 return "etc1bitmap_upload_raster_compressed";
203 } 203 }
204 } 204 }
205 } 205 }
206 206
207 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 207 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
208 SkPixelRef* pr = fBitmap.pixelRef(); 208 SkPixelRef* pr = fBitmap.pixelRef();
209 for (int i = 0; i < loops; ++i) { 209 for (int i = 0; i < loops; ++i) {
210 if (pr) { 210 if (pr) {
211 pr->notifyPixelsChanged(); 211 pr->notifyPixelsChanged();
212 } 212 }
213 canvas->drawBitmap(this->fBitmap, 0, 0, NULL); 213 canvas->drawBitmap(this->fBitmap, 0, 0, NULL);
214 } 214 }
215 } 215 }
216 216
217 private: 217 private:
218 typedef ETCBitmapBench INHERITED; 218 typedef ETCBitmapBench INHERITED;
219 }; 219 };
220 220
221 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kRaster_Backend);) 221 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kRaster_Backend);)
222 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kRaster_Backend);) 222 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kRaster_Backend);)
223 223
224 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) 224 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);)
225 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) 225 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);)
226 226
227 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) 227 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);)
228 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) 228 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);)
229 229
230 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) 230 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);)
231 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) 231 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);)
232 232
233 #endif // SK_IGNORE_ETC1_SUPPORT 233 #endif // SK_IGNORE_ETC1_SUPPORT
OLDNEW
« no previous file with comments | « bench/DisplacementBench.cpp ('k') | bench/FSRectBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698