Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp

Issue 2483243003: Re-enable image_decode_bench target (Closed)
Patch Set: Re-enable image_decode_bench target Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 26 matching lines...) Expand all
302 return !decoder->failed(); 301 return !decoder->failed();
303 } 302 }
304 303
305 int main(int argc, char* argv[]) { 304 int main(int argc, char* argv[]) {
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);
313 WebVector<char> profile;
314 getScreenColorProfile(&profile); // Returns a color spin color profile.
315 ImageDecoder::setTargetColorProfile(profile);
316 }
314 317
315 if (argc < 2) { 318 if (argc < 2) {
316 fprintf(stderr, 319 fprintf(stderr,
317 "Usage: %s [--color-correct] file [iterations] [packetSize]\n", 320 "Usage: %s [--color-correct] file [iterations] [packetSize]\n",
318 argv[0]); 321 argv[0]);
319 exit(1); 322 exit(1);
320 } 323 }
321 324
322 // Control decode bench iterations and packet size. 325 // Control decode bench iterations and packet size.
323 326
(...skipping 17 matching lines...) Expand all
341 if (*end != '\0') { 344 if (*end != '\0') {
342 fprintf(stderr, 345 fprintf(stderr,
343 "Third argument should be packet size. Default is " 346 "Third argument should be packet size. Default is "
344 "0, meaning to decode the entire image in one packet. You " 347 "0, meaning to decode the entire image in one packet. You "
345 "supplied %s\n", 348 "supplied %s\n",
346 argv[3]); 349 argv[3]);
347 exit(1); 350 exit(1);
348 } 351 }
349 } 352 }
350 353
351 // Create a web platform without V8. 354 // Create a web platform. blink::Platform can't be used directly because its
355 // constructor is protected.
352 356
353 class WebPlatform : public blink::Platform { 357 class WebPlatform : public blink::Platform {};
354 public:
355 void screenColorProfile(WebVector<char>* profile) override {
356 getScreenColorProfile(profile); // Returns a color spin color profile.
357 }
358 };
359 358
360 Platform::initialize(new WebPlatform()); 359 Platform::initialize(new WebPlatform());
361 360
362 // Read entire file content to data, and consolidate the SharedBuffer data 361 // Read entire file content to data, and consolidate the SharedBuffer data
363 // segments into one, contiguous block of memory. 362 // segments into one, contiguous block of memory.
364 363
365 RefPtr<SharedBuffer> data = readFile(argv[1]); 364 RefPtr<SharedBuffer> data = readFile(argv[1]);
366 if (!data.get() || !data->size()) { 365 if (!data.get() || !data->size()) {
367 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); 366 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]);
368 exit(2); 367 exit(2);
(...skipping 23 matching lines...) Expand all
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 }
OLDNEW
« third_party/WebKit/Source/platform/BUILD.gn ('K') | « third_party/WebKit/Source/platform/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698