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

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

Issue 1675963002: Move MaxScrollOffset to property_trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests failures 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
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get(); 120 LayerImpl* clip_child = LayerImpl::Create(host_impl.active_tree(), 6).get();
121 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>(); 121 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>();
122 clip_children->insert(clip_child); 122 clip_children->insert(clip_child);
123 clip_children->insert(root); 123 clip_children->insert(root);
124 124
125 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7)); 125 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 7));
126 LayerImpl* child = root->children()[0].get(); 126 LayerImpl* child = root->children()[0].get();
127 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8)); 127 child->AddChild(LayerImpl::Create(host_impl.active_tree(), 8));
128 LayerImpl* grand_child = child->children()[0].get(); 128 LayerImpl* grand_child = child->children()[0].get();
129 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr)); 129 host_impl.active_tree()->SetRootLayer(std::move(root_clip_ptr));
130 root->SetScrollClipLayer(root_clip->id());
130 host_impl.active_tree()->BuildPropertyTreesForTesting(); 131 host_impl.active_tree()->BuildPropertyTreesForTesting();
131 132
132 root->SetScrollClipLayer(root_clip->id());
133
134 // Adding children is an internal operation and should not mark layers as 133 // Adding children is an internal operation and should not mark layers as
135 // changed. 134 // changed.
136 EXPECT_FALSE(root->LayerPropertyChanged()); 135 EXPECT_FALSE(root->LayerPropertyChanged());
137 EXPECT_FALSE(child->LayerPropertyChanged()); 136 EXPECT_FALSE(child->LayerPropertyChanged());
138 EXPECT_FALSE(grand_child->LayerPropertyChanged()); 137 EXPECT_FALSE(grand_child->LayerPropertyChanged());
139 138
140 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); 139 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
141 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f); 140 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f);
142 float arbitrary_number = 0.352f; 141 float arbitrary_number = 0.352f;
143 gfx::Size arbitrary_size = gfx::Size(111, 222); 142 gfx::Size arbitrary_size = gfx::Size(111, 222);
144 gfx::Point arbitrary_point = gfx::Point(333, 444); 143 gfx::Point arbitrary_point = gfx::Point(333, 444);
145 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 144 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
146 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); 145 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size);
147 gfx::RectF arbitrary_rect_f = 146 gfx::RectF arbitrary_rect_f =
148 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); 147 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f));
149 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 148 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
150 gfx::Transform arbitrary_transform; 149 gfx::Transform arbitrary_transform;
151 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); 150 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
152 FilterOperations arbitrary_filters; 151 FilterOperations arbitrary_filters;
153 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); 152 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
154 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; 153 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode;
155 154
156 // These properties are internal, and should not be considered "change" when 155 // These properties are internal, and should not be considered "change" when
157 // they are used. 156 // they are used.
158 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 157 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
159 root->SetUpdateRect(arbitrary_rect)); 158 root->SetUpdateRect(arbitrary_rect));
160 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;
161 host_impl.active_tree()->BuildPropertyTreesForTesting();
161 162
162 // Changing these properties affects the entire subtree of layers. 163 // Changing these properties affects the entire subtree of layers.
163 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 164 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
164 root->SetTransformOrigin(arbitrary_point_3f)); 165 root->SetTransformOrigin(arbitrary_point_3f));
165 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); 166 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters));
166 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations())); 167 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations()));
167 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 168 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
168 root->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 9))); 169 root->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 9)));
169 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); 170 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true));
170 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); 171 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true));
(...skipping 17 matching lines...) Expand all
188 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true)); 189 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetDrawsContent(true));
189 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 190 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
190 root->SetBackgroundColor(arbitrary_color)); 191 root->SetBackgroundColor(arbitrary_color));
191 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED( 192 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(
192 root->SetBackgroundFilters(arbitrary_filters)); 193 root->SetBackgroundFilters(arbitrary_filters));
193 194
194 // Special case: check that SetBounds changes behavior depending on 195 // Special case: check that SetBounds changes behavior depending on
195 // masksToBounds. 196 // masksToBounds.
196 root->SetMasksToBounds(false); 197 root->SetMasksToBounds(false);
197 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(gfx::Size(135, 246))); 198 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(gfx::Size(135, 246)));
199 host_impl.active_tree()->property_trees()->needs_rebuild = true;
200 host_impl.active_tree()->BuildPropertyTreesForTesting();
201
198 root->SetMasksToBounds(true); 202 root->SetMasksToBounds(true);
199 // Should be a different size than previous call, to ensure it marks tree 203 // Should be a different size than previous call, to ensure it marks tree
200 // changed. 204 // changed.
201 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBounds(arbitrary_size)); 205 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetBounds(arbitrary_size));
206 host_impl.active_tree()->property_trees()->needs_rebuild = true;
207 host_impl.active_tree()->BuildPropertyTreesForTesting();
202 208
203 // Changing these properties does not cause the layer to be marked as changed 209 // Changing these properties does not cause the layer to be marked as changed
204 // but does cause the layer to need to push properties. 210 // but does cause the layer to need to push properties.
205 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 211 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
206 root->SetIsRootForIsolatedGroup(true)); 212 root->SetIsRootForIsolatedGroup(true));
207 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 213 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
208 root->SetElementId(2)); 214 root->SetElementId(2));
209 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 215 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
210 root->SetMutableProperties(MutableProperty::kOpacity)); 216 root->SetMutableProperties(MutableProperty::kOpacity));
211 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 217 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 LayerImplScrollTest() 466 LayerImplScrollTest()
461 : host_impl_(settings(), 467 : host_impl_(settings(),
462 &task_runner_provider_, 468 &task_runner_provider_,
463 &shared_bitmap_manager_, 469 &shared_bitmap_manager_,
464 &task_graph_runner_), 470 &task_graph_runner_),
465 root_id_(7) { 471 root_id_(7) {
466 host_impl_.active_tree()->SetRootLayer( 472 host_impl_.active_tree()->SetRootLayer(
467 LayerImpl::Create(host_impl_.active_tree(), root_id_)); 473 LayerImpl::Create(host_impl_.active_tree(), root_id_));
468 host_impl_.active_tree()->root_layer()->AddChild( 474 host_impl_.active_tree()->root_layer()->AddChild(
469 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1)); 475 LayerImpl::Create(host_impl_.active_tree(), root_id_ + 1));
470 host_impl_.active_tree()->BuildPropertyTreesForTesting();
471 layer()->SetScrollClipLayer(root_id_); 476 layer()->SetScrollClipLayer(root_id_);
472 // Set the max scroll offset by noting that the root layer has bounds (1,1), 477 // Set the max scroll offset by noting that the root layer has bounds (1,1),
473 // thus whatever bounds are set for the layer will be the max scroll 478 // thus whatever bounds are set for the layer will be the max scroll
474 // offset plus 1 in each direction. 479 // offset plus 1 in each direction.
475 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1)); 480 host_impl_.active_tree()->root_layer()->SetBounds(gfx::Size(1, 1));
476 gfx::Vector2d max_scroll_offset(51, 81); 481 gfx::Vector2d max_scroll_offset(51, 81);
477 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y())); 482 layer()->SetBounds(gfx::Size(max_scroll_offset.x(), max_scroll_offset.y()));
483 host_impl_.active_tree()->BuildPropertyTreesForTesting();
478 } 484 }
479 485
480 LayerImpl* layer() { 486 LayerImpl* layer() {
481 return host_impl_.active_tree()->root_layer()->children()[0].get(); 487 return host_impl_.active_tree()->root_layer()->children()[0].get();
482 } 488 }
483 489
484 LayerTreeHostImpl& host_impl() { return host_impl_; } 490 LayerTreeHostImpl& host_impl() { return host_impl_; }
485 491
486 LayerTreeImpl* tree() { return host_impl_.active_tree(); } 492 LayerTreeImpl* tree() { return host_impl_.active_tree(); }
487 493
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 607
602 pending_layer->PushPropertiesTo(layer()); 608 pending_layer->PushPropertiesTo(layer());
603 609
604 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); 610 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset());
605 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), 611 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(),
606 pending_layer->CurrentScrollOffset()); 612 pending_layer->CurrentScrollOffset());
607 } 613 }
608 614
609 } // namespace 615 } // namespace
610 } // namespace cc 616 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698