Chromium Code Reviews| Index: cc/layer_tree_host.cc |
| diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc |
| index cccc83a0b7e6cb005f76898af75bd3fe9f5d0878..8ea40ca7a343746602e44a23be184b18f191249b 100644 |
| --- a/cc/layer_tree_host.cc |
| +++ b/cc/layer_tree_host.cc |
| @@ -24,6 +24,7 @@ |
| #include "cc/occlusion_tracker.h" |
| #include "cc/overdraw_metrics.h" |
| #include "cc/prioritized_resource_manager.h" |
| +#include "cc/rendering_stats_instrumentation.h" |
| #include "cc/single_thread_proxy.h" |
| #include "cc/switches.h" |
| #include "cc/thread.h" |
| @@ -74,7 +75,7 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, |
| needs_filter_context_(false), |
| client_(client), |
| commit_number_(0), |
| - rendering_stats_(), |
| + rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
| renderer_initialized_(false), |
| output_surface_lost_(false), |
| num_failed_recreate_attempts_(0), |
| @@ -92,6 +93,9 @@ LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, |
| if (settings_.acceleratedAnimationEnabled) |
| animation_registrar_ = AnimationRegistrar::create(); |
| s_num_layer_tree_instances++; |
| + |
| + rendering_stats_instrumentation_->set_record_rendering_stats( |
| + debug_state_.recordRenderingStats()); |
| } |
| bool LayerTreeHost::Initialize(scoped_ptr<Thread> impl_thread) { |
| @@ -227,7 +231,7 @@ void LayerTreeHost::UpdateAnimations(base::TimeTicks frame_begin_time) { |
| AnimateLayers(frame_begin_time); |
| animating_ = false; |
| - rendering_stats_.numAnimationFrames++; |
| + rendering_stats_instrumentation_->IncrementAnimationFrameCount(); |
| } |
| void LayerTreeHost::DidStopFlinging() { |
| @@ -334,8 +338,11 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
| sync_tree->DidBecomeActive(); |
| } |
| - if (debug_state_.continuousPainting) |
| - host_impl->SavePaintTime(rendering_stats_.totalPaintTime, commit_number()); |
| + if (debug_state_.continuousPainting) { |
| + host_impl->SavePaintTime( |
| + rendering_stats_instrumentation_->GetRenderingStats().totalPaintTime, |
| + commit_number()); |
| + } |
| commit_number_++; |
| } |
| @@ -373,7 +380,10 @@ scoped_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
| LayerTreeHostImplClient* client) { |
| DCHECK(proxy_->IsImplThread()); |
| scoped_ptr<LayerTreeHostImpl> host_impl = |
| - LayerTreeHostImpl::Create(settings_, client, proxy_.get()); |
| + LayerTreeHostImpl::Create(settings_, |
| + client, |
| + proxy_.get(), |
| + rendering_stats_instrumentation_.get()); |
| if (settings_.calculateTopControlsPosition && |
| host_impl->top_controls_manager()) { |
| top_controls_manager_weak_ptr_ = |
| @@ -412,8 +422,7 @@ void LayerTreeHost::DidDeferCommit() {} |
| void LayerTreeHost::CollectRenderingStats(RenderingStats* stats) const { |
| CHECK(debug_state_.recordRenderingStats()); |
| - *stats = rendering_stats_; |
| - proxy_->CollectRenderingStats(stats); |
| + *stats = rendering_stats_instrumentation_->GetRenderingStats(); |
| } |
| const RendererCapabilities& LayerTreeHost::GetRendererCapabilities() const { |
| @@ -482,6 +491,9 @@ void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { |
| debug_state_ = new_debug_state; |
| SetNeedsCommit(); |
| + |
| + rendering_stats_instrumentation_->set_record_rendering_stats( |
|
danakj
2013/03/15 17:28:48
The general pattern is to change states, then call
egraether
2013/03/15 21:14:26
Done.
|
| + debug_state_.recordRenderingStats()); |
| } |
| void LayerTreeHost::SetViewportSize(gfx::Size layout_viewport_size, |
| @@ -714,15 +726,13 @@ size_t LayerTreeHost::CalculateMemoryForRenderSurfaces( |
| } |
| bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer, |
| - ResourceUpdateQueue* queue) { |
| + ResourceUpdateQueue* queue, |
| + RenderingStats* stats) { |
| // Note: Masks and replicas only exist for layers that own render surfaces. If |
| // we reach this point in code, we already know that at least something will |
| // be drawn into this render surface, so the mask and replica should be |
| // painted. |
| - RenderingStats* stats = |
| - debug_state_.recordRenderingStats() ? &rendering_stats_ : NULL; |
| - |
| bool need_more_updates = false; |
| Layer* mask_layer = render_surface_layer->mask_layer(); |
| if (mask_layer) { |
| @@ -762,8 +772,10 @@ bool LayerTreeHost::PaintLayerContents( |
| PrioritizeTextures(render_surface_layer_list, |
| occlusion_tracker.overdraw_metrics()); |
| - RenderingStats* stats = debug_state_.recordRenderingStats() ? |
| - &rendering_stats_ : NULL; |
| + // TODO(egraether): Use RenderingStatsInstrumentation in Layer::update() |
| + RenderingStats stats; |
| + RenderingStats* stats_ptr = |
| + debug_state_.recordRenderingStats() ? &stats : NULL; |
| LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list); |
| for (LayerIteratorType it = |
| @@ -775,16 +787,18 @@ bool LayerTreeHost::PaintLayerContents( |
| if (it.representsTargetRenderSurface()) { |
| DCHECK(it->render_surface()->draw_opacity() || |
| it->render_surface()->draw_opacity_is_animating()); |
| - need_more_updates |= PaintMasksForRenderSurface(*it, queue); |
| + need_more_updates |= PaintMasksForRenderSurface(*it, queue, stats_ptr); |
| } else if (it.representsItself()) { |
| DCHECK(!it->bounds().IsEmpty()); |
| - it->Update(queue, &occlusion_tracker, stats); |
| + it->Update(queue, &occlusion_tracker, stats_ptr); |
| need_more_updates |= it->NeedMoreUpdates(); |
| } |
| occlusion_tracker.LeaveLayer(it); |
| } |
| + rendering_stats_instrumentation_->AddStats(stats); |
| + |
| occlusion_tracker.overdraw_metrics()->RecordMetrics(this); |
| return need_more_updates; |