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 && |
| 11 // ./out/Release/image_decode_bench file [iterations] | 11 // ./out/Release/image_decode_bench file [iterations] |
| 12 // | 12 // |
| 13 // TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute | 13 // TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute |
| 14 // the decoded image frame md5 and output that value. | 14 // the decoded image frame md5 and output that value. |
| 15 // | 15 // |
| 16 // TODO(noel): Consider integrating this tool in Chrome telemetry for realz, | 16 // TODO(noel): Consider integrating this tool in Chrome telemetry for realz, |
| 17 // using the image corpii used to assess Blink image decode performance. Refer | 17 // using the image corpii used to assess Blink image decode performance. Refer |
| 18 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5 | 18 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5 |
| 19 | 19 |
| 20 #include "platform/SharedBuffer.h" | 20 #include "platform/SharedBuffer.h" |
| 21 #include "platform/image-decoders/ImageDecoder.h" | 21 #include "platform/image-decoders/ImageDecoder.h" |
| 22 #include "platform/testing/TestingPlatformSupport.h" | 22 #include "platform/testing/TestingPlatformSupport.h" |
| 23 #include "public/platform/Platform.h" | 23 #include "public/platform/Platform.h" |
| 24 #include "public/web/WebKit.h" | 24 #include "public/web/WebKit.h" |
| 25 #include "wtf/OwnPtr.h" | 25 #include "wtf/OwnPtr.h" |
| 26 #include "wtf/PassRefPtr.h" | 26 #include "wtf/PassRefPtr.h" |
| 27 | 27 |
| 28 #if defined(_WIN32) | 28 #if defined(_WIN32) |
| 29 #if defined(WIN32_LEAN_AND_MEAN) | 29 #if defined(WIN32_LEAN_AND_MEAN) |
| 30 #error Fix: WIN32_LEAN_AND_MEAN disables timeBeginPeriod/TimeEndPeriod. | 30 #error Fix: WIN32_LEAN_AND_MEAN disables timeBeginPeriod/TimeEndPeriod. |
|
Noel Gordon
2016/04/26 14:09:59
We will probably need to remove this #if #else cla
scroggo_chromium
2016/04/29 13:44:30
I'm guessing you mean the #if #error clause, and n
Noel Gordon
2016/05/02 12:31:09
Correct, just these 3 lines need to be removed.
-
| |
| 31 #endif | 31 #endif |
| 32 #include <mmsystem.h> | 32 #include <mmsystem.h> |
| 33 #include <sys/stat.h> | 33 #include <sys/stat.h> |
| 34 #include <time.h> | 34 #include <time.h> |
| 35 #define stat(x,y) _stat(x,y) | 35 #define stat(x,y) _stat(x,y) |
| 36 typedef struct _stat sttype; | 36 typedef struct _stat sttype; |
| 37 #else | 37 #else |
| 38 #include <sys/stat.h> | 38 #include <sys/stat.h> |
| 39 #include <sys/time.h> | 39 #include <sys/time.h> |
| 40 typedef struct stat sttype; | 40 typedef struct stat sttype; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 int frameCount = decoder->frameCount(); | 273 int frameCount = decoder->frameCount(); |
| 274 for (int i = 0; i < frameCount; ++i) { | 274 for (int i = 0; i < frameCount; ++i) { |
| 275 if (!decoder->frameBufferAtIndex(i)) | 275 if (!decoder->frameBufferAtIndex(i)) |
| 276 return false; | 276 return false; |
| 277 } | 277 } |
| 278 | 278 |
| 279 return !decoder->failed(); | 279 return !decoder->failed(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 RefPtr<SharedBuffer> packetData = SharedBuffer::create(); | 282 RefPtr<SharedBuffer> packetData = SharedBuffer::create(); |
| 283 unsigned position = 0; | 283 size_t position = 0; |
| 284 while (true) { | 284 while (true) { |
| 285 const char* packet; | 285 const char* packet; |
| 286 unsigned length = data->getSomeData(packet, position); | 286 size_t length = data->getSomeData(packet, position); |
| 287 | 287 |
| 288 length = std::min(static_cast<size_t>(length), packetSize); | 288 length = std::min(static_cast<size_t>(length), packetSize); |
| 289 packetData->append(packet, length); | 289 packetData->append(packet, length); |
| 290 position += length; | 290 position += length; |
| 291 | 291 |
| 292 bool allDataReceived = position == data->size(); | 292 bool allDataReceived = position == data->size(); |
| 293 decoder->setData(packetData.get(), allDataReceived); | 293 decoder->setData(packetData.get(), allDataReceived); |
| 294 | 294 |
| 295 int frameCount = decoder->frameCount(); | 295 int frameCount = decoder->frameCount(); |
| 296 for (int i = 0; i < frameCount; ++i) { | 296 for (int i = 0; i < frameCount; ++i) { |
| 297 if (!decoder->frameBufferAtIndex(i)) | 297 if (!decoder->frameBufferAtIndex(i)) |
| 298 break; | 298 break; |
| 299 } | 299 } |
| 300 | 300 |
| 301 if (allDataReceived || decoder->failed()) | 301 if (allDataReceived || decoder->failed()) |
| 302 break; | 302 break; |
| 303 } | 303 } |
| 304 | 304 |
| 305 return !decoder->failed(); | 305 return !decoder->failed(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 int main(int argc, char* argv[]) | 308 int main(int argc, char* argv[]) |
| 309 { | 309 { |
| 310 char* name = argv[0]; | 310 char* name = argv[0]; |
|
Noel Gordon
2016/04/26 14:09:59
blink::Platform increasingly depends on src/base i
| |
| 311 | 311 |
| 312 // If the platform supports color correction, allow it to be controlled. | 312 // If the platform supports color correction, allow it to be controlled. |
| 313 | 313 |
| 314 bool applyColorCorrection = false; | 314 bool applyColorCorrection = false; |
| 315 | 315 |
| 316 #if USE(QCMSLIB) | 316 #if USE(QCMSLIB) |
| 317 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) | 317 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) |
| 318 applyColorCorrection = (--argc, ++argv, true); | 318 applyColorCorrection = (--argc, ++argv, true); |
| 319 | 319 |
| 320 if (argc < 2) { | 320 if (argc < 2) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 348 if (*end != '\0') { | 348 if (*end != '\0') { |
| 349 fprintf(stderr, "Third argument should be packet size. Default is " | 349 fprintf(stderr, "Third argument should be packet size. Default is " |
| 350 "0, meaning to decode the entire image in one packet. You " | 350 "0, meaning to decode the entire image in one packet. You " |
| 351 "supplied %s\n", argv[3]); | 351 "supplied %s\n", argv[3]); |
| 352 exit(1); | 352 exit(1); |
| 353 } | 353 } |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Create a web platform without V8. | 356 // Create a web platform without V8. |
| 357 | 357 |
| 358 class WebPlatform : public TestingPlatformSupport { | 358 class WebPlatform : public TestingPlatformSupport { |
|
Noel Gordon
2016/04/26 14:09:59
Could you try changing this to
class WebPlatf
scroggo_chromium
2016/04/29 13:44:30
Yes, that works. It seems a little weird to me tha
Noel Gordon
2016/05/02 12:31:09
TestingWebPlatform provides very few overrides, an
| |
| 359 public: | 359 public: |
| 360 void screenColorProfile(WebVector<char>* profile) override | 360 void screenColorProfile(WebVector<char>* profile) override |
| 361 { | 361 { |
| 362 getScreenColorProfile(profile); // Returns a whacked color profile. | 362 getScreenColorProfile(profile); // Returns a whacked color profile. |
| 363 } | 363 } |
| 364 }; | 364 }; |
| 365 | 365 |
| 366 Platform::initialize(new WebPlatform()); | 366 Platform::initialize(new WebPlatform()); |
| 367 | 367 |
| 368 // Set image decoding Platform options. | 368 // Set image decoding Platform options. |
| 369 | 369 |
|
Noel Gordon
2016/04/26 14:09:59
Maybe a DeferredImageDecoder::setEnabled(false); i
scroggo_chromium
2016/04/29 13:44:30
I don't see how this is necessary. That only affec
Noel Gordon
2016/05/02 12:31:09
I recall in testing the older code last week, that
| |
| 370 #if USE(QCMSLIB) | 370 #if USE(QCMSLIB) |
| 371 ImageDecoder::qcmsOutputDeviceProfile(); // Initialize screen colorProfile. | 371 // FIXME: This method has been removed, but it is important. |
|
ccameron
2016/04/21 07:30:42
Could you give a bit more detail about what is "im
scroggo_chromium
2016/04/29 13:44:30
As I understand it, the question is not whether th
Noel Gordon
2016/05/02 12:31:09
Yeap, that's right, to remove profile initializati
| |
| 372 // ImageDecoder::qcmsOutputDeviceProfile(); // Initialize screen colorProfil e. | |
| 372 #endif | 373 #endif |
| 373 | 374 |
| 374 // Read entire file content to data. | 375 // Read entire file content to data. |
| 375 | 376 |
| 376 RefPtr<SharedBuffer> data = readFile(argv[1]); | 377 RefPtr<SharedBuffer> data = readFile(argv[1]); |
| 377 if (!data.get() || !data->size()) { | 378 if (!data.get() || !data->size()) { |
| 378 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); | 379 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); |
| 379 exit(2); | 380 exit(2); |
| 380 } | 381 } |
| 381 | 382 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 396 exit(3); | 397 exit(3); |
| 397 } | 398 } |
| 398 } | 399 } |
| 399 | 400 |
| 400 // Results to stdout. | 401 // Results to stdout. |
| 401 | 402 |
| 402 double averageTime = totalTime / static_cast<double>(iterations); | 403 double averageTime = totalTime / static_cast<double>(iterations); |
| 403 printf("%f %f\n", totalTime, averageTime); | 404 printf("%f %f\n", totalTime, averageTime); |
| 404 return 0; | 405 return 0; |
| 405 } | 406 } |
| OLD | NEW |