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

Side by Side Diff: bench/ETCBitmapBench.cpp

Issue 1685963004: Revert of Make SkPicture/SkImageGenerator default to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | dm/DMSrcSink.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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
79 // This is the base class for all of the benches in this file. In general 76 // This is the base class for all of the benches in this file. In general
80 // the ETC1 benches should all be working on the same data. Due to the 77 // the ETC1 benches should all be working on the same data. Due to the
81 // simplicity of the PKM file, that data is the 128x128 mandrill etc1 78 // simplicity of the PKM file, that data is the 128x128 mandrill etc1
82 // compressed texture repeated by some factor (currently 8 -> 1024x1024) 79 // compressed texture repeated by some factor (currently 8 -> 1024x1024)
83 class ETCBitmapBenchBase : public Benchmark { 80 class ETCBitmapBenchBase : public Benchmark {
84 public: 81 public:
85 ETCBitmapBenchBase() : fPKMData(loadPKM()) { 82 ETCBitmapBenchBase() : fPKMData(loadPKM()) {
86 if (nullptr == fPKMData) { 83 if (nullptr == fPKMData) {
87 SkDebugf("Could not load PKM data!\n"); 84 SkDebugf("Could not load PKM data!\n");
88 } 85 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 144 }
148 } 145 }
149 146
150 void onDelayedSetup() override { 147 void onDelayedSetup() override {
151 if (nullptr == fPKMData) { 148 if (nullptr == fPKMData) {
152 SkDebugf("Failed to load PKM data!\n"); 149 SkDebugf("Failed to load PKM data!\n");
153 return; 150 return;
154 } 151 }
155 152
156 if (fDecompress) { 153 if (fDecompress) {
157 SkAutoTDelete<SkImageGenerator> gen(decoder_image_generator(fPKMData )); 154 SkAutoTDelete<SkImageGenerator> gen(SkImageGenerator::NewFromEncoded (fPKMData));
158 gen->generateBitmap(&fBitmap); 155 gen->generateBitmap(&fBitmap);
159 } else { 156 } else {
160 fImage.reset(SkImage::NewFromGenerator(decoder_image_generator(fPKMD ata))); 157 fImage.reset(SkImage::NewFromEncoded(fPKMData));
161 } 158 }
162 } 159 }
163 160
164 void onDraw(int loops, SkCanvas* canvas) override { 161 void onDraw(int loops, SkCanvas* canvas) override {
165 for (int i = 0; i < loops; ++i) { 162 for (int i = 0; i < loops; ++i) {
166 if (fDecompress) { 163 if (fDecompress) {
167 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr); 164 canvas->drawBitmap(this->fBitmap, 0, 0, nullptr);
168 } else { 165 } else {
169 canvas->drawImage(fImage, 0, 0, nullptr); 166 canvas->drawImage(fImage, 0, 0, nullptr);
170 } 167 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) 226 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);)
230 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) 227 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);)
231 228
232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) 229 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);)
233 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) 230 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);)
234 231
235 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) 232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);)
236 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);) 233 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kGPU_Backend);)
237 234
238 #endif // SK_IGNORE_ETC1_SUPPORT 235 #endif // SK_IGNORE_ETC1_SUPPORT
OLDNEW
« no previous file with comments | « no previous file | dm/DMSrcSink.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698