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 "Resources.h" | 9 #include "Resources.h" |
9 #include "SkBenchmark.h" | |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkDecodingImageGenerator.h" | 12 #include "SkDecodingImageGenerator.h" |
13 #include "SkImageDecoder.h" | 13 #include "SkImageDecoder.h" |
14 #include "SkOSFile.h" | 14 #include "SkOSFile.h" |
15 #include "SkPixelRef.h" | 15 #include "SkPixelRef.h" |
16 | 16 |
17 #ifndef SK_IGNORE_ETC1_SUPPORT | 17 #ifndef SK_IGNORE_ETC1_SUPPORT |
18 | 18 |
19 #include "etc1.h" | 19 #include "etc1.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 copyInto += origRowSzInBytes; | 70 copyInto += origRowSzInBytes; |
71 } | 71 } |
72 } | 72 } |
73 return newData; | 73 return newData; |
74 } | 74 } |
75 | 75 |
76 // 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 |
77 // 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 |
78 // 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 |
79 // compressed texture repeated by some factor (currently 8 -> 1024x1024) | 79 // compressed texture repeated by some factor (currently 8 -> 1024x1024) |
80 class ETCBitmapBenchBase : public SkBenchmark { | 80 class ETCBitmapBenchBase : public Benchmark { |
81 public: | 81 public: |
82 ETCBitmapBenchBase() : fPKMData(loadPKM()) { | 82 ETCBitmapBenchBase() : fPKMData(loadPKM()) { |
83 if (NULL == fPKMData) { | 83 if (NULL == fPKMData) { |
84 SkDebugf("Could not load PKM data!"); | 84 SkDebugf("Could not load PKM data!"); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 protected: | 88 protected: |
89 SkAutoDataUnref fPKMData; | 89 SkAutoDataUnref fPKMData; |
90 | 90 |
(...skipping 17 matching lines...) Expand all Loading... |
108 SkDebugf("Error expanding ETC1 data by factor of %d\n", kExpansionFa
ctor); | 108 SkDebugf("Error expanding ETC1 data by factor of %d\n", kExpansionFa
ctor); |
109 return NULL; | 109 return NULL; |
110 } | 110 } |
111 | 111 |
112 etc1_uint32 width = etc1_pkm_get_width(expandedETC1); | 112 etc1_uint32 width = etc1_pkm_get_width(expandedETC1); |
113 etc1_uint32 height = etc1_pkm_get_width(expandedETC1); | 113 etc1_uint32 height = etc1_pkm_get_width(expandedETC1); |
114 etc1_uint32 dataSz = ETC_PKM_HEADER_SIZE + etc1_get_encoded_data_size(wi
dth, height); | 114 etc1_uint32 dataSz = ETC_PKM_HEADER_SIZE + etc1_get_encoded_data_size(wi
dth, height); |
115 return SkData::NewFromMalloc(expandedETC1, dataSz); | 115 return SkData::NewFromMalloc(expandedETC1, dataSz); |
116 } | 116 } |
117 | 117 |
118 typedef SkBenchmark INHERITED; | 118 typedef Benchmark INHERITED; |
119 }; | 119 }; |
120 | 120 |
121 // This is the rendering benchmark. Prior to rendering the data, create a | 121 // This is the rendering benchmark. Prior to rendering the data, create a |
122 // bitmap using the etc1 data. | 122 // bitmap using the etc1 data. |
123 class ETCBitmapBench : public ETCBitmapBenchBase { | 123 class ETCBitmapBench : public ETCBitmapBenchBase { |
124 public: | 124 public: |
125 ETCBitmapBench(bool decompress, Backend backend) | 125 ETCBitmapBench(bool decompress, Backend backend) |
126 : fDecompress(decompress), fBackend(backend) { } | 126 : fDecompress(decompress), fBackend(backend) { } |
127 | 127 |
128 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { | 128 virtual bool isSuitableFor(Backend backend) SK_OVERRIDE { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 for (int i = 0; i < loops; ++i) { | 213 for (int i = 0; i < loops; ++i) { |
214 this->fBitmap.pixelRef()->notifyPixelsChanged(); | 214 this->fBitmap.pixelRef()->notifyPixelsChanged(); |
215 canvas->drawBitmap(this->fBitmap, 0, 0, NULL); | 215 canvas->drawBitmap(this->fBitmap, 0, 0, NULL); |
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, SkBenchmark::kRaster_Backend);) | 223 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kRaster_Backend);) |
224 DEF_BENCH(return new ETCBitmapBench(true, SkBenchmark::kRaster_Backend);) | 224 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kRaster_Backend);) |
225 | 225 |
226 DEF_BENCH(return new ETCBitmapBench(false, SkBenchmark::kGPU_Backend);) | 226 DEF_BENCH(return new ETCBitmapBench(false, Benchmark::kGPU_Backend);) |
227 DEF_BENCH(return new ETCBitmapBench(true, SkBenchmark::kGPU_Backend);) | 227 DEF_BENCH(return new ETCBitmapBench(true, Benchmark::kGPU_Backend);) |
228 | 228 |
229 DEF_BENCH(return new ETCBitmapUploadBench(false, SkBenchmark::kRaster_Backend);) | 229 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kRaster_Backend);) |
230 DEF_BENCH(return new ETCBitmapUploadBench(true, SkBenchmark::kRaster_Backend);) | 230 DEF_BENCH(return new ETCBitmapUploadBench(true, Benchmark::kRaster_Backend);) |
231 | 231 |
232 DEF_BENCH(return new ETCBitmapUploadBench(false, SkBenchmark::kGPU_Backend);) | 232 DEF_BENCH(return new ETCBitmapUploadBench(false, Benchmark::kGPU_Backend);) |
233 DEF_BENCH(return new ETCBitmapUploadBench(true, SkBenchmark::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 |