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

Unified Diff: cc/resources/tile_manager.cc

Issue 12519006: cc:: Add RenderingStatsInstrumentation to manage collection of RenderingStats (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to LayerTreeTest Created 7 years, 9 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
Index: cc/resources/tile_manager.cc
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc
index 61e112b9193bbedd619130aa5949691a0485aac9..6fa8f910d95310a37d63dd18f25d73295894b961 100644
--- a/cc/resources/tile_manager.cc
+++ b/cc/resources/tile_manager.cc
@@ -152,7 +152,8 @@ TileManager::TileManager(
size_t num_raster_threads,
bool use_cheapness_estimator,
bool use_color_estimator,
- bool prediction_benchmarking)
+ bool prediction_benchmarking,
+ RenderingStatsInstrumentation* rendering_stats_instrumentation)
: client_(client),
resource_pool_(ResourcePool::Create(resource_provider)),
raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)),
@@ -161,12 +162,12 @@ TileManager::TileManager(
bytes_pending_upload_(0),
has_performed_uploads_since_last_flush_(false),
ever_exceeded_memory_budget_(false),
- record_rendering_stats_(false),
use_cheapness_estimator_(use_cheapness_estimator),
use_color_estimator_(use_color_estimator),
prediction_benchmarking_(prediction_benchmarking),
pending_tasks_(0),
- max_pending_tasks_(kMaxNumPendingTasksPerThread * num_raster_threads) {
+ max_pending_tasks_(kMaxNumPendingTasksPerThread * num_raster_threads),
+ rendering_stats_instrumentation_(rendering_stats_instrumentation) {
for (int i = 0; i < NUM_STATES; ++i) {
for (int j = 0; j < NUM_TREES; ++j) {
for (int k = 0; k < NUM_BINS; ++k)
@@ -494,24 +495,6 @@ scoped_ptr<base::Value> TileManager::GetMemoryRequirementsAsValue() const {
return requirements.PassAs<base::Value>();
}
-void TileManager::SetRecordRenderingStats(bool record_rendering_stats) {
- if (record_rendering_stats_ == record_rendering_stats)
- return;
-
- record_rendering_stats_ = record_rendering_stats;
- raster_worker_pool_->SetRecordRenderingStats(record_rendering_stats);
-}
-
-void TileManager::GetRenderingStats(RenderingStats* stats) {
- CHECK(record_rendering_stats_);
- raster_worker_pool_->GetRenderingStats(stats);
- stats->totalDeferredImageCacheHitCount =
- rendering_stats_.totalDeferredImageCacheHitCount;
- stats->totalImageGatheringCount = rendering_stats_.totalImageGatheringCount;
- stats->totalImageGatheringTime =
- rendering_stats_.totalImageGatheringTime;
-}
-
bool TileManager::HasPendingWorkScheduled(WhichTree tree) const {
// Always true when ManageTiles() call is pending.
if (manage_tiles_pending_)
@@ -738,19 +721,16 @@ void TileManager::GatherPixelRefsForTile(Tile* tile) {
TRACE_EVENT0("cc", "TileManager::GatherPixelRefsForTile");
ManagedTileState& managed_tile_state = tile->managed_state();
if (managed_tile_state.need_to_gather_pixel_refs) {
- base::TimeTicks gather_begin_time;
- if (record_rendering_stats_)
- gather_begin_time = base::TimeTicks::HighResNow();
+ base::TimeTicks start_time =
+ rendering_stats_instrumentation_->StartRecording();
tile->picture_pile()->GatherPixelRefs(
tile->content_rect_,
tile->contents_scale_,
managed_tile_state.pending_pixel_refs);
managed_tile_state.need_to_gather_pixel_refs = false;
- if (record_rendering_stats_) {
- rendering_stats_.totalImageGatheringCount++;
- rendering_stats_.totalImageGatheringTime +=
- base::TimeTicks::HighResNow() - gather_begin_time;
- }
+ base::TimeDelta duration =
+ rendering_stats_instrumentation_->EndRecording(start_time);
+ rendering_stats_instrumentation_->AddImageGathering(duration);
}
}
@@ -767,7 +747,7 @@ void TileManager::DispatchImageDecodeTasksForTile(Tile* tile) {
}
// TODO(qinmin): passing correct image size to PrepareToDecode().
if ((*it)->PrepareToDecode(skia::LazyPixelRef::PrepareParams())) {
- rendering_stats_.totalDeferredImageCacheHitCount++;
+ rendering_stats_instrumentation_->IncrementDeferredImageCacheHitCount();
pending_pixel_refs.erase(it++);
} else {
if (pending_tasks_ >= max_pending_tasks_)
@@ -787,7 +767,9 @@ void TileManager::DispatchOneImageDecodeTask(
pending_decode_tasks_[pixel_ref_id] = pixel_ref;
raster_worker_pool_->PostTaskAndReply(
- base::Bind(&TileManager::RunImageDecodeTask, pixel_ref),
+ base::Bind(&TileManager::RunImageDecodeTask,
+ pixel_ref,
+ rendering_stats_instrumentation_),
base::Bind(&TileManager::OnImageDecodeTaskCompleted,
base::Unretained(this),
tile,
@@ -862,7 +844,8 @@ void TileManager::DispatchOneRasterTask(scoped_refptr<Tile> tile) {
buffer,
tile->content_rect(),
tile->contents_scale(),
- GetRasterTaskMetadata(*tile)),
+ GetRasterTaskMetadata(*tile),
+ rendering_stats_instrumentation_),
base::Bind(&TileManager::OnRasterTaskCompleted,
base::Unretained(this),
tile,
@@ -972,12 +955,13 @@ void TileManager::DidTileTreeBinChange(Tile* tile,
}
// static
-void TileManager::RunRasterTask(uint8* buffer,
- const gfx::Rect& rect,
- float contents_scale,
- const RasterTaskMetadata& metadata,
- PicturePileImpl* picture_pile,
- RenderingStats* stats) {
+void TileManager::RunRasterTask(
+ uint8* buffer,
+ const gfx::Rect& rect,
+ float contents_scale,
+ const RasterTaskMetadata& metadata,
+ RenderingStatsInstrumentation* stats_instrumentation,
+ PicturePileImpl* picture_pile) {
TRACE_EVENT2(
"cc", "TileManager::RunRasterTask",
"is_on_pending_tree",
@@ -995,22 +979,18 @@ void TileManager::RunRasterTask(uint8* buffer,
SkDevice device(bitmap);
SkCanvas canvas(&device);
- base::TimeTicks begin_time;
- if (stats)
- begin_time = base::TimeTicks::HighResNow();
+ base::TimeTicks start_time = stats_instrumentation->StartRecording();
int64 total_pixels_rasterized = 0;
picture_pile->Raster(&canvas, rect, contents_scale,
&total_pixels_rasterized);
- if (stats) {
- stats->totalPixelsRasterized += total_pixels_rasterized;
+ base::TimeDelta duration = stats_instrumentation->EndRecording(start_time);
- base::TimeTicks end_time = base::TimeTicks::HighResNow();
- base::TimeDelta duration = end_time - begin_time;
- stats->totalRasterizeTime += duration;
- if (metadata.is_tile_in_pending_tree_now_bin)
- stats->totalRasterizeTimeForNowBinsOnPendingTree += duration;
+ if (stats_instrumentation->record_rendering_stats()) {
+ stats_instrumentation->AddRaster(duration,
+ total_pixels_rasterized,
+ metadata.is_tile_in_pending_tree_now_bin);
UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.PictureRasterTimeMS",
duration.InMilliseconds(),
@@ -1103,18 +1083,14 @@ void TileManager::RecordSolidColorPredictorResults(
}
// static
-void TileManager::RunImageDecodeTask(skia::LazyPixelRef* pixel_ref,
- RenderingStats* stats) {
+void TileManager::RunImageDecodeTask(
+ skia::LazyPixelRef* pixel_ref,
+ RenderingStatsInstrumentation* stats_instrumentation) {
TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask");
- base::TimeTicks decode_begin_time;
- if (stats)
- decode_begin_time = base::TimeTicks::HighResNow();
+ base::TimeTicks start_time = stats_instrumentation->StartRecording();
pixel_ref->Decode();
- if (stats) {
- stats->totalDeferredImageDecodeCount++;
- stats->totalDeferredImageDecodeTime +=
- base::TimeTicks::HighResNow() - decode_begin_time;
- }
+ base::TimeDelta duration = stats_instrumentation->EndRecording(start_time);
+ stats_instrumentation->AddDeferredImageDecode(duration);
}
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698