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 14 matching lines...) Expand all Loading... | |
25 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5 | 25 // to http://crbug.com/398235#c103 and http://crbug.com/258324#c5 |
26 | 26 |
27 #include <memory> | 27 #include <memory> |
28 #include <vector> | 28 #include <vector> |
29 #include "base/command_line.h" | 29 #include "base/command_line.h" |
30 #include "platform/SharedBuffer.h" | 30 #include "platform/SharedBuffer.h" |
31 #include "platform/image-decoders/ImageDecoder.h" | 31 #include "platform/image-decoders/ImageDecoder.h" |
32 #include "platform/wtf/PassRefPtr.h" | 32 #include "platform/wtf/PassRefPtr.h" |
33 #include "platform/wtf/PtrUtil.h" | 33 #include "platform/wtf/PtrUtil.h" |
34 #include "public/platform/Platform.h" | 34 #include "public/platform/Platform.h" |
35 #include "third_party/skia/include/core/SkCanvas.h" | |
36 #include "third_party/skia/include/core/SkSurface.h" | |
35 #include "ui/gfx/test/icc_profiles.h" | 37 #include "ui/gfx/test/icc_profiles.h" |
36 | 38 |
37 #if defined(_WIN32) | 39 #if defined(_WIN32) |
38 #include <mmsystem.h> | 40 #include <mmsystem.h> |
39 #include <sys/stat.h> | 41 #include <sys/stat.h> |
40 #include <time.h> | 42 #include <time.h> |
41 #define stat(x, y) _stat(x, y) | 43 #define stat(x, y) _stat(x, y) |
42 typedef struct _stat sttype; | 44 typedef struct _stat sttype; |
43 #else | 45 #else |
44 #include <sys/stat.h> | 46 #include <sys/stat.h> |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 } | 299 } |
298 } | 300 } |
299 | 301 |
300 if (all_data_received || decoder->Failed()) | 302 if (all_data_received || decoder->Failed()) |
301 return; | 303 return; |
302 } | 304 } |
303 | 305 |
304 Print2DResults(timings); | 306 Print2DResults(timings); |
305 } | 307 } |
306 | 308 |
309 void TimeRaster(ImageDecoder* decoder, | |
310 PassRefPtr<SharedBuffer> data, | |
311 size_t iterations) { | |
312 // Force enough parsing to later determine the image's size. | |
scroggo_chromium
2017/05/22 12:50:14
I find this comment confusing. Calling FrameBuffer
cblume
2017/05/22 21:33:02
Done.
I think you are right that if we don't have
| |
313 const bool all_data_received = true; | |
314 decoder->SetData(data.Get(), all_data_received); | |
315 ImageFrame* frame = decoder->FrameBufferAtIndex(0); | |
316 | |
317 const auto size = decoder->Size(); | |
318 auto surface = SkSurface::MakeRasterN32Premul(size.Width(), size.Height()); | |
319 auto canvas = surface->getCanvas(); | |
320 | |
321 std::vector<double> timings(iterations); | |
322 for (size_t iteration = 0; iteration < iterations; ++iteration) { | |
scroggo_chromium
2017/05/22 12:50:14
nit: I would change "iteration" to "i". It makes i
cblume
2017/05/22 21:33:02
Done.
| |
323 double start_time = GetCurrentTime(); | |
324 canvas->drawBitmap(frame->Bitmap(), 0, 0, nullptr); | |
325 double elapsed_time = GetCurrentTime() - start_time; | |
326 timings[iteration] = elapsed_time; | |
327 } | |
328 | |
329 for (double iteration_time : timings) { | |
330 printf("%f,\n", iteration_time); | |
331 } | |
332 printf("\n"); | |
333 } | |
334 | |
307 } // namespace | 335 } // namespace |
308 | 336 |
309 int Main(int argc, char* argv[]) { | 337 int Main(int argc, char* argv[]) { |
310 base::CommandLine::Init(argc, argv); | 338 base::CommandLine::Init(argc, argv); |
311 | 339 |
312 // If the platform supports color correction, allow it to be controlled. | 340 // If the platform supports color correction, allow it to be controlled. |
313 | 341 |
314 bool apply_color_correction = false; | 342 bool apply_color_correction = false; |
315 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) { | 343 if (argc >= 2 && strcmp(argv[1], "--color-correct") == 0) { |
316 --argc; | 344 --argc; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 } | 416 } |
389 | 417 |
390 return 0; | 418 return 0; |
391 } | 419 } |
392 | 420 |
393 } // namespace blink | 421 } // namespace blink |
394 | 422 |
395 int main(int argc, char* argv[]) { | 423 int main(int argc, char* argv[]) { |
396 return blink::Main(argc, argv); | 424 return blink::Main(argc, argv); |
397 } | 425 } |
OLD | NEW |