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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 // this in multi-threaded mode since the real thread id's will be | 154 // this in multi-threaded mode since the real thread id's will be |
155 // correct. In fact, setting fake thread id's interferes with the real | 155 // correct. In fact, setting fake thread id's interferes with the real |
156 // thread id's and causes breakage. | 156 // thread id's and causes breakage. |
157 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; | 157 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; |
158 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { | 158 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { |
159 set_impl_thread.reset( | 159 set_impl_thread.reset( |
160 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); | 160 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); |
161 } | 161 } |
162 | 162 |
163 layer_tree_host_impl_->Animate( | 163 layer_tree_host_impl_->Animate( |
164 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 164 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); |
165 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); | 165 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); |
166 bool start_ready_animations = true; | 166 bool start_ready_animations = true; |
167 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 167 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
168 | 168 |
169 if (layer_tree_host_impl_->pending_tree()) { | 169 if (layer_tree_host_impl_->pending_tree()) { |
170 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); | 170 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); |
171 layer_tree_host_impl_->ManageTiles(); | 171 layer_tree_host_impl_->ManageTiles(); |
172 } | 172 } |
173 | 173 |
174 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 174 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
175 } | 175 } |
176 | 176 |
177 void SetActive(bool active) { | 177 void SetActive(bool active) { |
178 if (active != time_source_->Active()) | 178 if (active != time_source_->Active()) |
179 time_source_->SetActive(active); | 179 time_source_->SetActive(active); |
180 } | 180 } |
181 | 181 |
182 bool Active() const { return time_source_->Active(); } | 182 bool Active() const { return time_source_->Active(); } |
183 | 183 |
184 private: | 184 private: |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1665 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { | 1665 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { |
1666 if (output_surface_) | 1666 if (output_surface_) |
1667 output_surface_->SetNeedsBeginFrame(enable); | 1667 output_surface_->SetNeedsBeginFrame(enable); |
1668 else | 1668 else |
1669 DCHECK(!enable); | 1669 DCHECK(!enable); |
1670 } | 1670 } |
1671 | 1671 |
1672 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { | 1672 void LayerTreeHostImpl::WillBeginImplFrame(const BeginFrameArgs& args) { |
1673 // Sample the frame time now. This time will be used for updating animations | 1673 // Sample the frame time now. This time will be used for updating animations |
1674 // when we draw. | 1674 // when we draw. |
1675 UpdateCurrentFrameTime(); | 1675 UpdateCurrentBeginFrameArgs(args); |
1676 // Cache the begin impl frame interval | 1676 // Cache the begin impl frame interval |
1677 begin_impl_frame_interval_ = args.interval; | 1677 begin_impl_frame_interval_ = args.interval; |
1678 } | 1678 } |
1679 | 1679 |
1680 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { | 1680 gfx::SizeF LayerTreeHostImpl::ComputeInnerViewportContainerSize() const { |
1681 gfx::SizeF dip_size = | 1681 gfx::SizeF dip_size = |
1682 gfx::ScaleSize(device_viewport_size_, 1.f / device_scale_factor()); | 1682 gfx::ScaleSize(device_viewport_size_, 1.f / device_scale_factor()); |
1683 | 1683 |
1684 float top_offset = | 1684 float top_offset = |
1685 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; | 1685 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2384 if (!animation) | 2384 if (!animation) |
2385 return ScrollIgnored; | 2385 return ScrollIgnored; |
2386 | 2386 |
2387 ScrollOffsetAnimationCurve* curve = | 2387 ScrollOffsetAnimationCurve* curve = |
2388 animation->curve()->ToScrollOffsetAnimationCurve(); | 2388 animation->curve()->ToScrollOffsetAnimationCurve(); |
2389 | 2389 |
2390 gfx::Vector2dF new_target = curve->target_value() + scroll_delta; | 2390 gfx::Vector2dF new_target = curve->target_value() + scroll_delta; |
2391 new_target.SetToMax(gfx::Vector2dF()); | 2391 new_target.SetToMax(gfx::Vector2dF()); |
2392 new_target.SetToMin(layer_impl->MaxScrollOffset()); | 2392 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
2393 | 2393 |
2394 curve->UpdateTarget( | 2394 curve->UpdateTarget(animation->TrimTimeToCurrentIteration( |
2395 animation->TrimTimeToCurrentIteration(CurrentFrameTimeTicks()), | 2395 CurrentBeginFrameArgs().frame_time), |
2396 new_target); | 2396 new_target); |
2397 | 2397 |
2398 return ScrollStarted; | 2398 return ScrollStarted; |
2399 } | 2399 } |
2400 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling | 2400 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling |
2401 // behavior as ScrollBy to determine which layer to animate, but we do not | 2401 // behavior as ScrollBy to determine which layer to animate, but we do not |
2402 // do the Android-specific things in ScrollBy like showing top controls. | 2402 // do the Android-specific things in ScrollBy like showing top controls. |
2403 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel); | 2403 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel); |
2404 if (scroll_status == ScrollStarted) { | 2404 if (scroll_status == ScrollStarted) { |
2405 gfx::Vector2dF pending_delta = scroll_delta; | 2405 gfx::Vector2dF pending_delta = scroll_delta; |
2406 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; | 2406 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3145 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { | 3145 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { |
3146 if (!tile_manager_) | 3146 if (!tile_manager_) |
3147 return; | 3147 return; |
3148 | 3148 |
3149 if (global_tile_state_.tree_priority == priority) | 3149 if (global_tile_state_.tree_priority == priority) |
3150 return; | 3150 return; |
3151 global_tile_state_.tree_priority = priority; | 3151 global_tile_state_.tree_priority = priority; |
3152 DidModifyTilePriorities(); | 3152 DidModifyTilePriorities(); |
3153 } | 3153 } |
3154 | 3154 |
3155 void LayerTreeHostImpl::UpdateCurrentFrameTime() { | 3155 void LayerTreeHostImpl::UpdateCurrentBeginFrameArgs( |
3156 DCHECK(current_frame_timeticks_.is_null()); | 3156 const BeginFrameArgs& args) { |
3157 current_frame_timeticks_ = gfx::FrameTime::Now(); | 3157 DCHECK(!current_begin_frame_args_.IsValid()); |
3158 current_begin_frame_args_ = args; | |
3159 current_begin_frame_args_.frame_time = gfx::FrameTime::Now(); | |
brianderson
2014/08/16 00:11:51
I'd say just add a TODO, so it's clear that we int
Sami
2014/08/18 10:48:16
Good idea, done.
| |
3158 } | 3160 } |
3159 | 3161 |
3160 void LayerTreeHostImpl::ResetCurrentFrameTimeForNextFrame() { | 3162 void LayerTreeHostImpl::ResetCurrentBeginFrameArgsForNextFrame() { |
3161 current_frame_timeticks_ = base::TimeTicks(); | 3163 current_begin_frame_args_ = BeginFrameArgs(); |
3162 } | 3164 } |
3163 | 3165 |
3164 base::TimeTicks LayerTreeHostImpl::CurrentFrameTimeTicks() { | 3166 BeginFrameArgs LayerTreeHostImpl::CurrentBeginFrameArgs() const { |
3165 // Try to use the current frame time to keep animations non-jittery. But if | 3167 // Try to use the current frame time to keep animations non-jittery. But if |
3166 // we're not in a frame (because this is during an input event or a delayed | 3168 // we're not in a frame (because this is during an input event or a delayed |
3167 // task), fall back to physical time. This should still be monotonic. | 3169 // task), fall back to physical time. This should still be monotonic. |
3168 if (!current_frame_timeticks_.is_null()) | 3170 if (current_begin_frame_args_.IsValid()) |
3169 return current_frame_timeticks_; | 3171 return current_begin_frame_args_; |
3170 return gfx::FrameTime::Now(); | 3172 return BeginFrameArgs::Create(gfx::FrameTime::Now(), |
3173 base::TimeTicks(), | |
3174 BeginFrameArgs::DefaultInterval()); | |
3171 } | 3175 } |
3172 | 3176 |
3173 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3177 scoped_refptr<base::debug::ConvertableToTraceFormat> |
3174 LayerTreeHostImpl::AsValue() const { | 3178 LayerTreeHostImpl::AsValue() const { |
3175 return AsValueWithFrame(NULL); | 3179 return AsValueWithFrame(NULL); |
3176 } | 3180 } |
3177 | 3181 |
3178 scoped_refptr<base::debug::ConvertableToTraceFormat> | 3182 scoped_refptr<base::debug::ConvertableToTraceFormat> |
3179 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { | 3183 LayerTreeHostImpl::AsValueWithFrame(FrameData* frame) const { |
3180 scoped_refptr<base::debug::TracedValue> state = | 3184 scoped_refptr<base::debug::TracedValue> state = |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3369 } | 3373 } |
3370 | 3374 |
3371 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3375 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3372 std::vector<PictureLayerImpl*>::iterator it = | 3376 std::vector<PictureLayerImpl*>::iterator it = |
3373 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3377 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3374 DCHECK(it != picture_layers_.end()); | 3378 DCHECK(it != picture_layers_.end()); |
3375 picture_layers_.erase(it); | 3379 picture_layers_.erase(it); |
3376 } | 3380 } |
3377 | 3381 |
3378 } // namespace cc | 3382 } // namespace cc |
OLD | NEW |