| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 | 255 |
| 256 fclose(fp); | 256 fclose(fp); |
| 257 return SharedBuffer::create(buffer.get(), fileSize); | 257 return SharedBuffer::create(buffer.get(), fileSize); |
| 258 } | 258 } |
| 259 | 259 |
| 260 bool decodeImageData(SharedBuffer* data, bool colorCorrection, size_t packetSize
) | 260 bool decodeImageData(SharedBuffer* data, bool colorCorrection, size_t packetSize
) |
| 261 { | 261 { |
| 262 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(*data, | 262 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create(*data, |
| 263 ImageDecoder::AlphaPremultiplied, colorCorrection ? | 263 ImageDecoder::AlphaPremultiplied, colorCorrection ? |
| 264 ImageDecoder::GammaAndColorProfileApplied : ImageDecoder::GammaAndCo
lorProfileIgnored); | 264 ImageDecoder::GammaAndColorProfileApplied : ImageDecoder::GammaAndCo
lorProfileNotApplied); |
| 265 | 265 |
| 266 if (!packetSize) { | 266 if (!packetSize) { |
| 267 bool allDataReceived = true; | 267 bool allDataReceived = true; |
| 268 decoder->setData(data, allDataReceived); | 268 decoder->setData(data, allDataReceived); |
| 269 | 269 |
| 270 int frameCount = decoder->frameCount(); | 270 int frameCount = decoder->frameCount(); |
| 271 for (int i = 0; i < frameCount; ++i) { | 271 for (int i = 0; i < frameCount; ++i) { |
| 272 if (!decoder->frameBufferAtIndex(i)) | 272 if (!decoder->frameBufferAtIndex(i)) |
| 273 return false; | 273 return false; |
| 274 } | 274 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 exit(3); | 394 exit(3); |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Results to stdout. | 398 // Results to stdout. |
| 399 | 399 |
| 400 double averageTime = totalTime / static_cast<double>(iterations); | 400 double averageTime = totalTime / static_cast<double>(iterations); |
| 401 printf("%f %f\n", totalTime, averageTime); | 401 printf("%f %f\n", totalTime, averageTime); |
| 402 return 0; | 402 return 0; |
| 403 } | 403 } |
| OLD | NEW |