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

Side by Side Diff: cc/layers/layer_impl_unittest.cc

Issue 2254543004: cc : Delete LayerImpl::transform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use test properties transform Created 4 years, 4 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
« no previous file with comments | « cc/layers/layer_impl_test_properties.h ('k') | cc/layers/layer_utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "cc/animation/mutable_properties.h" 7 #include "cc/animation/mutable_properties.h"
8 #include "cc/layers/painted_scrollbar_layer_impl.h" 8 #include "cc/layers/painted_scrollbar_layer_impl.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
10 #include "cc/output/filter_operation.h" 10 #include "cc/output/filter_operation.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 EXPECT_TRUE( \ 59 EXPECT_TRUE( \
60 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ 60 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \
61 EXPECT_FALSE( \ 61 EXPECT_FALSE( \
62 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ 62 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \
63 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ 63 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \
64 grand_child)); \ 64 grand_child)); \
65 EXPECT_FALSE(root->LayerPropertyChanged()); \ 65 EXPECT_FALSE(root->LayerPropertyChanged()); \
66 EXPECT_FALSE(child->LayerPropertyChanged()); \ 66 EXPECT_FALSE(child->LayerPropertyChanged()); \
67 EXPECT_FALSE(grand_child->LayerPropertyChanged()); 67 EXPECT_FALSE(grand_child->LayerPropertyChanged());
68 68
69 #define EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED( \
70 code_to_test) \
71 root->layer_tree_impl()->ResetAllChangeTracking(); \
72 code_to_test; \
73 EXPECT_FALSE( \
74 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \
75 EXPECT_FALSE( \
76 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \
77 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \
78 grand_child)); \
79 EXPECT_TRUE(root->LayerPropertyChanged()); \
80 EXPECT_TRUE(child->LayerPropertyChanged()); \
81 EXPECT_TRUE(grand_child->LayerPropertyChanged());
82
69 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \ 83 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(code_to_test) \
70 root->layer_tree_impl()->ResetAllChangeTracking(); \ 84 root->layer_tree_impl()->ResetAllChangeTracking(); \
71 root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \ 85 root->layer_tree_impl()->property_trees()->full_tree_damaged = false; \
72 code_to_test; \ 86 code_to_test; \
73 EXPECT_TRUE( \ 87 EXPECT_TRUE( \
74 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \ 88 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(root)); \
75 EXPECT_FALSE( \ 89 EXPECT_FALSE( \
76 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \ 90 root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting(child)); \
77 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \ 91 EXPECT_FALSE(root->layer_tree_impl()->LayerNeedsPushPropertiesForTesting( \
78 grand_child)); \ 92 grand_child)); \
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 root->SetUpdateRect(arbitrary_rect)); 177 root->SetUpdateRect(arbitrary_rect));
164 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); 178 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size));
165 host_impl.active_tree()->property_trees()->needs_rebuild = true; 179 host_impl.active_tree()->property_trees()->needs_rebuild = true;
166 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); 180 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
167 181
168 // Changing these properties affects the entire subtree of layers. 182 // Changing these properties affects the entire subtree of layers.
169 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->OnFilterAnimated(arbitrary_filters)); 183 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->OnFilterAnimated(arbitrary_filters));
170 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 184 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
171 root->OnFilterAnimated(FilterOperations())); 185 root->OnFilterAnimated(FilterOperations()));
172 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->OnOpacityAnimated(arbitrary_number)); 186 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->OnOpacityAnimated(arbitrary_number));
173 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 187 EXECUTE_AND_VERIFY_NO_NEED_TO_PUSH_PROPERTIES_AND_SUBTREE_CHANGED(
174 root->OnTransformAnimated(arbitrary_transform)); 188 root->OnTransformAnimated(arbitrary_transform));
175 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d); 189 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d);
176 root->SetNeedsPushProperties()); 190 root->SetNeedsPushProperties());
177 // SetBoundsDelta changes subtree only when masks_to_bounds is true and it 191 // SetBoundsDelta changes subtree only when masks_to_bounds is true and it
178 // doesn't set needs_push_properties as it is always called on active tree. 192 // doesn't set needs_push_properties as it is always called on active tree.
179 root->SetMasksToBounds(true); 193 root->SetMasksToBounds(true);
180 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBoundsDelta(arbitrary_vector2d); 194 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBoundsDelta(arbitrary_vector2d);
181 root->SetNeedsPushProperties()); 195 root->SetNeedsPushProperties());
182 196
183 // Changing these properties only affects the layer itself. 197 // Changing these properties only affects the layer itself.
(...skipping 20 matching lines...) Expand all
204 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 218 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
205 root->SetMutableProperties(MutableProperty::kOpacity); 219 root->SetMutableProperties(MutableProperty::kOpacity);
206 root->SetNeedsPushProperties()); 220 root->SetNeedsPushProperties());
207 221
208 // After setting all these properties already, setting to the exact same 222 // After setting all these properties already, setting to the exact same
209 // values again should not cause any change. 223 // values again should not cause any change.
210 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true)); 224 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true));
211 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 225 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
212 root->SetPosition(arbitrary_point_f)); 226 root->SetPosition(arbitrary_point_f));
213 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); 227 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1));
214 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
215 root->SetTransform(arbitrary_transform));
216 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); 228 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true));
217 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); 229 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true));
218 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size)); 230 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size));
219 } 231 }
220 232
221 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { 233 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) {
222 FakeImplTaskRunnerProvider task_runner_provider; 234 FakeImplTaskRunnerProvider task_runner_provider;
223 TestSharedBitmapManager shared_bitmap_manager; 235 TestSharedBitmapManager shared_bitmap_manager;
224 TestTaskGraphRunner task_graph_runner; 236 TestTaskGraphRunner task_graph_runner;
225 std::unique_ptr<OutputSurface> output_surface = 237 std::unique_ptr<OutputSurface> output_surface =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 332 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
321 layer->OnFilterAnimated(arbitrary_filters)); 333 layer->OnFilterAnimated(arbitrary_filters));
322 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); 334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true));
323 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); 335 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true));
324 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 336 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
325 layer2->SetPosition(arbitrary_point_f)); 337 layer2->SetPosition(arbitrary_point_f));
326 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1)); 338 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1));
327 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); 339 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
328 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 340 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
329 layer->SetBackgroundColor(arbitrary_color)); 341 layer->SetBackgroundColor(arbitrary_color));
330 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
331 layer->SetTransform(arbitrary_transform));
332 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); 342 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size));
333 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0))); 343 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0)));
334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 344 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
335 layer->SetMutableProperties(MutableProperty::kTransform)); 345 layer->SetMutableProperties(MutableProperty::kTransform));
336 } 346 }
337 347
338 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { 348 TEST(LayerImplTest, SafeOpaqueBackgroundColor) {
339 FakeImplTaskRunnerProvider task_runner_provider; 349 FakeImplTaskRunnerProvider task_runner_provider;
340 TestSharedBitmapManager shared_bitmap_manager; 350 TestSharedBitmapManager shared_bitmap_manager;
341 TestTaskGraphRunner task_graph_runner; 351 TestTaskGraphRunner task_graph_runner;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 566
557 pending_layer->PushPropertiesTo(layer()); 567 pending_layer->PushPropertiesTo(layer());
558 568
559 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 569 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
560 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 570 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
561 pending_layer->CurrentScrollOffset()); 571 pending_layer->CurrentScrollOffset());
562 } 572 }
563 573
564 } // namespace 574 } // namespace
565 } // namespace cc 575 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl_test_properties.h ('k') | cc/layers/layer_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698