blob: 8090415b7a5505bc32a6f935f5546a07b6a275cc [file] [log] [blame]
[email protected]c0dd24c2012-08-30 23:25:271// Copyright 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]556fd292013-03-18 08:03:045#include "cc/trees/tree_synchronizer.h"
[email protected]c0dd24c2012-08-30 23:25:276
avi02a4d172015-12-21 06:14:367#include <stddef.h>
8
[email protected]ac7c7f52012-11-08 06:26:509#include <algorithm>
[email protected]0e98cdd2013-08-23 00:44:3010#include <set>
[email protected]bf691c22013-03-26 21:15:0611#include <vector>
[email protected]ac7c7f52012-11-08 06:26:5012
[email protected]d097e242014-02-28 21:51:1113#include "base/format_macros.h"
danakj60bc3bc2016-04-09 00:24:4814#include "base/memory/ptr_util.h"
[email protected]d097e242014-02-28 21:51:1115#include "base/strings/stringprintf.h"
[email protected]cc3cfaa2013-03-18 09:05:5216#include "cc/layers/layer.h"
17#include "cc/layers/layer_impl.h"
[email protected]101441ce2012-10-16 01:45:0318#include "cc/test/animation_test_common.h"
khushalsagarb64b360d2015-10-21 19:25:1619#include "cc/test/fake_impl_task_runner_provider.h"
[email protected]f4e25f92013-07-13 20:54:5320#include "cc/test/fake_layer_tree_host.h"
hendrikw9b7f6d982014-11-04 22:28:3521#include "cc/test/fake_rendering_stats_instrumentation.h"
danakjffc181a2016-07-22 22:48:4322#include "cc/test/stub_layer_tree_host_single_thread_client.h"
[email protected]4e2eb352014-03-20 17:25:4523#include "cc/test/test_shared_bitmap_manager.h"
danakjcf610582015-06-16 22:48:5624#include "cc/test/test_task_graph_runner.h"
trchendba8b1502016-07-08 09:47:0125#include "cc/trees/effect_node.h"
jaydasika13c05062016-04-01 18:12:2726#include "cc/trees/layer_tree_host_common.h"
[email protected]556fd292013-03-18 08:03:0427#include "cc/trees/single_thread_proxy.h"
khushalsagarb64b360d2015-10-21 19:25:1628#include "cc/trees/task_runner_provider.h"
[email protected]7f0c53db2012-10-02 00:23:1829#include "testing/gtest/include/gtest/gtest.h"
[email protected]c0dd24c2012-08-30 23:25:2730
[email protected]ba565742012-11-10 09:29:4831namespace cc {
[email protected]c0dd24c2012-08-30 23:25:2732namespace {
33
[email protected]96baf3e2012-10-22 23:09:5534class MockLayerImpl : public LayerImpl {
[email protected]b5651c22013-03-14 15:06:3335 public:
danakj60bc3bc2016-04-09 00:24:4836 static std::unique_ptr<MockLayerImpl> Create(LayerTreeImpl* tree_impl,
37 int layer_id) {
38 return base::WrapUnique(new MockLayerImpl(tree_impl, layer_id));
[email protected]b5651c22013-03-14 15:06:3339 }
dcheng716bedf2014-10-21 09:51:0840 ~MockLayerImpl() override {
[email protected]b5651c22013-03-14 15:06:3341 if (layer_impl_destruction_list_)
42 layer_impl_destruction_list_->push_back(id());
43 }
[email protected]c0dd24c2012-08-30 23:25:2744
[email protected]b5651c22013-03-14 15:06:3345 void SetLayerImplDestructionList(std::vector<int>* list) {
46 layer_impl_destruction_list_ = list;
47 }
[email protected]c0dd24c2012-08-30 23:25:2748
[email protected]b5651c22013-03-14 15:06:3349 private:
50 MockLayerImpl(LayerTreeImpl* tree_impl, int layer_id)
vollick83fbfc82016-03-22 18:33:2751 : LayerImpl(tree_impl, layer_id), layer_impl_destruction_list_(NULL) {}
[email protected]c0dd24c2012-08-30 23:25:2752
[email protected]b5651c22013-03-14 15:06:3353 std::vector<int>* layer_impl_destruction_list_;
[email protected]c0dd24c2012-08-30 23:25:2754};
55
[email protected]96baf3e2012-10-22 23:09:5556class MockLayer : public Layer {
[email protected]b5651c22013-03-14 15:06:3357 public:
58 static scoped_refptr<MockLayer> Create(
59 std::vector<int>* layer_impl_destruction_list) {
loyso0940d412016-03-14 01:30:3160 return make_scoped_refptr(new MockLayer(layer_impl_destruction_list));
[email protected]b5651c22013-03-14 15:06:3361 }
[email protected]c0dd24c2012-08-30 23:25:2762
danakj60bc3bc2016-04-09 00:24:4863 std::unique_ptr<LayerImpl> CreateLayerImpl(
64 LayerTreeImpl* tree_impl) override {
khushalsagarb51998f2016-07-08 01:04:2165 return MockLayerImpl::Create(tree_impl, id());
[email protected]b5651c22013-03-14 15:06:3366 }
[email protected]c0dd24c2012-08-30 23:25:2767
dcheng716bedf2014-10-21 09:51:0868 void PushPropertiesTo(LayerImpl* layer_impl) override {
[email protected]b5651c22013-03-14 15:06:3369 Layer::PushPropertiesTo(layer_impl);
[email protected]c0dd24c2012-08-30 23:25:2770
[email protected]b5651c22013-03-14 15:06:3371 MockLayerImpl* mock_layer_impl = static_cast<MockLayerImpl*>(layer_impl);
72 mock_layer_impl->SetLayerImplDestructionList(layer_impl_destruction_list_);
73 }
[email protected]d58499a2012-10-09 22:27:4774
[email protected]b5651c22013-03-14 15:06:3375 private:
loyso0940d412016-03-14 01:30:3176 explicit MockLayer(std::vector<int>* layer_impl_destruction_list)
77 : layer_impl_destruction_list_(layer_impl_destruction_list) {}
dcheng716bedf2014-10-21 09:51:0878 ~MockLayer() override {}
[email protected]c0dd24c2012-08-30 23:25:2779
[email protected]b5651c22013-03-14 15:06:3380 std::vector<int>* layer_impl_destruction_list_;
[email protected]c0dd24c2012-08-30 23:25:2781};
82
jaydasika4b0fd7512016-06-09 18:12:5383void ExpectTreesAreIdentical(Layer* root_layer,
84 LayerImpl* root_layer_impl,
[email protected]b5651c22013-03-14 15:06:3385 LayerTreeImpl* tree_impl) {
jaydasika4b0fd7512016-06-09 18:12:5386 auto layer_iter = root_layer->layer_tree_host()->begin();
87 auto layer_impl_iter = tree_impl->begin();
88 for (; layer_iter != root_layer->layer_tree_host()->end();
89 ++layer_iter, ++layer_impl_iter) {
90 Layer* layer = *layer_iter;
91 LayerImpl* layer_impl = *layer_impl_iter;
92 ASSERT_TRUE(layer);
93 ASSERT_TRUE(layer_impl);
[email protected]c0dd24c2012-08-30 23:25:2794
jaydasika4b0fd7512016-06-09 18:12:5395 EXPECT_EQ(layer->id(), layer_impl->id());
96 EXPECT_EQ(layer_impl->layer_tree_impl(), tree_impl);
[email protected]c0dd24c2012-08-30 23:25:2797
jaydasika4b0fd7512016-06-09 18:12:5398 EXPECT_EQ(layer->non_fast_scrollable_region(),
99 layer_impl->non_fast_scrollable_region());
[email protected]c0dd24c2012-08-30 23:25:27100
ajuma1d4026a32016-06-14 13:18:50101 const EffectTree& effect_tree = tree_impl->property_trees()->effect_tree;
jaydasika4b0fd7512016-06-09 18:12:53102 if (layer->mask_layer()) {
103 SCOPED_TRACE("mask_layer");
ajuma1d4026a32016-06-14 13:18:50104 int mask_layer_id = layer->mask_layer()->id();
105 EXPECT_TRUE(tree_impl->LayerById(mask_layer_id));
trchendba8b1502016-07-08 09:47:01106 EXPECT_EQ(
107 mask_layer_id,
108 effect_tree.Node(layer_impl->effect_tree_index())->mask_layer_id);
jaydasika4b0fd7512016-06-09 18:12:53109 }
[email protected]c0dd24c2012-08-30 23:25:27110
jaydasika4b0fd7512016-06-09 18:12:53111 if (layer->replica_layer()) {
112 SCOPED_TRACE("replica_layer");
ajuma1d4026a32016-06-14 13:18:50113 int replica_layer_id = layer->replica_layer()->id();
114 EXPECT_TRUE(tree_impl->LayerById(layer->replica_layer()->id()));
trchendba8b1502016-07-08 09:47:01115 EXPECT_EQ(
116 replica_layer_id,
117 effect_tree.Node(layer_impl->effect_tree_index())->replica_layer_id);
jaydasika4b0fd7512016-06-09 18:12:53118 if (layer->replica_layer()->mask_layer()) {
ajuma1d4026a32016-06-14 13:18:50119 SCOPED_TRACE("replica_mask_layer");
120 int replica_mask_layer_id = layer->replica_layer()->mask_layer()->id();
121 EXPECT_TRUE(tree_impl->LayerById(replica_mask_layer_id));
122 EXPECT_EQ(replica_mask_layer_id,
123 effect_tree.Node(layer_impl->effect_tree_index())
trchendba8b1502016-07-08 09:47:01124 ->replica_mask_layer_id);
jaydasika4b0fd7512016-06-09 18:12:53125 }
126 }
[email protected]c0dd24c2012-08-30 23:25:27127
jaydasika4b0fd7512016-06-09 18:12:53128 const Layer* layer_scroll_parent = layer->scroll_parent();
[email protected]c0dd24c2012-08-30 23:25:27129
jaydasika4b0fd7512016-06-09 18:12:53130 if (layer_scroll_parent) {
131 ASSERT_TRUE(layer_scroll_parent->scroll_children()->find(layer) !=
132 layer_scroll_parent->scroll_children()->end());
133 }
[email protected]c0dd24c2012-08-30 23:25:27134
jaydasika4b0fd7512016-06-09 18:12:53135 const Layer* layer_clip_parent = layer->clip_parent();
[email protected]0e98cdd2013-08-23 00:44:30136
jaydasika4b0fd7512016-06-09 18:12:53137 if (layer_clip_parent) {
138 const std::set<Layer*>* clip_children =
139 layer_clip_parent->clip_children();
140 ASSERT_TRUE(clip_children->find(layer) != clip_children->end());
141 }
[email protected]b5651c22013-03-14 15:06:33142 }
[email protected]c0dd24c2012-08-30 23:25:27143}
144
[email protected]c2282382012-12-16 00:46:03145class TreeSynchronizerTest : public testing::Test {
[email protected]b5651c22013-03-14 15:06:33146 protected:
danakj6021ec32016-07-22 22:16:08147 TreeSynchronizerTest()
148 : host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {}
sunxdc36713a2016-03-03 22:31:10149
150 bool is_equal(ScrollTree::ScrollOffsetMap map,
151 ScrollTree::ScrollOffsetMap other) {
152 if (map.size() != other.size())
153 return false;
154 for (auto& map_entry : map) {
155 if (other.find(map_entry.first) == other.end())
156 return false;
157 SyncedScrollOffset& from_map = *map_entry.second.get();
158 SyncedScrollOffset& from_other = *other[map_entry.first].get();
159 if (from_map.PendingBase() != from_other.PendingBase() ||
160 from_map.ActiveBase() != from_other.ActiveBase() ||
161 from_map.Delta() != from_other.Delta() ||
162 from_map.PendingDelta().get() != from_other.PendingDelta().get())
163 return false;
164 }
165 return true;
166 }
danakj6021ec32016-07-22 22:16:08167
168 FakeLayerTreeHostClient client_;
danakjffc181a2016-07-22 22:48:43169 StubLayerTreeHostSingleThreadClient single_thread_client_;
danakj6021ec32016-07-22 22:16:08170 TestTaskGraphRunner task_graph_runner_;
171 std::unique_ptr<FakeLayerTreeHost> host_;
[email protected]c2282382012-12-16 00:46:03172};
173
[email protected]c0dd24c2012-08-30 23:25:27174// Attempts to synchronizes a null tree. This should not crash, and should
175// return a null tree.
[email protected]b5651c22013-03-14 15:06:33176TEST_F(TreeSynchronizerTest, SyncNullTree) {
vollick83fbfc82016-03-22 18:33:27177 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL),
178 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59179 EXPECT_TRUE(!host_->active_tree()->root_layer_for_testing());
[email protected]c0dd24c2012-08-30 23:25:27180}
181
[email protected]b5651c22013-03-14 15:06:33182// Constructs a very simple tree and synchronizes it without trying to reuse any
183// preexisting layers.
184TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) {
loyso0940d412016-03-14 01:30:31185 scoped_refptr<Layer> layer_tree_root = Layer::Create();
186 layer_tree_root->AddChild(Layer::Create());
187 layer_tree_root->AddChild(Layer::Create());
[email protected]c0dd24c2012-08-30 23:25:27188
[email protected]f4e25f92013-07-13 20:54:53189 host_->SetRootLayer(layer_tree_root);
190
vollick83fbfc82016-03-22 18:33:27191 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
192 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27193
[email protected]b5651c22013-03-14 15:06:33194 ExpectTreesAreIdentical(layer_tree_root.get(),
jaydasikabf1875a2016-06-28 03:39:59195 host_->active_tree()->root_layer_for_testing(),
[email protected]f4e25f92013-07-13 20:54:53196 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27197}
198
[email protected]b5651c22013-03-14 15:06:33199// Constructs a very simple tree and synchronizes it attempting to reuse some
200// layers
201TEST_F(TreeSynchronizerTest, SyncSimpleTreeReusingLayers) {
202 std::vector<int> layer_impl_destruction_list;
[email protected]c0dd24c2012-08-30 23:25:27203
[email protected]b5651c22013-03-14 15:06:33204 scoped_refptr<Layer> layer_tree_root =
loyso0940d412016-03-14 01:30:31205 MockLayer::Create(&layer_impl_destruction_list);
206 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
207 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
jaydasika4b0fd7512016-06-09 18:12:53208 int second_layer_impl_id = layer_tree_root->children()[1]->id();
[email protected]c0dd24c2012-08-30 23:25:27209
[email protected]f4e25f92013-07-13 20:54:53210 host_->SetRootLayer(layer_tree_root);
211
vollick83fbfc82016-03-22 18:33:27212 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
213 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59214 LayerImpl* layer_impl_tree_root =
215 host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27216 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53217 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27218
[email protected]b5651c22013-03-14 15:06:33219 // We have to push properties to pick up the destruction list pointer.
jaydasika9234e402016-03-21 20:44:22220 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
221 host_->active_tree());
[email protected]5c4824e12013-01-12 16:34:53222
[email protected]b5651c22013-03-14 15:06:33223 // Add a new layer to the Layer side
loysoa6edaaff2015-05-25 03:26:44224 layer_tree_root->children()[0]->AddChild(
loyso0940d412016-03-14 01:30:31225 MockLayer::Create(&layer_impl_destruction_list));
[email protected]b5651c22013-03-14 15:06:33226 // Remove one.
227 layer_tree_root->children()[1]->RemoveFromParent();
[email protected]c0dd24c2012-08-30 23:25:27228
[email protected]b5651c22013-03-14 15:06:33229 // Synchronize again. After the sync the trees should be equivalent and we
230 // should have created and destroyed one LayerImpl.
vollick83fbfc82016-03-22 18:33:27231 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
232 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59233 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27234
235 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53236 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27237
[email protected]b5651c22013-03-14 15:06:33238 ASSERT_EQ(1u, layer_impl_destruction_list.size());
239 EXPECT_EQ(second_layer_impl_id, layer_impl_destruction_list[0]);
vollick83fbfc82016-03-22 18:33:27240
rockot2176f922016-06-08 19:18:32241 host_->active_tree()->DetachLayers();
[email protected]c0dd24c2012-08-30 23:25:27242}
243
[email protected]b5651c22013-03-14 15:06:33244// Constructs a very simple tree and checks that a stacking-order change is
245// tracked properly.
246TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndTrackStackingOrderChange) {
247 std::vector<int> layer_impl_destruction_list;
[email protected]c0dd24c2012-08-30 23:25:27248
[email protected]b5651c22013-03-14 15:06:33249 // Set up the tree and sync once. child2 needs to be synced here, too, even
250 // though we remove it to set up the intended scenario.
251 scoped_refptr<Layer> layer_tree_root =
loyso0940d412016-03-14 01:30:31252 MockLayer::Create(&layer_impl_destruction_list);
253 scoped_refptr<Layer> child2 = MockLayer::Create(&layer_impl_destruction_list);
254 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
[email protected]b5651c22013-03-14 15:06:33255 layer_tree_root->AddChild(child2);
jaydasika4b0fd7512016-06-09 18:12:53256 int child1_id = layer_tree_root->children()[0]->id();
257 int child2_id = layer_tree_root->children()[1]->id();
[email protected]f4e25f92013-07-13 20:54:53258
259 host_->SetRootLayer(layer_tree_root);
260
vollick83fbfc82016-03-22 18:33:27261 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
262 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59263 LayerImpl* layer_impl_tree_root =
264 host_->active_tree()->root_layer_for_testing();
jaydasikaef64f9e42016-03-12 01:08:18265 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53266 host_->active_tree());
[email protected]5c4824e12013-01-12 16:34:53267
[email protected]b5651c22013-03-14 15:06:33268 // We have to push properties to pick up the destruction list pointer.
jaydasika9234e402016-03-21 20:44:22269 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
270 host_->active_tree());
[email protected]5c4824e12013-01-12 16:34:53271
jaydasikad6f778b2016-05-19 22:51:26272 host_->active_tree()->ResetAllChangeTracking();
[email protected]c0dd24c2012-08-30 23:25:27273
[email protected]b5651c22013-03-14 15:06:33274 // re-insert the layer and sync again.
275 child2->RemoveFromParent();
276 layer_tree_root->AddChild(child2);
vollick83fbfc82016-03-22 18:33:27277 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
278 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59279 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
jaydasikaef64f9e42016-03-12 01:08:18280 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53281 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27282
jaydasika9234e402016-03-21 20:44:22283 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
284 host_->active_tree());
[email protected]5c4824e12013-01-12 16:34:53285
[email protected]b5651c22013-03-14 15:06:33286 // Check that the impl thread properly tracked the change.
287 EXPECT_FALSE(layer_impl_tree_root->LayerPropertyChanged());
jaydasika4b0fd7512016-06-09 18:12:53288 EXPECT_FALSE(
289 host_->active_tree()->LayerById(child1_id)->LayerPropertyChanged());
290 EXPECT_TRUE(
291 host_->active_tree()->LayerById(child2_id)->LayerPropertyChanged());
rockot2176f922016-06-08 19:18:32292 host_->active_tree()->DetachLayers();
[email protected]c0dd24c2012-08-30 23:25:27293}
294
[email protected]b5651c22013-03-14 15:06:33295TEST_F(TreeSynchronizerTest, SyncSimpleTreeAndProperties) {
loyso0940d412016-03-14 01:30:31296 scoped_refptr<Layer> layer_tree_root = Layer::Create();
297 layer_tree_root->AddChild(Layer::Create());
298 layer_tree_root->AddChild(Layer::Create());
[email protected]c0dd24c2012-08-30 23:25:27299
[email protected]f4e25f92013-07-13 20:54:53300 host_->SetRootLayer(layer_tree_root);
301
[email protected]b5651c22013-03-14 15:06:33302 // Pick some random properties to set. The values are not important, we're
303 // just testing that at least some properties are making it through.
304 gfx::PointF root_position = gfx::PointF(2.3f, 7.4f);
305 layer_tree_root->SetPosition(root_position);
[email protected]c0dd24c2012-08-30 23:25:27306
[email protected]b5651c22013-03-14 15:06:33307 gfx::Size second_child_bounds = gfx::Size(25, 53);
308 layer_tree_root->children()[1]->SetBounds(second_child_bounds);
[email protected]445881f2013-04-16 01:11:59309 layer_tree_root->children()[1]->SavePaintProperties();
jaydasika4b0fd7512016-06-09 18:12:53310 int second_child_id = layer_tree_root->children()[1]->id();
[email protected]c0dd24c2012-08-30 23:25:27311
vollick83fbfc82016-03-22 18:33:27312 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
313 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59314 LayerImpl* layer_impl_tree_root =
315 host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27316 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53317 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27318
jaydasika9234e402016-03-21 20:44:22319 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
320 host_->active_tree());
[email protected]5c4824e12013-01-12 16:34:53321
[email protected]b5651c22013-03-14 15:06:33322 // Check that the property values we set on the Layer tree are reflected in
323 // the LayerImpl tree.
324 gfx::PointF root_layer_impl_position = layer_impl_tree_root->position();
325 EXPECT_EQ(root_position.x(), root_layer_impl_position.x());
326 EXPECT_EQ(root_position.y(), root_layer_impl_position.y());
[email protected]c0dd24c2012-08-30 23:25:27327
bokancccfde72014-10-08 15:15:22328 gfx::Size second_layer_impl_child_bounds =
jaydasika4b0fd7512016-06-09 18:12:53329 layer_impl_tree_root->layer_tree_impl()
330 ->LayerById(second_child_id)
331 ->bounds();
[email protected]b5651c22013-03-14 15:06:33332 EXPECT_EQ(second_child_bounds.width(),
333 second_layer_impl_child_bounds.width());
334 EXPECT_EQ(second_child_bounds.height(),
335 second_layer_impl_child_bounds.height());
[email protected]c0dd24c2012-08-30 23:25:27336}
337
[email protected]b5651c22013-03-14 15:06:33338TEST_F(TreeSynchronizerTest, ReuseLayerImplsAfterStructuralChange) {
339 std::vector<int> layer_impl_destruction_list;
[email protected]c0dd24c2012-08-30 23:25:27340
[email protected]b5651c22013-03-14 15:06:33341 // Set up a tree with this sort of structure:
342 // root --- A --- B ---+--- C
343 // |
344 // +--- D
345 scoped_refptr<Layer> layer_tree_root =
loyso0940d412016-03-14 01:30:31346 MockLayer::Create(&layer_impl_destruction_list);
347 layer_tree_root->AddChild(MockLayer::Create(&layer_impl_destruction_list));
[email protected]c0dd24c2012-08-30 23:25:27348
vollick83fbfc82016-03-22 18:33:27349 scoped_refptr<Layer> layer_a = layer_tree_root->children()[0];
loyso0940d412016-03-14 01:30:31350 layer_a->AddChild(MockLayer::Create(&layer_impl_destruction_list));
[email protected]c0dd24c2012-08-30 23:25:27351
vollick83fbfc82016-03-22 18:33:27352 scoped_refptr<Layer> layer_b = layer_a->children()[0];
loyso0940d412016-03-14 01:30:31353 layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list));
[email protected]c0dd24c2012-08-30 23:25:27354
vollick83fbfc82016-03-22 18:33:27355 scoped_refptr<Layer> layer_c = layer_b->children()[0];
loyso0940d412016-03-14 01:30:31356 layer_b->AddChild(MockLayer::Create(&layer_impl_destruction_list));
vollick83fbfc82016-03-22 18:33:27357 scoped_refptr<Layer> layer_d = layer_b->children()[1];
[email protected]c0dd24c2012-08-30 23:25:27358
[email protected]f4e25f92013-07-13 20:54:53359 host_->SetRootLayer(layer_tree_root);
360
vollick83fbfc82016-03-22 18:33:27361 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
362 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59363 LayerImpl* layer_impl_tree_root =
364 host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27365 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53366 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27367
[email protected]b5651c22013-03-14 15:06:33368 // We have to push properties to pick up the destruction list pointer.
jaydasika9234e402016-03-21 20:44:22369 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(),
370 host_->active_tree());
[email protected]5c4824e12013-01-12 16:34:53371
[email protected]b5651c22013-03-14 15:06:33372 // Now restructure the tree to look like this:
373 // root --- D ---+--- A
374 // |
375 // +--- C --- B
376 layer_tree_root->RemoveAllChildren();
377 layer_d->RemoveAllChildren();
378 layer_tree_root->AddChild(layer_d);
379 layer_a->RemoveAllChildren();
380 layer_d->AddChild(layer_a);
381 layer_c->RemoveAllChildren();
382 layer_d->AddChild(layer_c);
383 layer_b->RemoveAllChildren();
384 layer_c->AddChild(layer_b);
[email protected]c0dd24c2012-08-30 23:25:27385
[email protected]b5651c22013-03-14 15:06:33386 // After another synchronize our trees should match and we should not have
387 // destroyed any LayerImpls
vollick83fbfc82016-03-22 18:33:27388 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(),
389 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59390 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27391 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53392 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27393
[email protected]b5651c22013-03-14 15:06:33394 EXPECT_EQ(0u, layer_impl_destruction_list.size());
vollick83fbfc82016-03-22 18:33:27395
rockot2176f922016-06-08 19:18:32396 host_->active_tree()->DetachLayers();
[email protected]c0dd24c2012-08-30 23:25:27397}
398
[email protected]b5651c22013-03-14 15:06:33399// Constructs a very simple tree, synchronizes it, then synchronizes to a
400// totally new tree. All layers from the old tree should be deleted.
401TEST_F(TreeSynchronizerTest, SyncSimpleTreeThenDestroy) {
402 std::vector<int> layer_impl_destruction_list;
[email protected]c0dd24c2012-08-30 23:25:27403
[email protected]b5651c22013-03-14 15:06:33404 scoped_refptr<Layer> old_layer_tree_root =
loyso0940d412016-03-14 01:30:31405 MockLayer::Create(&layer_impl_destruction_list);
[email protected]b5651c22013-03-14 15:06:33406 old_layer_tree_root->AddChild(
loyso0940d412016-03-14 01:30:31407 MockLayer::Create(&layer_impl_destruction_list));
[email protected]b5651c22013-03-14 15:06:33408 old_layer_tree_root->AddChild(
loyso0940d412016-03-14 01:30:31409 MockLayer::Create(&layer_impl_destruction_list));
[email protected]c0dd24c2012-08-30 23:25:27410
[email protected]f4e25f92013-07-13 20:54:53411 host_->SetRootLayer(old_layer_tree_root);
412
[email protected]b5651c22013-03-14 15:06:33413 int old_tree_root_layer_id = old_layer_tree_root->id();
414 int old_tree_first_child_layer_id = old_layer_tree_root->children()[0]->id();
415 int old_tree_second_child_layer_id = old_layer_tree_root->children()[1]->id();
[email protected]c0dd24c2012-08-30 23:25:27416
vollick83fbfc82016-03-22 18:33:27417 TreeSynchronizer::SynchronizeTrees(old_layer_tree_root.get(),
418 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59419 LayerImpl* layer_impl_tree_root =
420 host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27421 ExpectTreesAreIdentical(old_layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53422 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27423
[email protected]b5651c22013-03-14 15:06:33424 // We have to push properties to pick up the destruction list pointer.
jaydasika9234e402016-03-21 20:44:22425 TreeSynchronizer::PushLayerProperties(old_layer_tree_root->layer_tree_host(),
426 host_->active_tree());
[email protected]5c4824e12013-01-12 16:34:53427
[email protected]b5651c22013-03-14 15:06:33428 // Remove all children on the Layer side.
429 old_layer_tree_root->RemoveAllChildren();
[email protected]c0dd24c2012-08-30 23:25:27430
[email protected]b5651c22013-03-14 15:06:33431 // Synchronize again. After the sync all LayerImpls from the old tree should
432 // be deleted.
loyso0940d412016-03-14 01:30:31433 scoped_refptr<Layer> new_layer_tree_root = Layer::Create();
[email protected]f4e25f92013-07-13 20:54:53434 host_->SetRootLayer(new_layer_tree_root);
vollick83fbfc82016-03-22 18:33:27435
436 TreeSynchronizer::SynchronizeTrees(new_layer_tree_root.get(),
437 host_->active_tree());
jaydasikabf1875a2016-06-28 03:39:59438 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27439 ExpectTreesAreIdentical(new_layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53440 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27441
[email protected]b5651c22013-03-14 15:06:33442 ASSERT_EQ(3u, layer_impl_destruction_list.size());
[email protected]2cdbdba2012-10-28 13:15:05443
[email protected]b5651c22013-03-14 15:06:33444 EXPECT_TRUE(std::find(layer_impl_destruction_list.begin(),
445 layer_impl_destruction_list.end(),
446 old_tree_root_layer_id) !=
447 layer_impl_destruction_list.end());
448 EXPECT_TRUE(std::find(layer_impl_destruction_list.begin(),
449 layer_impl_destruction_list.end(),
450 old_tree_first_child_layer_id) !=
451 layer_impl_destruction_list.end());
452 EXPECT_TRUE(std::find(layer_impl_destruction_list.begin(),
453 layer_impl_destruction_list.end(),
454 old_tree_second_child_layer_id) !=
455 layer_impl_destruction_list.end());
[email protected]c0dd24c2012-08-30 23:25:27456}
457
458// Constructs+syncs a tree with mask, replica, and replica mask layers.
[email protected]b5651c22013-03-14 15:06:33459TEST_F(TreeSynchronizerTest, SyncMaskReplicaAndReplicaMaskLayers) {
loyso0940d412016-03-14 01:30:31460 scoped_refptr<Layer> layer_tree_root = Layer::Create();
461 layer_tree_root->AddChild(Layer::Create());
462 layer_tree_root->AddChild(Layer::Create());
463 layer_tree_root->AddChild(Layer::Create());
[email protected]c0dd24c2012-08-30 23:25:27464
[email protected]b5651c22013-03-14 15:06:33465 // First child gets a mask layer.
loyso0940d412016-03-14 01:30:31466 scoped_refptr<Layer> mask_layer = Layer::Create();
[email protected]b5651c22013-03-14 15:06:33467 layer_tree_root->children()[0]->SetMaskLayer(mask_layer.get());
[email protected]c0dd24c2012-08-30 23:25:27468
[email protected]b5651c22013-03-14 15:06:33469 // Second child gets a replica layer.
loyso0940d412016-03-14 01:30:31470 scoped_refptr<Layer> replica_layer = Layer::Create();
[email protected]b5651c22013-03-14 15:06:33471 layer_tree_root->children()[1]->SetReplicaLayer(replica_layer.get());
[email protected]c0dd24c2012-08-30 23:25:27472
[email protected]b5651c22013-03-14 15:06:33473 // Third child gets a replica layer with a mask layer.
loyso0940d412016-03-14 01:30:31474 scoped_refptr<Layer> replica_layer_with_mask = Layer::Create();
475 scoped_refptr<Layer> replica_mask_layer = Layer::Create();
[email protected]b5651c22013-03-14 15:06:33476 replica_layer_with_mask->SetMaskLayer(replica_mask_layer.get());
vollick83fbfc82016-03-22 18:33:27477 layer_tree_root->children()[2]->SetReplicaLayer(
478 replica_layer_with_mask.get());
[email protected]c0dd24c2012-08-30 23:25:27479
[email protected]f4e25f92013-07-13 20:54:53480 host_->SetRootLayer(layer_tree_root);
ajuma1d4026a32016-06-14 13:18:50481 host_->BuildPropertyTreesForTesting();
482 host_->CommitAndCreateLayerImplTree();
[email protected]f4e25f92013-07-13 20:54:53483
jaydasikabf1875a2016-06-28 03:39:59484 LayerImpl* layer_impl_tree_root =
485 host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27486 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53487 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27488
[email protected]b5651c22013-03-14 15:06:33489 // Remove the mask layer.
490 layer_tree_root->children()[0]->SetMaskLayer(NULL);
ajuma1d4026a32016-06-14 13:18:50491 host_->BuildPropertyTreesForTesting();
492 host_->CommitAndCreateLayerImplTree();
493
jaydasikabf1875a2016-06-28 03:39:59494 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27495 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53496 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27497
[email protected]b5651c22013-03-14 15:06:33498 // Remove the replica layer.
499 layer_tree_root->children()[1]->SetReplicaLayer(NULL);
ajuma1d4026a32016-06-14 13:18:50500 host_->BuildPropertyTreesForTesting();
501 host_->CommitAndCreateLayerImplTree();
502
jaydasikabf1875a2016-06-28 03:39:59503 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27504 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53505 host_->active_tree());
[email protected]c0dd24c2012-08-30 23:25:27506
[email protected]b5651c22013-03-14 15:06:33507 // Remove the replica mask.
508 replica_layer_with_mask->SetMaskLayer(NULL);
ajuma1d4026a32016-06-14 13:18:50509 host_->BuildPropertyTreesForTesting();
510 host_->CommitAndCreateLayerImplTree();
511
jaydasikabf1875a2016-06-28 03:39:59512 layer_impl_tree_root = host_->active_tree()->root_layer_for_testing();
vollick83fbfc82016-03-22 18:33:27513 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root,
[email protected]f4e25f92013-07-13 20:54:53514 host_->active_tree());
vollick83fbfc82016-03-22 18:33:27515
rockot2176f922016-06-08 19:18:32516 host_->active_tree()->DetachLayers();
[email protected]c0dd24c2012-08-30 23:25:27517}
518
sunxd54e08e9d2016-02-22 23:01:28519TEST_F(TreeSynchronizerTest, SynchronizeCurrentlyScrollingNode) {
520 LayerTreeSettings settings;
521 FakeLayerTreeHostImplClient client;
522 FakeImplTaskRunnerProvider task_runner_provider;
523 FakeRenderingStatsInstrumentation stats_instrumentation;
524 TestSharedBitmapManager shared_bitmap_manager;
525 TestTaskGraphRunner task_graph_runner;
526 FakeLayerTreeHostImpl* host_impl = host_->host_impl();
527 host_impl->CreatePendingTree();
528
loyso0940d412016-03-14 01:30:31529 scoped_refptr<Layer> layer_tree_root = Layer::Create();
530 scoped_refptr<Layer> scroll_clip_layer = Layer::Create();
531 scoped_refptr<Layer> scroll_layer = Layer::Create();
532 scoped_refptr<Layer> transient_scroll_clip_layer = Layer::Create();
533 scoped_refptr<Layer> transient_scroll_layer = Layer::Create();
sunxd54e08e9d2016-02-22 23:01:28534
535 layer_tree_root->AddChild(transient_scroll_clip_layer);
536 transient_scroll_clip_layer->AddChild(transient_scroll_layer);
537 transient_scroll_layer->AddChild(scroll_clip_layer);
538 scroll_clip_layer->AddChild(scroll_layer);
539
540 transient_scroll_layer->SetScrollClipLayerId(
541 transient_scroll_clip_layer->id());
542 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id());
543 host_->SetRootLayer(layer_tree_root);
544 host_->BuildPropertyTreesForTesting();
545 host_->CommitAndCreatePendingTree();
546 host_impl->ActivateSyncTree();
547
548 ExpectTreesAreIdentical(layer_tree_root.get(),
jaydasikabf1875a2016-06-28 03:39:59549 host_impl->active_tree()->root_layer_for_testing(),
sunxd54e08e9d2016-02-22 23:01:28550 host_impl->active_tree());
551
552 host_impl->active_tree()->SetCurrentlyScrollingLayer(
vollickcb3f6b12016-03-01 23:44:10553 host_impl->active_tree()->LayerById(scroll_layer->id()));
sunxd54e08e9d2016-02-22 23:01:28554 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID);
555 host_->BuildPropertyTreesForTesting();
556
557 host_impl->CreatePendingTree();
558 host_->CommitAndCreatePendingTree();
559 host_impl->ActivateSyncTree();
560
561 EXPECT_EQ(scroll_layer->id(),
562 host_impl->active_tree()->CurrentlyScrollingLayer()->id());
563}
564
sunxdc36713a2016-03-03 22:31:10565TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) {
danakjffc181a2016-07-22 22:48:43566 host_->InitializeSingleThreaded(&single_thread_client_,
567 base::ThreadTaskRunnerHandle::Get(), nullptr);
sunxdc36713a2016-03-03 22:31:10568 LayerTreeSettings settings;
569 FakeLayerTreeHostImplClient client;
570 FakeImplTaskRunnerProvider task_runner_provider;
571 FakeRenderingStatsInstrumentation stats_instrumentation;
572 TestSharedBitmapManager shared_bitmap_manager;
573 TestTaskGraphRunner task_graph_runner;
574 FakeLayerTreeHostImpl* host_impl = host_->host_impl();
575 host_impl->CreatePendingTree();
576
loyso0940d412016-03-14 01:30:31577 scoped_refptr<Layer> layer_tree_root = Layer::Create();
578 scoped_refptr<Layer> scroll_clip_layer = Layer::Create();
579 scoped_refptr<Layer> scroll_layer = Layer::Create();
580 scoped_refptr<Layer> transient_scroll_clip_layer = Layer::Create();
581 scoped_refptr<Layer> transient_scroll_layer = Layer::Create();
sunxdc36713a2016-03-03 22:31:10582
583 layer_tree_root->AddChild(transient_scroll_clip_layer);
584 transient_scroll_clip_layer->AddChild(transient_scroll_layer);
585 transient_scroll_layer->AddChild(scroll_clip_layer);
586 scroll_clip_layer->AddChild(scroll_layer);
587
588 transient_scroll_layer->SetScrollClipLayerId(
589 transient_scroll_clip_layer->id());
590 scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id());
591 transient_scroll_layer->SetScrollOffset(gfx::ScrollOffset(1, 2));
592 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
593
594 host_->SetRootLayer(layer_tree_root);
595 host_->BuildPropertyTreesForTesting();
596 host_->CommitAndCreatePendingTree();
597 host_impl->ActivateSyncTree();
598
599 ExpectTreesAreIdentical(layer_tree_root.get(),
jaydasikabf1875a2016-06-28 03:39:59600 host_impl->active_tree()->root_layer_for_testing(),
sunxdc36713a2016-03-03 22:31:10601 host_impl->active_tree());
602
603 // After the initial commit, scroll_offset_map in scroll_tree is expected to
604 // have one entry for scroll_layer and one entry for transient_scroll_layer,
605 // the pending base and active base must be the same at this stage.
606 ScrollTree::ScrollOffsetMap scroll_offset_map;
607 scroll_offset_map[scroll_layer->id()] = new SyncedScrollOffset;
608 scroll_offset_map[transient_scroll_layer->id()] = new SyncedScrollOffset;
609 scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
610 scroll_layer->scroll_offset());
611 scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
612 scroll_offset_map[transient_scroll_layer->id()]->PushFromMainThread(
613 transient_scroll_layer->scroll_offset());
614 scroll_offset_map[transient_scroll_layer->id()]->PushPendingToActive();
615 EXPECT_TRUE(
616 is_equal(scroll_offset_map, host_impl->active_tree()
617 ->property_trees()
618 ->scroll_tree.scroll_offset_map()));
619
620 // Set ScrollOffset active delta: gfx::ScrollOffset(10, 10)
621 LayerImpl* scroll_layer_impl =
622 host_impl->active_tree()->LayerById(scroll_layer->id());
623 ScrollTree& scroll_tree =
624 host_impl->active_tree()->property_trees()->scroll_tree;
sunxdc044b11a2016-03-16 16:23:20625 scroll_tree.SetScrollOffset(scroll_layer_impl->id(),
626 gfx::ScrollOffset(20, 30));
sunxdc36713a2016-03-03 22:31:10627
628 // Pull ScrollOffset delta for main thread, and change offset on main thread
danakj60bc3bc2016-04-09 00:24:48629 std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet());
bokan4222c272016-07-18 17:24:54630 scroll_tree.CollectScrollDeltas(scroll_info.get(), Layer::INVALID_ID);
sunxdc36713a2016-03-03 22:31:10631 host_->proxy()->SetNeedsCommit();
632 host_->ApplyScrollAndScale(scroll_info.get());
633 EXPECT_EQ(gfx::ScrollOffset(20, 30), scroll_layer->scroll_offset());
634 scroll_layer->SetScrollOffset(gfx::ScrollOffset(100, 100));
635
636 // More update to ScrollOffset active delta: gfx::ScrollOffset(20, 20)
sunxdc044b11a2016-03-16 16:23:20637 scroll_tree.SetScrollOffset(scroll_layer_impl->id(),
638 gfx::ScrollOffset(40, 50));
sunxdc36713a2016-03-03 22:31:10639 host_impl->active_tree()->SetCurrentlyScrollingLayer(scroll_layer_impl);
640
641 // Make one layer unscrollable so that scroll tree topology changes
642 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID);
643 host_->BuildPropertyTreesForTesting();
644
645 host_impl->CreatePendingTree();
646 host_->CommitAndCreatePendingTree();
647 host_impl->ActivateSyncTree();
648
649 EXPECT_EQ(scroll_layer->id(),
650 host_impl->active_tree()->CurrentlyScrollingLayer()->id());
651 scroll_offset_map.erase(transient_scroll_layer->id());
652 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(20, 30));
653 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread();
654 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50));
655 scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
656 gfx::ScrollOffset(100, 100));
657 scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
658 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map()));
659}
660
sunxdf468675e2016-06-30 23:56:18661TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) {
danakjffc181a2016-07-22 22:48:43662 host_->InitializeSingleThreaded(&single_thread_client_,
663 base::ThreadTaskRunnerHandle::Get(), nullptr);
sunxdf468675e2016-06-30 23:56:18664 LayerTreeSettings settings;
665 FakeLayerTreeHostImplClient client;
666 FakeImplTaskRunnerProvider task_runner_provider;
667 FakeRenderingStatsInstrumentation stats_instrumentation;
668 TestSharedBitmapManager shared_bitmap_manager;
669 TestTaskGraphRunner task_graph_runner;
670 FakeLayerTreeHostImpl* host_impl = host_->host_impl();
671 host_impl->CreatePendingTree();
672
673 scoped_refptr<Layer> layer_tree_root = Layer::Create();
674 scoped_refptr<Layer> transform_layer = Layer::Create();
675
676 gfx::Transform scale_transform;
677 scale_transform.Scale3d(2.f, 2.f, 2.f);
678 // Force adding a transform node for the layer.
679 transform_layer->SetTransform(scale_transform);
680
681 layer_tree_root->AddChild(transform_layer);
682
683 host_->SetRootLayer(layer_tree_root);
684 host_->BuildPropertyTreesForTesting();
685 host_->CommitAndCreatePendingTree();
686 host_impl->ActivateSyncTree();
687
688 // This arbitrarily set the animation scale for transform_layer and see if it
689 // is
690 // refreshed when pushing layer trees.
691 host_impl->active_tree()->property_trees()->SetAnimationScalesForTesting(
692 transform_layer->transform_tree_index(), 10.f, 10.f);
693 EXPECT_EQ(
694 CombinedAnimationScale(10.f, 10.f),
695 host_impl->active_tree()->property_trees()->GetAnimationScales(
696 transform_layer->transform_tree_index(), host_impl->active_tree()));
697
698 host_impl->CreatePendingTree();
699 host_->CommitAndCreatePendingTree();
700 host_impl->ActivateSyncTree();
701 EXPECT_EQ(
702 CombinedAnimationScale(0.f, 0.f),
703 host_impl->active_tree()->property_trees()->GetAnimationScales(
704 transform_layer->transform_tree_index(), host_impl->active_tree()));
705}
706
[email protected]ba565742012-11-10 09:29:48707} // namespace
708} // namespace cc