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

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

Issue 295193002: Get rid of graphics layer anchor points, and replace with transform origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_iterator_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/output/filter_operation.h" 7 #include "cc/output/filter_operation.h"
8 #include "cc/output/filter_operations.h" 8 #include "cc/output/filter_operations.h"
9 #include "cc/test/fake_impl_proxy.h" 9 #include "cc/test/fake_impl_proxy.h"
10 #include "cc/test/fake_layer_tree_host_impl.h" 10 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 root->SetScrollClipLayer(root_clip->id()); 115 root->SetScrollClipLayer(root_clip->id());
116 116
117 // Adding children is an internal operation and should not mark layers as 117 // Adding children is an internal operation and should not mark layers as
118 // changed. 118 // changed.
119 EXPECT_FALSE(root->LayerPropertyChanged()); 119 EXPECT_FALSE(root->LayerPropertyChanged());
120 EXPECT_FALSE(child->LayerPropertyChanged()); 120 EXPECT_FALSE(child->LayerPropertyChanged());
121 EXPECT_FALSE(grand_child->LayerPropertyChanged()); 121 EXPECT_FALSE(grand_child->LayerPropertyChanged());
122 122
123 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); 123 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
124 gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f);
124 float arbitrary_number = 0.352f; 125 float arbitrary_number = 0.352f;
125 gfx::Size arbitrary_size = gfx::Size(111, 222); 126 gfx::Size arbitrary_size = gfx::Size(111, 222);
126 gfx::Point arbitrary_point = gfx::Point(333, 444); 127 gfx::Point arbitrary_point = gfx::Point(333, 444);
127 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); 128 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222);
128 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); 129 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size);
129 gfx::RectF arbitrary_rect_f = 130 gfx::RectF arbitrary_rect_f =
130 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f)); 131 gfx::RectF(arbitrary_point_f, gfx::SizeF(1.234f, 5.678f));
131 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); 132 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30);
132 gfx::Transform arbitrary_transform; 133 gfx::Transform arbitrary_transform;
133 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); 134 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
134 FilterOperations arbitrary_filters; 135 FilterOperations arbitrary_filters;
135 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); 136 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f));
136 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; 137 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode;
137 138
138 // These properties are internal, and should not be considered "change" when 139 // These properties are internal, and should not be considered "change" when
139 // they are used. 140 // they are used.
140 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 141 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
141 root->SetUpdateRect(arbitrary_rect_f)); 142 root->SetUpdateRect(arbitrary_rect_f));
142 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); 143 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size));
143 144
144 // Changing these properties affects the entire subtree of layers. 145 // Changing these properties affects the entire subtree of layers.
145 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPoint(arbitrary_point_f)); 146 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
146 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetAnchorPointZ(arbitrary_number)); 147 root->SetTransformOrigin(arbitrary_point_3f));
147 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters)); 148 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(arbitrary_filters));
148 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations())); 149 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetFilters(FilterOperations()));
149 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 150 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
150 root->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 9))); 151 root->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 9)));
151 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true)); 152 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMasksToBounds(true));
152 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true)); 153 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetContentsOpaque(true));
153 EXECUTE_AND_VERIFY_SUBTREE_CHANGED( 154 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(
154 root->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 10))); 155 root->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 10)));
155 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPosition(arbitrary_point_f)); 156 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetPosition(arbitrary_point_f));
156 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false)); 157 EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetShouldFlattenTransform(false));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 196 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
196 root->SetScrollChildren(scroll_children)); 197 root->SetScrollChildren(scroll_children));
197 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 198 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
198 root->SetClipParent(clip_parent.get())); 199 root->SetClipParent(clip_parent.get()));
199 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( 200 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE(
200 root->SetClipChildren(clip_children)); 201 root->SetClipChildren(clip_children));
201 202
202 // After setting all these properties already, setting to the exact same 203 // After setting all these properties already, setting to the exact same
203 // values again should not cause any change. 204 // values again should not cause any change.
204 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 205 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
205 root->SetAnchorPoint(arbitrary_point_f)); 206 root->SetTransformOrigin(arbitrary_point_3f));
206 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
207 root->SetAnchorPointZ(arbitrary_number));
208 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true)); 207 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true));
209 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 208 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
210 root->SetPosition(arbitrary_point_f)); 209 root->SetPosition(arbitrary_point_f));
211 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 210 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
212 root->SetShouldFlattenTransform(false)); 211 root->SetShouldFlattenTransform(false));
213 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetIs3dSorted(true)); 212 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetIs3dSorted(true));
214 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 213 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
215 root->SetTransform(arbitrary_transform)); 214 root->SetTransform(arbitrary_transform));
216 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( 215 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(
217 root->SetDoubleSided(false)); // constructor initializes it to "true". 216 root->SetDoubleSided(false)); // constructor initializes it to "true".
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 288 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
290 layer->SetScrollDelta(arbitrary_vector2d)); 289 layer->SetScrollDelta(arbitrary_vector2d));
291 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 290 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
292 layer->SetScrollDelta(arbitrary_vector2d)); 291 layer->SetScrollDelta(arbitrary_vector2d));
293 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 292 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
294 layer->SetScrollOffset(arbitrary_vector2d)); 293 layer->SetScrollOffset(arbitrary_vector2d));
295 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 294 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
296 layer->SetScrollOffset(arbitrary_vector2d)); 295 layer->SetScrollOffset(arbitrary_vector2d));
297 296
298 // Unrelated functions, always set to new values, always set needs update. 297 // Unrelated functions, always set to new values, always set needs update.
299 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetAnchorPointZ(arbitrary_number));
300 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 298 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
301 layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4))); 299 layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4)));
302 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); 300 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true));
303 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); 301 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true));
304 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 302 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
305 layer->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5))); 303 layer->SetReplicaLayer(LayerImpl::Create(host_impl.active_tree(), 5)));
306 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetPosition(arbitrary_point_f)); 304 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetPosition(arbitrary_point_f));
307 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetShouldFlattenTransform(false)); 305 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetShouldFlattenTransform(false));
308 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetIs3dSorted(true)); 306 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetIs3dSorted(true));
309 307
310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 308 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
311 layer->SetDoubleSided(false)); // constructor initializes it to "true". 309 layer->SetDoubleSided(false)); // constructor initializes it to "true".
312 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentBounds(arbitrary_size)); 310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentBounds(arbitrary_size));
313 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 311 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
314 layer->SetContentsScale(arbitrary_number, arbitrary_number)); 312 layer->SetContentsScale(arbitrary_number, arbitrary_number));
315 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); 313 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true));
316 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 314 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
317 layer->SetBackgroundColor(arbitrary_color)); 315 layer->SetBackgroundColor(arbitrary_color));
318 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 316 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
319 layer->SetBackgroundFilters(arbitrary_filters)); 317 layer->SetBackgroundFilters(arbitrary_filters));
320 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetOpacity(arbitrary_number)); 318 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetOpacity(arbitrary_number));
321 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( 319 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(
322 layer->SetBlendMode(arbitrary_blend_mode)); 320 layer->SetBlendMode(arbitrary_blend_mode));
323 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetTransform(arbitrary_transform)); 321 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetTransform(arbitrary_transform));
324 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); 322 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size));
325 323
326 // Unrelated functions, set to the same values, no needs update. 324 // Unrelated functions, set to the same values, no needs update.
327 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 325 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
328 layer->SetAnchorPointZ(arbitrary_number));
329 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
330 layer->SetIsRootForIsolatedGroup(true)); 326 layer->SetIsRootForIsolatedGroup(true));
331 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters)); 327 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetFilters(arbitrary_filters));
332 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); 328 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true));
333 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); 329 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true));
334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetPosition(arbitrary_point_f)); 330 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetPosition(arbitrary_point_f));
335 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetIs3dSorted(true)); 331 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetIs3dSorted(true));
336 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 332 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
337 layer->SetDoubleSided(false)); // constructor initializes it to "true". 333 layer->SetDoubleSided(false)); // constructor initializes it to "true".
338 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( 334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(
339 layer->SetContentBounds(arbitrary_size)); 335 layer->SetContentBounds(arbitrary_size));
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 layer()->set_user_scrollable_vertical(false); 654 layer()->set_user_scrollable_vertical(false);
659 layer()->SetScrollOffset(scroll_offset); 655 layer()->SetScrollOffset(scroll_offset);
660 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta); 656 gfx::Vector2dF unscrolled = layer()->ScrollBy(scroll_delta);
661 657
662 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled); 658 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 8.5f), unscrolled);
663 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset()); 659 EXPECT_VECTOR_EQ(gfx::Vector2dF(30.5f, 5), layer()->TotalScrollOffset());
664 } 660 }
665 661
666 } // namespace 662 } // namespace
667 } // namespace cc 663 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.cc ('k') | cc/layers/layer_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698