OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { | 76 class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { |
77 public: | 77 public: |
78 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( | 78 static scoped_ptr<LayerTreeHostImplTimeSourceAdapter> Create( |
79 LayerTreeHostImpl* layer_tree_host_impl, | 79 LayerTreeHostImpl* layer_tree_host_impl, |
80 scoped_refptr<DelayBasedTimeSource> time_source) { | 80 scoped_refptr<DelayBasedTimeSource> time_source) { |
81 return make_scoped_ptr( | 81 return make_scoped_ptr( |
82 new LayerTreeHostImplTimeSourceAdapter(layer_tree_host_impl, | 82 new LayerTreeHostImplTimeSourceAdapter(layer_tree_host_impl, |
83 time_source)); | 83 time_source)); |
84 } | 84 } |
85 virtual ~LayerTreeHostImplTimeSourceAdapter() { | 85 virtual ~LayerTreeHostImplTimeSourceAdapter() { |
86 time_source_->setClient(NULL); | 86 time_source_->SetClient(NULL); |
87 time_source_->setActive(false); | 87 time_source_->SetActive(false); |
88 } | 88 } |
89 | 89 |
90 virtual void onTimerTick() OVERRIDE { | 90 virtual void OnTimerTick() OVERRIDE { |
91 // In single threaded mode we attempt to simulate changing the current | 91 // In single threaded mode we attempt to simulate changing the current |
92 // thread by maintaining a fake thread id. When we switch from one | 92 // thread by maintaining a fake thread id. When we switch from one |
93 // thread to another, we construct DebugScopedSetXXXThread objects that | 93 // thread to another, we construct DebugScopedSetXXXThread objects that |
94 // update the thread id. This lets DCHECKS that ensure we're on the | 94 // update the thread id. This lets DCHECKS that ensure we're on the |
95 // right thread to work correctly in single threaded mode. The problem | 95 // right thread to work correctly in single threaded mode. The problem |
96 // here is that the timer tasks are run via the message loop, and when | 96 // here is that the timer tasks are run via the message loop, and when |
97 // they run, we've had no chance to construct a DebugScopedSetXXXThread | 97 // they run, we've had no chance to construct a DebugScopedSetXXXThread |
98 // object. The result is that we report that we're running on the main | 98 // object. The result is that we report that we're running on the main |
99 // thread. In multi-threaded mode, this timer is run on the compositor | 99 // thread. In multi-threaded mode, this timer is run on the compositor |
100 // thread, so to keep this consistent in single-threaded mode, we'll | 100 // thread, so to keep this consistent in single-threaded mode, we'll |
101 // construct a DebugScopedSetImplThread object. There is no need to do | 101 // construct a DebugScopedSetImplThread object. There is no need to do |
102 // this in multi-threaded mode since the real thread id's will be | 102 // this in multi-threaded mode since the real thread id's will be |
103 // correct. In fact, setting fake thread id's interferes with the real | 103 // correct. In fact, setting fake thread id's interferes with the real |
104 // thread id's and causes breakage. | 104 // thread id's and causes breakage. |
105 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; | 105 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; |
106 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { | 106 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { |
107 set_impl_thread.reset( | 107 set_impl_thread.reset( |
108 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); | 108 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); |
109 } | 109 } |
110 | 110 |
111 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); | 111 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); |
112 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now()); | 112 layer_tree_host_impl_->Animate(base::TimeTicks::Now(), base::Time::Now()); |
113 layer_tree_host_impl_->BeginNextFrame(); | 113 layer_tree_host_impl_->BeginNextFrame(); |
114 } | 114 } |
115 | 115 |
116 void SetActive(bool active) { | 116 void SetActive(bool active) { |
117 if (active != time_source_->active()) | 117 if (active != time_source_->Active()) |
118 time_source_->setActive(active); | 118 time_source_->SetActive(active); |
119 } | 119 } |
120 | 120 |
121 private: | 121 private: |
122 LayerTreeHostImplTimeSourceAdapter( | 122 LayerTreeHostImplTimeSourceAdapter( |
123 LayerTreeHostImpl* layer_tree_host_impl, | 123 LayerTreeHostImpl* layer_tree_host_impl, |
124 scoped_refptr<DelayBasedTimeSource> time_source) | 124 scoped_refptr<DelayBasedTimeSource> time_source) |
125 : layer_tree_host_impl_(layer_tree_host_impl), | 125 : layer_tree_host_impl_(layer_tree_host_impl), |
126 time_source_(time_source) { | 126 time_source_(time_source) { |
127 time_source_->setClient(this); | 127 time_source_->SetClient(this); |
128 } | 128 } |
129 | 129 |
130 LayerTreeHostImpl* layer_tree_host_impl_; | 130 LayerTreeHostImpl* layer_tree_host_impl_; |
131 scoped_refptr<DelayBasedTimeSource> time_source_; | 131 scoped_refptr<DelayBasedTimeSource> time_source_; |
132 | 132 |
133 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImplTimeSourceAdapter); | 133 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImplTimeSourceAdapter); |
134 }; | 134 }; |
135 | 135 |
136 LayerTreeHostImpl::FrameData::FrameData() | 136 LayerTreeHostImpl::FrameData::FrameData() |
137 : contains_incomplete_tile(false) {} | 137 : contains_incomplete_tile(false) {} |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 | 657 |
658 return draw_frame; | 658 return draw_frame; |
659 } | 659 } |
660 | 660 |
661 void LayerTreeHostImpl::SetBackgroundTickingEnabled(bool enabled) { | 661 void LayerTreeHostImpl::SetBackgroundTickingEnabled(bool enabled) { |
662 // Lazily create the time_source adapter so that we can vary the interval for | 662 // Lazily create the time_source adapter so that we can vary the interval for |
663 // testing. | 663 // testing. |
664 if (!time_source_client_adapter_) { | 664 if (!time_source_client_adapter_) { |
665 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( | 665 time_source_client_adapter_ = LayerTreeHostImplTimeSourceAdapter::Create( |
666 this, | 666 this, |
667 DelayBasedTimeSource::create(LowFrequencyAnimationInterval(), | 667 DelayBasedTimeSource::Create(LowFrequencyAnimationInterval(), |
668 proxy_->CurrentThread())); | 668 proxy_->CurrentThread())); |
669 } | 669 } |
670 | 670 |
671 time_source_client_adapter_->SetActive(enabled); | 671 time_source_client_adapter_->SetActive(enabled); |
672 } | 672 } |
673 | 673 |
674 static inline RenderPass* FindRenderPassById( | 674 static inline RenderPass* FindRenderPassById( |
675 RenderPass::Id render_pass_id, | 675 RenderPass::Id render_pass_id, |
676 const LayerTreeHostImpl::FrameData& frame) { | 676 const LayerTreeHostImpl::FrameData& frame) { |
677 RenderPassIdHashMap::const_iterator it = | 677 RenderPassIdHashMap::const_iterator it = |
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 tile_manager_->SetRecordRenderingStats(debug_state_.RecordRenderingStats()); | 1967 tile_manager_->SetRecordRenderingStats(debug_state_.RecordRenderingStats()); |
1968 } | 1968 } |
1969 | 1969 |
1970 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, | 1970 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, |
1971 int commit_number) { | 1971 int commit_number) { |
1972 DCHECK(debug_state_.continuous_painting); | 1972 DCHECK(debug_state_.continuous_painting); |
1973 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); | 1973 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); |
1974 } | 1974 } |
1975 | 1975 |
1976 } // namespace cc | 1976 } // namespace cc |
OLD | NEW |