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

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

Issue 2041193005: [compositorworker] compositor proxy mutation updates underlying layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor-worker-upstream-registration
Patch Set: raise if not initialized Created 4 years, 6 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 "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "cc/test/fake_impl_task_runner_provider.h" 8 #include "cc/test/fake_impl_task_runner_provider.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/fake_output_surface.h" 10 #include "cc/test/fake_output_surface.h"
11 #include "cc/test/test_shared_bitmap_manager.h" 11 #include "cc/test/test_shared_bitmap_manager.h"
12 #include "cc/test/test_task_graph_runner.h" 12 #include "cc/test/test_task_graph_runner.h"
13 #include "cc/trees/layer_tree_host_impl.h" 13 #include "cc/trees/layer_tree_host_impl.h"
14 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
15 #include "platform/graphics/CompositorMutableProperties.h" 15 #include "platform/graphics/CompositorMutableProperties.h"
16 #include "platform/graphics/CompositorMutableStateProvider.h" 16 #include "platform/graphics/CompositorMutableStateProvider.h"
17 #include "platform/graphics/CompositorMutation.h" 17 #include "platform/graphics/CompositorMutation.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "wtf/OwnPtr.h" 19
20 #include <memory>
20 21
21 namespace blink { 22 namespace blink {
22 23
23 using cc::FakeImplTaskRunnerProvider; 24 using cc::FakeImplTaskRunnerProvider;
24 using cc::FakeLayerTreeHostImpl; 25 using cc::FakeLayerTreeHostImpl;
25 using cc::FakeOutputSurface; 26 using cc::FakeOutputSurface;
26 using cc::LayerImpl; 27 using cc::LayerImpl;
27 using cc::LayerTreeSettings; 28 using cc::LayerTreeSettings;
28 using cc::OutputSurface; 29 using cc::OutputSurface;
29 using cc::TestTaskGraphRunner; 30 using cc::TestTaskGraphRunner;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // properties. We should not be able to get any mutable state. 73 // properties. We should not be able to get any mutable state.
73 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree() , 42); 74 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree() , 42);
74 SetLayerPropertiesForTesting(root.get()); 75 SetLayerPropertiesForTesting(root.get());
75 76
76 hostImpl().SetViewportSize(root->bounds()); 77 hostImpl().SetViewportSize(root->bounds());
77 hostImpl().active_tree()->SetRootLayer(std::move(root)); 78 hostImpl().active_tree()->SetRootLayer(std::move(root));
78 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 79 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
79 80
80 CompositorMutations mutations; 81 CompositorMutations mutations;
81 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations ); 82 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations );
82 OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42)); 83 std::unique_ptr<CompositorMutableState> state(provider.getMutableStateFor(42 ));
83 EXPECT_FALSE(state); 84 EXPECT_FALSE(state);
84 } 85 }
85 86
86 TEST_F(CompositorMutableStateTest, MutableStateNoMutableProperties) 87 TEST_F(CompositorMutableStateTest, MutableStateNoMutableProperties)
87 { 88 {
88 // In this test, there is a layer with an element id, but no mutable 89 // In this test, there is a layer with an element id, but no mutable
89 // properties. This should behave just as if we'd had no element id. 90 // properties. This should behave just as if we'd had no element id.
90 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree() , 42); 91 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree() , 42);
91 SetLayerPropertiesForTesting(root.get()); 92 SetLayerPropertiesForTesting(root.get());
92 root->SetElementId(42); 93 root->SetElementId(42);
93 94
94 hostImpl().SetViewportSize(root->bounds()); 95 hostImpl().SetViewportSize(root->bounds());
95 hostImpl().active_tree()->SetRootLayer(std::move(root)); 96 hostImpl().active_tree()->SetRootLayer(std::move(root));
96 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 97 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
97 98
98 CompositorMutations mutations; 99 CompositorMutations mutations;
99 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations ); 100 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations );
100 OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42)); 101 std::unique_ptr<CompositorMutableState> state(provider.getMutableStateFor(42 ));
101 EXPECT_FALSE(state); 102 EXPECT_FALSE(state);
102 } 103 }
103 104
104 TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) 105 TEST_F(CompositorMutableStateTest, MutableStateMutableProperties)
105 { 106 {
106 // In this test, there is a layer with an element id and mutable properties. 107 // In this test, there is a layer with an element id and mutable properties.
107 // In this case, we should get a valid mutable state for this element id tha t 108 // In this case, we should get a valid mutable state for this element id tha t
108 // has a real effect on the corresponding layer. 109 // has a real effect on the corresponding layer.
109 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree() , 42); 110 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree() , 42);
110 111
(...skipping 11 matching lines...) Expand all
122 root->SetMutableProperties(CompositorMutableProperty::kOpacity | CompositorM utableProperty::kTransform); 123 root->SetMutableProperties(CompositorMutableProperty::kOpacity | CompositorM utableProperty::kTransform);
123 layer->SetMutableProperties(CompositorMutableProperty::kScrollLeft | Composi torMutableProperty::kScrollTop); 124 layer->SetMutableProperties(CompositorMutableProperty::kScrollLeft | Composi torMutableProperty::kScrollTop);
124 125
125 hostImpl().SetViewportSize(layer->bounds()); 126 hostImpl().SetViewportSize(layer->bounds());
126 hostImpl().active_tree()->SetRootLayer(std::move(root)); 127 hostImpl().active_tree()->SetRootLayer(std::move(root));
127 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 128 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
128 129
129 CompositorMutations mutations; 130 CompositorMutations mutations;
130 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations ); 131 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations );
131 132
132 OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(layer->elem ent_id())); 133 std::unique_ptr<CompositorMutableState> state(provider.getMutableStateFor(la yer->element_id()));
133 EXPECT_TRUE(state.get()); 134 EXPECT_TRUE(state.get());
134 135
135 EXPECT_EQ(1.0, rootLayer()->Opacity()); 136 EXPECT_EQ(1.0, rootLayer()->Opacity());
136 EXPECT_EQ(gfx::Transform().ToString(), rootLayer()->transform().ToString()); 137 EXPECT_EQ(gfx::Transform().ToString(), rootLayer()->transform().ToString());
137 EXPECT_EQ(0.0, layer->CurrentScrollOffset().x()); 138 EXPECT_EQ(0.0, layer->CurrentScrollOffset().x());
138 EXPECT_EQ(0.0, layer->CurrentScrollOffset().y()); 139 EXPECT_EQ(0.0, layer->CurrentScrollOffset().y());
139 140
140 gfx::Transform zero(0, 0, 0, 0, 0, 0); 141 gfx::Transform zero(0, 0, 0, 0, 0, 0);
141 state->setOpacity(0.5); 142 state->setOpacity(0.5);
142 state->setTransform(zero.matrix()); 143 state->setTransform(zero.matrix());
(...skipping 14 matching lines...) Expand all
157 EXPECT_TRUE(mutation.isScrollLeftMutated()); 158 EXPECT_TRUE(mutation.isScrollLeftMutated());
158 EXPECT_TRUE(mutation.isScrollTopMutated()); 159 EXPECT_TRUE(mutation.isScrollTopMutated());
159 160
160 EXPECT_EQ(0.5, mutation.opacity()); 161 EXPECT_EQ(0.5, mutation.opacity());
161 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString()); 162 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString());
162 EXPECT_EQ(1.0, mutation.scrollLeft()); 163 EXPECT_EQ(1.0, mutation.scrollLeft());
163 EXPECT_EQ(1.0, mutation.scrollTop()); 164 EXPECT_EQ(1.0, mutation.scrollTop());
164 } 165 }
165 166
166 } // namespace blink 167 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698