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

Unified Diff: third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp

Issue 2893023003: Add raster timing to ImageDecodeBench
Patch Set: Rebase. Remove blink:: and use fprintf() / exit() like upstream Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0a1c00bcb26e40deb9bb76c1f54e174578b391e3..516fc074d677f086f158482127fee7317fe462da 100644
--- a/third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp
+++ b/third_party/WebKit/Source/platform/testing/ImageDecodeBench.cpp
@@ -2,19 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Provides a minimal wrapping of the Blink image decoders. Used to perform
-// a non-threaded, memory-to-memory image decode using micro second accuracy
-// clocks to measure image decode time. Optionally applies color correction
-// during image decoding on supported platforms (default off). Usage:
+// Provides a minimal wrapping of the Blink image decoders & Skia raster.
+// Used to perform a non-threaded, memory-to-memory image decode/raster using
+// micro second accuracy clocks to measure image decode time. Optionally
+// applies color correction during image decoding on supported platforms
+// (default off). Usage:
//
// % ninja -C out/Release image_decode_bench &&
-// ./out/Release/image_decode_bench file [iterations]
+// ./out/Release/image_decode_bench file [--raster] [iterations]
//
// The output is formatted for use in a csv file (comma-separated variable).
// Each row represents successive frames in an animated image.
// Each column represents a successive iteration of decoding the whole animated
// image.
// This means non-animated images will show up as one column.
+// Raster timing also shows up as one column.
//
// TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute
// the decoded image frame md5 and output that value.
@@ -31,6 +33,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)
@@ -310,6 +314,41 @@ void TimePacketedDecode(ImageDecoder* decoder,
Print2DResults(timings);
}
+void TimeRaster(ImageDecoder* decoder,
+ PassRefPtr<SharedBuffer> data,
+ size_t iterations) {
+ const bool all_data_received = true;
+ decoder->SetData(data.Get(), all_data_received);
+
+ if (!decoder->IsSizeAvailable()) {
+ fprintf(stderr, "failed to decode size\n");
+ exit(3);
scroggo_chromium 2017/05/23 15:57:09 Right now it looks like we pass the following valu
cblume 2017/05/23 18:07:31 ImageDecodeBench currently (prior to this patch) r
+ }
+ const auto size = decoder->Size();
+
+ ImageFrame* frame = decoder->FrameBufferAtIndex(0);
+ if (frame->GetStatus() != ImageFrame::kFrameComplete) {
+ fprintf(stderr, "failed to decode first frame\n");
+ exit(3);
+ }
+
+ auto surface = SkSurface::MakeRasterN32Premul(size.Width(), size.Height());
+ auto canvas = surface->getCanvas();
+
+ std::vector<double> timings(iterations);
+ for (size_t i = 0; i < iterations; ++i) {
+ double start_time = GetCurrentTime();
+ canvas->drawBitmap(frame->Bitmap(), 0, 0, nullptr);
+ double elapsed_time = GetCurrentTime() - start_time;
+ timings[i] = elapsed_time;
+ }
+
+ for (double iteration_time : timings) {
+ printf("%f,\n", iteration_time);
+ }
+ printf("\n");
+}
+
} // namespace
int Main(int argc, char* argv[]) {
@@ -326,9 +365,17 @@ int Main(int argc, char* argv[]) {
ColorBehavior::SetGlobalTargetColorProfile(profile);
}
+ bool time_raster = false;
+ if (argc >= 2 && strcmp(argv[1], "--raster") == 0) {
+ --argc;
+ ++argv;
+ time_raster = true;
+ }
+
if (argc < 2) {
fprintf(stderr,
- "Usage: %s [--color-correct] file [iterations] [packetSize]\n",
+ "Usage: %s [--color-correct] [--raster] file [iterations] "
+ "[packetSize]\n",
argv[0]);
exit(1);
}
@@ -386,10 +433,15 @@ int Main(int argc, char* argv[]) {
data, true, ImageDecoder::kAlphaPremultiplied,
apply_color_correction ? ColorBehavior::TransformToTargetForTesting()
: ColorBehavior::Ignore());
- if (packet_size) {
- TimePacketedDecode(decoder.get(), data.Get(), packet_size, iterations);
+ if (time_raster) {
+ TimeRaster(decoder.get(), data.Get(), iterations);
} else {
- TimeDecode(decoder.get(), data.Get(), iterations);
+ if (packet_size) {
+ TimePacketedDecode(decoder.get(), data.Get(), packet_size,
+ iterations);
+ } else {
+ TimeDecode(decoder.get(), data.Get(), iterations);
+ }
}
return 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698