Adding hooks for gathering total pixels painted and rasterized stats.
Blocked on: https://bugs.webkit.org/show_bug.cgi?id=98269 BUG=156087 Review URL: https://chromiumcodereview.appspot.com/10982078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166911 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include "cc/bitmap_content_layer_updater.h"
|
||||
|
||||
#include "cc/layer_painter.h"
|
||||
#include "cc/rendering_stats.h"
|
||||
#include "cc/resource_update.h"
|
||||
#include "cc/resource_update_queue.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
@ -55,6 +56,8 @@ void BitmapContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, co
|
||||
m_canvas = make_scoped_ptr(skia::CreateBitmapCanvas(m_canvasSize.width(), m_canvasSize.height(), m_opaque));
|
||||
}
|
||||
|
||||
stats.totalPixelsRasterized += contentRect.width() * contentRect.height();
|
||||
|
||||
paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats);
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ void BitmapSkPictureContentLayerUpdater::paintContentsRect(SkCanvas* canvas, con
|
||||
base::TimeTicks rasterizeBeginTime = base::TimeTicks::Now();
|
||||
drawPicture(canvas);
|
||||
stats.totalRasterizeTimeInSeconds += (base::TimeTicks::Now() - rasterizeBeginTime).InSecondsF();
|
||||
stats.totalPixelsRasterized += sourceRect.width() * sourceRect.height();
|
||||
}
|
||||
|
||||
} // namespace cc
|
||||
|
@ -150,6 +150,7 @@
|
||||
'render_surface_impl.h',
|
||||
'renderer.cc',
|
||||
'renderer.h',
|
||||
'rendering_stats.cc',
|
||||
'rendering_stats.h',
|
||||
'resource.cc',
|
||||
'resource.h',
|
||||
|
@ -56,6 +56,8 @@ void ContentLayerUpdater::paintContents(SkCanvas* canvas, const gfx::Rect& conte
|
||||
stats.totalPaintTimeInSeconds += (base::TimeTicks::Now() - paintBeginTime).InSecondsF();
|
||||
canvas->restore();
|
||||
|
||||
stats.totalPixelsPainted += contentRect.width() * contentRect.height();
|
||||
|
||||
gfx::RectF opaqueContentRect = gfx::ScaleRect(opaqueLayerRect, contentsWidthScale, contentsHeightScale);
|
||||
resultingOpaqueRect = gfx::ToEnclosedRect(opaqueContentRect);
|
||||
|
||||
|
23
cc/rendering_stats.cc
Normal file
23
cc/rendering_stats.cc
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "cc/rendering_stats.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
RenderingStats::RenderingStats()
|
||||
: numAnimationFrames(0),
|
||||
numFramesSentToScreen(0),
|
||||
droppedFrameCount(0),
|
||||
totalPaintTimeInSeconds(0),
|
||||
totalRasterizeTimeInSeconds(0),
|
||||
totalCommitTimeInSeconds(0),
|
||||
totalCommitCount(0),
|
||||
totalPixelsPainted(0),
|
||||
totalPixelsRasterized(0),
|
||||
numImplThreadScrolls(0),
|
||||
numMainThreadScrolls(0) {
|
||||
}
|
||||
|
||||
} // namespace cc
|
@ -5,34 +5,28 @@
|
||||
#ifndef CC_RENDERING_STATS_H_
|
||||
#define CC_RENDERING_STATS_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "cc/cc_export.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
struct RenderingStats {
|
||||
struct CC_EXPORT RenderingStats {
|
||||
// FIXME: Rename these to animationFrameCount and screenFrameCount, crbug.com/138641.
|
||||
int numAnimationFrames;
|
||||
int numFramesSentToScreen;
|
||||
int droppedFrameCount;
|
||||
int64 numAnimationFrames;
|
||||
int64 numFramesSentToScreen;
|
||||
int64 droppedFrameCount;
|
||||
double totalPaintTimeInSeconds;
|
||||
double totalRasterizeTimeInSeconds;
|
||||
double totalCommitTimeInSeconds;
|
||||
size_t totalCommitCount;
|
||||
size_t numImplThreadScrolls;
|
||||
size_t numMainThreadScrolls;
|
||||
int64 totalPixelsPainted;
|
||||
int64 totalPixelsRasterized;
|
||||
int64 numImplThreadScrolls;
|
||||
int64 numMainThreadScrolls;
|
||||
|
||||
RenderingStats()
|
||||
: numAnimationFrames(0)
|
||||
, numFramesSentToScreen(0)
|
||||
, droppedFrameCount(0)
|
||||
, totalPaintTimeInSeconds(0)
|
||||
, totalRasterizeTimeInSeconds(0)
|
||||
, totalCommitTimeInSeconds(0)
|
||||
, totalCommitCount(0)
|
||||
, numImplThreadScrolls(0)
|
||||
, numMainThreadScrolls(0)
|
||||
{
|
||||
}
|
||||
RenderingStats();
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace cc
|
||||
|
||||
#endif // CC_RENDERING_STATS_H_
|
||||
|
@ -176,6 +176,10 @@ class GpuBenchmarkingWrapper : public v8::Extension {
|
||||
v8::Integer::New(stats.numImplThreadScrolls));
|
||||
stats_object->Set(v8::String::New("numMainThreadScrolls"),
|
||||
v8::Integer::New(stats.numMainThreadScrolls));
|
||||
stats_object->Set(v8::String::New("totalPixelsPainted"),
|
||||
v8::Integer::New(stats.totalPixelsPainted));
|
||||
stats_object->Set(v8::String::New("totalPixelsRasterized"),
|
||||
v8::Integer::New(stats.totalPixelsRasterized));
|
||||
|
||||
stats_object->Set(v8::String::New("globalTextureUploadCount"),
|
||||
v8::Number::New(gpu_stats.global_texture_upload_count));
|
||||
|
@ -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 {
|
||||
|
@ -179,6 +179,8 @@ void WebLayerTreeViewImpl::renderingStats(WebRenderingStats& stats) const
|
||||
stats.totalRasterizeTimeInSeconds = ccStats.totalRasterizeTimeInSeconds;
|
||||
stats.totalCommitTimeInSeconds = ccStats.totalCommitTimeInSeconds;
|
||||
stats.totalCommitCount = ccStats.totalCommitCount;
|
||||
stats.totalPixelsPainted = ccStats.totalPixelsPainted;
|
||||
stats.totalPixelsRasterized = ccStats.totalPixelsRasterized;
|
||||
stats.numImplThreadScrolls = ccStats.numImplThreadScrolls;
|
||||
stats.numMainThreadScrolls = ccStats.numMainThreadScrolls;
|
||||
}
|
||||
|
Reference in New Issue
Block a user