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

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

Issue 2483243003: Re-enable image_decode_bench target (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 "Third argument should be packet size. Default is " 343 "Third argument should be packet size. Default is "
344 "0, meaning to decode the entire image in one packet. You " 344 "0, meaning to decode the entire image in one packet. You "
345 "supplied %s\n", 345 "supplied %s\n",
346 argv[3]); 346 argv[3]);
347 exit(1); 347 exit(1);
348 } 348 }
349 } 349 }
350 350
351 // Create a web platform without V8. 351 // Create a web platform without V8.
352 352
353 class WebPlatform : public blink::Platform { 353 class WebPlatform : public blink::Platform {};
354 public:
355 void screenColorProfile(WebVector<char>* profile) override {
356 getScreenColorProfile(profile); // Returns a color spin color profile.
scroggo_chromium 2016/11/09 14:16:59 msarett@, do you know the right way to set this no
msarett1 2016/11/09 15:01:58 I'm not aware that this has changed. The profile
Simon Hosie 2016/11/09 17:29:13 The method it overrides was deleted in https://chr
msarett1 2016/11/09 18:18:28 Ahh thanks! It looks to me like now instead we ca
357 }
358 };
359 354
360 Platform::initialize(new WebPlatform()); 355 Platform::initialize(new WebPlatform());
361 356
362 // Read entire file content to data, and consolidate the SharedBuffer data 357 // Read entire file content to data, and consolidate the SharedBuffer data
363 // segments into one, contiguous block of memory. 358 // segments into one, contiguous block of memory.
364 359
365 RefPtr<SharedBuffer> data = readFile(argv[1]); 360 RefPtr<SharedBuffer> data = readFile(argv[1]);
366 if (!data.get() || !data->size()) { 361 if (!data.get() || !data->size()) {
367 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]); 362 fprintf(stderr, "Error reading image data from [%s]\n", argv[1]);
368 exit(2); 363 exit(2);
(...skipping 23 matching lines...) Expand all
392 exit(3); 387 exit(3);
393 } 388 }
394 } 389 }
395 390
396 // Results to stdout. 391 // Results to stdout.
397 392
398 double averageTime = totalTime / static_cast<double>(iterations); 393 double averageTime = totalTime / static_cast<double>(iterations);
399 printf("%f %f\n", totalTime, averageTime); 394 printf("%f %f\n", totalTime, averageTime);
400 return 0; 395 return 0;
401 } 396 }
OLDNEW
« no previous file with comments | « 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