OLD | NEW |
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 if (fDecompress) { | 153 if (fDecompress) { |
154 SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded
(fPKMData)); | 154 SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded
(fPKMData)); |
155 gen->generateBitmap(&fBitmap); | 155 gen->generateBitmap(&fBitmap); |
156 } else { | 156 } else { |
157 fImage.reset(SkImage::NewFromEncoded(fPKMData)); | 157 fImage.reset(SkImage::NewFromEncoded(fPKMData)); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void onDraw(const int loops, SkCanvas* canvas) override { | 161 void onDraw(int loops, SkCanvas* canvas) override { |
162 for (int i = 0; i < loops; ++i) { | 162 for (int i = 0; i < loops; ++i) { |
163 if (fDecompress) { | 163 if (fDecompress) { |
164 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); | 164 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); |
165 } else { | 165 } else { |
166 canvas->drawImage(fImage, 0, 0, nullptr); | 166 canvas->drawImage(fImage, 0, 0, nullptr); |
167 } | 167 } |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 protected: | 171 protected: |
(...skipping 27 matching lines...) Expand all Loading... |
199 } else { | 199 } else { |
200 SkASSERT(kRaster_Backend == this->backend()); | 200 SkASSERT(kRaster_Backend == this->backend()); |
201 if (this->decompress()) { | 201 if (this->decompress()) { |
202 return "etc1bitmap_upload_raster_decompressed"; | 202 return "etc1bitmap_upload_raster_decompressed"; |
203 } else { | 203 } else { |
204 return "etc1bitmap_upload_raster_compressed"; | 204 return "etc1bitmap_upload_raster_compressed"; |
205 } | 205 } |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 void onDraw(const int loops, SkCanvas* canvas) override { | 209 void onDraw(int loops, SkCanvas* canvas) override { |
210 SkPixelRef* pr = fBitmap.pixelRef(); | 210 SkPixelRef* pr = fBitmap.pixelRef(); |
211 for (int i = 0; i < loops; ++i) { | 211 for (int i = 0; i < loops; ++i) { |
212 if (pr) { | 212 if (pr) { |
213 pr->notifyPixelsChanged(); | 213 pr->notifyPixelsChanged(); |
214 } | 214 } |
215 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); | 215 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 private: | 219 private: |
220 typedef ETCBitmapBench INHERITED; | 220 typedef ETCBitmapBench INHERITED; |
221 }; | 221 }; |
222 | 222 |
223 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kRaster_Backend);) | 223 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kRaster_Backend);) |
224 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kRaster_Backend);) | 224 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kRaster_Backend);) |
225 | 225 |
226 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) | 226 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) |
227 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) | 227 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) |
228 | 228 |
229 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) | 229 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) |
230 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) | 230 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) |
231 | 231 |
232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) | 232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) |
233 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) | 233 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) |
234 | 234 |
235 #endif // SK_IGNORE_ETC1_SUPPORT | 235 #endif // SK_IGNORE_ETC1_SUPPORT |
OLD | NEW |