| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 void onPreDraw() override { | 147 void onPreDraw() override { |
| 148 if (nullptr == fPKMData) { | 148 if (nullptr == 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 if (fDecompress) { |
| 154 if (!SkInstallDiscardablePixelRef(fPKMData, &(this->fBitmap))) { | 154 SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded
(fPKMData)); |
| 155 SkDebugf("Could not install discardable pixel ref.\n"); | 155 gen->generateBitmap(&fBitmap); |
| 156 return; | 156 } else { |
| 157 } | 157 fImage.reset(SkImage::NewFromEncoded(fPKMData)); |
| 158 | |
| 159 // Decompress it if necessary | |
| 160 if (this->fDecompress) { | |
| 161 this->fBitmap.lockPixels(); | |
| 162 } | 158 } |
| 163 } | 159 } |
| 164 | 160 |
| 165 void onDraw(const int loops, SkCanvas* canvas) override { | 161 void onDraw(const int loops, SkCanvas* canvas) override { |
| 166 for (int i = 0; i < loops; ++i) { | 162 for (int i = 0; i < loops; ++i) { |
| 167 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); | 163 if (fDecompress) { |
| 164 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); |
| 165 } else { |
| 166 canvas->drawImage(fImage, 0, 0, nullptr); |
| 167 } |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 protected: | 171 protected: |
| 172 SkBitmap fBitmap; | 172 SkBitmap fBitmap; |
| 173 SkAutoTUnref<SkImage> fImage; |
| 174 |
| 173 bool decompress() const { return fDecompress; } | 175 bool decompress() const { return fDecompress; } |
| 174 Backend backend() const { return fBackend; } | 176 Backend backend() const { return fBackend; } |
| 175 private: | 177 private: |
| 176 const bool fDecompress; | 178 const bool fDecompress; |
| 177 const Backend fBackend; | 179 const Backend fBackend; |
| 178 typedef ETCBitmapBenchBase INHERITED; | 180 typedef ETCBitmapBenchBase INHERITED; |
| 179 }; | 181 }; |
| 180 | 182 |
| 181 // This benchmark is identical to the previous benchmark, but it explicitly forc
es | 183 // 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 | 184 // an upload to the GPU before each draw call. We do this by notifying the bitma
p |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) | 226 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) |
| 225 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) | 227 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) |
| 226 | 228 |
| 227 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) | 229 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) |
| 228 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) | 230 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) |
| 229 | 231 |
| 230 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) | 232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) |
| 231 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) | 233 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) |
| 232 | 234 |
| 233 #endif // SK_IGNORE_ETC1_SUPPORT | 235 #endif // SK_IGNORE_ETC1_SUPPORT |
| OLD | NEW |