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

Unified Diff: content/renderer/render_widget.cc

Issue 10982078: Adding hooks for gathering total pixels painted and rasterized stats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index ce2385bbe0ad6bcb9e6b09860093f17831828c88..7c4b75b13af05e21679ca67a6ae2088ae4a734ad 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -669,6 +669,13 @@ void RenderWidget::PaintRect(const gfx::Rect& rect,
skia::PlatformCanvas* canvas) {
TRACE_EVENT2("renderer", "PaintRect",
"width", rect.width(), "height", rect.height());
+
+ const bool kEnableGpuBenchmarking =
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableGpuBenchmarking);
+ base::TimeTicks rasterize_begin_ticks;
+ if (kEnableGpuBenchmarking)
+ rasterize_begin_ticks = base::TimeTicks::HighResNow();
canvas->save();
// Bring the canvas into the coordinate system of the paint rect.
@@ -724,22 +731,35 @@ void RenderWidget::PaintRect(const gfx::Rect& rect,
// WebKit and filling the background (which can be slow) and just painting
// the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
// required.
- base::TimeTicks paint_begin_ticks = base::TimeTicks::Now();
+ base::TimeTicks paint_begin_ticks;
+ if (kEnableGpuBenchmarking)
+ paint_begin_ticks = base::TimeTicks::HighResNow();
+
SkAutoCanvasRestore auto_restore(canvas, true);
canvas->scale(device_scale_factor_, device_scale_factor_);
optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
optimized_copy_location, rect);
canvas->restore();
- base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks;
- if (!is_accelerated_compositing_active_)
- software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
+ if (kEnableGpuBenchmarking) {
+ base::TimeDelta paint_time =
+ base::TimeTicks::HighResNow() - paint_begin_ticks;
+ if (!is_accelerated_compositing_active_)
+ software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
+ }
} else {
// Normal painting case.
- base::TimeTicks paint_begin_ticks = base::TimeTicks::Now();
+ base::TimeTicks paint_begin_ticks;
+ if (kEnableGpuBenchmarking)
+ paint_begin_ticks = base::TimeTicks::HighResNow();
+
webwidget_->paint(webkit_glue::ToWebCanvas(canvas), rect);
- base::TimeDelta paint_time = base::TimeTicks::Now() - paint_begin_ticks;
- if (!is_accelerated_compositing_active_)
- software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
+
+ if (kEnableGpuBenchmarking) {
+ base::TimeDelta paint_time =
+ base::TimeTicks::HighResNow() - paint_begin_ticks;
+ if (!is_accelerated_compositing_active_)
+ software_stats_.totalPaintTimeInSeconds += paint_time.InSecondsF();
+ }
// Flush to underlying bitmap. TODO(darin): is this needed?
skia::GetTopDevice(*canvas)->accessBitmap(false);
@@ -747,6 +767,16 @@ void RenderWidget::PaintRect(const gfx::Rect& rect,
PaintDebugBorder(rect, canvas);
canvas->restore();
+
+ if (kEnableGpuBenchmarking) {
+ base::TimeDelta rasterize_time =
+ base::TimeTicks::HighResNow() - rasterize_begin_ticks;
+ software_stats_.totalRasterizeTimeInSeconds += rasterize_time.InSecondsF();
+
+ int64 num_pixels_processed = rect.width() * rect.height();
+ software_stats_.totalPixelsPainted += num_pixels_processed;
+ software_stats_.totalPixelsRasterized += num_pixels_processed;
+ }
}
void RenderWidget::PaintDebugBorder(const gfx::Rect& rect,
@@ -1886,6 +1916,10 @@ void RenderWidget::GetRenderingStats(WebKit::WebRenderingStats& stats) const {
stats.numAnimationFrames += software_stats_.numAnimationFrames;
stats.numFramesSentToScreen += software_stats_.numFramesSentToScreen;
stats.totalPaintTimeInSeconds += software_stats_.totalPaintTimeInSeconds;
+ stats.totalPixelsPainted += software_stats_.totalPixelsPainted;
+ stats.totalRasterizeTimeInSeconds +=
+ software_stats_.totalRasterizeTimeInSeconds;
+ stats.totalPixelsRasterized += software_stats_.totalPixelsRasterized;
}
bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const {
« no previous file with comments | « content/renderer/gpu/gpu_benchmarking_extension.cc ('k') | webkit/compositor_bindings/web_layer_tree_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698