Chromium Code Reviews| 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 = ImageDecoder::create( | 261 std::unique_ptr<ImageDecoder> decoder = |
| 262 *data, ImageDecoder::AlphaPremultiplied, | 262 ImageDecoder::create(data, true, ImageDecoder::AlphaPremultiplied, |
| 263 colorCorrection ? ImageDecoder::GammaAndColorProfileApplied | 263 colorCorrection ? ImageDecoder::ColorSpaceApplied |
| 264 : ImageDecoder::GammaAndColorProfileIgnored); | 264 : ImageDecoder::ColorSpaceIgnored); |
| 265 if (colorCorrection) { | |
| 266 WebVector<char> profile; | |
| 267 getScreenColorProfile(&profile); // Returns a color spin color profile. | |
| 268 decoder->setTargetColorProfile(profile); | |
|
Simon Hosie
2016/11/15 01:50:00
So far as I could see `profile` doesn't need to li
scroggo_chromium
2016/11/15 14:54:42
Agreed. setTargetColorProfile will store an object
Simon Hosie
2016/11/16 01:36:33
Done.
| |
| 269 } | |
| 265 | 270 |
| 266 if (!packetSize) { | 271 if (!packetSize) { |
| 267 bool allDataReceived = true; | 272 bool allDataReceived = true; |
| 268 decoder->setData(data, allDataReceived); | 273 decoder->setData(data, allDataReceived); |
| 269 | 274 |
| 270 int frameCount = decoder->frameCount(); | 275 int frameCount = decoder->frameCount(); |
| 271 for (int i = 0; i < frameCount; ++i) { | 276 for (int i = 0; i < frameCount; ++i) { |
| 272 if (!decoder->frameBufferAtIndex(i)) | 277 if (!decoder->frameBufferAtIndex(i)) |
| 273 return false; | 278 return false; |
| 274 } | 279 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 if (*end != '\0') { | 346 if (*end != '\0') { |
| 342 fprintf(stderr, | 347 fprintf(stderr, |
| 343 "Third argument should be packet size. Default is " | 348 "Third argument should be packet size. Default is " |
| 344 "0, meaning to decode the entire image in one packet. You " | 349 "0, meaning to decode the entire image in one packet. You " |
| 345 "supplied %s\n", | 350 "supplied %s\n", |
| 346 argv[3]); | 351 argv[3]); |
| 347 exit(1); | 352 exit(1); |
| 348 } | 353 } |
| 349 } | 354 } |
| 350 | 355 |
| 351 // Create a web platform without V8. | 356 // Create a web platform without V8. |
|
scroggo_chromium
2016/11/15 14:54:42
This comment appears to no longer apply. When this
Simon Hosie
2016/11/16 01:36:32
Done.
| |
| 352 | 357 |
| 353 class WebPlatform : public blink::Platform { | 358 class WebPlatform : public blink::Platform {}; |
|
scroggo_chromium
2016/11/15 14:54:42
Without overriding anything, I don't think you nee
Simon Hosie
2016/11/16 01:36:32
Done.
| |
| 354 public: | |
| 355 void screenColorProfile(WebVector<char>* profile) override { | |
| 356 getScreenColorProfile(profile); // Returns a color spin color profile. | |
| 357 } | |
| 358 }; | |
| 359 | 359 |
| 360 Platform::initialize(new WebPlatform()); | 360 Platform::initialize(new WebPlatform()); |
| 361 | 361 |
| 362 // Read entire file content to data, and consolidate the SharedBuffer data | 362 // Read entire file content to data, and consolidate the SharedBuffer data |
| 363 // segments into one, contiguous block of memory. | 363 // segments into one, contiguous block of memory. |
| 364 | 364 |
| 365 RefPtr<SharedBuffer> data = readFile(argv[1]); | 365 RefPtr<SharedBuffer> data = readFile(argv[1]); |
| 366 if (!data.get() || !data->size()) { | 366 if (!data.get() || !data->size()) { |
| 367 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); | 367 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); |
| 368 exit(2); | 368 exit(2); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 392 exit(3); | 392 exit(3); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 // Results to stdout. | 396 // Results to stdout. |
| 397 | 397 |
| 398 double averageTime = totalTime / static_cast<double>(iterations); | 398 double averageTime = totalTime / static_cast<double>(iterations); |
| 399 printf("%f %f\n", totalTime, averageTime); | 399 printf("%f %f\n", totalTime, averageTime); |
| 400 return 0; | 400 return 0; |
| 401 } | 401 } |
| OLD | NEW |