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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2164833002: Use surface contents scale from effect tree (3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 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/trees/draw_property_utils.cc ('k') | cc/trees/property_tree.h » ('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/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { 200 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) {
201 gfx::Transform identity_matrix; 201 gfx::Transform identity_matrix;
202 LayerImpl* root = root_layer_for_testing(); 202 LayerImpl* root = root_layer_for_testing();
203 LayerImpl* layer = AddChild<LayerImpl>(root); 203 LayerImpl* layer = AddChild<LayerImpl>(root);
204 204
205 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 205 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
206 gfx::PointF(), gfx::Size(1, 2), true, false); 206 gfx::PointF(), gfx::Size(1, 2), true, false);
207 207
208 TransformTree& tree = 208 TransformTree& transform_tree =
209 host_impl()->active_tree()->property_trees()->transform_tree; 209 host_impl()->active_tree()->property_trees()->transform_tree;
210 EffectTree& effect_tree =
211 host_impl()->active_tree()->property_trees()->effect_tree;
210 212
211 // Case 2: Setting the bounds of the layer should not affect either the draw 213 // Case 2: Setting the bounds of the layer should not affect either the draw
212 // transform or the screenspace transform. 214 // transform or the screenspace transform.
213 gfx::Transform translation_to_center; 215 gfx::Transform translation_to_center;
214 translation_to_center.Translate(5.0, 6.0); 216 translation_to_center.Translate(5.0, 6.0);
215 SetLayerPropertiesForTesting(layer, identity_matrix, gfx::Point3F(), 217 SetLayerPropertiesForTesting(layer, identity_matrix, gfx::Point3F(),
216 gfx::PointF(), gfx::Size(10, 12), true, false); 218 gfx::PointF(), gfx::Size(10, 12), true, false);
217 ExecuteCalculateDrawProperties(root); 219 ExecuteCalculateDrawProperties(root);
218 EXPECT_TRANSFORMATION_MATRIX_EQ( 220 EXPECT_TRANSFORMATION_MATRIX_EQ(
219 identity_matrix, draw_property_utils::DrawTransform(layer, tree)); 221 identity_matrix,
222 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree));
220 EXPECT_TRANSFORMATION_MATRIX_EQ( 223 EXPECT_TRANSFORMATION_MATRIX_EQ(
221 identity_matrix, draw_property_utils::ScreenSpaceTransform(layer, tree)); 224 identity_matrix,
225 draw_property_utils::ScreenSpaceTransform(layer, transform_tree));
222 226
223 // Case 3: The anchor point by itself (without a layer transform) should have 227 // Case 3: The anchor point by itself (without a layer transform) should have
224 // no effect on the transforms. 228 // no effect on the transforms.
225 SetLayerPropertiesForTesting(layer, identity_matrix, 229 SetLayerPropertiesForTesting(layer, identity_matrix,
226 gfx::Point3F(2.5f, 3.0f, 0.f), gfx::PointF(), 230 gfx::Point3F(2.5f, 3.0f, 0.f), gfx::PointF(),
227 gfx::Size(10, 12), true, false); 231 gfx::Size(10, 12), true, false);
228 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 232 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
229 ExecuteCalculateDrawProperties(root); 233 ExecuteCalculateDrawProperties(root);
230 EXPECT_TRANSFORMATION_MATRIX_EQ( 234 EXPECT_TRANSFORMATION_MATRIX_EQ(
231 identity_matrix, draw_property_utils::DrawTransform(layer, tree)); 235 identity_matrix,
236 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree));
232 EXPECT_TRANSFORMATION_MATRIX_EQ( 237 EXPECT_TRANSFORMATION_MATRIX_EQ(
233 identity_matrix, draw_property_utils::ScreenSpaceTransform(layer, tree)); 238 identity_matrix,
239 draw_property_utils::ScreenSpaceTransform(layer, transform_tree));
234 240
235 // Case 4: A change in actual position affects both the draw transform and 241 // Case 4: A change in actual position affects both the draw transform and
236 // screen space transform. 242 // screen space transform.
237 gfx::Transform position_transform; 243 gfx::Transform position_transform;
238 position_transform.Translate(0.f, 1.2f); 244 position_transform.Translate(0.f, 1.2f);
239 SetLayerPropertiesForTesting( 245 SetLayerPropertiesForTesting(
240 layer, identity_matrix, gfx::Point3F(2.5f, 3.0f, 0.f), 246 layer, identity_matrix, gfx::Point3F(2.5f, 3.0f, 0.f),
241 gfx::PointF(0.f, 1.2f), gfx::Size(10, 12), true, false); 247 gfx::PointF(0.f, 1.2f), gfx::Size(10, 12), true, false);
242 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 248 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
243 ExecuteCalculateDrawProperties(root); 249 ExecuteCalculateDrawProperties(root);
244 EXPECT_TRANSFORMATION_MATRIX_EQ( 250 EXPECT_TRANSFORMATION_MATRIX_EQ(
245 position_transform, draw_property_utils::DrawTransform(layer, tree)); 251 position_transform,
252 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree));
246 EXPECT_TRANSFORMATION_MATRIX_EQ( 253 EXPECT_TRANSFORMATION_MATRIX_EQ(
247 position_transform, 254 position_transform,
248 draw_property_utils::ScreenSpaceTransform(layer, tree)); 255 draw_property_utils::ScreenSpaceTransform(layer, transform_tree));
249 256
250 // Case 5: In the correct sequence of transforms, the layer transform should 257 // Case 5: In the correct sequence of transforms, the layer transform should
251 // pre-multiply the translation_to_center. This is easily tested by using a 258 // pre-multiply the translation_to_center. This is easily tested by using a
252 // scale transform, because scale and translation are not commutative. 259 // scale transform, because scale and translation are not commutative.
253 gfx::Transform layer_transform; 260 gfx::Transform layer_transform;
254 layer_transform.Scale3d(2.0, 2.0, 1.0); 261 layer_transform.Scale3d(2.0, 2.0, 1.0);
255 SetLayerPropertiesForTesting(layer, layer_transform, gfx::Point3F(), 262 SetLayerPropertiesForTesting(layer, layer_transform, gfx::Point3F(),
256 gfx::PointF(), gfx::Size(10, 12), true, false); 263 gfx::PointF(), gfx::Size(10, 12), true, false);
257 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 264 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
258 ExecuteCalculateDrawProperties(root); 265 ExecuteCalculateDrawProperties(root);
259 EXPECT_TRANSFORMATION_MATRIX_EQ( 266 EXPECT_TRANSFORMATION_MATRIX_EQ(
260 layer_transform, draw_property_utils::DrawTransform(layer, tree)); 267 layer_transform,
268 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree));
261 EXPECT_TRANSFORMATION_MATRIX_EQ( 269 EXPECT_TRANSFORMATION_MATRIX_EQ(
262 layer_transform, draw_property_utils::ScreenSpaceTransform(layer, tree)); 270 layer_transform,
271 draw_property_utils::ScreenSpaceTransform(layer, transform_tree));
263 272
264 // Case 6: The layer transform should occur with respect to the anchor point. 273 // Case 6: The layer transform should occur with respect to the anchor point.
265 gfx::Transform translation_to_anchor; 274 gfx::Transform translation_to_anchor;
266 translation_to_anchor.Translate(5.0, 0.0); 275 translation_to_anchor.Translate(5.0, 0.0);
267 gfx::Transform expected_result = 276 gfx::Transform expected_result =
268 translation_to_anchor * layer_transform * Inverse(translation_to_anchor); 277 translation_to_anchor * layer_transform * Inverse(translation_to_anchor);
269 SetLayerPropertiesForTesting(layer, layer_transform, 278 SetLayerPropertiesForTesting(layer, layer_transform,
270 gfx::Point3F(5.0f, 0.f, 0.f), gfx::PointF(), 279 gfx::Point3F(5.0f, 0.f, 0.f), gfx::PointF(),
271 gfx::Size(10, 12), true, false); 280 gfx::Size(10, 12), true, false);
272 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 281 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
273 ExecuteCalculateDrawProperties(root); 282 ExecuteCalculateDrawProperties(root);
274 EXPECT_TRANSFORMATION_MATRIX_EQ( 283 EXPECT_TRANSFORMATION_MATRIX_EQ(
275 expected_result, draw_property_utils::DrawTransform(layer, tree)); 284 expected_result,
285 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree));
276 EXPECT_TRANSFORMATION_MATRIX_EQ( 286 EXPECT_TRANSFORMATION_MATRIX_EQ(
277 expected_result, draw_property_utils::ScreenSpaceTransform(layer, tree)); 287 expected_result,
288 draw_property_utils::ScreenSpaceTransform(layer, transform_tree));
278 289
279 // Case 7: Verify that position pre-multiplies the layer transform. The 290 // Case 7: Verify that position pre-multiplies the layer transform. The
280 // current implementation of CalculateDrawProperties does this implicitly, but 291 // current implementation of CalculateDrawProperties does this implicitly, but
281 // it is still worth testing to detect accidental regressions. 292 // it is still worth testing to detect accidental regressions.
282 expected_result = position_transform * translation_to_anchor * 293 expected_result = position_transform * translation_to_anchor *
283 layer_transform * Inverse(translation_to_anchor); 294 layer_transform * Inverse(translation_to_anchor);
284 SetLayerPropertiesForTesting( 295 SetLayerPropertiesForTesting(
285 layer, layer_transform, gfx::Point3F(5.0f, 0.f, 0.f), 296 layer, layer_transform, gfx::Point3F(5.0f, 0.f, 0.f),
286 gfx::PointF(0.f, 1.2f), gfx::Size(10, 12), true, false); 297 gfx::PointF(0.f, 1.2f), gfx::Size(10, 12), true, false);
287 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 298 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
288 ExecuteCalculateDrawProperties(root); 299 ExecuteCalculateDrawProperties(root);
289 EXPECT_TRANSFORMATION_MATRIX_EQ( 300 EXPECT_TRANSFORMATION_MATRIX_EQ(
290 expected_result, draw_property_utils::DrawTransform(layer, tree)); 301 expected_result,
302 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree));
291 EXPECT_TRANSFORMATION_MATRIX_EQ( 303 EXPECT_TRANSFORMATION_MATRIX_EQ(
292 expected_result, draw_property_utils::ScreenSpaceTransform(layer, tree)); 304 expected_result,
305 draw_property_utils::ScreenSpaceTransform(layer, transform_tree));
293 } 306 }
294 307
295 TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) { 308 TEST_F(LayerTreeHostCommonTest, TransformsAboutScrollOffset) {
296 const gfx::ScrollOffset kScrollOffset(50, 100); 309 const gfx::ScrollOffset kScrollOffset(50, 100);
297 const gfx::Vector2dF kScrollDelta(2.34f, 5.67f); 310 const gfx::Vector2dF kScrollDelta(2.34f, 5.67f);
298 const gfx::Vector2d kMaxScrollOffset(200, 200); 311 const gfx::Vector2d kMaxScrollOffset(200, 200);
299 const gfx::PointF kScrollLayerPosition(-kScrollOffset.x(), 312 const gfx::PointF kScrollLayerPosition(-kScrollOffset.x(),
300 -kScrollOffset.y()); 313 -kScrollOffset.y());
301 float page_scale = 0.888f; 314 float page_scale = 0.888f;
302 const float kDeviceScale = 1.666f; 315 const float kDeviceScale = 1.666f;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 gfx::Transform identity_matrix; 430 gfx::Transform identity_matrix;
418 LayerImpl* root = root_layer_for_testing(); 431 LayerImpl* root = root_layer_for_testing();
419 LayerImpl* parent = AddChild<LayerImpl>(root); 432 LayerImpl* parent = AddChild<LayerImpl>(root);
420 LayerImpl* child = AddChild<LayerImpl>(parent); 433 LayerImpl* child = AddChild<LayerImpl>(parent);
421 LayerImpl* grand_child = AddChild<LayerImpl>(child); 434 LayerImpl* grand_child = AddChild<LayerImpl>(child);
422 435
423 // One-time setup of root layer 436 // One-time setup of root layer
424 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 437 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
425 gfx::PointF(), gfx::Size(1, 2), true, false); 438 gfx::PointF(), gfx::Size(1, 2), true, false);
426 439
427 TransformTree& tree = 440 TransformTree& transform_tree =
428 host_impl()->active_tree()->property_trees()->transform_tree; 441 host_impl()->active_tree()->property_trees()->transform_tree;
442 EffectTree& effect_tree =
443 host_impl()->active_tree()->property_trees()->effect_tree;
429 444
430 // Case 1: parent's anchor point should not affect child or grand_child. 445 // Case 1: parent's anchor point should not affect child or grand_child.
431 SetLayerPropertiesForTesting(parent, identity_matrix, 446 SetLayerPropertiesForTesting(parent, identity_matrix,
432 gfx::Point3F(2.5f, 3.0f, 0.f), gfx::PointF(), 447 gfx::Point3F(2.5f, 3.0f, 0.f), gfx::PointF(),
433 gfx::Size(10, 12), true, false); 448 gfx::Size(10, 12), true, false);
434 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 449 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
435 gfx::PointF(), gfx::Size(16, 18), true, false); 450 gfx::PointF(), gfx::Size(16, 18), true, false);
436 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 451 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
437 gfx::PointF(), gfx::Size(76, 78), true, false); 452 gfx::PointF(), gfx::Size(76, 78), true, false);
438 ExecuteCalculateDrawProperties(root); 453 ExecuteCalculateDrawProperties(root);
439 454
440 EXPECT_TRANSFORMATION_MATRIX_EQ( 455 EXPECT_TRANSFORMATION_MATRIX_EQ(
441 identity_matrix, draw_property_utils::DrawTransform(child, tree)); 456 identity_matrix,
442 EXPECT_TRANSFORMATION_MATRIX_EQ( 457 draw_property_utils::DrawTransform(child, transform_tree, effect_tree));
443 identity_matrix, draw_property_utils::ScreenSpaceTransform(child, tree));
444 EXPECT_TRANSFORMATION_MATRIX_EQ(
445 identity_matrix, draw_property_utils::DrawTransform(grand_child, tree));
446 EXPECT_TRANSFORMATION_MATRIX_EQ( 458 EXPECT_TRANSFORMATION_MATRIX_EQ(
447 identity_matrix, 459 identity_matrix,
448 draw_property_utils::ScreenSpaceTransform(grand_child, tree)); 460 draw_property_utils::ScreenSpaceTransform(child, transform_tree));
461 EXPECT_TRANSFORMATION_MATRIX_EQ(
462 identity_matrix, draw_property_utils::DrawTransform(
463 grand_child, transform_tree, effect_tree));
464 EXPECT_TRANSFORMATION_MATRIX_EQ(
465 identity_matrix,
466 draw_property_utils::ScreenSpaceTransform(grand_child, transform_tree));
449 467
450 // Case 2: parent's position affects child and grand_child. 468 // Case 2: parent's position affects child and grand_child.
451 gfx::Transform parent_position_transform; 469 gfx::Transform parent_position_transform;
452 parent_position_transform.Translate(0.f, 1.2f); 470 parent_position_transform.Translate(0.f, 1.2f);
453 SetLayerPropertiesForTesting( 471 SetLayerPropertiesForTesting(
454 parent, identity_matrix, gfx::Point3F(2.5f, 3.0f, 0.f), 472 parent, identity_matrix, gfx::Point3F(2.5f, 3.0f, 0.f),
455 gfx::PointF(0.f, 1.2f), gfx::Size(10, 12), true, false); 473 gfx::PointF(0.f, 1.2f), gfx::Size(10, 12), true, false);
456 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 474 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
457 gfx::PointF(), gfx::Size(16, 18), true, false); 475 gfx::PointF(), gfx::Size(16, 18), true, false);
458 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 476 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
459 gfx::PointF(), gfx::Size(76, 78), true, false); 477 gfx::PointF(), gfx::Size(76, 78), true, false);
460 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 478 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
461 ExecuteCalculateDrawProperties(root); 479 ExecuteCalculateDrawProperties(root);
462 EXPECT_TRANSFORMATION_MATRIX_EQ( 480 EXPECT_TRANSFORMATION_MATRIX_EQ(
463 parent_position_transform, 481 parent_position_transform,
464 draw_property_utils::DrawTransform(child, tree)); 482 draw_property_utils::DrawTransform(child, transform_tree, effect_tree));
465 EXPECT_TRANSFORMATION_MATRIX_EQ( 483 EXPECT_TRANSFORMATION_MATRIX_EQ(
466 parent_position_transform, 484 parent_position_transform,
467 draw_property_utils::ScreenSpaceTransform(child, tree)); 485 draw_property_utils::ScreenSpaceTransform(child, transform_tree));
486 EXPECT_TRANSFORMATION_MATRIX_EQ(
487 parent_position_transform, draw_property_utils::DrawTransform(
488 grand_child, transform_tree, effect_tree));
468 EXPECT_TRANSFORMATION_MATRIX_EQ( 489 EXPECT_TRANSFORMATION_MATRIX_EQ(
469 parent_position_transform, 490 parent_position_transform,
470 draw_property_utils::DrawTransform(grand_child, tree)); 491 draw_property_utils::ScreenSpaceTransform(grand_child, transform_tree));
471 EXPECT_TRANSFORMATION_MATRIX_EQ(
472 parent_position_transform,
473 draw_property_utils::ScreenSpaceTransform(grand_child, tree));
474 492
475 // Case 3: parent's local transform affects child and grandchild 493 // Case 3: parent's local transform affects child and grandchild
476 gfx::Transform parent_layer_transform; 494 gfx::Transform parent_layer_transform;
477 parent_layer_transform.Scale3d(2.0, 2.0, 1.0); 495 parent_layer_transform.Scale3d(2.0, 2.0, 1.0);
478 gfx::Transform parent_translation_to_anchor; 496 gfx::Transform parent_translation_to_anchor;
479 parent_translation_to_anchor.Translate(2.5, 3.0); 497 parent_translation_to_anchor.Translate(2.5, 3.0);
480 gfx::Transform parent_composite_transform = 498 gfx::Transform parent_composite_transform =
481 parent_translation_to_anchor * parent_layer_transform * 499 parent_translation_to_anchor * parent_layer_transform *
482 Inverse(parent_translation_to_anchor); 500 Inverse(parent_translation_to_anchor);
483 SetLayerPropertiesForTesting(parent, parent_layer_transform, 501 SetLayerPropertiesForTesting(parent, parent_layer_transform,
484 gfx::Point3F(2.5f, 3.0f, 0.f), gfx::PointF(), 502 gfx::Point3F(2.5f, 3.0f, 0.f), gfx::PointF(),
485 gfx::Size(10, 12), true, false); 503 gfx::Size(10, 12), true, false);
486 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), 504 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(),
487 gfx::PointF(), gfx::Size(16, 18), true, false); 505 gfx::PointF(), gfx::Size(16, 18), true, false);
488 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), 506 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(),
489 gfx::PointF(), gfx::Size(76, 78), true, false); 507 gfx::PointF(), gfx::Size(76, 78), true, false);
490 host_impl()->active_tree()->property_trees()->needs_rebuild = true; 508 host_impl()->active_tree()->property_trees()->needs_rebuild = true;
491 ExecuteCalculateDrawProperties(root); 509 ExecuteCalculateDrawProperties(root);
492 EXPECT_TRANSFORMATION_MATRIX_EQ( 510 EXPECT_TRANSFORMATION_MATRIX_EQ(
493 parent_composite_transform, 511 parent_composite_transform,
494 draw_property_utils::DrawTransform(child, tree)); 512 draw_property_utils::DrawTransform(child, transform_tree, effect_tree));
495 EXPECT_TRANSFORMATION_MATRIX_EQ( 513 EXPECT_TRANSFORMATION_MATRIX_EQ(
496 parent_composite_transform, 514 parent_composite_transform,
497 draw_property_utils::ScreenSpaceTransform(child, tree)); 515 draw_property_utils::ScreenSpaceTransform(child, transform_tree));
498 EXPECT_TRANSFORMATION_MATRIX_EQ( 516 EXPECT_TRANSFORMATION_MATRIX_EQ(
499 parent_composite_transform, 517 parent_composite_transform,
500 draw_property_utils::DrawTransform(grand_child, tree)); 518 draw_property_utils::DrawTransform(grand_child, transform_tree,
519 effect_tree));
501 EXPECT_TRANSFORMATION_MATRIX_EQ( 520 EXPECT_TRANSFORMATION_MATRIX_EQ(
502 parent_composite_transform, 521 parent_composite_transform,
503 draw_property_utils::ScreenSpaceTransform(grand_child, tree)); 522 draw_property_utils::ScreenSpaceTransform(grand_child, transform_tree));
504 } 523 }
505 524
506 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) { 525 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) {
507 LayerImpl* root = root_layer_for_testing(); 526 LayerImpl* root = root_layer_for_testing();
508 LayerImpl* parent = AddChildToRoot<LayerImpl>(); 527 LayerImpl* parent = AddChildToRoot<LayerImpl>();
509 LayerImpl* child = AddChild<LayerImpl>(parent); 528 LayerImpl* child = AddChild<LayerImpl>(parent);
510 LayerImpl* grand_child = AddChild<LayerImpl>(child); 529 LayerImpl* grand_child = AddChild<LayerImpl>(child);
511 grand_child->SetDrawsContent(true); 530 grand_child->SetDrawsContent(true);
512 531
513 gfx::Transform identity_matrix; 532 gfx::Transform identity_matrix;
(...skipping 6669 matching lines...) Expand 10 before | Expand all | Expand 10 after
7183 false); 7202 false);
7184 SetLayerPropertiesForTesting(fixed, gfx::Transform(), gfx::Point3F(), 7203 SetLayerPropertiesForTesting(fixed, gfx::Transform(), gfx::Point3F(),
7185 gfx::PointF(10.f, 15.f), gfx::Size(50, 50), true, 7204 gfx::PointF(10.f, 15.f), gfx::Size(50, 50), true,
7186 false); 7205 false);
7187 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), 7206 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(),
7188 gfx::PointF(1.f, 2.f), gfx::Size(50, 50), true, 7207 gfx::PointF(1.f, 2.f), gfx::Size(50, 50), true,
7189 false); 7208 false);
7190 7209
7191 ExecuteCalculateDrawProperties(root); 7210 ExecuteCalculateDrawProperties(root);
7192 7211
7193 TransformTree& tree = 7212 TransformTree& transform_tree =
7194 host_impl()->active_tree()->property_trees()->transform_tree; 7213 host_impl()->active_tree()->property_trees()->transform_tree;
7214 EffectTree& effect_tree =
7215 host_impl()->active_tree()->property_trees()->effect_tree;
7195 7216
7196 gfx::Transform expected_fixed_draw_transform; 7217 gfx::Transform expected_fixed_draw_transform;
7197 expected_fixed_draw_transform.Translate(10.f, 15.f); 7218 expected_fixed_draw_transform.Translate(10.f, 15.f);
7198 EXPECT_TRANSFORMATION_MATRIX_EQ( 7219 EXPECT_TRANSFORMATION_MATRIX_EQ(
7199 expected_fixed_draw_transform, 7220 expected_fixed_draw_transform,
7200 draw_property_utils::DrawTransform(fixed, tree)); 7221 draw_property_utils::DrawTransform(fixed, transform_tree, effect_tree));
7201 7222
7202 gfx::Transform expected_fixed_screen_space_transform; 7223 gfx::Transform expected_fixed_screen_space_transform;
7203 expected_fixed_screen_space_transform.Translate(17.f, 24.f); 7224 expected_fixed_screen_space_transform.Translate(17.f, 24.f);
7204 EXPECT_TRANSFORMATION_MATRIX_EQ( 7225 EXPECT_TRANSFORMATION_MATRIX_EQ(
7205 expected_fixed_screen_space_transform, 7226 expected_fixed_screen_space_transform,
7206 draw_property_utils::ScreenSpaceTransform(fixed, tree)); 7227 draw_property_utils::ScreenSpaceTransform(fixed, transform_tree));
7207 7228
7208 gfx::Transform expected_child_draw_transform; 7229 gfx::Transform expected_child_draw_transform;
7209 expected_child_draw_transform.Translate(11.f, 17.f); 7230 expected_child_draw_transform.Translate(11.f, 17.f);
7210 EXPECT_TRANSFORMATION_MATRIX_EQ( 7231 EXPECT_TRANSFORMATION_MATRIX_EQ(
7211 expected_child_draw_transform, 7232 expected_child_draw_transform,
7212 draw_property_utils::DrawTransform(child, tree)); 7233 draw_property_utils::DrawTransform(child, transform_tree, effect_tree));
7213 7234
7214 gfx::Transform expected_child_screen_space_transform; 7235 gfx::Transform expected_child_screen_space_transform;
7215 expected_child_screen_space_transform.Translate(18.f, 26.f); 7236 expected_child_screen_space_transform.Translate(18.f, 26.f);
7216 EXPECT_TRANSFORMATION_MATRIX_EQ( 7237 EXPECT_TRANSFORMATION_MATRIX_EQ(
7217 expected_child_screen_space_transform, 7238 expected_child_screen_space_transform,
7218 draw_property_utils::ScreenSpaceTransform(child, tree)); 7239 draw_property_utils::ScreenSpaceTransform(child, transform_tree));
7219 } 7240 }
7220 7241
7221 TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) { 7242 TEST_F(LayerTreeHostCommonTest, ScrollCompensationWithRounding) {
7222 // This test verifies that a scrolling layer that gets snapped to 7243 // This test verifies that a scrolling layer that gets snapped to
7223 // integer coordinates doesn't move a fixed position child. 7244 // integer coordinates doesn't move a fixed position child.
7224 // 7245 //
7225 // + root 7246 // + root
7226 // + container 7247 // + container
7227 // + scroller 7248 // + scroller
7228 // + fixed 7249 // + fixed
(...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after
10521 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10542 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10522 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10543 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10523 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10544 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10524 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10545 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10525 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10546 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10526 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10547 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10527 } 10548 }
10528 10549
10529 } // namespace 10550 } // namespace
10530 } // namespace cc 10551 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698