Index: cc/trees/layer_tree_host.cc |
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc |
index 2ec46969f214e11d317dcb599b3eb20323d7c971..b959c038b3d09ddd7e69d704e25f0e4a60ec8393 100644 |
--- a/cc/trees/layer_tree_host.cc |
+++ b/cc/trees/layer_tree_host.cc |
@@ -248,11 +248,10 @@ LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) |
image_serialization_processor_(params->image_serialization_processor), |
surface_client_id_(0u), |
next_surface_sequence_(1u), |
- layer_tree_(std::move(params->animation_host)) { |
+ layer_tree_(base::WrapUnique( |
+ new LayerTree(std::move(params->animation_host), this))) { |
DCHECK(task_graph_runner_); |
- layer_tree_.animation_host()->SetMutatorHostClient(this); |
- |
rendering_stats_instrumentation_->set_record_rendering_stats( |
debug_state_.RecordRenderingStats()); |
} |
@@ -362,14 +361,14 @@ void LayerTreeHost::InitializeProxy( |
proxy_ = std::move(proxy); |
proxy_->Start(std::move(external_begin_frame_source)); |
- layer_tree_.animation_host()->SetSupportsScrollAnimations( |
+ layer_tree_->animation_host()->SetSupportsScrollAnimations( |
proxy_->SupportsImplScrolling()); |
} |
LayerTreeHost::~LayerTreeHost() { |
TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
- layer_tree_.animation_host()->SetMutatorHostClient(nullptr); |
+ layer_tree_->animation_host()->SetMutatorHostClient(nullptr); |
Khushal
2016/08/08 16:55:03
This should be done in the LayerTree dtor. But you
ajuma
2016/08/08 17:56:34
Sounds good.
xingliu
2016/08/09 20:57:04
Done.
|
if (root_layer_.get()) |
root_layer_->SetLayerTreeHost(NULL); |
@@ -547,7 +546,7 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
{ |
TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
- TreeSynchronizer::PushLayerProperties(&layer_tree_, sync_tree); |
+ TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); |
// This must happen after synchronizing property trees and after push |
// properties, which updates property tree indices, but before animation |
@@ -558,7 +557,8 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); |
DCHECK(host_impl->animation_host()); |
- layer_tree_.animation_host()->PushPropertiesTo(host_impl->animation_host()); |
+ layer_tree_->animation_host()->PushPropertiesTo( |
+ host_impl->animation_host()); |
} |
// This must happen after synchronizing property trees and after pushing |
@@ -645,7 +645,8 @@ std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); |
std::unique_ptr<AnimationHost> animation_host_impl = |
- layer_tree_.animation_host()->CreateImplInstance(supports_impl_scrolling); |
+ layer_tree_->animation_host()->CreateImplInstance( |
+ supports_impl_scrolling); |
std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
settings_, client, task_runner_provider_.get(), |
@@ -750,7 +751,7 @@ void LayerTreeHost::SetNextCommitForcesRedraw() { |
void LayerTreeHost::SetAnimationEvents( |
std::unique_ptr<AnimationEvents> events) { |
DCHECK(task_runner_provider_->IsMainThread()); |
- layer_tree_.animation_host()->SetAnimationEvents(std::move(events)); |
+ layer_tree_->animation_host()->SetAnimationEvents(std::move(events)); |
} |
void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { |
@@ -1046,8 +1047,8 @@ bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { |
layer->SavePaintProperties(); |
bool content_is_suitable_for_gpu = true; |
- bool did_paint_content = |
- layer_tree_.UpdateLayers(update_layer_list, &content_is_suitable_for_gpu); |
+ bool did_paint_content = layer_tree_->UpdateLayers( |
+ update_layer_list, &content_is_suitable_for_gpu); |
if (content_is_suitable_for_gpu) { |
++num_consecutive_frames_suitable_for_gpu_; |
@@ -1146,7 +1147,7 @@ void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, |
} |
void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
- AnimationHost* animation_host = layer_tree_.animation_host(); |
+ AnimationHost* animation_host = layer_tree_->animation_host(); |
std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); |
if (animation_host->AnimateLayers(monotonic_time)) |
@@ -1309,146 +1310,7 @@ void LayerTreeHost::SetLayerTreeMutator( |
} |
Layer* LayerTreeHost::LayerById(int id) const { |
- return layer_tree_.LayerById(id); |
-} |
- |
-Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const { |
- ElementLayersMap::const_iterator iter = element_layers_map_.find(element_id); |
- return iter != element_layers_map_.end() ? iter->second : nullptr; |
-} |
- |
-void LayerTreeHost::AddToElementMap(Layer* layer) { |
- if (!layer->element_id()) |
- return; |
- |
- element_layers_map_[layer->element_id()] = layer; |
-} |
- |
-void LayerTreeHost::RemoveFromElementMap(Layer* layer) { |
- if (!layer->element_id()) |
- return; |
- |
- element_layers_map_.erase(layer->element_id()); |
-} |
- |
-bool LayerTreeHost::IsElementInList(ElementId element_id, |
- ElementListType list_type) const { |
- return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); |
-} |
- |
-void LayerTreeHost::SetMutatorsNeedCommit() { |
- SetNeedsCommit(); |
-} |
- |
-void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { |
- property_trees_.needs_rebuild = true; |
-} |
- |
-void LayerTreeHost::SetElementFilterMutated(ElementId element_id, |
- ElementListType list_type, |
- const FilterOperations& filters) { |
- Layer* layer = LayerByElementId(element_id); |
- DCHECK(layer); |
- layer->OnFilterAnimated(filters); |
-} |
- |
-void LayerTreeHost::SetElementOpacityMutated(ElementId element_id, |
- ElementListType list_type, |
- float opacity) { |
- Layer* layer = LayerByElementId(element_id); |
- DCHECK(layer); |
- layer->OnOpacityAnimated(opacity); |
-} |
- |
-void LayerTreeHost::SetElementTransformMutated( |
- ElementId element_id, |
- ElementListType list_type, |
- const gfx::Transform& transform) { |
- Layer* layer = LayerByElementId(element_id); |
- DCHECK(layer); |
- layer->OnTransformAnimated(transform); |
-} |
- |
-void LayerTreeHost::SetElementScrollOffsetMutated( |
- ElementId element_id, |
- ElementListType list_type, |
- const gfx::ScrollOffset& scroll_offset) { |
- Layer* layer = LayerByElementId(element_id); |
- DCHECK(layer); |
- layer->OnScrollOffsetAnimated(scroll_offset); |
-} |
- |
-void LayerTreeHost::ElementTransformIsAnimatingChanged( |
- ElementId element_id, |
- ElementListType list_type, |
- AnimationChangeType change_type, |
- bool is_animating) { |
- Layer* layer = LayerByElementId(element_id); |
- if (layer) { |
- switch (change_type) { |
- case AnimationChangeType::POTENTIAL: |
- layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); |
- break; |
- case AnimationChangeType::RUNNING: |
- layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); |
- break; |
- case AnimationChangeType::BOTH: |
- layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); |
- layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); |
- break; |
- } |
- } |
-} |
- |
-void LayerTreeHost::ElementOpacityIsAnimatingChanged( |
- ElementId element_id, |
- ElementListType list_type, |
- AnimationChangeType change_type, |
- bool is_animating) { |
- Layer* layer = LayerByElementId(element_id); |
- if (layer) { |
- switch (change_type) { |
- case AnimationChangeType::POTENTIAL: |
- layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); |
- break; |
- case AnimationChangeType::RUNNING: |
- layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); |
- break; |
- case AnimationChangeType::BOTH: |
- layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); |
- layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); |
- break; |
- } |
- } |
-} |
- |
-void LayerTreeHost::ElementFilterIsAnimatingChanged( |
- ElementId element_id, |
- ElementListType list_type, |
- AnimationChangeType change_type, |
- bool is_animating) { |
- Layer* layer = LayerByElementId(element_id); |
- if (layer) { |
- switch (change_type) { |
- case AnimationChangeType::POTENTIAL: |
- layer->OnFilterIsPotentiallyAnimatingChanged(is_animating); |
- break; |
- case AnimationChangeType::RUNNING: |
- layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); |
- break; |
- case AnimationChangeType::BOTH: |
- layer->OnFilterIsPotentiallyAnimatingChanged(is_animating); |
- layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); |
- break; |
- } |
- } |
-} |
- |
-gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( |
- ElementId element_id) const { |
- Layer* layer = LayerByElementId(element_id); |
- DCHECK(layer); |
- return layer->ScrollOffsetForAnimation(); |
+ return layer_tree_->LayerById(id); |
Khushal
2016/08/08 16:55:03
Callers can directly go to the LayerTree itself.
xingliu
2016/08/09 20:57:04
Done, also move the iterators and all call sites f
|
} |
bool LayerTreeHost::IsSingleThreaded() const { |
@@ -1512,7 +1374,7 @@ void LayerTreeHost::ToProtobufForCommit( |
// Serialize the LayerTree before serializing the properties. During layer |
// property serialization, we clear the list |layer_that_should_properties_| |
// from the LayerTree. |
- layer_tree_.ToProtobuf(proto->mutable_layer_tree()); |
+ layer_tree_->ToProtobuf(proto->mutable_layer_tree()); |
LayerProtoConverter::SerializeLayerProperties(this, |
proto->mutable_layer_updates()); |
@@ -1590,7 +1452,7 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { |
root_layer_ = new_root_layer; |
} |
- layer_tree_.FromProtobuf(proto.layer_tree()); |
+ layer_tree_->FromProtobuf(proto.layer_tree()); |
// Ensure ClientPictureCache contains all the necessary SkPictures before |
// deserializing the properties. |
@@ -1637,19 +1499,19 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { |
id_ = proto.id(); |
next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
- hud_layer_ = static_cast<HeadsUpDisplayLayer*>( |
- UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), &layer_tree_)); |
- overscroll_elasticity_layer_ = |
- UpdateAndGetLayer(overscroll_elasticity_layer_.get(), |
- proto.overscroll_elasticity_layer_id(), &layer_tree_); |
+ hud_layer_ = static_cast<HeadsUpDisplayLayer*>(UpdateAndGetLayer( |
+ hud_layer_.get(), proto.hud_layer_id(), layer_tree_.get())); |
+ overscroll_elasticity_layer_ = UpdateAndGetLayer( |
+ overscroll_elasticity_layer_.get(), |
+ proto.overscroll_elasticity_layer_id(), layer_tree_.get()); |
page_scale_layer_ = UpdateAndGetLayer( |
- page_scale_layer_.get(), proto.page_scale_layer_id(), &layer_tree_); |
- inner_viewport_scroll_layer_ = |
- UpdateAndGetLayer(inner_viewport_scroll_layer_.get(), |
- proto.inner_viewport_scroll_layer_id(), &layer_tree_); |
- outer_viewport_scroll_layer_ = |
- UpdateAndGetLayer(outer_viewport_scroll_layer_.get(), |
- proto.outer_viewport_scroll_layer_id(), &layer_tree_); |
+ page_scale_layer_.get(), proto.page_scale_layer_id(), layer_tree_.get()); |
+ inner_viewport_scroll_layer_ = UpdateAndGetLayer( |
+ inner_viewport_scroll_layer_.get(), |
+ proto.inner_viewport_scroll_layer_id(), layer_tree_.get()); |
+ outer_viewport_scroll_layer_ = UpdateAndGetLayer( |
+ outer_viewport_scroll_layer_.get(), |
+ proto.outer_viewport_scroll_layer_id(), layer_tree_.get()); |
LayerSelectionFromProtobuf(&selection_, proto.selection()); |
@@ -1672,7 +1534,7 @@ void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { |
} |
AnimationHost* LayerTreeHost::animation_host() const { |
- return layer_tree_.animation_host(); |
+ return layer_tree_->animation_host(); |
Khushal
2016/08/08 16:55:02
While we are at it, may be we can remove the metho
xingliu
2016/08/09 20:57:04
Done, also fix the call sites.
|
} |
} // namespace cc |