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

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 a974fde1764f92c91a0caf451e5fa7079d02f78f..0cf206c169c755eaaad599615cd65f1efb2d7828 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -673,6 +673,11 @@ void RenderWidget::PaintRect(const gfx::Rect& rect,
skia::PlatformCanvas* canvas) {
TRACE_EVENT2("renderer", "PaintRect",
"width", rect.width(), "height", rect.height());
+
+ base::TimeTicks rasterize_begin_ticks;
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableGpuBenchmarking))
+ rasterize_begin_ticks = base::TimeTicks::HighResNow();
canvas->save();
// Bring the canvas into the coordinate system of the paint rect.
@@ -728,22 +733,39 @@ 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 (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableGpuBenchmarking))
jamesr 2012/11/08 23:33:12 we're repeating this a lot - can we stash this in
hartmanng 2012/11/09 14:07:11 Done.
+ 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 (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::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 (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::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 (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::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);
@@ -751,6 +773,17 @@ void RenderWidget::PaintRect(const gfx::Rect& rect,
PaintDebugBorder(rect, canvas);
canvas->restore();
+
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::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,
@@ -1897,6 +1930,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