OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Provides a minimal wrapping of the Blink image decoders. Used to perform | 5 // Provides a minimal wrapping of the Blink image decoders. Used to perform |
6 // a non-threaded, memory-to-memory image decode using micro second accuracy | 6 // a non-threaded, memory-to-memory image decode using micro second accuracy |
7 // clocks to measure image decode time. Optionally applies color correction | 7 // clocks to measure image decode time. Optionally applies color correction |
8 // during image decoding on supported platforms (default off). Usage: | 8 // during image decoding on supported platforms (default off). Usage: |
9 // | 9 // |
10 // % ninja -C out/Release image_decode_bench && | 10 // % ninja -C out/Release image_decode_bench && |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 exit(2); | 251 exit(2); |
252 } | 252 } |
253 | 253 |
254 fclose(fp); | 254 fclose(fp); |
255 return SharedBuffer::create(buffer.get(), fileSize); | 255 return SharedBuffer::create(buffer.get(), fileSize); |
256 } | 256 } |
257 | 257 |
258 bool decodeImageData(SharedBuffer* data, | 258 bool decodeImageData(SharedBuffer* data, |
259 bool colorCorrection, | 259 bool colorCorrection, |
260 size_t packetSize) { | 260 size_t packetSize) { |
261 std::unique_ptr<ImageDecoder> decoder = | 261 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create( |
262 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, | 262 data, true, ImageDecoder::AlphaPremultiplied, |
263 colorCorrection ? ImageDecoder::ColorSpaceApplied | 263 colorCorrection ? ImageDecoder::ColorSpaceTransformed |
264 : ImageDecoder::ColorSpaceIgnored); | 264 : ImageDecoder::ColorSpaceIgnored, |
| 265 colorCorrection ? ImageDecoder::targetColorSpaceForTesting() : nullptr); |
265 if (!packetSize) { | 266 if (!packetSize) { |
266 bool allDataReceived = true; | 267 bool allDataReceived = true; |
267 decoder->setData(data, allDataReceived); | 268 decoder->setData(data, allDataReceived); |
268 | 269 |
269 int frameCount = decoder->frameCount(); | 270 int frameCount = decoder->frameCount(); |
270 for (int i = 0; i < frameCount; ++i) { | 271 for (int i = 0; i < frameCount; ++i) { |
271 if (!decoder->frameBufferAtIndex(i)) | 272 if (!decoder->frameBufferAtIndex(i)) |
272 return false; | 273 return false; |
273 } | 274 } |
274 | 275 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 exit(3); | 392 exit(3); |
392 } | 393 } |
393 } | 394 } |
394 | 395 |
395 // Results to stdout. | 396 // Results to stdout. |
396 | 397 |
397 double averageTime = totalTime / static_cast<double>(iterations); | 398 double averageTime = totalTime / static_cast<double>(iterations); |
398 printf("%f %f\n", totalTime, averageTime); | 399 printf("%f %f\n", totalTime, averageTime); |
399 return 0; | 400 return 0; |
400 } | 401 } |
OLD | NEW |