Chromium Code Reviews| Index: third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp |
| diff --git a/third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp b/third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp |
| index 7d1539721d518f9862524e60695f92cc660d42d9..5b53ae52417cb786c4e4ac07e7dded312c56c79d 100644 |
| --- a/third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp |
| +++ b/third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp |
| @@ -32,6 +32,8 @@ |
| #include "platform/wtf/PassRefPtr.h" |
| #include "platform/wtf/PtrUtil.h" |
| #include "public/platform/Platform.h" |
| +#include "third_party/skia/include/core/SkCanvas.h" |
| +#include "third_party/skia/include/core/SkSurface.h" |
| #include "ui/gfx/test/icc_profiles.h" |
| #if defined(_WIN32) |
| @@ -304,6 +306,32 @@ void TimePacketedDecode(ImageDecoder* decoder, |
| Print2DResults(timings); |
| } |
| +void TimeRaster(ImageDecoder* decoder, |
| + PassRefPtr<SharedBuffer> data, |
| + size_t iterations) { |
| + // 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
|
| + const bool all_data_received = true; |
| + decoder->SetData(data.Get(), all_data_received); |
| + ImageFrame* frame = decoder->FrameBufferAtIndex(0); |
| + |
| + const auto size = decoder->Size(); |
| + auto surface = SkSurface::MakeRasterN32Premul(size.Width(), size.Height()); |
| + auto canvas = surface->getCanvas(); |
| + |
| + std::vector<double> timings(iterations); |
| + 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.
|
| + double start_time = GetCurrentTime(); |
| + canvas->drawBitmap(frame->Bitmap(), 0, 0, nullptr); |
| + double elapsed_time = GetCurrentTime() - start_time; |
| + timings[iteration] = elapsed_time; |
| + } |
| + |
| + for (double iteration_time : timings) { |
| + printf("%f,\n", iteration_time); |
| + } |
| + printf("\n"); |
| +} |
| + |
| } // namespace |
| int Main(int argc, char* argv[]) { |