summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorjaydasika <jaydasika@chromium.org>2016-03-22 18:56:09 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-23 01:57:37 +0000
commit2411692cd8bd39dc354fe8fef2a0a948a3df19fd (patch)
tree6d6381e217bfae5d51b5f3e57eea6da51736f7b3 /cc
parent6f41abb4a42710b75ec828527c68eb71b8385593 (diff)
downloadchromium_src-2411692cd8bd39dc354fe8fef2a0a948a3df19fd.zip
chromium_src-2411692cd8bd39dc354fe8fef2a0a948a3df19fd.tar.gz
chromium_src-2411692cd8bd39dc354fe8fef2a0a948a3df19fd.tar.bz2
cc : Update render surfaces using LayerListIterator instead of treewalk
This is the update render surfaces treewalk in draw_property_utils.cc BUG=594024 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1823833002 Cr-Commit-Position: refs/heads/master@{#382767}
Diffstat (limited to 'cc')
-rw-r--r--cc/test/layer_test_common.cc12
-rw-r--r--cc/test/layer_test_common.h20
-rw-r--r--cc/test/layer_tree_host_common_test.cc8
-rw-r--r--cc/trees/damage_tracker_unittest.cc14
-rw-r--r--cc/trees/draw_property_utils.cc46
-rw-r--r--cc/trees/layer_tree_host_common_unittest.cc255
-rw-r--r--cc/trees/layer_tree_impl_unittest.cc33
-rw-r--r--cc/trees/occlusion_tracker_unittest.cc8
8 files changed, 230 insertions, 166 deletions
diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc
index 2979d5e..0e3020e 100644
--- a/cc/test/layer_test_common.cc
+++ b/cc/test/layer_test_common.cc
@@ -123,10 +123,12 @@ LayerTestCommon::LayerImplTest::LayerImplTest(const LayerTreeSettings& settings)
: client_(FakeLayerTreeHostClient::DIRECT_3D),
output_surface_(FakeOutputSurface::Create3d()),
host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_, settings)),
- root_layer_impl_(LayerImpl::Create(host_->host_impl()->active_tree(), 1)),
render_pass_(RenderPass::Create()),
layer_impl_id_(2) {
- root_layer_impl_->SetHasRenderSurface(true);
+ scoped_ptr<LayerImpl> root_layer_impl =
+ LayerImpl::Create(host_->host_impl()->active_tree(), 1);
+ root_layer_impl->SetHasRenderSurface(true);
+ host_->host_impl()->active_tree()->SetRootLayer(std::move(root_layer_impl));
host_->host_impl()->SetVisible(true);
host_->host_impl()->InitializeRenderer(output_surface_.get());
@@ -150,7 +152,8 @@ void LayerTestCommon::LayerImplTest::CalcDrawProps(
LayerImplList layer_list;
host_->host_impl()->active_tree()->IncrementRenderSurfaceListIdForTesting();
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root_layer_impl_.get(), viewport_size, &layer_list,
+ host_->host_impl()->active_tree()->root_layer(), viewport_size,
+ &layer_list,
host_->host_impl()->active_tree()->current_render_surface_list_id());
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
}
@@ -211,7 +214,8 @@ void LayerTestCommon::LayerImplTest::RequestCopyOfOutput() {
std::vector<scoped_ptr<CopyOutputRequest>> copy_requests;
copy_requests.push_back(
CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
- root_layer_impl_->PassCopyRequests(&copy_requests);
+ host_->host_impl()->active_tree()->root_layer()->PassCopyRequests(
+ &copy_requests);
}
} // namespace cc
diff --git a/cc/test/layer_test_common.h b/cc/test/layer_test_common.h
index af93e73..a1904b9 100644
--- a/cc/test/layer_test_common.h
+++ b/cc/test/layer_test_common.h
@@ -61,7 +61,8 @@ class LayerTestCommon {
scoped_ptr<T> layer =
T::Create(host_->host_impl()->active_tree(), layer_impl_id_++);
T* ptr = layer.get();
- root_layer_impl_->AddChild(std::move(layer));
+ LayerImpl* root_layer_impl = host_->active_tree()->root_layer();
+ root_layer_impl->AddChild(std::move(layer));
return ptr;
}
@@ -88,7 +89,8 @@ class LayerTestCommon {
scoped_ptr<T> layer =
T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a);
T* ptr = layer.get();
- root_layer_impl_->AddChild(std::move(layer));
+ LayerImpl* root_layer_impl = host_->active_tree()->root_layer();
+ root_layer_impl->AddChild(std::move(layer));
return ptr;
}
@@ -97,7 +99,8 @@ class LayerTestCommon {
scoped_ptr<T> layer =
T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a, b);
T* ptr = layer.get();
- root_layer_impl_->AddChild(std::move(layer));
+ LayerImpl* root_layer_impl = host_->active_tree()->root_layer();
+ root_layer_impl->AddChild(std::move(layer));
return ptr;
}
@@ -106,7 +109,8 @@ class LayerTestCommon {
scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(),
layer_impl_id_++, a, b, c, d);
T* ptr = layer.get();
- root_layer_impl_->AddChild(std::move(layer));
+ LayerImpl* root_layer_impl = host_->active_tree()->root_layer();
+ root_layer_impl->AddChild(std::move(layer));
return ptr;
}
@@ -124,7 +128,8 @@ class LayerTestCommon {
scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(),
layer_impl_id_++, a, b, c, d, e);
T* ptr = layer.get();
- root_layer_impl_->AddChild(std::move(layer));
+ LayerImpl* root_layer_impl = host_->active_tree()->root_layer();
+ root_layer_impl->AddChild(std::move(layer));
return ptr;
}
@@ -149,7 +154,9 @@ class LayerTestCommon {
ResourceProvider* resource_provider() const {
return host_->host_impl()->resource_provider();
}
- LayerImpl* root_layer() const { return root_layer_impl_.get(); }
+ LayerImpl* root_layer() const {
+ return host_->host_impl()->active_tree()->root_layer();
+ }
FakeLayerTreeHost* host() { return host_.get(); }
FakeLayerTreeHostImpl* host_impl() const { return host_->host_impl(); }
TaskRunnerProvider* task_runner_provider() const {
@@ -164,7 +171,6 @@ class LayerTestCommon {
TestTaskGraphRunner task_graph_runner_;
scoped_ptr<OutputSurface> output_surface_;
scoped_ptr<FakeLayerTreeHost> host_;
- scoped_ptr<LayerImpl> root_layer_impl_;
scoped_ptr<RenderPass> render_pass_;
scoped_refptr<AnimationTimeline> timeline_;
scoped_refptr<AnimationTimeline> timeline_impl_;
diff --git a/cc/test/layer_tree_host_common_test.cc b/cc/test/layer_tree_host_common_test.cc
index d1a7dc2..c923e50 100644
--- a/cc/test/layer_tree_host_common_test.cc
+++ b/cc/test/layer_tree_host_common_test.cc
@@ -166,8 +166,12 @@ void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties(
LayerImpl* page_scale_layer,
bool can_use_lcd_text,
bool layers_always_allowed_lcd_text) {
- host_impl()->active_tree()->SetDeviceScaleFactor(device_scale_factor);
- host_impl()->active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
+ root_layer->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor);
+ if (page_scale_layer)
+ root_layer->layer_tree_impl()->SetViewportLayersFromIds(
+ Layer::INVALID_ID, page_scale_layer->id(), Layer::INVALID_ID,
+ Layer::INVALID_ID);
+ root_layer->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor);
gfx::Transform identity_matrix;
gfx::Size device_viewport_size =
diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc
index 4dd597d..743631f 100644
--- a/cc/trees/damage_tracker_unittest.cc
+++ b/cc/trees/damage_tracker_unittest.cc
@@ -1465,12 +1465,14 @@ TEST_F(DamageTrackerTest, VerifyDamageForEmptyLayerList) {
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_.active_tree(), 1);
root->SetForceRenderSurface(true);
- root->layer_tree_impl()->property_trees()->needs_rebuild = true;
- EmulateDrawingOneFrame(root.get());
- root->draw_properties().render_target = root.get();
-
- ASSERT_EQ(root.get(), root->render_target());
- RenderSurfaceImpl* target_surface = root->render_surface();
+ host_impl_.active_tree()->SetRootLayer(std::move(root));
+ LayerImpl* root_ptr = host_impl_.active_tree()->root_layer();
+ root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ EmulateDrawingOneFrame(root_ptr);
+ root_ptr->draw_properties().render_target = root_ptr;
+
+ ASSERT_EQ(root_ptr, root_ptr->render_target());
+ RenderSurfaceImpl* target_surface = root_ptr->render_surface();
LayerImplList empty_list;
target_surface->damage_tracker()->UpdateDamageTrackingState(
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index d31fb06..ab28243 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -453,40 +453,28 @@ void FindLayersThatNeedUpdates(
}
template <typename LayerType>
-void UpdateRenderSurfacesWithEffectTreeInternal(EffectTree* effect_tree,
- LayerType* layer) {
+void UpdateRenderSurfaceForLayer(EffectTree* effect_tree,
+ bool non_root_surfaces_enabled,
+ LayerType* layer) {
+ if (!non_root_surfaces_enabled) {
+ layer->SetHasRenderSurface(!layer->parent());
+ return;
+ }
EffectNode* node = effect_tree->Node(layer->effect_tree_index());
if (node->owner_id == layer->id() && node->data.has_render_surface)
layer->SetHasRenderSurface(true);
else
layer->SetHasRenderSurface(false);
-
- for (size_t i = 0; i < layer->children().size(); ++i) {
- UpdateRenderSurfacesWithEffectTreeInternal<LayerType>(effect_tree,
- layer->child_at(i));
- }
-}
-
-void UpdateRenderSurfacesWithEffectTree(EffectTree* effect_tree, Layer* layer) {
- UpdateRenderSurfacesWithEffectTreeInternal<Layer>(effect_tree, layer);
}
-void UpdateRenderSurfacesNonRootSurfacesDisabled(LayerImpl* layer) {
- // Only root layer has render surface, all other layers don't.
- layer->SetHasRenderSurface(!layer->parent());
-
- for (size_t i = 0; i < layer->children().size(); ++i)
- UpdateRenderSurfacesNonRootSurfacesDisabled(layer->child_at(i));
-}
+void UpdateRenderSurfacesForLayersRecursive(EffectTree* effect_tree,
+ Layer* layer) {
+ UpdateRenderSurfaceForLayer(effect_tree, true, layer);
-void UpdateRenderSurfacesWithEffectTree(EffectTree* effect_tree,
- bool non_root_surfaces_enabled,
- LayerImpl* layer) {
- if (!non_root_surfaces_enabled)
- UpdateRenderSurfacesNonRootSurfacesDisabled(layer);
- else
- UpdateRenderSurfacesWithEffectTreeInternal<LayerImpl>(effect_tree, layer);
+ for (size_t i = 0; i < layer->children().size(); ++i) {
+ UpdateRenderSurfacesForLayersRecursive(effect_tree, layer->child_at(i));
+ }
}
} // namespace
@@ -697,7 +685,8 @@ void BuildPropertyTreesAndComputeVisibleRects(
outer_viewport_scroll_layer, overscroll_elasticity_layer,
elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
device_transform, property_trees);
- UpdateRenderSurfacesWithEffectTree(&property_trees->effect_tree, root_layer);
+ UpdateRenderSurfacesForLayersRecursive(&property_trees->effect_tree,
+ root_layer);
ValidateRenderSurfaces(root_layer);
ComputeVisibleRects(root_layer, property_trees,
can_render_to_separate_surface, update_layer_list);
@@ -740,8 +729,9 @@ void ComputeVisibleRects(LayerImpl* root_layer,
PropertyTrees* property_trees,
bool can_render_to_separate_surface,
LayerImplList* visible_layer_list) {
- UpdateRenderSurfacesWithEffectTree(
- &property_trees->effect_tree, can_render_to_separate_surface, root_layer);
+ for (auto* layer : *root_layer->layer_tree_impl())
+ UpdateRenderSurfaceForLayer(&property_trees->effect_tree,
+ can_render_to_separate_surface, layer);
if (can_render_to_separate_surface)
ValidateRenderSurfaces(root_layer);
LayerImplList update_layer_list;
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 24352bc..08e6113 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -359,9 +359,17 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) {
false);
root->AddChild(std::move(clip_layer_scoped_ptr));
root->SetHasRenderSurface(true);
+ LayerImpl* root_layer = root.get();
+ host_impl.active_tree()->SetRootLayer(std::move(root));
- ExecuteCalculateDrawProperties(
- root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
+ // We need property trees to exist when we try to update page scale factor on
+ // active tree. But we still need to rebuild property trees after that because
+ // BuildingPropertyTreesForTesting doesn't take into account the scale factors
+ // and the page scale layer.
+ root_layer->layer_tree_impl()->BuildPropertyTreesForTesting();
+ root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ ExecuteCalculateDrawProperties(root_layer, kDeviceScale, kPageScale,
+ scroll_layer->parent());
gfx::Transform expected_transform = identity_matrix;
gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta;
expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() *
@@ -382,9 +390,9 @@ TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) {
SetLayerPropertiesForTesting(scroll_layer, arbitrary_translate,
gfx::Point3F(), gfx::PointF(), gfx::Size(10, 20),
true, false, false);
- root->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(
- root.get(), kDeviceScale, kPageScale, scroll_layer->parent());
+ root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ ExecuteCalculateDrawProperties(root_layer, kDeviceScale, kPageScale,
+ scroll_layer->parent());
expected_transform.MakeIdentity();
expected_transform.Translate(
MathUtil::Round(kTranslateX * kPageScale * kDeviceScale +
@@ -4834,6 +4842,12 @@ TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) {
float device_scale_factor = 2.5f;
float page_scale_factor = 3.f;
+ // We need property trees to exist when we try to update page scale factor on
+ // active tree. But we still need to rebuild property trees after that because
+ // BuildingPropertyTreesForTesting doesn't take into account the scale factors
+ // and the page scale layer.
+ root->layer_tree_impl()->BuildPropertyTreesForTesting();
+ root->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor,
root);
@@ -4920,6 +4934,12 @@ TEST_F(LayerTreeHostCommonScalingTest, SmallIdealScale) {
float page_scale_factor = 0.01f;
{
+ // We need property trees to exist when we try to update page scale factor
+ // on active tree. But we still need to rebuild property trees after that
+ // because BuildingPropertyTreesForTesting doesn't take into account the
+ // scale factors and the page scale layer.
+ root->layer_tree_impl()->BuildPropertyTreesForTesting();
+ root->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor,
root);
@@ -5584,6 +5604,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
gfx::PointF(), gfx::Size(50, 50), true, false,
true);
root->SetDrawsContent(true);
+ LayerImpl* root_layer = root.get();
scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2);
SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(),
@@ -5601,20 +5622,21 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
child->AddChild(std::move(grand_child));
root->AddChild(std::move(child));
+ host_impl.pending_tree()->SetRootLayer(std::move(root));
LayerImplList render_surface_layer_list;
- root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
+ root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list,
- root->layer_tree_impl()->current_render_surface_list_id());
+ root_layer, root_layer->bounds(), &render_surface_layer_list,
+ root_layer->layer_tree_impl()->current_render_surface_list_id());
inputs.can_adjust_raster_scales = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
// We should have one render surface and one layers. The child has
// hidden itself and the grand child.
ASSERT_EQ(1u, render_surface_layer_list.size());
- ASSERT_EQ(1u, root->render_surface()->layer_list().size());
- EXPECT_EQ(1, root->render_surface()->layer_list().at(0)->id());
+ ASSERT_EQ(1u, root_layer->render_surface()->layer_list().size());
+ EXPECT_EQ(1, root_layer->render_surface()->layer_list().at(0)->id());
}
void EmptyCopyOutputCallback(scoped_ptr<CopyOutputResult> result) {}
@@ -5633,6 +5655,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
gfx::PointF(), gfx::Size(50, 50), true, false,
true);
root->SetDrawsContent(true);
+ LayerImpl* root_layer = root.get();
scoped_ptr<LayerImpl> copy_grand_parent =
LayerImpl::Create(host_impl.pending_tree(), 2);
@@ -5699,6 +5722,7 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
root->AddChild(std::move(copy_grand_parent_sibling_before));
root->AddChild(std::move(copy_grand_parent));
root->AddChild(std::move(copy_grand_parent_sibling_after));
+ host_impl.pending_tree()->SetRootLayer(std::move(root));
// Hide the copy_grand_parent and its subtree. But make a copy request in that
// hidden subtree on copy_layer. Also hide the copy grand child and its
@@ -5715,14 +5739,14 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
EXPECT_TRUE(copy_layer->HasCopyRequest());
LayerImplList render_surface_layer_list;
- root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
+ root_layer->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list,
- root->layer_tree_impl()->current_render_surface_list_id());
+ root_layer, root_layer->bounds(), &render_surface_layer_list,
+ root_layer->layer_tree_impl()->current_render_surface_list_id());
inputs.can_adjust_raster_scales = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
- EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0);
+ EXPECT_GT(root_layer->num_copy_requests_in_target_subtree(), 0);
EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0);
EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0);
EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0);
@@ -5731,17 +5755,18 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
// parent since it has opacity and two drawing descendants, one for the parent
// since it owns a surface, and one for the copy_layer.
ASSERT_EQ(4u, render_surface_layer_list.size());
- EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id());
+ EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id());
EXPECT_EQ(copy_grand_parent_layer->id(),
render_surface_layer_list.at(1)->id());
EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id());
EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id());
// The root render surface should have 2 contributing layers.
- ASSERT_EQ(2u, root->render_surface()->layer_list().size());
- EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id());
+ ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size());
+ EXPECT_EQ(root_layer->id(),
+ root_layer->render_surface()->layer_list().at(0)->id());
EXPECT_EQ(copy_grand_parent_layer->id(),
- root->render_surface()->layer_list().at(1)->id());
+ root_layer->render_surface()->layer_list().at(1)->id());
// Nothing actually draws into the copy parent, so only the copy_layer will
// appear in its list, since it needs to be drawn for the copy request.
@@ -5760,7 +5785,8 @@ TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
// but the copy_layer and copy_child should be drawn for the copy request.
// copy grand child should not be drawn as its hidden even in the copy
// request.
- EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree;
+ EffectTree tree =
+ root_layer->layer_tree_impl()->property_trees()->effect_tree;
EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index());
EXPECT_FALSE(node->data.is_drawn);
node = tree.Node(copy_parent_layer->effect_tree_index());
@@ -5823,23 +5849,26 @@ TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
copy_layer->AddChild(std::move(copy_child));
copy_parent->AddChild(std::move(copy_layer));
root->AddChild(std::move(copy_parent));
+ host_impl.pending_tree()->SetRootLayer(std::move(root));
+ LayerImpl* root_ptr = host_impl.pending_tree()->root_layer();
LayerImplList render_surface_layer_list;
- root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
+ root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list,
- root->layer_tree_impl()->current_render_surface_list_id());
+ root_ptr, root_ptr->bounds(), &render_surface_layer_list,
+ root_ptr->layer_tree_impl()->current_render_surface_list_id());
inputs.can_adjust_raster_scales = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
// We should have two render surface, as the others are clipped out.
ASSERT_EQ(2u, render_surface_layer_list.size());
- EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id());
+ EXPECT_EQ(root_ptr->id(), render_surface_layer_list.at(0)->id());
// The root render surface should only have 2 contributing layer, since the
// other layers are empty/clipped away.
- ASSERT_EQ(2u, root->render_surface()->layer_list().size());
- EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id());
+ ASSERT_EQ(2u, root_ptr->render_surface()->layer_list().size());
+ EXPECT_EQ(root_ptr->id(),
+ root_ptr->render_surface()->layer_list().at(0)->id());
}
TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
@@ -6386,14 +6415,16 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
child2->AddChild(std::move(child3));
child1->AddChild(std::move(child2));
root->AddChild(std::move(child1));
+ host_impl.active_tree()->SetRootLayer(std::move(root));
+ LayerImpl* root_ptr = host_impl.active_tree()->root_layer();
{
LayerImplList render_surface_layer_list;
- FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get());
- root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
+ FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_ptr);
+ root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list,
- root->layer_tree_impl()->current_render_surface_list_id());
+ root_ptr, root_ptr->bounds(), &render_surface_layer_list,
+ root_ptr->layer_tree_impl()->current_render_surface_list_id());
inputs.can_render_to_separate_surface = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
@@ -6423,10 +6454,10 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) {
{
LayerImplList render_surface_layer_list;
- root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
+ root_ptr->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting();
LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
- root.get(), root->bounds(), &render_surface_layer_list,
- root->layer_tree_impl()->current_render_surface_list_id());
+ root_ptr, root_ptr->bounds(), &render_surface_layer_list,
+ root_ptr->layer_tree_impl()->current_render_surface_list_id());
inputs.can_render_to_separate_surface = false;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
@@ -7315,12 +7346,14 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get();
AnimationScaleFactorTrackingLayerImpl* child_raw = child.get();
AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get();
+ AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get();
child->AddChild(std::move(grand_child));
parent->AddChild(std::move(child));
grand_parent->AddChild(std::move(parent));
+ host_impl.active_tree()->SetRootLayer(std::move(grand_parent));
- SetLayerPropertiesForTesting(grand_parent.get(), identity_matrix,
+ SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix,
gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
true, false, true);
SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(),
@@ -7334,19 +7367,21 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
gfx::PointF(), gfx::Size(1, 2), true, false,
false);
- ExecuteCalculateDrawProperties(grand_parent.get());
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// No layers have animations.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7366,16 +7401,18 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
TransformOperations(), translation);
// No layers have scale-affecting animations.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7390,19 +7427,21 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0,
TransformOperations(), scale);
child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(grand_parent.get());
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// Only |child| has a scale-affecting animation.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(5.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
5.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(1.f,
@@ -7411,14 +7450,15 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
1.f,
grand_child_raw->draw_properties().starting_animation_contents_scale);
- AddAnimatedTransformToLayerWithPlayer(grand_parent->id(), timeline, 1.0,
+ AddAnimatedTransformToLayerWithPlayer(grand_parent_raw->id(), timeline, 1.0,
TransformOperations(), scale);
- grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(grand_parent.get());
+ grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// |grand_parent| and |child| have scale-affecting animations.
- EXPECT_EQ(5.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 5.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(5.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
// We don't support combining animated scales from two nodes; 0.f means
@@ -7427,8 +7467,9 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(1.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 1.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(1.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7440,19 +7481,21 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0,
TransformOperations(), scale);
parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(grand_parent.get());
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// |grand_parent|, |parent|, and |child| have scale-affecting animations.
- EXPECT_EQ(5.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 5.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(1.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 1.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7461,7 +7504,7 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
0.f,
grand_child_raw->draw_properties().starting_animation_contents_scale);
- AbortAnimationsOnLayerWithPlayer(grand_parent->id(), timeline,
+ AbortAnimationsOnLayerWithPlayer(grand_parent_raw->id(), timeline,
TargetProperty::TRANSFORM);
AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline,
TargetProperty::TRANSFORM);
@@ -7474,20 +7517,22 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0,
TransformOperations(), perspective);
child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(grand_parent.get());
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// |child| has a scale-affecting animation but computing the maximum of this
// animation is not supported.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7500,18 +7545,19 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
TargetProperty::TRANSFORM);
gfx::Transform scale_matrix;
scale_matrix.Scale(1.f, 2.f);
- grand_parent->SetTransform(scale_matrix);
+ grand_parent_raw->SetTransform(scale_matrix);
parent_raw->SetTransform(scale_matrix);
- grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0,
TransformOperations(), scale);
- ExecuteCalculateDrawProperties(grand_parent.get());
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// |grand_parent| and |parent| each have scale 2.f. |parent| has a scale
// animation with maximum scale 5.f.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(10.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(10.f,
@@ -7520,8 +7566,9 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
10.f,
grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(2.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(2.f,
@@ -7533,20 +7580,22 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
gfx::Transform perspective_matrix;
perspective_matrix.ApplyPerspectiveDepth(2.f);
child_raw->SetTransform(perspective_matrix);
- grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(grand_parent.get());
+ grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// |child| has a transform that's neither a translation nor a scale.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(10.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(2.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7556,21 +7605,23 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
grand_child_raw->draw_properties().starting_animation_contents_scale);
parent_raw->SetTransform(perspective_matrix);
- grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(grand_parent.get());
+ grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// |parent| and |child| have transforms that are neither translations nor
// scales.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7581,22 +7632,24 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) {
parent_raw->SetTransform(identity_matrix);
child_raw->SetTransform(identity_matrix);
- grand_parent->SetTransform(perspective_matrix);
- grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ grand_parent_raw->SetTransform(perspective_matrix);
+ grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawProperties(grand_parent.get());
+ ExecuteCalculateDrawProperties(grand_parent_raw);
// |grand_parent| has a transform that's neither a translation nor a scale.
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().maximum_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(0.f, child_raw->draw_properties().maximum_animation_contents_scale);
EXPECT_EQ(
0.f, grand_child_raw->draw_properties().maximum_animation_contents_scale);
- EXPECT_EQ(0.f,
- grand_parent->draw_properties().starting_animation_contents_scale);
+ EXPECT_EQ(
+ 0.f,
+ grand_parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
parent_raw->draw_properties().starting_animation_contents_scale);
EXPECT_EQ(0.f,
@@ -7656,6 +7709,7 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) {
child->AddChild(std::move(grand_child2));
parent->AddChild(std::move(child));
grand_parent->AddChild(std::move(parent));
+ host_impl.active_tree()->SetRootLayer(std::move(grand_parent));
SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix,
gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2),
@@ -7899,6 +7953,7 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
root->AddChild(std::move(child2));
root->SetForceRenderSurface(true);
root->SetDrawsContent(true);
+ host_impl.active_tree()->SetRootLayer(std::move(root));
gfx::Transform identity_matrix, scale_transform_child1,
scale_transform_child2;
@@ -7938,7 +7993,7 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
true, false, false);
child2_layer->SetDrawsContent(true);
- root->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
ExecuteCalculateDrawProperties(root_layer);
EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale());
@@ -8011,7 +8066,7 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) {
device_scale_factor = 4.0f;
inputs.device_scale_factor = device_scale_factor;
inputs.can_adjust_raster_scales = true;
- root->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true;
LayerTreeHostCommon::CalculateDrawProperties(&inputs);
EXPECT_FLOAT_EQ(12.f, root_layer->GetIdealContentsScale());
@@ -8860,14 +8915,16 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
gfx::PointF(), gfx::Size(10, 10), true, false,
false);
+ LayerImpl* root_ptr = root.get();
LayerImpl* child_ptr = child.get();
LayerImpl* grandchild_ptr = grandchild.get();
child->AddChild(std::move(grandchild));
root->AddChild(std::move(child));
+ host_impl.active_tree()->SetRootLayer(std::move(root));
// Check the non-skipped case.
- ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
// Now we will reset the visible rect from property trees for the grandchild,
@@ -8879,17 +8936,17 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
singular.matrix().set(0, 0, 0);
child_ptr->SetTransform(singular);
- ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
child_ptr->SetTransform(identity);
child_ptr->SetHideLayerAndSubtree(true);
- ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
child_ptr->SetHideLayerAndSubtree(false);
child_ptr->SetOpacity(0.f);
- ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
// Now, even though child has zero opacity, we will configure |grandchild| and
@@ -8899,8 +8956,8 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeImpl) {
requests.push_back(CopyOutputRequest::CreateEmptyRequest());
grandchild_ptr->PassCopyRequests(&requests);
- root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true;
- ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get());
+ root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true;
+ ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr);
EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect());
}
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc
index 4a5f480..8cf4f01 100644
--- a/cc/trees/layer_tree_impl_unittest.cc
+++ b/cc/trees/layer_tree_impl_unittest.cc
@@ -648,6 +648,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) {
//
scoped_ptr<LayerImpl> root =
LayerImpl::Create(host_impl().active_tree(), 123);
+ LayerImpl* root_layer = root.get();
gfx::Transform identity_matrix;
gfx::Point3F transform_origin;
@@ -702,12 +703,12 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) {
grand_child->AddChild(std::move(rotated_leaf));
child->AddChild(std::move(grand_child));
root->AddChild(std::move(child));
+ host_impl().active_tree()->SetRootLayer(std::move(root));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawProperties(root_layer);
}
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().SetViewportSize(root_layer->bounds());
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// (11, 89) is close to the the bottom left corner within the clip, but it is
// not inside the layer.
@@ -830,6 +831,7 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) {
TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) {
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
+ LayerImpl* root_layer = root.get();
gfx::Transform identity_matrix;
gfx::Point3F transform_origin;
@@ -879,16 +881,16 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) {
child1->AddChild(std::move(grand_child1));
root->AddChild(std::move(child1));
root->AddChild(std::move(child2));
+ host_impl().active_tree()->SetRootLayer(std::move(root));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawProperties(root_layer);
}
- LayerImpl* child1 = root->children()[0];
- LayerImpl* child2 = root->children()[1];
+ LayerImpl* child1 = root_layer->children()[0];
+ LayerImpl* child2 = root_layer->children()[1];
LayerImpl* grand_child1 = child1->children()[0];
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().SetViewportSize(root_layer->bounds());
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -897,7 +899,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) {
ASSERT_TRUE(grand_child1);
ASSERT_EQ(1u, RenderSurfaceLayerList().size());
- RenderSurfaceImpl* root_render_surface = root_layer()->render_surface();
+ RenderSurfaceImpl* root_render_surface = root_layer->render_surface();
ASSERT_EQ(4u, root_render_surface->layer_list().size());
ASSERT_EQ(1, root_render_surface->layer_list().at(0)->id()); // root layer
ASSERT_EQ(2, root_render_surface->layer_list().at(1)->id()); // child1
@@ -1292,6 +1294,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
// all layers are forced to be render surfaces now.
//
scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
+ LayerImpl* root_layer = root.get();
gfx::Transform identity_matrix;
gfx::Point3F transform_origin;
@@ -1344,16 +1347,16 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
child1->AddChild(std::move(grand_child1));
root->AddChild(std::move(child1));
root->AddChild(std::move(child2));
+ host_impl().active_tree()->SetRootLayer(std::move(root));
- ExecuteCalculateDrawProperties(root.get());
+ ExecuteCalculateDrawProperties(root_layer);
}
- LayerImpl* child1 = root->children()[0];
- LayerImpl* child2 = root->children()[1];
+ LayerImpl* child1 = root_layer->children()[0];
+ LayerImpl* child2 = root_layer->children()[1];
LayerImpl* grand_child1 = child1->children()[0];
- host_impl().SetViewportSize(root->bounds());
- host_impl().active_tree()->SetRootLayer(std::move(root));
+ host_impl().SetViewportSize(root_layer->bounds());
host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
// Sanity check the scenario we just created.
@@ -1366,7 +1369,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) {
ASSERT_EQ(4u, RenderSurfaceLayerList().size());
// The root surface has the root layer, and child1's and child2's render
// surfaces.
- ASSERT_EQ(3u, root_layer()->render_surface()->layer_list().size());
+ ASSERT_EQ(3u, root_layer->render_surface()->layer_list().size());
// The child1 surface has the child1 layer and grand_child1's render surface.
ASSERT_EQ(2u, child1->render_surface()->layer_list().size());
ASSERT_EQ(1u, child2->render_surface()->layer_list().size());
diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc
index 5bfd312..5aa72c3 100644
--- a/cc/trees/occlusion_tracker_unittest.cc
+++ b/cc/trees/occlusion_tracker_unittest.cc
@@ -105,8 +105,7 @@ class OcclusionTrackerTest : public testing::Test {
TestContentLayerImpl* layer_ptr = layer.get();
SetProperties(layer_ptr, transform, position, bounds);
- DCHECK(!root_.get());
- root_ = std::move(layer);
+ host_->host_impl()->active_tree()->SetRootLayer(std::move(layer));
layer_ptr->SetForceRenderSurface(true);
SetRootLayerOnMainThread(layer_ptr);
@@ -196,7 +195,7 @@ class OcclusionTrackerTest : public testing::Test {
}
void DestroyLayers() {
- root_ = nullptr;
+ host_->host_impl()->active_tree()->SetRootLayer(nullptr);
render_surface_layer_list_impl_.clear();
replica_layers_.clear();
mask_layers_.clear();
@@ -219,7 +218,7 @@ class OcclusionTrackerTest : public testing::Test {
}
void CalcDrawEtc(TestContentLayerImpl* root) {
- DCHECK(root == root_.get());
+ DCHECK(root == root->layer_tree_impl()->root_layer());
// These occlusion tests attach and detach layers in multiple
// iterations, so rebuild property trees every time.
@@ -311,7 +310,6 @@ class OcclusionTrackerTest : public testing::Test {
TestTaskGraphRunner task_graph_runner_;
scoped_ptr<FakeLayerTreeHost> host_;
// These hold ownership of the layers for the duration of the test.
- scoped_ptr<LayerImpl> root_;
LayerImplList render_surface_layer_list_impl_;
LayerIterator layer_iterator_begin_;
LayerIterator layer_iterator_;