Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp

Issue 2866733002: Remove owning_id from EffectNode and replace it by an opaque stable_id (Closed)
Patch Set: none Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/CompositorMutableState.h" 5 #include "platform/graphics/CompositorMutableState.h"
6 6
7 #include <memory>
7 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
8 #include "cc/test/fake_compositor_frame_sink.h" 9 #include "cc/test/fake_compositor_frame_sink.h"
9 #include "cc/test/fake_impl_task_runner_provider.h" 10 #include "cc/test/fake_impl_task_runner_provider.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 11 #include "cc/test/fake_layer_tree_host_impl.h"
11 #include "cc/test/test_shared_bitmap_manager.h" 12 #include "cc/test/test_shared_bitmap_manager.h"
12 #include "cc/test/test_task_graph_runner.h" 13 #include "cc/test/test_task_graph_runner.h"
14 #include "cc/trees/effect_node.h"
13 #include "cc/trees/layer_tree_host_impl.h" 15 #include "cc/trees/layer_tree_host_impl.h"
14 #include "cc/trees/layer_tree_impl.h" 16 #include "cc/trees/layer_tree_impl.h"
15 #include "platform/graphics/CompositorElementId.h" 17 #include "platform/graphics/CompositorElementId.h"
16 #include "platform/graphics/CompositorMutableProperties.h" 18 #include "platform/graphics/CompositorMutableProperties.h"
17 #include "platform/graphics/CompositorMutableStateProvider.h" 19 #include "platform/graphics/CompositorMutableStateProvider.h"
18 #include "platform/graphics/CompositorMutation.h" 20 #include "platform/graphics/CompositorMutation.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 #include <memory>
21 22
22 namespace blink { 23 namespace blink {
23 24
24 using cc::FakeImplTaskRunnerProvider; 25 using cc::FakeImplTaskRunnerProvider;
25 using cc::FakeLayerTreeHostImpl; 26 using cc::FakeLayerTreeHostImpl;
26 using cc::FakeCompositorFrameSink; 27 using cc::FakeCompositorFrameSink;
27 using cc::LayerImpl; 28 using cc::LayerImpl;
28 using cc::LayerTreeSettings; 29 using cc::LayerTreeSettings;
29 using cc::TestTaskGraphRunner; 30 using cc::TestTaskGraphRunner;
30 using cc::TestSharedBitmapManager; 31 using cc::TestSharedBitmapManager;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 HostImpl().active_tree()->SetRootLayerForTesting(std::move(root)); 77 HostImpl().active_tree()->SetRootLayerForTesting(std::move(root));
77 HostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 78 HostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
78 79
79 CompositorMutations mutations; 80 CompositorMutations mutations;
80 CompositorMutableStateProvider provider(HostImpl().active_tree(), &mutations); 81 CompositorMutableStateProvider provider(HostImpl().active_tree(), &mutations);
81 std::unique_ptr<CompositorMutableState> state( 82 std::unique_ptr<CompositorMutableState> state(
82 provider.GetMutableStateFor(42)); 83 provider.GetMutableStateFor(42));
83 EXPECT_FALSE(state); 84 EXPECT_FALSE(state);
84 } 85 }
85 86
87 float OpacityForLayer(LayerImpl* layer_impl) {
88 return layer_impl->layer_tree_impl()
89 ->property_trees()
90 ->effect_tree.Node(layer_impl->effect_tree_index())
91 ->opacity;
92 }
93
86 TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) { 94 TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) {
87 // In this test, there is a layer with an element id and mutable properties. 95 // In this test, there is a layer with an element id and mutable properties.
88 // In this case, we should get a valid mutable state for this element id that 96 // In this case, we should get a valid mutable state for this element id that
89 // has a real effect on the corresponding layer. 97 // has a real effect on the corresponding layer.
90 std::unique_ptr<LayerImpl> root = 98 std::unique_ptr<LayerImpl> root =
91 LayerImpl::Create(HostImpl().active_tree(), 42); 99 LayerImpl::Create(HostImpl().active_tree(), 42);
92 100
93 std::unique_ptr<LayerImpl> scoped_layer = 101 std::unique_ptr<LayerImpl> scoped_layer =
94 LayerImpl::Create(HostImpl().active_tree(), 11); 102 LayerImpl::Create(HostImpl().active_tree(), 11);
95 LayerImpl* layer = scoped_layer.get(); 103 LayerImpl* layer = scoped_layer.get();
(...skipping 18 matching lines...) Expand all
114 HostImpl().active_tree()->SetRootLayerForTesting(std::move(root)); 122 HostImpl().active_tree()->SetRootLayerForTesting(std::move(root));
115 HostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 123 HostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
116 124
117 CompositorMutations mutations; 125 CompositorMutations mutations;
118 CompositorMutableStateProvider provider(HostImpl().active_tree(), &mutations); 126 CompositorMutableStateProvider provider(HostImpl().active_tree(), &mutations);
119 127
120 std::unique_ptr<CompositorMutableState> state( 128 std::unique_ptr<CompositorMutableState> state(
121 provider.GetMutableStateFor(primary_id)); 129 provider.GetMutableStateFor(primary_id));
122 EXPECT_TRUE(state.get()); 130 EXPECT_TRUE(state.get());
123 131
124 EXPECT_EQ(1.0, RootLayer()->Opacity()); 132 EXPECT_EQ(1.0, OpacityForLayer(RootLayer()));
125 EXPECT_EQ(gfx::Transform().ToString(), RootLayer()->Transform().ToString()); 133 EXPECT_EQ(gfx::Transform().ToString(), RootLayer()->Transform().ToString());
126 EXPECT_EQ(0.0, layer->CurrentScrollOffset().x()); 134 EXPECT_EQ(0.0, layer->CurrentScrollOffset().x());
127 EXPECT_EQ(0.0, layer->CurrentScrollOffset().y()); 135 EXPECT_EQ(0.0, layer->CurrentScrollOffset().y());
128 136
129 gfx::Transform zero(0, 0, 0, 0, 0, 0); 137 gfx::Transform zero(0, 0, 0, 0, 0, 0);
130 state->SetOpacity(0.5); 138 state->SetOpacity(0.5);
131 state->SetTransform(zero.matrix()); 139 state->SetTransform(zero.matrix());
132 state->SetScrollLeft(1.0); 140 state->SetScrollLeft(1.0);
133 state->SetScrollTop(1.0); 141 state->SetScrollTop(1.0);
134 142
135 EXPECT_EQ(0.5, RootLayer()->Opacity()); 143 EXPECT_EQ(0.5, OpacityForLayer(RootLayer()));
136 EXPECT_EQ(zero.ToString(), RootLayer()->Transform().ToString()); 144 EXPECT_EQ(zero.ToString(), RootLayer()->Transform().ToString());
137 EXPECT_EQ(1.0, layer->CurrentScrollOffset().x()); 145 EXPECT_EQ(1.0, layer->CurrentScrollOffset().x());
138 EXPECT_EQ(1.0, layer->CurrentScrollOffset().y()); 146 EXPECT_EQ(1.0, layer->CurrentScrollOffset().y());
139 147
140 // The corresponding mutation should reflect the changed values. 148 // The corresponding mutation should reflect the changed values.
141 EXPECT_EQ(1ul, mutations.map.size()); 149 EXPECT_EQ(1ul, mutations.map.size());
142 150
143 const CompositorMutation& mutation = *mutations.map.find(primary_id)->value; 151 const CompositorMutation& mutation = *mutations.map.find(primary_id)->value;
144 EXPECT_TRUE(mutation.IsOpacityMutated()); 152 EXPECT_TRUE(mutation.IsOpacityMutated());
145 EXPECT_TRUE(mutation.IsTransformMutated()); 153 EXPECT_TRUE(mutation.IsTransformMutated());
146 EXPECT_TRUE(mutation.IsScrollLeftMutated()); 154 EXPECT_TRUE(mutation.IsScrollLeftMutated());
147 EXPECT_TRUE(mutation.IsScrollTopMutated()); 155 EXPECT_TRUE(mutation.IsScrollTopMutated());
148 156
149 EXPECT_EQ(0.5, mutation.Opacity()); 157 EXPECT_EQ(0.5, mutation.Opacity());
150 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.Transform()).ToString()); 158 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.Transform()).ToString());
151 EXPECT_EQ(1.0, mutation.ScrollLeft()); 159 EXPECT_EQ(1.0, mutation.ScrollLeft());
152 EXPECT_EQ(1.0, mutation.ScrollTop()); 160 EXPECT_EQ(1.0, mutation.ScrollTop());
153 } 161 }
154 162
155 } // namespace blink 163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698