| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = ImageDecoder::create( | 261 std::unique_ptr<ImageDecoder> decoder = ImageDecoder::create( |
| 262 data, true, ImageDecoder::AlphaPremultiplied, | 262 data, true, ImageDecoder::AlphaPremultiplied, |
| 263 colorCorrection ? ImageDecoder::ColorSpaceTransformed | 263 colorCorrection ? ColorBehavior::transformToTargetForTesting() |
| 264 : ImageDecoder::ColorSpaceIgnored, | 264 : ColorBehavior::ignore()); |
| 265 colorCorrection ? ImageDecoder::targetColorSpaceForTesting() : nullptr); | |
| 266 if (!packetSize) { | 265 if (!packetSize) { |
| 267 bool allDataReceived = true; | 266 bool allDataReceived = true; |
| 268 decoder->setData(data, allDataReceived); | 267 decoder->setData(data, allDataReceived); |
| 269 | 268 |
| 270 int frameCount = decoder->frameCount(); | 269 int frameCount = decoder->frameCount(); |
| 271 for (int i = 0; i < frameCount; ++i) { | 270 for (int i = 0; i < frameCount; ++i) { |
| 272 if (!decoder->frameBufferAtIndex(i)) | 271 if (!decoder->frameBufferAtIndex(i)) |
| 273 return false; | 272 return false; |
| 274 } | 273 } |
| 275 | 274 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 306 base::CommandLine::Init(argc, argv); | 305 base::CommandLine::Init(argc, argv); |
| 307 | 306 |
| 308 // If the platform supports color correction, allow it to be controlled. | 307 // If the platform supports color correction, allow it to be controlled. |
| 309 | 308 |
| 310 bool applyColorCorrection = false; | 309 bool applyColorCorrection = false; |
| 311 | 310 |
| 312 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) { | 311 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) { |
| 313 applyColorCorrection = (--argc, ++argv, true); | 312 applyColorCorrection = (--argc, ++argv, true); |
| 314 WebVector<char> profile; | 313 WebVector<char> profile; |
| 315 getScreenColorProfile(&profile); // Returns a color spin color profile. | 314 getScreenColorProfile(&profile); // Returns a color spin color profile. |
| 316 ImageDecoder::setGlobalTargetColorProfile(profile); | 315 ColorBehavior::setGlobalTargetColorProfile(profile); |
| 317 } | 316 } |
| 318 | 317 |
| 319 if (argc < 2) { | 318 if (argc < 2) { |
| 320 fprintf(stderr, | 319 fprintf(stderr, |
| 321 "Usage: %s [--color-correct] file [iterations] [packetSize]\n", | 320 "Usage: %s [--color-correct] file [iterations] [packetSize]\n", |
| 322 argv[0]); | 321 argv[0]); |
| 323 exit(1); | 322 exit(1); |
| 324 } | 323 } |
| 325 | 324 |
| 326 // Control decode bench iterations and packet size. | 325 // Control decode bench iterations and packet size. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 exit(3); | 391 exit(3); |
| 393 } | 392 } |
| 394 } | 393 } |
| 395 | 394 |
| 396 // Results to stdout. | 395 // Results to stdout. |
| 397 | 396 |
| 398 double averageTime = totalTime / static_cast<double>(iterations); | 397 double averageTime = totalTime / static_cast<double>(iterations); |
| 399 printf("%f %f\n", totalTime, averageTime); | 398 printf("%f %f\n", totalTime, averageTime); |
| 400 return 0; | 399 return 0; |
| 401 } | 400 } |
| OLD | NEW |