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

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

Issue 1697613002: cc :: Move tracking of layer_property_changed to main thread (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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.cc ('k') | cc/layers/layer_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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // These properties are internal, and should not be considered "change" when 155 // These properties are internal, and should not be considered "change" when
156 // they are used. 156 // they are used.
157 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 157 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
158 root->SetUpdateRect(arbitrary_rect)); 158 root->SetUpdateRect(arbitrary_rect));
159 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); 159 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size));
160 host_impl.active_tree()->property_trees()->needs_rebuild = true; 160 host_impl.active_tree()->property_trees()->needs_rebuild = true;
161 host_impl.active_tree()->BuildPropertyTreesForTesting(); 161 host_impl.active_tree()->BuildPropertyTreesForTesting();
162 162
163 // Changing these properties affects the entire subtree of layers. 163 // Changing these properties affects the entire subtree of layers.
164 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
165 root->SetTransformOrigin(arbitrary_point_3f));
166 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); 164 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters));
167 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations())); 165 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations()));
168 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPosition(arbitrary_point_f));
169 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d)); 166 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->ScrollBy(arbitrary_vector2d));
170 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetScrollDelta(gfx::Vector2d())); 167 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetScrollDelta(gfx::Vector2d()));
171 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->PushScrollOffsetFromMainThread( 168 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->PushScrollOffsetFromMainThread(
172 gfx::ScrollOffset(arbitrary_vector2d))); 169 gfx::ScrollOffset(arbitrary_vector2d)));
173 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetOpacity(arbitrary_number)); 170 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetOpacity(arbitrary_number));
174 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetTransform(arbitrary_transform)); 171 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetTransform(arbitrary_transform));
175 172
176 // Changing these properties only affects the layer itself. 173 // Changing these properties only affects the layer itself.
177 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true)); 174 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true));
178 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 175 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
179 root->SetBackgroundColor(arbitrary_color)); 176 root->SetBackgroundColor(arbitrary_color));
180 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 177 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
181 root->SetBackgroundFilters(arbitrary_filters)); 178 root->SetBackgroundFilters(arbitrary_filters));
182 179
183 // Special case: check that SetBounds changes behavior depending on 180 // Special case: check that SetBounds changes behavior depending on
184 // masksToBounds. 181 // masksToBounds.
185 root->SetMasksToBounds(false); 182 root->SetMasksToBounds(false);
186 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(gfx::Size(135, 246))); 183 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(gfx::Size(135, 246)));
187 host_impl.active_tree()->property_trees()->needs_rebuild = true; 184 host_impl.active_tree()->property_trees()->needs_rebuild = true;
188 host_impl.active_tree()->BuildPropertyTreesForTesting(); 185 host_impl.active_tree()->BuildPropertyTreesForTesting();
189 186
190 root->SetMasksToBounds(true); 187 root->SetMasksToBounds(true);
191 // Should be a different size than previous call, to ensure it marks tree
192 // changed.
193 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBounds(arbitrary_size));
194 host_impl.active_tree()->property_trees()->needs_rebuild = true; 188 host_impl.active_tree()->property_trees()->needs_rebuild = true;
195 host_impl.active_tree()->BuildPropertyTreesForTesting(); 189 host_impl.active_tree()->BuildPropertyTreesForTesting();
196 190
197 // Changing these properties does not cause the layer to be marked as changed 191 // Changing these properties does not cause the layer to be marked as changed
198 // but does cause the layer to need to push properties. 192 // but does cause the layer to need to push properties.
199 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 193 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
200 root->SetIsRootForIsolatedGroup(true)); 194 root->SetIsRootForIsolatedGroup(true));
201 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 195 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
202 root->SetElementId(2)); 196 root->SetElementId(2));
203 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 197 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)); 329 layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4));
336 layer->NoteLayerPropertyChanged()); 330 layer->NoteLayerPropertyChanged());
337 host_impl.active_tree()->BuildPropertyTreesForTesting(); 331 host_impl.active_tree()->BuildPropertyTreesForTesting();
338 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true); 332 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true);
339 layer->NoteLayerPropertyChanged()); 333 layer->NoteLayerPropertyChanged());
340 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true); 334 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true);
341 layer->NoteLayerPropertyChanged()); 335 layer->NoteLayerPropertyChanged());
342 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 336 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
343 layer->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5)); 337 layer->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5));
344 layer->NoteLayerPropertyChanged()); 338 layer->NoteLayerPropertyChanged());
345 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f)); 339 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f);
340 layer->NoteLayerPropertyChanged());
346 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetShouldFlattenTransform(false); 341 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetShouldFlattenTransform(false);
347 layer->NoteLayerPropertyChanged()); 342 layer->NoteLayerPropertyChanged());
348 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1); 343 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1);
349 layer->NoteLayerPropertyChanged()); 344 layer->NoteLayerPropertyChanged());
350 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 345 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
351 layer->SetDoubleSided(false); // constructor initializes it to "true". 346 layer->SetDoubleSided(false); // constructor initializes it to "true".
352 layer->NoteLayerPropertyChanged()); 347 layer->NoteLayerPropertyChanged());
353 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 348 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
354 layer->SetBackgroundColor(arbitrary_color)); 349 layer->SetBackgroundColor(arbitrary_color));
355 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 350 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
356 layer->SetBackgroundFilters(arbitrary_filters)); 351 layer->SetBackgroundFilters(arbitrary_filters));
357 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetOpacity(arbitrary_number)); 352 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetOpacity(arbitrary_number));
358 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBlendMode(arbitrary_blend_mode); 353 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBlendMode(arbitrary_blend_mode);
359 layer->NoteLayerPropertyChanged()); 354 layer->NoteLayerPropertyChanged());
360 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetTransform(arbitrary_transform)); 355 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetTransform(arbitrary_transform));
361 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); 356 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size);
357 layer->NoteLayerPropertyChanged());
362 358
363 // Unrelated functions, set to the same values, no needs update. 359 // Unrelated functions, set to the same values, no needs update.
364 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 360 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
365 layer->SetIsRootForIsolatedGroup(true)); 361 layer->SetIsRootForIsolatedGroup(true));
366 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 362 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters));
367 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); 363 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true));
368 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); 364 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true));
369 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 365 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
370 layer2->SetPosition(arbitrary_point_f)); 366 layer2->SetPosition(arbitrary_point_f));
371 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1)); 367 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 598
603 pending_layer->PushPropertiesTo(layer()); 599 pending_layer->PushPropertiesTo(layer());
604 600
605 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 601 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
606 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 602 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
607 pending_layer->CurrentScrollOffset()); 603 pending_layer->CurrentScrollOffset());
608 } 604 }
609 605
610 } // namespace 606 } // namespace
611 } // namespace cc 607 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698