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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 for (etc1_uint32 j = 0; j < newBlocksY; ++j) { | 66 for (etc1_uint32 j = 0; j < newBlocksY; ++j) { |
67 const etc1_byte* rowStart = origData + ((j % origBlocksY) * origRowSzInB
ytes); | 67 const etc1_byte* rowStart = origData + ((j % origBlocksY) * origRowSzInB
ytes); |
68 for(etc1_uint32 i = 0; i < newWidth; i += origWidth) { | 68 for(etc1_uint32 i = 0; i < newWidth; i += origWidth) { |
69 memcpy(copyInto, rowStart, origRowSzInBytes); | 69 memcpy(copyInto, rowStart, origRowSzInBytes); |
70 copyInto += origRowSzInBytes; | 70 copyInto += origRowSzInBytes; |
71 } | 71 } |
72 } | 72 } |
73 return newData; | 73 return newData; |
74 } | 74 } |
75 | 75 |
| 76 // Defined in SkImageDecoder_ktx.cpp |
| 77 extern SkImageGenerator* decoder_image_generator(SkData*); |
| 78 |
76 // This is the base class for all of the benches in this file. In general | 79 // This is the base class for all of the benches in this file. In general |
77 // the ETC1 benches should all be working on the same data. Due to the | 80 // the ETC1 benches should all be working on the same data. Due to the |
78 // simplicity of the PKM file, that data is the 128x128 mandrill etc1 | 81 // simplicity of the PKM file, that data is the 128x128 mandrill etc1 |
79 // compressed texture repeated by some factor (currently 8 -> 1024x1024) | 82 // compressed texture repeated by some factor (currently 8 -> 1024x1024) |
80 class ETCBitmapBenchBase : public Benchmark { | 83 class ETCBitmapBenchBase : public Benchmark { |
81 public: | 84 public: |
82 ETCBitmapBenchBase() : fPKMData(loadPKM()) { | 85 ETCBitmapBenchBase() : fPKMData(loadPKM()) { |
83 if (nullptr == fPKMData) { | 86 if (nullptr == fPKMData) { |
84 SkDebugf("Could not load PKM data!\n"); | 87 SkDebugf("Could not load PKM data!\n"); |
85 } | 88 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 147 } |
145 } | 148 } |
146 | 149 |
147 void onDelayedSetup() override { | 150 void onDelayedSetup() override { |
148 if (nullptr == fPKMData) { | 151 if (nullptr == fPKMData) { |
149 SkDebugf("Failed to load PKM data!\n"); | 152 SkDebugf("Failed to load PKM data!\n"); |
150 return; | 153 return; |
151 } | 154 } |
152 | 155 |
153 if (fDecompress) { | 156 if (fDecompress) { |
154 SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded
(fPKMData)); | 157 SkAutoTDelete<SkImageGenerator> gen(decoder_image_generator(fPKMData
)); |
155 gen->generateBitmap(&fBitmap); | 158 gen->generateBitmap(&fBitmap); |
156 } else { | 159 } else { |
157 fImage.reset(SkImage::NewFromEncoded(fPKMData)); | 160 fImage.reset(SkImage::NewFromGenerator(decoder_image_generator(fPKMD
ata))); |
158 } | 161 } |
159 } | 162 } |
160 | 163 |
161 void onDraw(int loops, SkCanvas* canvas) override { | 164 void onDraw(int loops, SkCanvas* canvas) override { |
162 for (int i = 0; i < loops; ++i) { | 165 for (int i = 0; i < loops; ++i) { |
163 if (fDecompress) { | 166 if (fDecompress) { |
164 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); | 167 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); |
165 } else { | 168 } else { |
166 canvas->drawImage(fImage, 0, 0, nullptr); | 169 canvas->drawImage(fImage, 0, 0, nullptr); |
167 } | 170 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) | 229 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) |
227 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) | 230 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) |
228 | 231 |
229 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) | 232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) |
230 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) | 233 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) |
231 | 234 |
232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) | 235 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) |
233 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) | 236 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) |
234 | 237 |
235 #endif // SK_IGNORE_ETC1_SUPPORT | 238 #endif // SK_IGNORE_ETC1_SUPPORT |
OLD | NEW |