| OLD | NEW |
| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 const gfx::Rect& layer_rect) { | 120 const gfx::Rect& layer_rect) { |
| 121 LayerImpl* root = root_layer_for_testing(); | 121 LayerImpl* root = root_layer_for_testing(); |
| 122 LayerImpl* target = AddChild<LayerImpl>(root); | 122 LayerImpl* target = AddChild<LayerImpl>(root); |
| 123 LayerImpl* drawing_layer = AddChild<LayerImpl>(target); | 123 LayerImpl* drawing_layer = AddChild<LayerImpl>(target); |
| 124 | 124 |
| 125 root->SetDrawsContent(true); | 125 root->SetDrawsContent(true); |
| 126 target->SetDrawsContent(true); | 126 target->SetDrawsContent(true); |
| 127 target->SetMasksToBounds(true); | 127 target->SetMasksToBounds(true); |
| 128 drawing_layer->SetDrawsContent(true); | 128 drawing_layer->SetDrawsContent(true); |
| 129 | 129 |
| 130 gfx::Transform identity; | |
| 131 | |
| 132 root->SetBounds(gfx::Size(500, 500)); | 130 root->SetBounds(gfx::Size(500, 500)); |
| 133 root->test_properties()->force_render_surface = true; | 131 root->test_properties()->force_render_surface = true; |
| 134 target->SetPosition(gfx::PointF(target_rect.origin())); | 132 target->SetPosition(gfx::PointF(target_rect.origin())); |
| 135 target->SetBounds(target_rect.size()); | 133 target->SetBounds(target_rect.size()); |
| 136 target->test_properties()->force_render_surface = true; | 134 target->test_properties()->force_render_surface = true; |
| 137 drawing_layer->SetTransform(layer_transform); | 135 drawing_layer->SetTransform(layer_transform); |
| 138 drawing_layer->SetPosition(gfx::PointF(layer_rect.origin())); | 136 drawing_layer->SetPosition(gfx::PointF(layer_rect.origin())); |
| 139 drawing_layer->SetBounds(layer_rect.size()); | 137 drawing_layer->SetBounds(layer_rect.size()); |
| 140 drawing_layer->test_properties()->should_flatten_transform = false; | 138 drawing_layer->test_properties()->should_flatten_transform = false; |
| 141 | 139 |
| 142 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 140 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 143 ExecuteCalculateDrawProperties(root); | 141 ExecuteCalculateDrawProperties(root); |
| 144 | 142 |
| 145 return drawing_layer; | 143 return drawing_layer; |
| 146 } | 144 } |
| 147 }; | 145 }; |
| 148 | 146 |
| 149 TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) { | 147 TEST_F(LayerTreeHostCommonTest, TransformsForNoOpLayer) { |
| 150 // Sanity check: For layers positioned at zero, with zero size, | 148 // Sanity check: For layers positioned at zero, with zero size, |
| 151 // and with identity transforms, then the draw transform, | 149 // and with identity transforms, then the draw transform, |
| 152 // screen space transform, and the hierarchy passed on to children | 150 // screen space transform, and the hierarchy passed on to children |
| 153 // layers should also be identity transforms. | 151 // layers should also be identity transforms. |
| 154 | 152 |
| 155 LayerImpl* parent = root_layer_for_testing(); | 153 LayerImpl* parent = root_layer_for_testing(); |
| 156 LayerImpl* child = AddChild<LayerImpl>(parent); | 154 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 157 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 155 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 158 | 156 |
| 159 gfx::Transform identity_matrix; | |
| 160 parent->SetBounds(gfx::Size(100, 100)); | 157 parent->SetBounds(gfx::Size(100, 100)); |
| 161 | 158 |
| 162 ExecuteCalculateDrawProperties(parent); | 159 ExecuteCalculateDrawProperties(parent); |
| 163 | 160 |
| 164 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->DrawTransform()); | 161 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); |
| 165 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 162 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 166 child->ScreenSpaceTransform()); | 163 child->ScreenSpaceTransform()); |
| 167 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 164 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 168 grand_child->DrawTransform()); | 165 grand_child->DrawTransform()); |
| 169 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 166 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 170 grand_child->ScreenSpaceTransform()); | 167 grand_child->ScreenSpaceTransform()); |
| 171 } | 168 } |
| 172 | 169 |
| 173 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { | 170 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { |
| 174 // Tests that effect tree node gets a valid transform id when a layer | 171 // Tests that effect tree node gets a valid transform id when a layer |
| 175 // has opacity but doesn't create a render surface. | 172 // has opacity but doesn't create a render surface. |
| 176 LayerImpl* parent = root_layer_for_testing(); | 173 LayerImpl* parent = root_layer_for_testing(); |
| 177 LayerImpl* child = AddChild<LayerImpl>(parent); | 174 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 178 child->SetDrawsContent(true); | 175 child->SetDrawsContent(true); |
| 179 | 176 |
| 180 gfx::Transform identity_matrix; | |
| 181 parent->SetBounds(gfx::Size(100, 100)); | 177 parent->SetBounds(gfx::Size(100, 100)); |
| 182 child->SetPosition(gfx::PointF(10, 10)); | 178 child->SetPosition(gfx::PointF(10, 10)); |
| 183 child->SetBounds(gfx::Size(100, 100)); | 179 child->SetBounds(gfx::Size(100, 100)); |
| 184 child->test_properties()->opacity = 0.f; | 180 child->test_properties()->opacity = 0.f; |
| 185 ExecuteCalculateDrawProperties(parent); | 181 ExecuteCalculateDrawProperties(parent); |
| 186 EffectTree& effect_tree = | 182 EffectTree& effect_tree = |
| 187 parent->layer_tree_impl()->property_trees()->effect_tree; | 183 parent->layer_tree_impl()->property_trees()->effect_tree; |
| 188 EffectNode* node = effect_tree.Node(child->effect_tree_index()); | 184 EffectNode* node = effect_tree.Node(child->effect_tree_index()); |
| 189 const int transform_tree_size = parent->layer_tree_impl() | 185 const int transform_tree_size = parent->layer_tree_impl() |
| 190 ->property_trees() | 186 ->property_trees() |
| 191 ->transform_tree.next_available_id(); | 187 ->transform_tree.next_available_id(); |
| 192 EXPECT_LT(node->transform_id, transform_tree_size); | 188 EXPECT_LT(node->transform_id, transform_tree_size); |
| 193 } | 189 } |
| 194 | 190 |
| 195 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { | 191 TEST_F(LayerTreeHostCommonTest, TransformsForSingleLayer) { |
| 196 gfx::Transform identity_matrix; | |
| 197 LayerImpl* root = root_layer_for_testing(); | 192 LayerImpl* root = root_layer_for_testing(); |
| 198 LayerImpl* layer = AddChild<LayerImpl>(root); | 193 LayerImpl* layer = AddChild<LayerImpl>(root); |
| 199 | 194 |
| 200 TransformTree& transform_tree = | 195 TransformTree& transform_tree = |
| 201 host_impl()->active_tree()->property_trees()->transform_tree; | 196 host_impl()->active_tree()->property_trees()->transform_tree; |
| 202 EffectTree& effect_tree = | 197 EffectTree& effect_tree = |
| 203 host_impl()->active_tree()->property_trees()->effect_tree; | 198 host_impl()->active_tree()->property_trees()->effect_tree; |
| 204 | 199 |
| 205 root->SetBounds(gfx::Size(1, 2)); | 200 root->SetBounds(gfx::Size(1, 2)); |
| 206 | 201 |
| 207 // Case 1: Setting the bounds of the layer should not affect either the draw | 202 // Case 1: Setting the bounds of the layer should not affect either the draw |
| 208 // transform or the screenspace transform. | 203 // transform or the screenspace transform. |
| 209 layer->SetBounds(gfx::Size(10, 12)); | 204 layer->SetBounds(gfx::Size(10, 12)); |
| 210 ExecuteCalculateDrawProperties(root); | 205 ExecuteCalculateDrawProperties(root); |
| 211 EXPECT_TRANSFORMATION_MATRIX_EQ( | 206 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 212 identity_matrix, | 207 gfx::Transform(), |
| 213 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); | 208 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); |
| 214 EXPECT_TRANSFORMATION_MATRIX_EQ( | 209 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 215 identity_matrix, | 210 gfx::Transform(), |
| 216 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); | 211 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); |
| 217 | 212 |
| 218 // Case 2: The anchor point by itself (without a layer transform) should have | 213 // Case 2: The anchor point by itself (without a layer transform) should have |
| 219 // no effect on the transforms. | 214 // no effect on the transforms. |
| 220 layer->test_properties()->transform_origin = gfx::Point3F(2.5f, 3.0f, 0.f); | 215 layer->test_properties()->transform_origin = gfx::Point3F(2.5f, 3.0f, 0.f); |
| 221 layer->SetBounds(gfx::Size(10, 12)); | 216 layer->SetBounds(gfx::Size(10, 12)); |
| 222 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 217 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 223 ExecuteCalculateDrawProperties(root); | 218 ExecuteCalculateDrawProperties(root); |
| 224 EXPECT_TRANSFORMATION_MATRIX_EQ( | 219 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 225 identity_matrix, | 220 gfx::Transform(), |
| 226 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); | 221 draw_property_utils::DrawTransform(layer, transform_tree, effect_tree)); |
| 227 EXPECT_TRANSFORMATION_MATRIX_EQ( | 222 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 228 identity_matrix, | 223 gfx::Transform(), |
| 229 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); | 224 draw_property_utils::ScreenSpaceTransform(layer, transform_tree)); |
| 230 | 225 |
| 231 // Case 3: A change in actual position affects both the draw transform and | 226 // Case 3: A change in actual position affects both the draw transform and |
| 232 // screen space transform. | 227 // screen space transform. |
| 233 gfx::Transform position_transform; | 228 gfx::Transform position_transform; |
| 234 position_transform.Translate(0.f, 1.2f); | 229 position_transform.Translate(0.f, 1.2f); |
| 235 layer->SetPosition(gfx::PointF(0.f, 1.2f)); | 230 layer->SetPosition(gfx::PointF(0.f, 1.2f)); |
| 236 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 231 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 237 ExecuteCalculateDrawProperties(root); | 232 ExecuteCalculateDrawProperties(root); |
| 238 EXPECT_TRANSFORMATION_MATRIX_EQ( | 233 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 -kScrollOffset.y()); | 293 -kScrollOffset.y()); |
| 299 float page_scale = 0.888f; | 294 float page_scale = 0.888f; |
| 300 const float kDeviceScale = 1.666f; | 295 const float kDeviceScale = 1.666f; |
| 301 | 296 |
| 302 FakeImplTaskRunnerProvider task_runner_provider; | 297 FakeImplTaskRunnerProvider task_runner_provider; |
| 303 TestSharedBitmapManager shared_bitmap_manager; | 298 TestSharedBitmapManager shared_bitmap_manager; |
| 304 TestTaskGraphRunner task_graph_runner; | 299 TestTaskGraphRunner task_graph_runner; |
| 305 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 300 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 306 &task_graph_runner); | 301 &task_graph_runner); |
| 307 | 302 |
| 308 gfx::Transform identity_matrix; | |
| 309 std::unique_ptr<LayerImpl> sublayer_scoped_ptr( | 303 std::unique_ptr<LayerImpl> sublayer_scoped_ptr( |
| 310 LayerImpl::Create(host_impl.active_tree(), 1)); | 304 LayerImpl::Create(host_impl.active_tree(), 1)); |
| 311 LayerImpl* sublayer = sublayer_scoped_ptr.get(); | 305 LayerImpl* sublayer = sublayer_scoped_ptr.get(); |
| 312 sublayer->SetDrawsContent(true); | 306 sublayer->SetDrawsContent(true); |
| 313 sublayer->SetBounds(gfx::Size(500, 500)); | 307 sublayer->SetBounds(gfx::Size(500, 500)); |
| 314 | 308 |
| 315 std::unique_ptr<LayerImpl> scroll_layer_scoped_ptr( | 309 std::unique_ptr<LayerImpl> scroll_layer_scoped_ptr( |
| 316 LayerImpl::Create(host_impl.active_tree(), 2)); | 310 LayerImpl::Create(host_impl.active_tree(), 2)); |
| 317 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); | 311 LayerImpl* scroll_layer = scroll_layer_scoped_ptr.get(); |
| 318 scroll_layer->SetBounds(gfx::Size(10, 20)); | 312 scroll_layer->SetBounds(gfx::Size(10, 20)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 338 std::unique_ptr<LayerImpl> root( | 332 std::unique_ptr<LayerImpl> root( |
| 339 LayerImpl::Create(host_impl.active_tree(), 3)); | 333 LayerImpl::Create(host_impl.active_tree(), 3)); |
| 340 root->SetBounds(gfx::Size(3, 4)); | 334 root->SetBounds(gfx::Size(3, 4)); |
| 341 root->test_properties()->AddChild(std::move(clip_layer_scoped_ptr)); | 335 root->test_properties()->AddChild(std::move(clip_layer_scoped_ptr)); |
| 342 root->SetHasRenderSurface(true); | 336 root->SetHasRenderSurface(true); |
| 343 LayerImpl* root_layer = root.get(); | 337 LayerImpl* root_layer = root.get(); |
| 344 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 338 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 345 | 339 |
| 346 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, | 340 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, |
| 347 scroll_layer->test_properties()->parent); | 341 scroll_layer->test_properties()->parent); |
| 348 gfx::Transform expected_transform = identity_matrix; | 342 gfx::Transform expected_transform; |
| 349 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; | 343 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; |
| 350 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() * | 344 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() * |
| 351 page_scale * kDeviceScale), | 345 page_scale * kDeviceScale), |
| 352 MathUtil::Round(sub_layer_screen_position.y() * | 346 MathUtil::Round(sub_layer_screen_position.y() * |
| 353 page_scale * kDeviceScale)); | 347 page_scale * kDeviceScale)); |
| 354 expected_transform.Scale(page_scale * kDeviceScale, | 348 expected_transform.Scale(page_scale * kDeviceScale, |
| 355 page_scale * kDeviceScale); | 349 page_scale * kDeviceScale); |
| 356 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 350 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
| 357 sublayer->DrawTransform()); | 351 sublayer->DrawTransform()); |
| 358 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 352 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 MathUtil::Round(kTranslateY * page_scale * kDeviceScale + | 391 MathUtil::Round(kTranslateY * page_scale * kDeviceScale + |
| 398 sub_layer_screen_position.y() * page_scale * | 392 sub_layer_screen_position.y() * page_scale * |
| 399 kDeviceScale)); | 393 kDeviceScale)); |
| 400 expected_transform.Scale(page_scale * kDeviceScale, | 394 expected_transform.Scale(page_scale * kDeviceScale, |
| 401 page_scale * kDeviceScale); | 395 page_scale * kDeviceScale); |
| 402 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, | 396 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform, |
| 403 sublayer->DrawTransform()); | 397 sublayer->DrawTransform()); |
| 404 } | 398 } |
| 405 | 399 |
| 406 TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) { | 400 TEST_F(LayerTreeHostCommonTest, TransformsForSimpleHierarchy) { |
| 407 gfx::Transform identity_matrix; | |
| 408 LayerImpl* root = root_layer_for_testing(); | 401 LayerImpl* root = root_layer_for_testing(); |
| 409 LayerImpl* parent = AddChild<LayerImpl>(root); | 402 LayerImpl* parent = AddChild<LayerImpl>(root); |
| 410 LayerImpl* child = AddChild<LayerImpl>(parent); | 403 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 411 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 404 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 412 | 405 |
| 413 // One-time setup of root layer | 406 // One-time setup of root layer |
| 414 root->SetBounds(gfx::Size(1, 2)); | 407 root->SetBounds(gfx::Size(1, 2)); |
| 415 | 408 |
| 416 TransformTree& transform_tree = | 409 TransformTree& transform_tree = |
| 417 host_impl()->active_tree()->property_trees()->transform_tree; | 410 host_impl()->active_tree()->property_trees()->transform_tree; |
| 418 EffectTree& effect_tree = | 411 EffectTree& effect_tree = |
| 419 host_impl()->active_tree()->property_trees()->effect_tree; | 412 host_impl()->active_tree()->property_trees()->effect_tree; |
| 420 | 413 |
| 421 // Case 1: parent's anchor point should not affect child or grand_child. | 414 // Case 1: parent's anchor point should not affect child or grand_child. |
| 422 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 3.0f, 0.f); | 415 parent->test_properties()->transform_origin = gfx::Point3F(2.5f, 3.0f, 0.f); |
| 423 parent->SetBounds(gfx::Size(10, 12)); | 416 parent->SetBounds(gfx::Size(10, 12)); |
| 424 child->SetBounds(gfx::Size(16, 18)); | 417 child->SetBounds(gfx::Size(16, 18)); |
| 425 grand_child->SetBounds(gfx::Size(76, 78)); | 418 grand_child->SetBounds(gfx::Size(76, 78)); |
| 426 ExecuteCalculateDrawProperties(root); | 419 ExecuteCalculateDrawProperties(root); |
| 427 | 420 |
| 428 EXPECT_TRANSFORMATION_MATRIX_EQ( | 421 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 429 identity_matrix, | 422 gfx::Transform(), |
| 430 draw_property_utils::DrawTransform(child, transform_tree, effect_tree)); | 423 draw_property_utils::DrawTransform(child, transform_tree, effect_tree)); |
| 431 EXPECT_TRANSFORMATION_MATRIX_EQ( | 424 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 432 identity_matrix, | 425 gfx::Transform(), |
| 433 draw_property_utils::ScreenSpaceTransform(child, transform_tree)); | 426 draw_property_utils::ScreenSpaceTransform(child, transform_tree)); |
| 434 EXPECT_TRANSFORMATION_MATRIX_EQ( | 427 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 435 identity_matrix, draw_property_utils::DrawTransform( | 428 gfx::Transform(), draw_property_utils::DrawTransform( |
| 436 grand_child, transform_tree, effect_tree)); | 429 grand_child, transform_tree, effect_tree)); |
| 437 EXPECT_TRANSFORMATION_MATRIX_EQ( | 430 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 438 identity_matrix, | 431 gfx::Transform(), |
| 439 draw_property_utils::ScreenSpaceTransform(grand_child, transform_tree)); | 432 draw_property_utils::ScreenSpaceTransform(grand_child, transform_tree)); |
| 440 | 433 |
| 441 // Case 2: parent's position affects child and grand_child. | 434 // Case 2: parent's position affects child and grand_child. |
| 442 gfx::Transform parent_position_transform; | 435 gfx::Transform parent_position_transform; |
| 443 parent_position_transform.Translate(0.f, 1.2f); | 436 parent_position_transform.Translate(0.f, 1.2f); |
| 444 parent->SetPosition(gfx::PointF(0.f, 1.2f)); | 437 parent->SetPosition(gfx::PointF(0.f, 1.2f)); |
| 445 host_impl()->active_tree()->property_trees()->needs_rebuild = true; | 438 host_impl()->active_tree()->property_trees()->needs_rebuild = true; |
| 446 ExecuteCalculateDrawProperties(root); | 439 ExecuteCalculateDrawProperties(root); |
| 447 EXPECT_TRANSFORMATION_MATRIX_EQ( | 440 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 448 parent_position_transform, | 441 parent_position_transform, |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 ASSERT_TRUE(child->has_render_surface()); | 1011 ASSERT_TRUE(child->has_render_surface()); |
| 1019 // This is the real test, the rest are sanity checks. | 1012 // This is the real test, the rest are sanity checks. |
| 1020 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1013 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1021 child->render_surface()->draw_transform()); | 1014 child->render_surface()->draw_transform()); |
| 1022 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); | 1015 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), child->DrawTransform()); |
| 1023 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1016 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1024 grand_child->DrawTransform()); | 1017 grand_child->DrawTransform()); |
| 1025 } | 1018 } |
| 1026 | 1019 |
| 1027 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { | 1020 TEST_F(LayerTreeHostCommonTest, RenderSurfaceWithSublayerScale) { |
| 1028 const gfx::Transform identity_matrix; | |
| 1029 LayerImpl* root = root_layer_for_testing(); | 1021 LayerImpl* root = root_layer_for_testing(); |
| 1030 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 1022 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 1031 LayerImpl* child = AddChild<LayerImpl>(render_surface); | 1023 LayerImpl* child = AddChild<LayerImpl>(render_surface); |
| 1032 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1024 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 1033 | 1025 |
| 1034 gfx::Transform translate; | 1026 gfx::Transform translate; |
| 1035 translate.Translate3d(5, 5, 5); | 1027 translate.Translate3d(5, 5, 5); |
| 1036 | 1028 |
| 1037 root->SetBounds(gfx::Size(100, 100)); | 1029 root->SetBounds(gfx::Size(100, 100)); |
| 1038 render_surface->SetTransform(translate); | 1030 render_surface->SetTransform(translate); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1056 // Between grand_child and render_surface, we translate by (10, 10) and scale | 1048 // Between grand_child and render_surface, we translate by (10, 10) and scale |
| 1057 // by a factor of 2. | 1049 // by a factor of 2. |
| 1058 gfx::Vector2dF expected_translation(20.0f, 20.0f); | 1050 gfx::Vector2dF expected_translation(20.0f, 20.0f); |
| 1059 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(), | 1051 EXPECT_EQ(grand_child->DrawTransform().To2dTranslation(), |
| 1060 expected_translation); | 1052 expected_translation); |
| 1061 } | 1053 } |
| 1062 | 1054 |
| 1063 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { | 1055 TEST_F(LayerTreeHostCommonTest, TransformAboveRootLayer) { |
| 1064 // Transformations applied at the root of the tree should be forwarded | 1056 // Transformations applied at the root of the tree should be forwarded |
| 1065 // to child layers instead of applied to the root RenderSurface. | 1057 // to child layers instead of applied to the root RenderSurface. |
| 1066 const gfx::Transform identity_matrix; | |
| 1067 LayerImpl* root = root_layer_for_testing(); | 1058 LayerImpl* root = root_layer_for_testing(); |
| 1068 LayerImpl* child = AddChild<LayerImpl>(root); | 1059 LayerImpl* child = AddChild<LayerImpl>(root); |
| 1069 | 1060 |
| 1070 root->SetDrawsContent(true); | 1061 root->SetDrawsContent(true); |
| 1071 root->SetBounds(gfx::Size(20, 20)); | 1062 root->SetBounds(gfx::Size(20, 20)); |
| 1072 child->SetDrawsContent(true); | 1063 child->SetDrawsContent(true); |
| 1073 child->SetScrollClipLayer(root->id()); | 1064 child->SetScrollClipLayer(root->id()); |
| 1074 child->SetBounds(gfx::Size(20, 20)); | 1065 child->SetBounds(gfx::Size(20, 20)); |
| 1075 | 1066 |
| 1076 gfx::Transform translate; | 1067 gfx::Transform translate; |
| 1077 translate.Translate(50, 50); | 1068 translate.Translate(50, 50); |
| 1078 { | 1069 { |
| 1079 LayerImplList render_surface_layer_list_impl; | 1070 LayerImplList render_surface_layer_list_impl; |
| 1080 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1071 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1081 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1072 root, root->bounds(), translate, &render_surface_layer_list_impl); |
| 1082 inputs.property_trees->needs_rebuild = true; | 1073 inputs.property_trees->needs_rebuild = true; |
| 1083 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1074 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1084 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1075 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1085 translate, root->draw_properties().target_space_transform); | 1076 translate, root->draw_properties().target_space_transform); |
| 1086 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1077 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1087 translate, child->draw_properties().target_space_transform); | 1078 translate, child->draw_properties().target_space_transform); |
| 1088 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1079 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1089 root->render_surface()->draw_transform()); | 1080 root->render_surface()->draw_transform()); |
| 1090 } | 1081 } |
| 1091 | 1082 |
| 1092 gfx::Transform scale; | 1083 gfx::Transform scale; |
| 1093 scale.Scale(2, 2); | 1084 scale.Scale(2, 2); |
| 1094 { | 1085 { |
| 1095 LayerImplList render_surface_layer_list_impl; | 1086 LayerImplList render_surface_layer_list_impl; |
| 1096 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1087 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1097 root, root->bounds(), scale, &render_surface_layer_list_impl); | 1088 root, root->bounds(), scale, &render_surface_layer_list_impl); |
| 1098 inputs.property_trees->needs_rebuild = true; | 1089 inputs.property_trees->needs_rebuild = true; |
| 1099 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1090 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1100 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1091 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1101 scale, root->draw_properties().target_space_transform); | 1092 scale, root->draw_properties().target_space_transform); |
| 1102 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1093 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1103 scale, child->draw_properties().target_space_transform); | 1094 scale, child->draw_properties().target_space_transform); |
| 1104 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1095 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1105 root->render_surface()->draw_transform()); | 1096 root->render_surface()->draw_transform()); |
| 1106 } | 1097 } |
| 1107 | 1098 |
| 1108 gfx::Transform rotate; | 1099 gfx::Transform rotate; |
| 1109 rotate.Rotate(2); | 1100 rotate.Rotate(2); |
| 1110 { | 1101 { |
| 1111 LayerImplList render_surface_layer_list_impl; | 1102 LayerImplList render_surface_layer_list_impl; |
| 1112 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1103 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1113 root, root->bounds(), rotate, &render_surface_layer_list_impl); | 1104 root, root->bounds(), rotate, &render_surface_layer_list_impl); |
| 1114 inputs.property_trees->needs_rebuild = true; | 1105 inputs.property_trees->needs_rebuild = true; |
| 1115 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1106 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1116 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1107 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1117 rotate, root->draw_properties().target_space_transform); | 1108 rotate, root->draw_properties().target_space_transform); |
| 1118 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1109 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1119 rotate, child->draw_properties().target_space_transform); | 1110 rotate, child->draw_properties().target_space_transform); |
| 1120 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1111 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1121 root->render_surface()->draw_transform()); | 1112 root->render_surface()->draw_transform()); |
| 1122 } | 1113 } |
| 1123 | 1114 |
| 1124 gfx::Transform composite; | 1115 gfx::Transform composite; |
| 1125 composite.ConcatTransform(translate); | 1116 composite.ConcatTransform(translate); |
| 1126 composite.ConcatTransform(scale); | 1117 composite.ConcatTransform(scale); |
| 1127 composite.ConcatTransform(rotate); | 1118 composite.ConcatTransform(rotate); |
| 1128 { | 1119 { |
| 1129 LayerImplList render_surface_layer_list_impl; | 1120 LayerImplList render_surface_layer_list_impl; |
| 1130 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1121 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1131 root, root->bounds(), composite, &render_surface_layer_list_impl); | 1122 root, root->bounds(), composite, &render_surface_layer_list_impl); |
| 1132 inputs.property_trees->needs_rebuild = true; | 1123 inputs.property_trees->needs_rebuild = true; |
| 1133 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1124 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1134 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1125 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1135 composite, root->draw_properties().target_space_transform); | 1126 composite, root->draw_properties().target_space_transform); |
| 1136 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1127 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1137 composite, child->draw_properties().target_space_transform); | 1128 composite, child->draw_properties().target_space_transform); |
| 1138 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1129 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1139 root->render_surface()->draw_transform()); | 1130 root->render_surface()->draw_transform()); |
| 1140 } | 1131 } |
| 1141 | 1132 |
| 1142 // Verify it composes correctly with device scale. | 1133 // Verify it composes correctly with device scale. |
| 1143 float device_scale_factor = 1.5f; | 1134 float device_scale_factor = 1.5f; |
| 1144 | 1135 |
| 1145 { | 1136 { |
| 1146 LayerImplList render_surface_layer_list_impl; | 1137 LayerImplList render_surface_layer_list_impl; |
| 1147 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1138 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1148 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1139 root, root->bounds(), translate, &render_surface_layer_list_impl); |
| 1149 inputs.device_scale_factor = device_scale_factor; | 1140 inputs.device_scale_factor = device_scale_factor; |
| 1150 inputs.property_trees->needs_rebuild = true; | 1141 inputs.property_trees->needs_rebuild = true; |
| 1151 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1142 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1152 gfx::Transform device_scaled_translate = translate; | 1143 gfx::Transform device_scaled_translate = translate; |
| 1153 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); | 1144 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); |
| 1154 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1145 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1155 device_scaled_translate, | 1146 device_scaled_translate, |
| 1156 root->draw_properties().target_space_transform); | 1147 root->draw_properties().target_space_transform); |
| 1157 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1148 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1158 device_scaled_translate, | 1149 device_scaled_translate, |
| 1159 child->draw_properties().target_space_transform); | 1150 child->draw_properties().target_space_transform); |
| 1160 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1151 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1161 root->render_surface()->draw_transform()); | 1152 root->render_surface()->draw_transform()); |
| 1162 } | 1153 } |
| 1163 | 1154 |
| 1164 // Verify it composes correctly with page scale. | 1155 // Verify it composes correctly with page scale. |
| 1165 float page_scale_factor = 2.f; | 1156 float page_scale_factor = 2.f; |
| 1166 | 1157 |
| 1167 { | 1158 { |
| 1168 LayerImplList render_surface_layer_list_impl; | 1159 LayerImplList render_surface_layer_list_impl; |
| 1169 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1160 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1170 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1161 root, root->bounds(), translate, &render_surface_layer_list_impl); |
| 1171 inputs.page_scale_factor = page_scale_factor; | 1162 inputs.page_scale_factor = page_scale_factor; |
| 1172 inputs.page_scale_layer = root; | 1163 inputs.page_scale_layer = root; |
| 1173 inputs.property_trees->needs_rebuild = true; | 1164 inputs.property_trees->needs_rebuild = true; |
| 1174 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1165 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1175 gfx::Transform page_scaled_translate = translate; | 1166 gfx::Transform page_scaled_translate = translate; |
| 1176 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); | 1167 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); |
| 1177 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1168 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1178 page_scaled_translate, root->draw_properties().target_space_transform); | 1169 page_scaled_translate, root->draw_properties().target_space_transform); |
| 1179 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1170 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1180 page_scaled_translate, child->draw_properties().target_space_transform); | 1171 page_scaled_translate, child->draw_properties().target_space_transform); |
| 1181 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1172 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1182 root->render_surface()->draw_transform()); | 1173 root->render_surface()->draw_transform()); |
| 1183 } | 1174 } |
| 1184 | 1175 |
| 1185 // Verify that it composes correctly with transforms directly on root layer. | 1176 // Verify that it composes correctly with transforms directly on root layer. |
| 1186 root->SetTransform(composite); | 1177 root->SetTransform(composite); |
| 1187 | 1178 |
| 1188 { | 1179 { |
| 1189 LayerImplList render_surface_layer_list_impl; | 1180 LayerImplList render_surface_layer_list_impl; |
| 1190 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1181 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1191 root, root->bounds(), composite, &render_surface_layer_list_impl); | 1182 root, root->bounds(), composite, &render_surface_layer_list_impl); |
| 1192 inputs.property_trees->needs_rebuild = true; | 1183 inputs.property_trees->needs_rebuild = true; |
| 1193 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1184 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 1194 gfx::Transform compositeSquared = composite; | 1185 gfx::Transform compositeSquared = composite; |
| 1195 compositeSquared.ConcatTransform(composite); | 1186 compositeSquared.ConcatTransform(composite); |
| 1196 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1187 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1197 compositeSquared, root->draw_properties().target_space_transform); | 1188 compositeSquared, root->draw_properties().target_space_transform); |
| 1198 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1189 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 1199 compositeSquared, child->draw_properties().target_space_transform); | 1190 compositeSquared, child->draw_properties().target_space_transform); |
| 1200 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 1191 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 1201 root->render_surface()->draw_transform()); | 1192 root->render_surface()->draw_transform()); |
| 1202 } | 1193 } |
| 1203 } | 1194 } |
| 1204 | 1195 |
| 1205 TEST_F(LayerTreeHostCommonTest, | 1196 TEST_F(LayerTreeHostCommonTest, |
| 1206 RenderSurfaceListForRenderSurfaceWithClippedLayer) { | 1197 RenderSurfaceListForRenderSurfaceWithClippedLayer) { |
| 1207 LayerImpl* root = root_layer_for_testing(); | 1198 LayerImpl* root = root_layer_for_testing(); |
| 1208 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); | 1199 LayerImpl* render_surface1 = AddChildToRoot<LayerImpl>(); |
| 1209 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 1200 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
| 1210 | 1201 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 | 1623 |
| 1633 // In this configuration, grand_child should be outside the clipped | 1624 // In this configuration, grand_child should be outside the clipped |
| 1634 // content rect of the child, making grand_child not appear in the | 1625 // content rect of the child, making grand_child not appear in the |
| 1635 // render_surface_layer_list. | 1626 // render_surface_layer_list. |
| 1636 | 1627 |
| 1637 LayerImpl* root = root_layer_for_testing(); | 1628 LayerImpl* root = root_layer_for_testing(); |
| 1638 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 1629 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 1639 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 1630 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 1640 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child); | 1631 LayerImpl* leaf_node = AddChild<LayerImpl>(grand_child); |
| 1641 | 1632 |
| 1642 const gfx::Transform identity_matrix; | |
| 1643 | |
| 1644 root->SetMasksToBounds(true); | 1633 root->SetMasksToBounds(true); |
| 1645 root->SetBounds(gfx::Size(100, 100)); | 1634 root->SetBounds(gfx::Size(100, 100)); |
| 1646 child->SetBounds(gfx::Size(20, 20)); | 1635 child->SetBounds(gfx::Size(20, 20)); |
| 1647 child->test_properties()->force_render_surface = true; | 1636 child->test_properties()->force_render_surface = true; |
| 1648 grand_child->SetPosition(gfx::PointF(200.f, 200.f)); | 1637 grand_child->SetPosition(gfx::PointF(200.f, 200.f)); |
| 1649 grand_child->SetBounds(gfx::Size(10, 10)); | 1638 grand_child->SetBounds(gfx::Size(10, 10)); |
| 1650 grand_child->test_properties()->force_render_surface = true; | 1639 grand_child->test_properties()->force_render_surface = true; |
| 1651 leaf_node->SetBounds(gfx::Size(10, 10)); | 1640 leaf_node->SetBounds(gfx::Size(10, 10)); |
| 1652 leaf_node->SetDrawsContent(true); | 1641 leaf_node->SetDrawsContent(true); |
| 1653 ExecuteCalculateDrawProperties(root); | 1642 ExecuteCalculateDrawProperties(root); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1665 // render target, | 1654 // render target, |
| 1666 // - a surface is clipped by an ancestor that contributes to the same | 1655 // - a surface is clipped by an ancestor that contributes to the same |
| 1667 // render target. | 1656 // render target. |
| 1668 // | 1657 // |
| 1669 // In particular, for a layer that owns a render surface: | 1658 // In particular, for a layer that owns a render surface: |
| 1670 // - the render surface inherits any clip from ancestors, and does NOT | 1659 // - the render surface inherits any clip from ancestors, and does NOT |
| 1671 // pass that clipped status to the layer itself. | 1660 // pass that clipped status to the layer itself. |
| 1672 // - but if the layer itself masks to bounds, it is considered clipped | 1661 // - but if the layer itself masks to bounds, it is considered clipped |
| 1673 // and propagates the clip to the subtree. | 1662 // and propagates the clip to the subtree. |
| 1674 | 1663 |
| 1675 const gfx::Transform identity_matrix; | |
| 1676 LayerImpl* root = root_layer_for_testing(); | 1664 LayerImpl* root = root_layer_for_testing(); |
| 1677 LayerImpl* parent = AddChild<LayerImpl>(root); | 1665 LayerImpl* parent = AddChild<LayerImpl>(root); |
| 1678 LayerImpl* child1 = AddChild<LayerImpl>(parent); | 1666 LayerImpl* child1 = AddChild<LayerImpl>(parent); |
| 1679 LayerImpl* child2 = AddChild<LayerImpl>(parent); | 1667 LayerImpl* child2 = AddChild<LayerImpl>(parent); |
| 1680 LayerImpl* grand_child = AddChild<LayerImpl>(child1); | 1668 LayerImpl* grand_child = AddChild<LayerImpl>(child1); |
| 1681 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child); | 1669 LayerImpl* leaf_node1 = AddChild<LayerImpl>(grand_child); |
| 1682 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2); | 1670 LayerImpl* leaf_node2 = AddChild<LayerImpl>(child2); |
| 1683 | 1671 |
| 1684 root->SetBounds(gfx::Size(100, 100)); | 1672 root->SetBounds(gfx::Size(100, 100)); |
| 1685 parent->SetBounds(gfx::Size(100, 100)); | 1673 parent->SetBounds(gfx::Size(100, 100)); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 // grand_child1 - completely inside the region; DrawableContentRect should | 1934 // grand_child1 - completely inside the region; DrawableContentRect should |
| 1947 // be the layer rect expressed in target space. | 1935 // be the layer rect expressed in target space. |
| 1948 // grand_child2 - partially clipped but NOT MasksToBounds; the clip rect | 1936 // grand_child2 - partially clipped but NOT MasksToBounds; the clip rect |
| 1949 // will be the intersection of layer bounds and the mask region. | 1937 // will be the intersection of layer bounds and the mask region. |
| 1950 // grand_child3 - partially clipped and MasksToBounds; the | 1938 // grand_child3 - partially clipped and MasksToBounds; the |
| 1951 // DrawableContentRect will still be the intersection of layer bounds and | 1939 // DrawableContentRect will still be the intersection of layer bounds and |
| 1952 // the mask region. | 1940 // the mask region. |
| 1953 // grand_child4 - outside parent's clip rect; the DrawableContentRect should | 1941 // grand_child4 - outside parent's clip rect; the DrawableContentRect should |
| 1954 // be empty. | 1942 // be empty. |
| 1955 | 1943 |
| 1956 const gfx::Transform identity_matrix; | |
| 1957 LayerImpl* parent = root_layer_for_testing(); | 1944 LayerImpl* parent = root_layer_for_testing(); |
| 1958 LayerImpl* child = AddChild<LayerImpl>(parent); | 1945 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 1959 LayerImpl* grand_child1 = AddChild<LayerImpl>(child); | 1946 LayerImpl* grand_child1 = AddChild<LayerImpl>(child); |
| 1960 LayerImpl* grand_child2 = AddChild<LayerImpl>(child); | 1947 LayerImpl* grand_child2 = AddChild<LayerImpl>(child); |
| 1961 LayerImpl* grand_child3 = AddChild<LayerImpl>(child); | 1948 LayerImpl* grand_child3 = AddChild<LayerImpl>(child); |
| 1962 LayerImpl* grand_child4 = AddChild<LayerImpl>(child); | 1949 LayerImpl* grand_child4 = AddChild<LayerImpl>(child); |
| 1963 | 1950 |
| 1964 parent->SetBounds(gfx::Size(500, 500)); | 1951 parent->SetBounds(gfx::Size(500, 500)); |
| 1965 child->SetMasksToBounds(true); | 1952 child->SetMasksToBounds(true); |
| 1966 child->SetBounds(gfx::Size(20, 20)); | 1953 child->SetBounds(gfx::Size(20, 20)); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 LayerImpl* root = root_layer_for_testing(); | 2489 LayerImpl* root = root_layer_for_testing(); |
| 2503 LayerImpl* child = AddChild<LayerImpl>(root); | 2490 LayerImpl* child = AddChild<LayerImpl>(root); |
| 2504 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 2491 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 2505 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); | 2492 LayerImpl* great_grand_child = AddChild<LayerImpl>(grand_child); |
| 2506 | 2493 |
| 2507 root->SetDrawsContent(true); | 2494 root->SetDrawsContent(true); |
| 2508 child->SetDrawsContent(true); | 2495 child->SetDrawsContent(true); |
| 2509 grand_child->SetDrawsContent(true); | 2496 grand_child->SetDrawsContent(true); |
| 2510 great_grand_child->SetDrawsContent(true); | 2497 great_grand_child->SetDrawsContent(true); |
| 2511 | 2498 |
| 2512 gfx::Transform identity; | |
| 2513 | |
| 2514 root->SetBounds(gfx::Size(10, 10)); | 2499 root->SetBounds(gfx::Size(10, 10)); |
| 2515 child->SetBounds(gfx::Size(10, 10)); | 2500 child->SetBounds(gfx::Size(10, 10)); |
| 2516 grand_child->SetBounds(gfx::Size(10, 10)); | 2501 grand_child->SetBounds(gfx::Size(10, 10)); |
| 2517 great_grand_child->SetBounds(gfx::Size(10, 10)); | 2502 great_grand_child->SetBounds(gfx::Size(10, 10)); |
| 2518 | 2503 |
| 2519 SetElementIdsForTesting(); | 2504 SetElementIdsForTesting(); |
| 2520 | 2505 |
| 2521 // Add a transform animation with a start delay to |grand_child|. | 2506 // Add a transform animation with a start delay to |grand_child|. |
| 2522 std::unique_ptr<Animation> animation = Animation::Create( | 2507 std::unique_ptr<Animation> animation = Animation::Create( |
| 2523 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, | 2508 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 0, 1, |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2935 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect()); | 2920 EXPECT_EQ(gfx::Rect(5, 5, 50, 50), grand_child1->drawable_content_rect()); |
| 2936 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect()); | 2921 EXPECT_EQ(gfx::Rect(75, 75, 25, 25), grand_child2->drawable_content_rect()); |
| 2937 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty()); | 2922 EXPECT_TRUE(grand_child3->drawable_content_rect().IsEmpty()); |
| 2938 } | 2923 } |
| 2939 | 2924 |
| 2940 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) { | 2925 TEST_F(LayerTreeHostCommonTest, VisibleContentRectWithClippingAndScaling) { |
| 2941 LayerImpl* root = root_layer_for_testing(); | 2926 LayerImpl* root = root_layer_for_testing(); |
| 2942 LayerImpl* child = AddChild<LayerImpl>(root); | 2927 LayerImpl* child = AddChild<LayerImpl>(root); |
| 2943 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 2928 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 2944 | 2929 |
| 2945 gfx::Transform identity_matrix; | |
| 2946 gfx::Transform child_scale_matrix; | 2930 gfx::Transform child_scale_matrix; |
| 2947 child_scale_matrix.Scale(0.25f, 0.25f); | 2931 child_scale_matrix.Scale(0.25f, 0.25f); |
| 2948 gfx::Transform grand_child_scale_matrix; | 2932 gfx::Transform grand_child_scale_matrix; |
| 2949 grand_child_scale_matrix.Scale(0.246f, 0.246f); | 2933 grand_child_scale_matrix.Scale(0.246f, 0.246f); |
| 2950 | 2934 |
| 2951 root->SetBounds(gfx::Size(100, 100)); | 2935 root->SetBounds(gfx::Size(100, 100)); |
| 2952 child->SetTransform(child_scale_matrix); | 2936 child->SetTransform(child_scale_matrix); |
| 2953 child->SetBounds(gfx::Size(10, 10)); | 2937 child->SetBounds(gfx::Size(10, 10)); |
| 2954 child->SetMasksToBounds(true); | 2938 child->SetMasksToBounds(true); |
| 2955 grand_child->SetTransform(grand_child_scale_matrix); | 2939 grand_child->SetTransform(grand_child_scale_matrix); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3231 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { | 3215 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { |
| 3232 LayerImpl* root = root_layer_for_testing(); | 3216 LayerImpl* root = root_layer_for_testing(); |
| 3233 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 3217 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 3234 | 3218 |
| 3235 root->SetBounds(gfx::Size(100, 100)); | 3219 root->SetBounds(gfx::Size(100, 100)); |
| 3236 child->SetPosition(gfx::PointF(5.f, 5.f)); | 3220 child->SetPosition(gfx::PointF(5.f, 5.f)); |
| 3237 child->SetBounds(gfx::Size(50, 50)); | 3221 child->SetBounds(gfx::Size(50, 50)); |
| 3238 child->SetDrawsContent(true); | 3222 child->SetDrawsContent(true); |
| 3239 | 3223 |
| 3240 // Case 1: a truly degenerate matrix | 3224 // Case 1: a truly degenerate matrix |
| 3241 gfx::Transform identity_matrix; | |
| 3242 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | 3225 gfx::Transform uninvertible_matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); |
| 3243 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); | 3226 ASSERT_FALSE(uninvertible_matrix.IsInvertible()); |
| 3244 | 3227 |
| 3245 child->SetTransform(uninvertible_matrix); | 3228 child->SetTransform(uninvertible_matrix); |
| 3246 ExecuteCalculateDrawProperties(root); | 3229 ExecuteCalculateDrawProperties(root); |
| 3247 | 3230 |
| 3248 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); | 3231 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); |
| 3249 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); | 3232 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
| 3250 | 3233 |
| 3251 // Case 2: a matrix with flattened z, uninvertible and not visible according | 3234 // Case 2: a matrix with flattened z, uninvertible and not visible according |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3272 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); | 3255 EXPECT_TRUE(child->visible_layer_rect().IsEmpty()); |
| 3273 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); | 3256 EXPECT_TRUE(child->drawable_content_rect().IsEmpty()); |
| 3274 } | 3257 } |
| 3275 | 3258 |
| 3276 TEST_F(LayerTreeHostCommonTest, | 3259 TEST_F(LayerTreeHostCommonTest, |
| 3277 VisibleContentRectForLayerWithUninvertibleDrawTransform) { | 3260 VisibleContentRectForLayerWithUninvertibleDrawTransform) { |
| 3278 LayerImpl* root = root_layer_for_testing(); | 3261 LayerImpl* root = root_layer_for_testing(); |
| 3279 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 3262 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 3280 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 3263 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 3281 | 3264 |
| 3282 gfx::Transform identity_matrix; | |
| 3283 | |
| 3284 gfx::Transform perspective; | 3265 gfx::Transform perspective; |
| 3285 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); | 3266 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); |
| 3286 | 3267 |
| 3287 gfx::Transform rotation; | 3268 gfx::Transform rotation; |
| 3288 rotation.RotateAboutYAxis(45.0); | 3269 rotation.RotateAboutYAxis(45.0); |
| 3289 | 3270 |
| 3290 root->SetBounds(gfx::Size(100, 100)); | 3271 root->SetBounds(gfx::Size(100, 100)); |
| 3291 child->SetTransform(perspective); | 3272 child->SetTransform(perspective); |
| 3292 child->SetPosition(gfx::PointF(10.f, 10.f)); | 3273 child->SetPosition(gfx::PointF(10.f, 10.f)); |
| 3293 child->SetBounds(gfx::Size(100, 100)); | 3274 child->SetBounds(gfx::Size(100, 100)); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3402 | 3383 |
| 3403 std::unique_ptr<LayerImpl> root = | 3384 std::unique_ptr<LayerImpl> root = |
| 3404 LayerImpl::Create(host_impl.active_tree(), 1); | 3385 LayerImpl::Create(host_impl.active_tree(), 1); |
| 3405 std::unique_ptr<LayerImpl> child = | 3386 std::unique_ptr<LayerImpl> child = |
| 3406 LayerImpl::Create(host_impl.active_tree(), 2); | 3387 LayerImpl::Create(host_impl.active_tree(), 2); |
| 3407 std::unique_ptr<LayerImpl> grand_child = | 3388 std::unique_ptr<LayerImpl> grand_child = |
| 3408 LayerImpl::Create(host_impl.active_tree(), 3); | 3389 LayerImpl::Create(host_impl.active_tree(), 3); |
| 3409 std::unique_ptr<LayerImpl> occluding_child = | 3390 std::unique_ptr<LayerImpl> occluding_child = |
| 3410 LayerImpl::Create(host_impl.active_tree(), 4); | 3391 LayerImpl::Create(host_impl.active_tree(), 4); |
| 3411 | 3392 |
| 3412 gfx::Transform identity_matrix; | |
| 3413 gfx::Transform perspective; | 3393 gfx::Transform perspective; |
| 3414 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); | 3394 perspective.ApplyPerspectiveDepth(SkDoubleToMScalar(1e-12)); |
| 3415 | 3395 |
| 3416 gfx::Transform rotation; | 3396 gfx::Transform rotation; |
| 3417 rotation.RotateAboutYAxis(45.0); | 3397 rotation.RotateAboutYAxis(45.0); |
| 3418 | 3398 |
| 3419 root->SetBounds(gfx::Size(1000, 1000)); | 3399 root->SetBounds(gfx::Size(1000, 1000)); |
| 3420 child->SetTransform(perspective); | 3400 child->SetTransform(perspective); |
| 3421 child->SetPosition(gfx::PointF(10.f, 10.f)); | 3401 child->SetPosition(gfx::PointF(10.f, 10.f)); |
| 3422 child->SetBounds(gfx::Size(300, 300)); | 3402 child->SetBounds(gfx::Size(300, 300)); |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3780 } | 3760 } |
| 3781 | 3761 |
| 3782 TEST_F(LayerTreeHostCommonTest, | 3762 TEST_F(LayerTreeHostCommonTest, |
| 3783 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { | 3763 DrawableAndVisibleContentRectsWithTransformOnUnclippedSurface) { |
| 3784 // Layers that have non-axis aligned bounds (due to transforms) have an | 3764 // Layers that have non-axis aligned bounds (due to transforms) have an |
| 3785 // expanded, axis-aligned DrawableContentRect and visible content rect. | 3765 // expanded, axis-aligned DrawableContentRect and visible content rect. |
| 3786 LayerImpl* root = root_layer_for_testing(); | 3766 LayerImpl* root = root_layer_for_testing(); |
| 3787 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); | 3767 LayerImpl* render_surface = AddChildToRoot<LayerImpl>(); |
| 3788 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); | 3768 LayerImpl* child1 = AddChild<LayerImpl>(render_surface); |
| 3789 | 3769 |
| 3790 gfx::Transform identity_matrix; | |
| 3791 gfx::Transform child_rotation; | 3770 gfx::Transform child_rotation; |
| 3792 child_rotation.Rotate(45.0); | 3771 child_rotation.Rotate(45.0); |
| 3793 | 3772 |
| 3794 root->SetBounds(gfx::Size(100, 100)); | 3773 root->SetBounds(gfx::Size(100, 100)); |
| 3795 render_surface->SetBounds(gfx::Size(3, 4)); | 3774 render_surface->SetBounds(gfx::Size(3, 4)); |
| 3796 render_surface->test_properties()->force_render_surface = true; | 3775 render_surface->test_properties()->force_render_surface = true; |
| 3797 child1->SetTransform(child_rotation); | 3776 child1->SetTransform(child_rotation); |
| 3798 child1->SetPosition(gfx::PointF(25.f, 25.f)); | 3777 child1->SetPosition(gfx::PointF(25.f, 25.f)); |
| 3799 child1->SetBounds(gfx::Size(50, 50)); | 3778 child1->SetBounds(gfx::Size(50, 50)); |
| 3800 child1->SetDrawsContent(true); | 3779 child1->SetDrawsContent(true); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3935 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); | 3914 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_layer_rect()); |
| 3936 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect()); | 3915 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_layer_rect()); |
| 3937 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); | 3916 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_layer_rect()); |
| 3938 } | 3917 } |
| 3939 | 3918 |
| 3940 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { | 3919 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithoutPreserves3d) { |
| 3941 // Verify the behavior of back-face culling when there are no preserve-3d | 3920 // Verify the behavior of back-face culling when there are no preserve-3d |
| 3942 // layers. Note that 3d transforms still apply in this case, but they are | 3921 // layers. Note that 3d transforms still apply in this case, but they are |
| 3943 // "flattened" to each parent layer according to current W3C spec. | 3922 // "flattened" to each parent layer according to current W3C spec. |
| 3944 | 3923 |
| 3945 const gfx::Transform identity_matrix; | |
| 3946 LayerImpl* root = root_layer_for_testing(); | 3924 LayerImpl* root = root_layer_for_testing(); |
| 3947 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>(); | 3925 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>(); |
| 3948 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>(); | 3926 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>(); |
| 3949 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); | 3927 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); |
| 3950 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); | 3928 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); |
| 3951 LayerImpl* front_facing_child_of_front_facing_surface = | 3929 LayerImpl* front_facing_child_of_front_facing_surface = |
| 3952 AddChild<LayerImpl>(front_facing_surface); | 3930 AddChild<LayerImpl>(front_facing_surface); |
| 3953 LayerImpl* back_facing_child_of_front_facing_surface = | 3931 LayerImpl* back_facing_child_of_front_facing_surface = |
| 3954 AddChild<LayerImpl>(front_facing_surface); | 3932 AddChild<LayerImpl>(front_facing_surface); |
| 3955 LayerImpl* front_facing_child_of_back_facing_surface = | 3933 LayerImpl* front_facing_child_of_back_facing_surface = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4026 EXPECT_TRUE(UpdateLayerListImplContains( | 4004 EXPECT_TRUE(UpdateLayerListImplContains( |
| 4027 front_facing_child_of_front_facing_surface->id())); | 4005 front_facing_child_of_front_facing_surface->id())); |
| 4028 EXPECT_TRUE(UpdateLayerListImplContains( | 4006 EXPECT_TRUE(UpdateLayerListImplContains( |
| 4029 front_facing_child_of_back_facing_surface->id())); | 4007 front_facing_child_of_back_facing_surface->id())); |
| 4030 } | 4008 } |
| 4031 | 4009 |
| 4032 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { | 4010 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithPreserves3d) { |
| 4033 // Verify the behavior of back-face culling when preserves-3d transform style | 4011 // Verify the behavior of back-face culling when preserves-3d transform style |
| 4034 // is used. | 4012 // is used. |
| 4035 | 4013 |
| 4036 const gfx::Transform identity_matrix; | |
| 4037 LayerImpl* root = root_layer_for_testing(); | 4014 LayerImpl* root = root_layer_for_testing(); |
| 4038 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>(); | 4015 LayerImpl* front_facing_child = AddChildToRoot<LayerImpl>(); |
| 4039 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>(); | 4016 LayerImpl* back_facing_child = AddChildToRoot<LayerImpl>(); |
| 4040 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); | 4017 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); |
| 4041 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); | 4018 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); |
| 4042 LayerImpl* front_facing_child_of_front_facing_surface = | 4019 LayerImpl* front_facing_child_of_front_facing_surface = |
| 4043 AddChild<LayerImpl>(front_facing_surface); | 4020 AddChild<LayerImpl>(front_facing_surface); |
| 4044 LayerImpl* back_facing_child_of_front_facing_surface = | 4021 LayerImpl* back_facing_child_of_front_facing_surface = |
| 4045 AddChild<LayerImpl>(front_facing_surface); | 4022 AddChild<LayerImpl>(front_facing_surface); |
| 4046 LayerImpl* front_facing_child_of_back_facing_surface = | 4023 LayerImpl* front_facing_child_of_back_facing_surface = |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4136 EXPECT_TRUE(UpdateLayerListImplContains( | 4113 EXPECT_TRUE(UpdateLayerListImplContains( |
| 4137 front_facing_child_of_front_facing_surface->id())); | 4114 front_facing_child_of_front_facing_surface->id())); |
| 4138 } | 4115 } |
| 4139 | 4116 |
| 4140 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { | 4117 TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { |
| 4141 // Verify that layers are appropriately culled when their back face is showing | 4118 // Verify that layers are appropriately culled when their back face is showing |
| 4142 // and they are not double sided, while animations are going on. | 4119 // and they are not double sided, while animations are going on. |
| 4143 // | 4120 // |
| 4144 // Even layers that are animating get culled if their back face is showing and | 4121 // Even layers that are animating get culled if their back face is showing and |
| 4145 // they are not double sided. | 4122 // they are not double sided. |
| 4146 const gfx::Transform identity_matrix; | |
| 4147 LayerImpl* root = root_layer_for_testing(); | 4123 LayerImpl* root = root_layer_for_testing(); |
| 4148 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 4124 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 4149 LayerImpl* animating_surface = AddChildToRoot<LayerImpl>(); | 4125 LayerImpl* animating_surface = AddChildToRoot<LayerImpl>(); |
| 4150 LayerImpl* child_of_animating_surface = | 4126 LayerImpl* child_of_animating_surface = |
| 4151 AddChild<LayerImpl>(animating_surface); | 4127 AddChild<LayerImpl>(animating_surface); |
| 4152 LayerImpl* animating_child = AddChildToRoot<LayerImpl>(); | 4128 LayerImpl* animating_child = AddChildToRoot<LayerImpl>(); |
| 4153 LayerImpl* child2 = AddChildToRoot<LayerImpl>(); | 4129 LayerImpl* child2 = AddChildToRoot<LayerImpl>(); |
| 4154 | 4130 |
| 4155 // Nothing is double-sided | 4131 // Nothing is double-sided |
| 4156 child->test_properties()->double_sided = false; | 4132 child->test_properties()->double_sided = false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4211 EXPECT_TRUE(animating_child->visible_layer_rect().IsEmpty()); | 4187 EXPECT_TRUE(animating_child->visible_layer_rect().IsEmpty()); |
| 4212 | 4188 |
| 4213 EXPECT_EQ(gfx::Rect(100, 100), child2->visible_layer_rect()); | 4189 EXPECT_EQ(gfx::Rect(100, 100), child2->visible_layer_rect()); |
| 4214 } | 4190 } |
| 4215 | 4191 |
| 4216 TEST_F(LayerTreeHostCommonTest, | 4192 TEST_F(LayerTreeHostCommonTest, |
| 4217 BackFaceCullingWithPreserves3dForFlatteningSurface) { | 4193 BackFaceCullingWithPreserves3dForFlatteningSurface) { |
| 4218 // Verify the behavior of back-face culling for a render surface that is | 4194 // Verify the behavior of back-face culling for a render surface that is |
| 4219 // created when it flattens its subtree, and its parent has preserves-3d. | 4195 // created when it flattens its subtree, and its parent has preserves-3d. |
| 4220 | 4196 |
| 4221 const gfx::Transform identity_matrix; | |
| 4222 LayerImpl* root = root_layer_for_testing(); | 4197 LayerImpl* root = root_layer_for_testing(); |
| 4223 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); | 4198 LayerImpl* front_facing_surface = AddChildToRoot<LayerImpl>(); |
| 4224 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); | 4199 LayerImpl* back_facing_surface = AddChildToRoot<LayerImpl>(); |
| 4225 LayerImpl* child1 = AddChild<LayerImpl>(front_facing_surface); | 4200 LayerImpl* child1 = AddChild<LayerImpl>(front_facing_surface); |
| 4226 LayerImpl* child2 = AddChild<LayerImpl>(back_facing_surface); | 4201 LayerImpl* child2 = AddChild<LayerImpl>(back_facing_surface); |
| 4227 | 4202 |
| 4228 // RenderSurfaces are not double-sided | 4203 // RenderSurfaces are not double-sided |
| 4229 front_facing_surface->test_properties()->double_sided = false; | 4204 front_facing_surface->test_properties()->double_sided = false; |
| 4230 back_facing_surface->test_properties()->double_sided = false; | 4205 back_facing_surface->test_properties()->double_sided = false; |
| 4231 | 4206 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4262 EXPECT_FALSE(child1->has_render_surface()); | 4237 EXPECT_FALSE(child1->has_render_surface()); |
| 4263 EXPECT_FALSE(child2->has_render_surface()); | 4238 EXPECT_FALSE(child2->has_render_surface()); |
| 4264 | 4239 |
| 4265 EXPECT_EQ(2u, update_layer_list_impl()->size()); | 4240 EXPECT_EQ(2u, update_layer_list_impl()->size()); |
| 4266 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); | 4241 EXPECT_TRUE(UpdateLayerListImplContains(front_facing_surface->id())); |
| 4267 EXPECT_TRUE(UpdateLayerListImplContains(child1->id())); | 4242 EXPECT_TRUE(UpdateLayerListImplContains(child1->id())); |
| 4268 } | 4243 } |
| 4269 | 4244 |
| 4270 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) { | 4245 TEST_F(LayerTreeHostCommonScalingTest, LayerTransformsInHighDPI) { |
| 4271 // Verify draw and screen space transforms of layers not in a surface. | 4246 // Verify draw and screen space transforms of layers not in a surface. |
| 4272 gfx::Transform identity_matrix; | |
| 4273 | |
| 4274 LayerImpl* root = root_layer_for_testing(); | 4247 LayerImpl* root = root_layer_for_testing(); |
| 4275 root->SetBounds(gfx::Size(100, 100)); | 4248 root->SetBounds(gfx::Size(100, 100)); |
| 4276 root->SetDrawsContent(true); | 4249 root->SetDrawsContent(true); |
| 4277 | 4250 |
| 4278 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 4251 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 4279 child->SetPosition(gfx::PointF(2.f, 2.f)); | 4252 child->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4280 child->SetBounds(gfx::Size(10, 10)); | 4253 child->SetBounds(gfx::Size(10, 10)); |
| 4281 child->SetDrawsContent(true); | 4254 child->SetDrawsContent(true); |
| 4282 | 4255 |
| 4283 LayerImpl* child2 = AddChildToRoot<LayerImpl>(); | 4256 LayerImpl* child2 = AddChildToRoot<LayerImpl>(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4348 gfx::SizeF(child->bounds())); | 4321 gfx::SizeF(child->bounds())); |
| 4349 expected_child_draw_rect.Scale(device_scale_factor); | 4322 expected_child_draw_rect.Scale(device_scale_factor); |
| 4350 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_draw_rect); | 4323 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_draw_rect); |
| 4351 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_screen_space_rect); | 4324 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child_screen_space_rect); |
| 4352 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_draw_rect); | 4325 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_draw_rect); |
| 4353 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_screen_space_rect); | 4326 EXPECT_FLOAT_RECT_EQ(expected_child_draw_rect, child2_screen_space_rect); |
| 4354 } | 4327 } |
| 4355 | 4328 |
| 4356 TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) { | 4329 TEST_F(LayerTreeHostCommonScalingTest, SurfaceLayerTransformsInHighDPI) { |
| 4357 // Verify draw and screen space transforms of layers in a surface. | 4330 // Verify draw and screen space transforms of layers in a surface. |
| 4358 gfx::Transform identity_matrix; | |
| 4359 gfx::Transform perspective_matrix; | 4331 gfx::Transform perspective_matrix; |
| 4360 perspective_matrix.ApplyPerspectiveDepth(2.0); | 4332 perspective_matrix.ApplyPerspectiveDepth(2.0); |
| 4361 | 4333 |
| 4362 gfx::Transform scale_small_matrix; | 4334 gfx::Transform scale_small_matrix; |
| 4363 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f); | 4335 scale_small_matrix.Scale(SK_MScalar1 / 10.f, SK_MScalar1 / 12.f); |
| 4364 | 4336 |
| 4365 LayerImpl* root = root_layer_for_testing(); | 4337 LayerImpl* root = root_layer_for_testing(); |
| 4366 root->SetBounds(gfx::Size(100, 100)); | 4338 root->SetBounds(gfx::Size(100, 100)); |
| 4367 | 4339 |
| 4368 LayerImpl* page_scale = AddChildToRoot<LayerImpl>(); | 4340 LayerImpl* page_scale = AddChildToRoot<LayerImpl>(); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4520 ExecuteCalculateDrawProperties(root); | 4492 ExecuteCalculateDrawProperties(root); |
| 4521 | 4493 |
| 4522 EXPECT_IDEAL_SCALE_EQ(initial_parent_scale, parent); | 4494 EXPECT_IDEAL_SCALE_EQ(initial_parent_scale, parent); |
| 4523 // Animating layers compute ideal scale in the same way as when | 4495 // Animating layers compute ideal scale in the same way as when |
| 4524 // they are static. | 4496 // they are static. |
| 4525 EXPECT_IDEAL_SCALE_EQ(initial_child_scale * initial_parent_scale, | 4497 EXPECT_IDEAL_SCALE_EQ(initial_child_scale * initial_parent_scale, |
| 4526 child_scale); | 4498 child_scale); |
| 4527 } | 4499 } |
| 4528 | 4500 |
| 4529 TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) { | 4501 TEST_F(LayerTreeHostCommonTest, RenderSurfaceTransformsInHighDPI) { |
| 4530 gfx::Transform identity_matrix; | |
| 4531 | |
| 4532 LayerImpl* parent = root_layer_for_testing(); | 4502 LayerImpl* parent = root_layer_for_testing(); |
| 4533 parent->SetBounds(gfx::Size(30, 30)); | 4503 parent->SetBounds(gfx::Size(30, 30)); |
| 4534 parent->SetDrawsContent(true); | 4504 parent->SetDrawsContent(true); |
| 4535 parent->Set3dSortingContextId(1); | 4505 parent->Set3dSortingContextId(1); |
| 4536 parent->test_properties()->should_flatten_transform = false; | 4506 parent->test_properties()->should_flatten_transform = false; |
| 4537 | 4507 |
| 4538 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 4508 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 4539 child->SetBounds(gfx::Size(10, 10)); | 4509 child->SetBounds(gfx::Size(10, 10)); |
| 4540 child->SetPosition(gfx::PointF(2.f, 2.f)); | 4510 child->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4541 child->SetDrawsContent(true); | 4511 child->SetDrawsContent(true); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4632 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4602 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 4633 expected_replica_screen_space_transform, | 4603 expected_replica_screen_space_transform, |
| 4634 child->render_surface()->replica_screen_space_transform()); | 4604 child->render_surface()->replica_screen_space_transform()); |
| 4635 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4605 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 4636 expected_replica_screen_space_transform, | 4606 expected_replica_screen_space_transform, |
| 4637 child->render_surface()->replica_screen_space_transform()); | 4607 child->render_surface()->replica_screen_space_transform()); |
| 4638 } | 4608 } |
| 4639 | 4609 |
| 4640 TEST_F(LayerTreeHostCommonTest, | 4610 TEST_F(LayerTreeHostCommonTest, |
| 4641 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { | 4611 RenderSurfaceTransformsInHighDPIAccurateScaleZeroPosition) { |
| 4642 gfx::Transform identity_matrix; | |
| 4643 | |
| 4644 LayerImpl* parent = root_layer_for_testing(); | 4612 LayerImpl* parent = root_layer_for_testing(); |
| 4645 parent->SetBounds(gfx::Size(33, 31)); | 4613 parent->SetBounds(gfx::Size(33, 31)); |
| 4646 parent->SetDrawsContent(true); | 4614 parent->SetDrawsContent(true); |
| 4647 | 4615 |
| 4648 LayerImpl* child = AddChildToRoot<LayerImpl>(); | 4616 LayerImpl* child = AddChildToRoot<LayerImpl>(); |
| 4649 child->SetBounds(gfx::Size(13, 11)); | 4617 child->SetBounds(gfx::Size(13, 11)); |
| 4650 child->SetDrawsContent(true); | 4618 child->SetDrawsContent(true); |
| 4651 child->test_properties()->force_render_surface = true; | 4619 child->test_properties()->force_render_surface = true; |
| 4652 | 4620 |
| 4653 gfx::Transform replica_transform; | 4621 gfx::Transform replica_transform; |
| 4654 replica_transform.Scale(1.0, -1.0); | 4622 replica_transform.Scale(1.0, -1.0); |
| 4655 std::unique_ptr<LayerImpl> replica = | 4623 std::unique_ptr<LayerImpl> replica = |
| 4656 LayerImpl::Create(host_impl()->active_tree(), 7); | 4624 LayerImpl::Create(host_impl()->active_tree(), 7); |
| 4657 replica->SetTransform(replica_transform); | 4625 replica->SetTransform(replica_transform); |
| 4658 child->test_properties()->SetReplicaLayer(std::move(replica)); | 4626 child->test_properties()->SetReplicaLayer(std::move(replica)); |
| 4659 | 4627 |
| 4660 float device_scale_factor = 1.7f; | 4628 float device_scale_factor = 1.7f; |
| 4661 ExecuteCalculateDrawProperties(parent, device_scale_factor); | 4629 ExecuteCalculateDrawProperties(parent, device_scale_factor); |
| 4662 | 4630 |
| 4663 // We should have two render surfaces. The root's render surface and child's | 4631 // We should have two render surfaces. The root's render surface and child's |
| 4664 // render surface (it needs one because it has a replica layer). | 4632 // render surface (it needs one because it has a replica layer). |
| 4665 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); | 4633 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); |
| 4666 | 4634 |
| 4667 gfx::Transform identity_transform; | 4635 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 4668 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_transform, | |
| 4669 child->render_surface()->draw_transform()); | 4636 child->render_surface()->draw_transform()); |
| 4670 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_transform, | 4637 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
| 4671 child->render_surface()->draw_transform()); | 4638 child->render_surface()->draw_transform()); |
| 4672 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4639 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 4673 identity_transform, child->render_surface()->screen_space_transform()); | 4640 gfx::Transform(), child->render_surface()->screen_space_transform()); |
| 4674 | 4641 |
| 4675 gfx::Transform expected_replica_draw_transform; | 4642 gfx::Transform expected_replica_draw_transform; |
| 4676 expected_replica_draw_transform.matrix().set(1, 1, -1.0); | 4643 expected_replica_draw_transform.matrix().set(1, 1, -1.0); |
| 4677 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4644 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 4678 expected_replica_draw_transform, | 4645 expected_replica_draw_transform, |
| 4679 child->render_surface()->replica_draw_transform()); | 4646 child->render_surface()->replica_draw_transform()); |
| 4680 | 4647 |
| 4681 gfx::Transform expected_replica_screen_space_transform; | 4648 gfx::Transform expected_replica_screen_space_transform; |
| 4682 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); | 4649 expected_replica_screen_space_transform.matrix().set(1, 1, -1.0); |
| 4683 EXPECT_TRANSFORMATION_MATRIX_EQ( | 4650 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4873 host_impl_.active_tree()->SetElementIdsForTesting(); | 4840 host_impl_.active_tree()->SetElementIdsForTesting(); |
| 4874 | 4841 |
| 4875 root_->SetContentsOpaque(true); | 4842 root_->SetContentsOpaque(true); |
| 4876 child_->SetContentsOpaque(true); | 4843 child_->SetContentsOpaque(true); |
| 4877 grand_child_->SetContentsOpaque(true); | 4844 grand_child_->SetContentsOpaque(true); |
| 4878 | 4845 |
| 4879 root_->SetDrawsContent(true); | 4846 root_->SetDrawsContent(true); |
| 4880 child_->SetDrawsContent(true); | 4847 child_->SetDrawsContent(true); |
| 4881 grand_child_->SetDrawsContent(true); | 4848 grand_child_->SetDrawsContent(true); |
| 4882 | 4849 |
| 4883 gfx::Transform identity_matrix; | |
| 4884 root_->SetBounds(gfx::Size(1, 1)); | 4850 root_->SetBounds(gfx::Size(1, 1)); |
| 4885 child_->SetBounds(gfx::Size(1, 1)); | 4851 child_->SetBounds(gfx::Size(1, 1)); |
| 4886 grand_child_->SetBounds(gfx::Size(1, 1)); | 4852 grand_child_->SetBounds(gfx::Size(1, 1)); |
| 4887 | 4853 |
| 4888 child_->test_properties()->force_render_surface = | 4854 child_->test_properties()->force_render_surface = |
| 4889 std::tr1::get<2>(GetParam()); | 4855 std::tr1::get<2>(GetParam()); |
| 4890 } | 4856 } |
| 4891 | 4857 |
| 4892 bool can_use_lcd_text_; | 4858 bool can_use_lcd_text_; |
| 4893 bool layers_always_allowed_lcd_text_; | 4859 bool layers_always_allowed_lcd_text_; |
| 4894 | 4860 |
| 4895 FakeImplTaskRunnerProvider task_runner_provider_; | 4861 FakeImplTaskRunnerProvider task_runner_provider_; |
| 4896 TestSharedBitmapManager shared_bitmap_manager_; | 4862 TestSharedBitmapManager shared_bitmap_manager_; |
| 4897 TestTaskGraphRunner task_graph_runner_; | 4863 TestTaskGraphRunner task_graph_runner_; |
| 4898 FakeLayerTreeHostImpl host_impl_; | 4864 FakeLayerTreeHostImpl host_impl_; |
| 4899 scoped_refptr<AnimationTimeline> timeline_; | 4865 scoped_refptr<AnimationTimeline> timeline_; |
| 4900 | 4866 |
| 4901 LayerImpl* root_; | 4867 LayerImpl* root_; |
| 4902 LayerImpl* child_; | 4868 LayerImpl* child_; |
| 4903 LayerImpl* grand_child_; | 4869 LayerImpl* grand_child_; |
| 4904 }; | 4870 }; |
| 4905 | 4871 |
| 4906 TEST_P(LCDTextTest, CanUseLCDText) { | 4872 TEST_P(LCDTextTest, CanUseLCDText) { |
| 4907 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; | 4873 bool expect_lcd_text = can_use_lcd_text_ || layers_always_allowed_lcd_text_; |
| 4908 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; | 4874 bool expect_not_lcd_text = layers_always_allowed_lcd_text_; |
| 4909 | 4875 |
| 4910 // Case 1: Identity transform. | 4876 // Case 1: Identity transform. |
| 4911 gfx::Transform identity_matrix; | |
| 4912 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 4877 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 4913 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 4878 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 4914 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 4879 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
| 4915 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 4880 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 4916 | 4881 |
| 4917 // Case 2: Integral translation. | 4882 // Case 2: Integral translation. |
| 4918 gfx::Transform integral_translation; | 4883 gfx::Transform integral_translation; |
| 4919 integral_translation.Translate(1.0, 2.0); | 4884 integral_translation.Translate(1.0, 2.0); |
| 4920 child_->SetTransform(integral_translation); | 4885 child_->SetTransform(integral_translation); |
| 4921 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 4886 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4958 gfx::Transform skew; | 4923 gfx::Transform skew; |
| 4959 skew.Skew(10.0, 0.0); | 4924 skew.Skew(10.0, 0.0); |
| 4960 child_->SetTransform(skew); | 4925 child_->SetTransform(skew); |
| 4961 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 4926 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 4962 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 4927 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 4963 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 4928 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 4964 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 4929 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 4965 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 4930 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 4966 | 4931 |
| 4967 // Case 7: Translucent. | 4932 // Case 7: Translucent. |
| 4968 child_->SetTransform(identity_matrix); | 4933 child_->SetTransform(gfx::Transform()); |
| 4969 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 4934 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 4970 child_->test_properties()->opacity = 0.5f; | 4935 child_->test_properties()->opacity = 0.5f; |
| 4971 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 4936 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 4972 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 4937 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 4973 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); | 4938 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); |
| 4974 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); | 4939 EXPECT_EQ(expect_not_lcd_text, grand_child_->CanUseLCDText()); |
| 4975 | 4940 |
| 4976 // Case 8: Sanity check: restore transform and opacity. | 4941 // Case 8: Sanity check: restore transform and opacity. |
| 4977 child_->SetTransform(identity_matrix); | 4942 child_->SetTransform(gfx::Transform()); |
| 4978 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; | 4943 child_->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 4979 child_->test_properties()->opacity = 1.f; | 4944 child_->test_properties()->opacity = 1.f; |
| 4980 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 4945 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| 4981 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); | 4946 EXPECT_EQ(expect_lcd_text, root_->CanUseLCDText()); |
| 4982 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); | 4947 EXPECT_EQ(expect_lcd_text, child_->CanUseLCDText()); |
| 4983 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); | 4948 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); |
| 4984 | 4949 |
| 4985 // Case 9: Non-opaque content. | 4950 // Case 9: Non-opaque content. |
| 4986 child_->SetContentsOpaque(false); | 4951 child_->SetContentsOpaque(false); |
| 4987 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); | 4952 ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5050 testing::Bool(), | 5015 testing::Bool(), |
| 5051 testing::Bool())); | 5016 testing::Bool())); |
| 5052 | 5017 |
| 5053 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { | 5018 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) { |
| 5054 FakeImplTaskRunnerProvider task_runner_provider; | 5019 FakeImplTaskRunnerProvider task_runner_provider; |
| 5055 TestSharedBitmapManager shared_bitmap_manager; | 5020 TestSharedBitmapManager shared_bitmap_manager; |
| 5056 TestTaskGraphRunner task_graph_runner; | 5021 TestTaskGraphRunner task_graph_runner; |
| 5057 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5022 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5058 &task_graph_runner); | 5023 &task_graph_runner); |
| 5059 host_impl.CreatePendingTree(); | 5024 host_impl.CreatePendingTree(); |
| 5060 const gfx::Transform identity_matrix; | |
| 5061 | 5025 |
| 5062 std::unique_ptr<LayerImpl> root = | 5026 std::unique_ptr<LayerImpl> root = |
| 5063 LayerImpl::Create(host_impl.pending_tree(), 1); | 5027 LayerImpl::Create(host_impl.pending_tree(), 1); |
| 5064 root->SetBounds(gfx::Size(50, 50)); | 5028 root->SetBounds(gfx::Size(50, 50)); |
| 5065 root->SetDrawsContent(true); | 5029 root->SetDrawsContent(true); |
| 5066 LayerImpl* root_layer = root.get(); | 5030 LayerImpl* root_layer = root.get(); |
| 5067 | 5031 |
| 5068 std::unique_ptr<LayerImpl> child = | 5032 std::unique_ptr<LayerImpl> child = |
| 5069 LayerImpl::Create(host_impl.pending_tree(), 2); | 5033 LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5070 child->SetBounds(gfx::Size(40, 40)); | 5034 child->SetBounds(gfx::Size(40, 40)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5095 EXPECT_EQ(2, root_layer->render_surface()->layer_list().at(1)->id()); | 5059 EXPECT_EQ(2, root_layer->render_surface()->layer_list().at(1)->id()); |
| 5096 } | 5060 } |
| 5097 | 5061 |
| 5098 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { | 5062 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) { |
| 5099 FakeImplTaskRunnerProvider task_runner_provider; | 5063 FakeImplTaskRunnerProvider task_runner_provider; |
| 5100 TestSharedBitmapManager shared_bitmap_manager; | 5064 TestSharedBitmapManager shared_bitmap_manager; |
| 5101 TestTaskGraphRunner task_graph_runner; | 5065 TestTaskGraphRunner task_graph_runner; |
| 5102 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5066 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5103 &task_graph_runner); | 5067 &task_graph_runner); |
| 5104 host_impl.CreatePendingTree(); | 5068 host_impl.CreatePendingTree(); |
| 5105 const gfx::Transform identity_matrix; | |
| 5106 | 5069 |
| 5107 std::unique_ptr<LayerImpl> root = | 5070 std::unique_ptr<LayerImpl> root = |
| 5108 LayerImpl::Create(host_impl.pending_tree(), 1); | 5071 LayerImpl::Create(host_impl.pending_tree(), 1); |
| 5109 root->SetBounds(gfx::Size(50, 50)); | 5072 root->SetBounds(gfx::Size(50, 50)); |
| 5110 root->SetDrawsContent(true); | 5073 root->SetDrawsContent(true); |
| 5111 LayerImpl* root_layer = root.get(); | 5074 LayerImpl* root_layer = root.get(); |
| 5112 | 5075 |
| 5113 std::unique_ptr<LayerImpl> child = | 5076 std::unique_ptr<LayerImpl> child = |
| 5114 LayerImpl::Create(host_impl.pending_tree(), 2); | 5077 LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5115 child->SetBounds(gfx::Size(40, 40)); | 5078 child->SetBounds(gfx::Size(40, 40)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5140 | 5103 |
| 5141 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} | 5104 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} |
| 5142 | 5105 |
| 5143 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { | 5106 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { |
| 5144 FakeImplTaskRunnerProvider task_runner_provider; | 5107 FakeImplTaskRunnerProvider task_runner_provider; |
| 5145 TestSharedBitmapManager shared_bitmap_manager; | 5108 TestSharedBitmapManager shared_bitmap_manager; |
| 5146 TestTaskGraphRunner task_graph_runner; | 5109 TestTaskGraphRunner task_graph_runner; |
| 5147 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5110 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5148 &task_graph_runner); | 5111 &task_graph_runner); |
| 5149 host_impl.CreatePendingTree(); | 5112 host_impl.CreatePendingTree(); |
| 5150 const gfx::Transform identity_matrix; | |
| 5151 | 5113 |
| 5152 std::unique_ptr<LayerImpl> root = | 5114 std::unique_ptr<LayerImpl> root = |
| 5153 LayerImpl::Create(host_impl.pending_tree(), 1); | 5115 LayerImpl::Create(host_impl.pending_tree(), 1); |
| 5154 root->SetBounds(gfx::Size(50, 50)); | 5116 root->SetBounds(gfx::Size(50, 50)); |
| 5155 root->SetDrawsContent(true); | 5117 root->SetDrawsContent(true); |
| 5156 LayerImpl* root_layer = root.get(); | 5118 LayerImpl* root_layer = root.get(); |
| 5157 | 5119 |
| 5158 std::unique_ptr<LayerImpl> copy_grand_parent = | 5120 std::unique_ptr<LayerImpl> copy_grand_parent = |
| 5159 LayerImpl::Create(host_impl.pending_tree(), 2); | 5121 LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5160 copy_grand_parent->SetBounds(gfx::Size(40, 40)); | 5122 copy_grand_parent->SetBounds(gfx::Size(40, 40)); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5287 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); | 5249 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); |
| 5288 } | 5250 } |
| 5289 | 5251 |
| 5290 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5252 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
| 5291 FakeImplTaskRunnerProvider task_runner_provider; | 5253 FakeImplTaskRunnerProvider task_runner_provider; |
| 5292 TestSharedBitmapManager shared_bitmap_manager; | 5254 TestSharedBitmapManager shared_bitmap_manager; |
| 5293 TestTaskGraphRunner task_graph_runner; | 5255 TestTaskGraphRunner task_graph_runner; |
| 5294 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5256 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5295 &task_graph_runner); | 5257 &task_graph_runner); |
| 5296 host_impl.CreatePendingTree(); | 5258 host_impl.CreatePendingTree(); |
| 5297 const gfx::Transform identity_matrix; | |
| 5298 | 5259 |
| 5299 std::unique_ptr<LayerImpl> root = | 5260 std::unique_ptr<LayerImpl> root = |
| 5300 LayerImpl::Create(host_impl.pending_tree(), 1); | 5261 LayerImpl::Create(host_impl.pending_tree(), 1); |
| 5301 root->SetBounds(gfx::Size(50, 50)); | 5262 root->SetBounds(gfx::Size(50, 50)); |
| 5302 root->SetDrawsContent(true); | 5263 root->SetDrawsContent(true); |
| 5303 | 5264 |
| 5304 std::unique_ptr<LayerImpl> copy_parent = | 5265 std::unique_ptr<LayerImpl> copy_parent = |
| 5305 LayerImpl::Create(host_impl.pending_tree(), 2); | 5266 LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5306 copy_parent->SetDrawsContent(true); | 5267 copy_parent->SetDrawsContent(true); |
| 5307 copy_parent->SetMasksToBounds(true); | 5268 copy_parent->SetMasksToBounds(true); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5337 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); | 5298 EXPECT_EQ(root_layer->id(), render_surface_layer_list.at(0)->id()); |
| 5338 | 5299 |
| 5339 // The root render surface should only have 2 contributing layer, since the | 5300 // The root render surface should only have 2 contributing layer, since the |
| 5340 // other layers are empty/clipped away. | 5301 // other layers are empty/clipped away. |
| 5341 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); | 5302 ASSERT_EQ(2u, root_layer->render_surface()->layer_list().size()); |
| 5342 EXPECT_EQ(root_layer->id(), | 5303 EXPECT_EQ(root_layer->id(), |
| 5343 root_layer->render_surface()->layer_list().at(0)->id()); | 5304 root_layer->render_surface()->layer_list().at(0)->id()); |
| 5344 } | 5305 } |
| 5345 | 5306 |
| 5346 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { | 5307 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
| 5347 const gfx::Transform identity_matrix; | |
| 5348 | |
| 5349 LayerImpl* root = root_layer_for_testing(); | 5308 LayerImpl* root = root_layer_for_testing(); |
| 5350 root->SetBounds(gfx::Size(50, 50)); | 5309 root->SetBounds(gfx::Size(50, 50)); |
| 5351 root->SetDrawsContent(true); | 5310 root->SetDrawsContent(true); |
| 5352 root->SetMasksToBounds(true); | 5311 root->SetMasksToBounds(true); |
| 5353 | 5312 |
| 5354 LayerImpl* copy_layer = AddChild<LayerImpl>(root); | 5313 LayerImpl* copy_layer = AddChild<LayerImpl>(root); |
| 5355 copy_layer->SetBounds(gfx::Size(100, 100)); | 5314 copy_layer->SetBounds(gfx::Size(100, 100)); |
| 5356 copy_layer->SetDrawsContent(true); | 5315 copy_layer->SetDrawsContent(true); |
| 5357 copy_layer->test_properties()->force_render_surface = true; | 5316 copy_layer->test_properties()->force_render_surface = true; |
| 5358 | 5317 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5461 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 5420 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); |
| 5462 clip_children->insert(clip_child); | 5421 clip_children->insert(clip_child); |
| 5463 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 5422 clip_parent->test_properties()->clip_children.reset(clip_children.release()); |
| 5464 | 5423 |
| 5465 intervening->SetMasksToBounds(true); | 5424 intervening->SetMasksToBounds(true); |
| 5466 clip_parent->SetMasksToBounds(true); | 5425 clip_parent->SetMasksToBounds(true); |
| 5467 | 5426 |
| 5468 gfx::Transform scale_transform; | 5427 gfx::Transform scale_transform; |
| 5469 scale_transform.Scale(2, 2); | 5428 scale_transform.Scale(2, 2); |
| 5470 | 5429 |
| 5471 gfx::Transform identity_transform; | 5430 root->SetBounds(gfx::Size(50, 50)); |
| 5472 | 5431 render_surface->SetBounds(gfx::Size(10, 10)); |
| 5473 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 5432 render_surface->test_properties()->force_render_surface = true; |
| 5474 gfx::PointF(), gfx::Size(50, 50), true, false, | 5433 clip_parent->SetTransform(scale_transform); |
| 5475 true); | 5434 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5476 SetLayerPropertiesForTesting(render_surface, identity_transform, | 5435 clip_parent->SetBounds(gfx::Size(10, 10)); |
| 5477 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | 5436 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5478 true, false, true); | 5437 intervening->SetBounds(gfx::Size(5, 5)); |
| 5479 SetLayerPropertiesForTesting(clip_parent, scale_transform, gfx::Point3F(), | 5438 clip_child->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5480 gfx::PointF(1.f, 1.f), gfx::Size(10, 10), true, | 5439 clip_child->SetBounds(gfx::Size(10, 10)); |
| 5481 false, false); | |
| 5482 SetLayerPropertiesForTesting(intervening, identity_transform, gfx::Point3F(), | |
| 5483 gfx::PointF(1.f, 1.f), gfx::Size(5, 5), true, | |
| 5484 false, false); | |
| 5485 SetLayerPropertiesForTesting(clip_child, identity_transform, gfx::Point3F(), | |
| 5486 gfx::PointF(1.f, 1.f), gfx::Size(10, 10), true, | |
| 5487 false, false); | |
| 5488 | |
| 5489 ExecuteCalculateDrawProperties(root); | 5440 ExecuteCalculateDrawProperties(root); |
| 5490 | 5441 |
| 5491 ASSERT_TRUE(root->render_surface()); | 5442 ASSERT_TRUE(root->render_surface()); |
| 5492 ASSERT_TRUE(render_surface->render_surface()); | 5443 ASSERT_TRUE(render_surface->render_surface()); |
| 5493 | 5444 |
| 5494 // Ensure that we've inherited our clip parent's clip and weren't affected | 5445 // Ensure that we've inherited our clip parent's clip and weren't affected |
| 5495 // by the intervening clip layer. | 5446 // by the intervening clip layer. |
| 5496 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), clip_parent->clip_rect()); | 5447 ASSERT_EQ(gfx::Rect(1, 1, 20, 20), clip_parent->clip_rect()); |
| 5497 ASSERT_EQ(clip_parent->clip_rect(), clip_child->clip_rect()); | 5448 ASSERT_EQ(clip_parent->clip_rect(), clip_child->clip_rect()); |
| 5498 ASSERT_EQ(gfx::Rect(3, 3, 10, 10), intervening->clip_rect()); | 5449 ASSERT_EQ(gfx::Rect(3, 3, 10, 10), intervening->clip_rect()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5533 clip_child->SetDrawsContent(true); | 5484 clip_child->SetDrawsContent(true); |
| 5534 | 5485 |
| 5535 clip_child->test_properties()->clip_parent = clip_parent; | 5486 clip_child->test_properties()->clip_parent = clip_parent; |
| 5536 | 5487 |
| 5537 intervening->SetMasksToBounds(true); | 5488 intervening->SetMasksToBounds(true); |
| 5538 clip_parent->SetMasksToBounds(true); | 5489 clip_parent->SetMasksToBounds(true); |
| 5539 | 5490 |
| 5540 gfx::Transform translation_transform; | 5491 gfx::Transform translation_transform; |
| 5541 translation_transform.Translate(2, 2); | 5492 translation_transform.Translate(2, 2); |
| 5542 | 5493 |
| 5543 gfx::Transform identity_transform; | 5494 root->SetBounds(gfx::Size(50, 50)); |
| 5544 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 5495 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5545 gfx::PointF(), gfx::Size(50, 50), true, false, | 5496 clip_parent->SetBounds(gfx::Size(40, 40)); |
| 5546 true); | 5497 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 5547 SetLayerPropertiesForTesting(clip_parent, translation_transform, | 5498 render_surface1->test_properties()->force_render_surface = true; |
| 5548 gfx::Point3F(), gfx::PointF(1.f, 1.f), | 5499 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5549 gfx::Size(40, 40), true, false, false); | 5500 intervening->SetBounds(gfx::Size(5, 5)); |
| 5550 SetLayerPropertiesForTesting(render_surface1, identity_transform, | 5501 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 5551 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | 5502 render_surface2->test_properties()->force_render_surface = true; |
| 5552 true, false, true); | 5503 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 5553 SetLayerPropertiesForTesting(intervening, identity_transform, gfx::Point3F(), | 5504 clip_child->SetBounds(gfx::Size(60, 60)); |
| 5554 gfx::PointF(1.f, 1.f), gfx::Size(5, 5), true, | |
| 5555 false, false); | |
| 5556 SetLayerPropertiesForTesting(render_surface2, identity_transform, | |
| 5557 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | |
| 5558 true, false, true); | |
| 5559 SetLayerPropertiesForTesting(clip_child, identity_transform, gfx::Point3F(), | |
| 5560 gfx::PointF(-10.f, -10.f), gfx::Size(60, 60), | |
| 5561 true, false, false); | |
| 5562 | |
| 5563 ExecuteCalculateDrawProperties(root); | 5505 ExecuteCalculateDrawProperties(root); |
| 5564 | 5506 |
| 5565 EXPECT_TRUE(root->render_surface()); | 5507 EXPECT_TRUE(root->render_surface()); |
| 5566 EXPECT_TRUE(render_surface1->render_surface()); | 5508 EXPECT_TRUE(render_surface1->render_surface()); |
| 5567 EXPECT_TRUE(render_surface2->render_surface()); | 5509 EXPECT_TRUE(render_surface2->render_surface()); |
| 5568 | 5510 |
| 5569 // Since the render surfaces could have expanded, they should not clip (their | 5511 // Since the render surfaces could have expanded, they should not clip (their |
| 5570 // bounds would no longer be reliable). We should resort to layer clipping | 5512 // bounds would no longer be reliable). We should resort to layer clipping |
| 5571 // in this case. | 5513 // in this case. |
| 5572 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5514 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5624 clip_child->test_properties()->clip_parent = clip_parent; | 5566 clip_child->test_properties()->clip_parent = clip_parent; |
| 5625 | 5567 |
| 5626 intervening->SetMasksToBounds(true); | 5568 intervening->SetMasksToBounds(true); |
| 5627 clip_parent->SetMasksToBounds(true); | 5569 clip_parent->SetMasksToBounds(true); |
| 5628 intervening->SetScrollClipLayer(clip_parent->id()); | 5570 intervening->SetScrollClipLayer(clip_parent->id()); |
| 5629 intervening->SetCurrentScrollOffset(gfx::ScrollOffset(3, 3)); | 5571 intervening->SetCurrentScrollOffset(gfx::ScrollOffset(3, 3)); |
| 5630 | 5572 |
| 5631 gfx::Transform translation_transform; | 5573 gfx::Transform translation_transform; |
| 5632 translation_transform.Translate(2, 2); | 5574 translation_transform.Translate(2, 2); |
| 5633 | 5575 |
| 5634 gfx::Transform identity_transform; | 5576 root->SetBounds(gfx::Size(50, 50)); |
| 5635 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 5577 clip_parent->SetTransform(translation_transform); |
| 5636 gfx::PointF(), gfx::Size(50, 50), true, false, | 5578 clip_parent->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5637 true); | 5579 clip_parent->SetBounds(gfx::Size(40, 40)); |
| 5638 SetLayerPropertiesForTesting(clip_parent, translation_transform, | 5580 render_surface1->SetBounds(gfx::Size(10, 10)); |
| 5639 gfx::Point3F(), gfx::PointF(1.f, 1.f), | 5581 render_surface1->test_properties()->force_render_surface = true; |
| 5640 gfx::Size(40, 40), true, false, false); | 5582 intervening->SetPosition(gfx::PointF(1.f, 1.f)); |
| 5641 SetLayerPropertiesForTesting(render_surface1, identity_transform, | 5583 intervening->SetBounds(gfx::Size(5, 5)); |
| 5642 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | 5584 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 5643 true, false, true); | 5585 render_surface2->test_properties()->force_render_surface = true; |
| 5644 SetLayerPropertiesForTesting(intervening, identity_transform, gfx::Point3F(), | 5586 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 5645 gfx::PointF(1.f, 1.f), gfx::Size(5, 5), true, | 5587 clip_child->SetBounds(gfx::Size(60, 60)); |
| 5646 false, false); | |
| 5647 SetLayerPropertiesForTesting(render_surface2, identity_transform, | |
| 5648 gfx::Point3F(), gfx::PointF(), gfx::Size(10, 10), | |
| 5649 true, false, true); | |
| 5650 SetLayerPropertiesForTesting(clip_child, identity_transform, gfx::Point3F(), | |
| 5651 gfx::PointF(-10.f, -10.f), gfx::Size(60, 60), | |
| 5652 true, false, false); | |
| 5653 | |
| 5654 ExecuteCalculateDrawProperties(root); | 5588 ExecuteCalculateDrawProperties(root); |
| 5655 | 5589 |
| 5656 EXPECT_TRUE(root->render_surface()); | 5590 EXPECT_TRUE(root->render_surface()); |
| 5657 EXPECT_TRUE(render_surface1->render_surface()); | 5591 EXPECT_TRUE(render_surface1->render_surface()); |
| 5658 EXPECT_TRUE(render_surface2->render_surface()); | 5592 EXPECT_TRUE(render_surface2->render_surface()); |
| 5659 | 5593 |
| 5660 // Since the render surfaces could have expanded, they should not clip (their | 5594 // Since the render surfaces could have expanded, they should not clip (their |
| 5661 // bounds would no longer be reliable). We should resort to layer clipping | 5595 // bounds would no longer be reliable). We should resort to layer clipping |
| 5662 // in this case. | 5596 // in this case. |
| 5663 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5597 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5701 // | 5635 // |
| 5702 LayerImpl* root = root_layer_for_testing(); | 5636 LayerImpl* root = root_layer_for_testing(); |
| 5703 LayerImpl* clip_parent = AddChild<LayerImpl>(root); | 5637 LayerImpl* clip_parent = AddChild<LayerImpl>(root); |
| 5704 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent); | 5638 LayerImpl* intervening = AddChild<LayerImpl>(clip_parent); |
| 5705 LayerImpl* clip_child = AddChild<LayerImpl>(intervening); | 5639 LayerImpl* clip_child = AddChild<LayerImpl>(intervening); |
| 5706 LayerImpl* child = AddChild<LayerImpl>(clip_child); | 5640 LayerImpl* child = AddChild<LayerImpl>(clip_child); |
| 5707 clip_child->SetDrawsContent(true); | 5641 clip_child->SetDrawsContent(true); |
| 5708 child->SetDrawsContent(true); | 5642 child->SetDrawsContent(true); |
| 5709 | 5643 |
| 5710 clip_child->test_properties()->clip_parent = clip_parent; | 5644 clip_child->test_properties()->clip_parent = clip_parent; |
| 5711 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 5645 clip_parent->test_properties()->clip_children = |
| 5712 clip_children->insert(clip_child); | 5646 base::MakeUnique<std::set<LayerImpl*>>(); |
| 5713 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 5647 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 5714 | 5648 |
| 5649 root->SetBounds(gfx::Size(50, 50)); |
| 5650 clip_parent->SetBounds(gfx::Size(40, 40)); |
| 5651 clip_parent->SetMasksToBounds(true); |
| 5652 intervening->SetBounds(gfx::Size(5, 5)); |
| 5715 intervening->SetMasksToBounds(true); | 5653 intervening->SetMasksToBounds(true); |
| 5716 clip_parent->SetMasksToBounds(true); | 5654 clip_child->SetBounds(gfx::Size(60, 60)); |
| 5717 | 5655 child->SetBounds(gfx::Size(60, 60)); |
| 5718 gfx::Transform identity_transform; | |
| 5719 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 5720 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 5721 true); | |
| 5722 SetLayerPropertiesForTesting(clip_parent, identity_transform, gfx::Point3F(), | |
| 5723 gfx::PointF(), gfx::Size(40, 40), true, false, | |
| 5724 false); | |
| 5725 SetLayerPropertiesForTesting(intervening, identity_transform, gfx::Point3F(), | |
| 5726 gfx::PointF(), gfx::Size(5, 5), true, false, | |
| 5727 false); | |
| 5728 SetLayerPropertiesForTesting(clip_child, identity_transform, gfx::Point3F(), | |
| 5729 gfx::PointF(), gfx::Size(60, 60), true, false, | |
| 5730 false); | |
| 5731 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | |
| 5732 gfx::PointF(), gfx::Size(60, 60), true, false, | |
| 5733 false); | |
| 5734 | 5656 |
| 5735 ExecuteCalculateDrawProperties(root); | 5657 ExecuteCalculateDrawProperties(root); |
| 5736 | 5658 |
| 5737 EXPECT_TRUE(root->render_surface()); | 5659 EXPECT_TRUE(root->render_surface()); |
| 5738 | 5660 |
| 5739 // Neither the clip child nor its descendant should have inherited the clip | 5661 // Neither the clip child nor its descendant should have inherited the clip |
| 5740 // from |intervening|. | 5662 // from |intervening|. |
| 5741 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), clip_child->clip_rect()); | 5663 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), clip_child->clip_rect()); |
| 5742 EXPECT_TRUE(clip_child->is_clipped()); | 5664 EXPECT_TRUE(clip_child->is_clipped()); |
| 5743 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), child->visible_layer_rect()); | 5665 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), child->visible_layer_rect()); |
| 5744 EXPECT_TRUE(child->is_clipped()); | 5666 EXPECT_TRUE(child->is_clipped()); |
| 5745 } | 5667 } |
| 5746 | 5668 |
| 5747 TEST_F(LayerTreeHostCommonTest, | 5669 TEST_F(LayerTreeHostCommonTest, |
| 5748 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { | 5670 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { |
| 5749 // Ensures that non-descendant clip children in the tree do not affect | 5671 // Ensures that non-descendant clip children in the tree do not affect |
| 5750 // render surfaces. | 5672 // render surfaces. |
| 5751 // | 5673 // |
| 5752 // root (a render surface) | 5674 // root (a render surface) |
| 5753 // + clip_parent (masks to bounds) | 5675 // + clip_parent (masks to bounds) |
| 5754 // + render_surface1 | 5676 // + render_surface1 |
| 5755 // + clip_child | 5677 // + clip_child |
| 5756 // + render_surface2 | 5678 // + render_surface2 |
| 5757 // + non_clip_child | 5679 // + non_clip_child |
| 5758 // | 5680 // |
| 5759 // In this example render_surface2 should be unaffected by clip_child. | 5681 // In this example render_surface2 should be unaffected by clip_child. |
| 5760 LayerImpl* root = root_layer_for_testing(); | 5682 LayerImpl* root = root_layer_for_testing(); |
| 5761 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 5683 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 5762 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); | 5684 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); |
| 5763 render_surface1->SetDrawsContent(true); | |
| 5764 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); | 5685 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); |
| 5765 clip_child->SetDrawsContent(true); | |
| 5766 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_parent); | 5686 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_parent); |
| 5767 render_surface2->SetDrawsContent(true); | |
| 5768 LayerImpl* non_clip_child = AddChild<LayerImpl>(render_surface2); | 5687 LayerImpl* non_clip_child = AddChild<LayerImpl>(render_surface2); |
| 5769 non_clip_child->SetDrawsContent(true); | |
| 5770 | 5688 |
| 5771 clip_child->test_properties()->clip_parent = clip_parent; | 5689 clip_child->test_properties()->clip_parent = clip_parent; |
| 5772 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 5690 clip_parent->test_properties()->clip_children = |
| 5773 clip_children->insert(clip_child); | 5691 base::MakeUnique<std::set<LayerImpl*>>(); |
| 5774 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 5692 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 5775 | 5693 |
| 5776 clip_parent->SetMasksToBounds(true); | 5694 clip_parent->SetMasksToBounds(true); |
| 5777 render_surface1->SetMasksToBounds(true); | 5695 render_surface1->SetMasksToBounds(true); |
| 5778 | 5696 |
| 5779 gfx::Transform identity_transform; | 5697 render_surface1->SetDrawsContent(true); |
| 5780 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 5698 clip_child->SetDrawsContent(true); |
| 5781 gfx::PointF(), gfx::Size(15, 15), true, false, | 5699 render_surface2->SetDrawsContent(true); |
| 5782 true); | 5700 non_clip_child->SetDrawsContent(true); |
| 5783 SetLayerPropertiesForTesting(clip_parent, identity_transform, gfx::Point3F(), | 5701 |
| 5784 gfx::PointF(), gfx::Size(10, 10), true, false, | 5702 root->SetBounds(gfx::Size(15, 15)); |
| 5785 false); | 5703 clip_parent->SetBounds(gfx::Size(10, 10)); |
| 5786 SetLayerPropertiesForTesting(render_surface1, identity_transform, | 5704 render_surface1->SetPosition(gfx::PointF(5, 5)); |
| 5787 gfx::Point3F(), gfx::PointF(5, 5), | 5705 render_surface1->SetBounds(gfx::Size(5, 5)); |
| 5788 gfx::Size(5, 5), true, false, true); | 5706 render_surface1->test_properties()->force_render_surface = true; |
| 5789 SetLayerPropertiesForTesting(render_surface2, identity_transform, | 5707 render_surface2->SetBounds(gfx::Size(5, 5)); |
| 5790 gfx::Point3F(), gfx::PointF(), gfx::Size(5, 5), | 5708 render_surface2->test_properties()->force_render_surface = true; |
| 5791 true, false, true); | 5709 clip_child->SetPosition(gfx::PointF(-1, 1)); |
| 5792 SetLayerPropertiesForTesting(clip_child, identity_transform, gfx::Point3F(), | 5710 clip_child->SetBounds(gfx::Size(10, 10)); |
| 5793 gfx::PointF(-1, 1), gfx::Size(10, 10), true, | 5711 non_clip_child->SetBounds(gfx::Size(5, 5)); |
| 5794 false, false); | |
| 5795 SetLayerPropertiesForTesting(non_clip_child, identity_transform, | |
| 5796 gfx::Point3F(), gfx::PointF(), gfx::Size(5, 5), | |
| 5797 true, false, false); | |
| 5798 | 5712 |
| 5799 ExecuteCalculateDrawProperties(root); | 5713 ExecuteCalculateDrawProperties(root); |
| 5800 | 5714 |
| 5801 EXPECT_TRUE(root->render_surface()); | 5715 EXPECT_TRUE(root->render_surface()); |
| 5802 EXPECT_TRUE(render_surface1->render_surface()); | 5716 EXPECT_TRUE(render_surface1->render_surface()); |
| 5803 EXPECT_TRUE(render_surface2->render_surface()); | 5717 EXPECT_TRUE(render_surface2->render_surface()); |
| 5804 | 5718 |
| 5805 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface1->clip_rect()); | 5719 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface1->clip_rect()); |
| 5806 EXPECT_TRUE(render_surface1->is_clipped()); | 5720 EXPECT_TRUE(render_surface1->is_clipped()); |
| 5807 | 5721 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5834 TEST_F(LayerTreeHostCommonTest, | 5748 TEST_F(LayerTreeHostCommonTest, |
| 5835 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { | 5749 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { |
| 5836 // Verifies that Render Surfaces are created at the edge of rendering context. | 5750 // Verifies that Render Surfaces are created at the edge of rendering context. |
| 5837 | 5751 |
| 5838 LayerImpl* root = root_layer_for_testing(); | 5752 LayerImpl* root = root_layer_for_testing(); |
| 5839 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); | 5753 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); |
| 5840 LayerImpl* child2 = AddChild<LayerImpl>(child1); | 5754 LayerImpl* child2 = AddChild<LayerImpl>(child1); |
| 5841 LayerImpl* child3 = AddChild<LayerImpl>(child2); | 5755 LayerImpl* child3 = AddChild<LayerImpl>(child2); |
| 5842 root->SetDrawsContent(true); | 5756 root->SetDrawsContent(true); |
| 5843 | 5757 |
| 5844 const gfx::Transform identity_matrix; | |
| 5845 gfx::Point3F transform_origin; | |
| 5846 gfx::PointF position; | |
| 5847 gfx::Size bounds(100, 100); | 5758 gfx::Size bounds(100, 100); |
| 5848 | 5759 |
| 5849 SetLayerPropertiesForTesting(root, identity_matrix, transform_origin, | 5760 root->SetBounds(bounds); |
| 5850 position, bounds, true, false); | 5761 child1->SetBounds(bounds); |
| 5851 SetLayerPropertiesForTesting(child1, identity_matrix, transform_origin, | |
| 5852 position, bounds, false, true); | |
| 5853 child1->SetDrawsContent(true); | 5762 child1->SetDrawsContent(true); |
| 5854 SetLayerPropertiesForTesting(child2, identity_matrix, transform_origin, | 5763 child1->Set3dSortingContextId(1); |
| 5855 position, bounds, true, false); | 5764 child1->test_properties()->should_flatten_transform = false; |
| 5765 child2->SetBounds(bounds); |
| 5856 child2->SetDrawsContent(true); | 5766 child2->SetDrawsContent(true); |
| 5857 SetLayerPropertiesForTesting(child3, identity_matrix, transform_origin, | 5767 child2->Set3dSortingContextId(1); |
| 5858 position, bounds, true, false); | 5768 child3->SetBounds(bounds); |
| 5859 child3->SetDrawsContent(true); | 5769 child3->SetDrawsContent(true); |
| 5860 | |
| 5861 child2->Set3dSortingContextId(1); | |
| 5862 child3->Set3dSortingContextId(1); | 5770 child3->Set3dSortingContextId(1); |
| 5863 | |
| 5864 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); | 5771 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); |
| 5865 | 5772 |
| 5866 // Verify which render surfaces were created. | 5773 // Verify which render surfaces were created. |
| 5867 EXPECT_TRUE(root->has_render_surface()); | 5774 EXPECT_TRUE(root->has_render_surface()); |
| 5868 EXPECT_FALSE(child1->has_render_surface()); | 5775 EXPECT_FALSE(child1->has_render_surface()); |
| 5869 EXPECT_TRUE(child2->has_render_surface()); | 5776 EXPECT_TRUE(child2->has_render_surface()); |
| 5870 EXPECT_FALSE(child3->has_render_surface()); | 5777 EXPECT_FALSE(child3->has_render_surface()); |
| 5871 } | 5778 } |
| 5872 | 5779 |
| 5873 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { | 5780 TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { |
| 5874 FakeImplTaskRunnerProvider task_runner_provider; | 5781 FakeImplTaskRunnerProvider task_runner_provider; |
| 5875 TestSharedBitmapManager shared_bitmap_manager; | 5782 TestSharedBitmapManager shared_bitmap_manager; |
| 5876 TestTaskGraphRunner task_graph_runner; | 5783 TestTaskGraphRunner task_graph_runner; |
| 5877 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5784 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5878 &task_graph_runner); | 5785 &task_graph_runner); |
| 5879 | 5786 |
| 5880 std::unique_ptr<LayerImpl> root = | 5787 std::unique_ptr<LayerImpl> root = |
| 5881 LayerImpl::Create(host_impl.active_tree(), 12345); | 5788 LayerImpl::Create(host_impl.active_tree(), 12345); |
| 5882 std::unique_ptr<LayerImpl> child1 = | 5789 std::unique_ptr<LayerImpl> child1 = |
| 5883 LayerImpl::Create(host_impl.active_tree(), 123456); | 5790 LayerImpl::Create(host_impl.active_tree(), 123456); |
| 5884 std::unique_ptr<LayerImpl> child2 = | 5791 std::unique_ptr<LayerImpl> child2 = |
| 5885 LayerImpl::Create(host_impl.active_tree(), 1234567); | 5792 LayerImpl::Create(host_impl.active_tree(), 1234567); |
| 5886 std::unique_ptr<LayerImpl> child3 = | 5793 std::unique_ptr<LayerImpl> child3 = |
| 5887 LayerImpl::Create(host_impl.active_tree(), 12345678); | 5794 LayerImpl::Create(host_impl.active_tree(), 12345678); |
| 5888 | 5795 |
| 5889 gfx::Transform identity_matrix; | |
| 5890 gfx::Point3F transform_origin; | |
| 5891 gfx::PointF position; | |
| 5892 gfx::Size bounds(100, 100); | 5796 gfx::Size bounds(100, 100); |
| 5893 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 5797 |
| 5894 position, bounds, true, false, true); | 5798 root->SetBounds(bounds); |
| 5895 root->SetDrawsContent(true); | 5799 root->SetDrawsContent(true); |
| 5896 | 5800 |
| 5897 // This layer structure normally forces render surface due to preserves3d | 5801 // This layer structure normally forces render surface due to preserves3d |
| 5898 // behavior. | 5802 // behavior. |
| 5899 SetLayerPropertiesForTesting(child1.get(), identity_matrix, transform_origin, | 5803 child1->SetBounds(bounds); |
| 5900 position, bounds, false, true, false); | |
| 5901 child1->SetDrawsContent(true); | 5804 child1->SetDrawsContent(true); |
| 5902 SetLayerPropertiesForTesting(child2.get(), identity_matrix, transform_origin, | 5805 child1->Set3dSortingContextId(1); |
| 5903 position, bounds, true, false, true); | 5806 child1->test_properties()->should_flatten_transform = false; |
| 5807 child2->SetBounds(bounds); |
| 5904 child2->SetDrawsContent(true); | 5808 child2->SetDrawsContent(true); |
| 5905 SetLayerPropertiesForTesting(child3.get(), identity_matrix, transform_origin, | 5809 child2->Set3dSortingContextId(1); |
| 5906 position, bounds, true, false, false); | 5810 child3->SetBounds(bounds); |
| 5907 child3->SetDrawsContent(true); | 5811 child3->SetDrawsContent(true); |
| 5908 | |
| 5909 child2->Set3dSortingContextId(1); | |
| 5910 child3->Set3dSortingContextId(1); | 5812 child3->Set3dSortingContextId(1); |
| 5911 | 5813 |
| 5912 child2->test_properties()->AddChild(std::move(child3)); | 5814 child2->test_properties()->AddChild(std::move(child3)); |
| 5913 child1->test_properties()->AddChild(std::move(child2)); | 5815 child1->test_properties()->AddChild(std::move(child2)); |
| 5914 root->test_properties()->AddChild(std::move(child1)); | 5816 root->test_properties()->AddChild(std::move(child1)); |
| 5915 LayerImpl* root_layer = root.get(); | 5817 LayerImpl* root_layer = root.get(); |
| 5916 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root)); | 5818 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root)); |
| 5917 | 5819 |
| 5918 { | 5820 { |
| 5919 LayerImplList render_surface_layer_list; | 5821 LayerImplList render_surface_layer_list; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5979 } | 5881 } |
| 5980 } | 5882 } |
| 5981 | 5883 |
| 5982 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { | 5884 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleSurfaces) { |
| 5983 LayerImpl* root = root_layer_for_testing(); | 5885 LayerImpl* root = root_layer_for_testing(); |
| 5984 LayerImpl* back_facing = AddChild<LayerImpl>(root); | 5886 LayerImpl* back_facing = AddChild<LayerImpl>(root); |
| 5985 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); | 5887 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); |
| 5986 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); | 5888 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); |
| 5987 LayerImpl* child1 = AddChild<LayerImpl>(render_surface1); | 5889 LayerImpl* child1 = AddChild<LayerImpl>(render_surface1); |
| 5988 LayerImpl* child2 = AddChild<LayerImpl>(render_surface2); | 5890 LayerImpl* child2 = AddChild<LayerImpl>(render_surface2); |
| 5891 |
| 5989 child1->SetDrawsContent(true); | 5892 child1->SetDrawsContent(true); |
| 5990 child2->SetDrawsContent(true); | 5893 child2->SetDrawsContent(true); |
| 5991 | 5894 |
| 5992 gfx::Transform identity_transform; | 5895 root->SetBounds(gfx::Size(50, 50)); |
| 5993 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 5896 root->Set3dSortingContextId(1); |
| 5994 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 5995 true); | |
| 5996 SetLayerPropertiesForTesting(back_facing, identity_transform, gfx::Point3F(), | |
| 5997 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 5998 false); | |
| 5999 SetLayerPropertiesForTesting(render_surface1, identity_transform, | |
| 6000 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6001 false, true, true); | |
| 6002 SetLayerPropertiesForTesting(render_surface2, identity_transform, | |
| 6003 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6004 false, true, true); | |
| 6005 SetLayerPropertiesForTesting(child1, identity_transform, gfx::Point3F(), | |
| 6006 gfx::PointF(), gfx::Size(20, 20), true, false, | |
| 6007 false); | |
| 6008 SetLayerPropertiesForTesting(child2, identity_transform, gfx::Point3F(), | |
| 6009 gfx::PointF(), gfx::Size(20, 20), true, false, | |
| 6010 false); | |
| 6011 | |
| 6012 root->test_properties()->should_flatten_transform = false; | 5897 root->test_properties()->should_flatten_transform = false; |
| 6013 root->Set3dSortingContextId(1); | 5898 back_facing->SetBounds(gfx::Size(50, 50)); |
| 6014 back_facing->Set3dSortingContextId(1); | 5899 back_facing->Set3dSortingContextId(1); |
| 6015 back_facing->test_properties()->should_flatten_transform = false; | 5900 back_facing->test_properties()->should_flatten_transform = false; |
| 5901 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 5902 render_surface1->Set3dSortingContextId(1); |
| 5903 render_surface1->test_properties()->should_flatten_transform = false; |
| 5904 render_surface1->test_properties()->force_render_surface = true; |
| 6016 render_surface1->test_properties()->double_sided = false; | 5905 render_surface1->test_properties()->double_sided = false; |
| 5906 render_surface2->SetBounds(gfx::Size(30, 30)); |
| 5907 // Different context from the rest. |
| 6017 render_surface2->Set3dSortingContextId(2); | 5908 render_surface2->Set3dSortingContextId(2); |
| 5909 render_surface2->test_properties()->should_flatten_transform = false; |
| 5910 render_surface2->test_properties()->force_render_surface = true; |
| 6018 render_surface2->test_properties()->double_sided = false; | 5911 render_surface2->test_properties()->double_sided = false; |
| 5912 child1->SetBounds(gfx::Size(20, 20)); |
| 5913 child2->SetBounds(gfx::Size(20, 20)); |
| 6019 | 5914 |
| 6020 ExecuteCalculateDrawProperties(root); | 5915 ExecuteCalculateDrawProperties(root); |
| 6021 | 5916 |
| 6022 EXPECT_EQ(render_surface1->sorting_context_id(), root->sorting_context_id()); | 5917 EXPECT_EQ(render_surface1->sorting_context_id(), root->sorting_context_id()); |
| 6023 EXPECT_NE(render_surface2->sorting_context_id(), root->sorting_context_id()); | 5918 EXPECT_NE(render_surface2->sorting_context_id(), root->sorting_context_id()); |
| 6024 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); | 5919 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); |
| 6025 EXPECT_EQ(2u, render_surface_layer_list_impl() | 5920 EXPECT_EQ(2u, render_surface_layer_list_impl() |
| 6026 ->at(0) | 5921 ->at(0) |
| 6027 ->render_surface() | 5922 ->render_surface() |
| 6028 ->layer_list() | 5923 ->layer_list() |
| 6029 .size()); | 5924 .size()); |
| 6030 EXPECT_EQ(1u, render_surface_layer_list_impl() | 5925 EXPECT_EQ(1u, render_surface_layer_list_impl() |
| 6031 ->at(1) | 5926 ->at(1) |
| 6032 ->render_surface() | 5927 ->render_surface() |
| 6033 ->layer_list() | 5928 ->layer_list() |
| 6034 .size()); | 5929 .size()); |
| 6035 | 5930 |
| 6036 gfx::Transform rotation_transform = identity_transform; | 5931 gfx::Transform rotation_transform; |
| 6037 rotation_transform.RotateAboutXAxis(180.0); | 5932 rotation_transform.RotateAboutXAxis(180.0); |
| 6038 | 5933 |
| 6039 back_facing->SetTransform(rotation_transform); | 5934 back_facing->SetTransform(rotation_transform); |
| 6040 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5935 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6041 | 5936 |
| 6042 ExecuteCalculateDrawProperties(root); | 5937 ExecuteCalculateDrawProperties(root); |
| 6043 | 5938 |
| 6044 // render_surface1 is in the same 3d rendering context as back_facing and is | 5939 // render_surface1 is in the same 3d rendering context as back_facing and is |
| 6045 // not double sided, so it should not be in RSLL. render_surface2 is also not | 5940 // not double sided, so it should not be in RSLL. render_surface2 is also not |
| 6046 // double-sided, but will still be in RSLL as it's in a different 3d rendering | 5941 // double-sided, but will still be in RSLL as it's in a different 3d rendering |
| 6047 // context. | 5942 // context. |
| 6048 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); | 5943 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); |
| 6049 EXPECT_EQ(1u, render_surface_layer_list_impl() | 5944 EXPECT_EQ(1u, render_surface_layer_list_impl() |
| 6050 ->at(0) | 5945 ->at(0) |
| 6051 ->render_surface() | 5946 ->render_surface() |
| 6052 ->layer_list() | 5947 ->layer_list() |
| 6053 .size()); | 5948 .size()); |
| 6054 } | 5949 } |
| 6055 | 5950 |
| 6056 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) { | 5951 TEST_F(LayerTreeHostCommonTest, DoNotIncludeBackfaceInvisibleLayers) { |
| 6057 LayerImpl* root = root_layer_for_testing(); | 5952 LayerImpl* root = root_layer_for_testing(); |
| 6058 LayerImpl* child = AddChild<LayerImpl>(root); | 5953 LayerImpl* child = AddChild<LayerImpl>(root); |
| 6059 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 5954 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 5955 |
| 5956 root->SetBounds(gfx::Size(50, 50)); |
| 5957 root->test_properties()->should_flatten_transform = false; |
| 5958 child->SetBounds(gfx::Size(30, 30)); |
| 5959 child->test_properties()->double_sided = false; |
| 5960 child->test_properties()->should_flatten_transform = false; |
| 5961 grand_child->SetBounds(gfx::Size(20, 20)); |
| 6060 grand_child->SetDrawsContent(true); | 5962 grand_child->SetDrawsContent(true); |
| 6061 | |
| 6062 child->test_properties()->double_sided = false; | |
| 6063 grand_child->SetUseParentBackfaceVisibility(true); | 5963 grand_child->SetUseParentBackfaceVisibility(true); |
| 6064 | 5964 grand_child->test_properties()->should_flatten_transform = false; |
| 6065 gfx::Transform identity_transform; | |
| 6066 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 6067 gfx::PointF(), gfx::Size(50, 50), false, false, | |
| 6068 true); | |
| 6069 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | |
| 6070 gfx::PointF(), gfx::Size(30, 30), false, false, | |
| 6071 false); | |
| 6072 SetLayerPropertiesForTesting(grand_child, identity_transform, gfx::Point3F(), | |
| 6073 gfx::PointF(), gfx::Size(20, 20), false, false, | |
| 6074 false); | |
| 6075 | |
| 6076 ExecuteCalculateDrawProperties(root); | 5965 ExecuteCalculateDrawProperties(root); |
| 6077 | 5966 |
| 6078 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); | 5967 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); |
| 6079 EXPECT_EQ(grand_child, render_surface_layer_list_impl() | 5968 EXPECT_EQ(grand_child, render_surface_layer_list_impl() |
| 6080 ->at(0) | 5969 ->at(0) |
| 6081 ->render_surface() | 5970 ->render_surface() |
| 6082 ->layer_list()[0]); | 5971 ->layer_list()[0]); |
| 6083 | 5972 |
| 6084 // As all layers have identity transform, we shouldn't check for backface | 5973 // As all layers have identity transform, we shouldn't check for backface |
| 6085 // visibility. | 5974 // visibility. |
| 6086 EXPECT_FALSE(root->should_check_backface_visibility()); | 5975 EXPECT_FALSE(root->should_check_backface_visibility()); |
| 6087 EXPECT_FALSE(child->should_check_backface_visibility()); | 5976 EXPECT_FALSE(child->should_check_backface_visibility()); |
| 6088 EXPECT_FALSE(grand_child->should_check_backface_visibility()); | 5977 EXPECT_FALSE(grand_child->should_check_backface_visibility()); |
| 6089 // As there are no 3d rendering contexts, all layers should use their local | 5978 // As there are no 3d rendering contexts, all layers should use their local |
| 6090 // transform for backface visibility. | 5979 // transform for backface visibility. |
| 6091 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); | 5980 EXPECT_TRUE(root->use_local_transform_for_backface_visibility()); |
| 6092 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); | 5981 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); |
| 6093 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); | 5982 EXPECT_TRUE(grand_child->use_local_transform_for_backface_visibility()); |
| 6094 | 5983 |
| 6095 gfx::Transform rotation_transform = identity_transform; | 5984 gfx::Transform rotation_transform; |
| 6096 rotation_transform.RotateAboutXAxis(180.0); | 5985 rotation_transform.RotateAboutXAxis(180.0); |
| 6097 | 5986 |
| 6098 child->SetTransform(rotation_transform); | 5987 child->SetTransform(rotation_transform); |
| 6099 child->Set3dSortingContextId(1); | 5988 child->Set3dSortingContextId(1); |
| 6100 grand_child->Set3dSortingContextId(1); | 5989 grand_child->Set3dSortingContextId(1); |
| 6101 child->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5990 child->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6102 | 5991 |
| 6103 ExecuteCalculateDrawProperties(root); | 5992 ExecuteCalculateDrawProperties(root); |
| 6104 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); | 5993 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); |
| 6105 EXPECT_EQ(0u, render_surface_layer_list_impl() | 5994 EXPECT_EQ(0u, render_surface_layer_list_impl() |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6146 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); | 6035 EXPECT_TRUE(child->use_local_transform_for_backface_visibility()); |
| 6147 EXPECT_FALSE(grand_child->use_local_transform_for_backface_visibility()); | 6036 EXPECT_FALSE(grand_child->use_local_transform_for_backface_visibility()); |
| 6148 } | 6037 } |
| 6149 | 6038 |
| 6150 TEST_F(LayerTreeHostCommonTest, TransformAnimationUpdatesBackfaceVisibility) { | 6039 TEST_F(LayerTreeHostCommonTest, TransformAnimationUpdatesBackfaceVisibility) { |
| 6151 LayerImpl* root = root_layer_for_testing(); | 6040 LayerImpl* root = root_layer_for_testing(); |
| 6152 LayerImpl* back_facing = AddChild<LayerImpl>(root); | 6041 LayerImpl* back_facing = AddChild<LayerImpl>(root); |
| 6153 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); | 6042 LayerImpl* render_surface1 = AddChild<LayerImpl>(back_facing); |
| 6154 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); | 6043 LayerImpl* render_surface2 = AddChild<LayerImpl>(back_facing); |
| 6155 | 6044 |
| 6156 gfx::Transform identity_transform; | |
| 6157 gfx::Transform rotate_about_y; | 6045 gfx::Transform rotate_about_y; |
| 6158 rotate_about_y.RotateAboutYAxis(180.0); | 6046 rotate_about_y.RotateAboutYAxis(180.0); |
| 6159 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 6160 gfx::PointF(), gfx::Size(50, 50), false, true, | |
| 6161 true); | |
| 6162 SetLayerPropertiesForTesting(back_facing, rotate_about_y, gfx::Point3F(), | |
| 6163 gfx::PointF(), gfx::Size(50, 50), false, true, | |
| 6164 false); | |
| 6165 SetLayerPropertiesForTesting(render_surface1, identity_transform, | |
| 6166 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6167 false, true, true); | |
| 6168 SetLayerPropertiesForTesting(render_surface2, identity_transform, | |
| 6169 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6170 false, true, true); | |
| 6171 | 6047 |
| 6048 root->SetBounds(gfx::Size(50, 50)); |
| 6049 root->Set3dSortingContextId(1); |
| 6050 root->test_properties()->should_flatten_transform = false; |
| 6051 back_facing->SetTransform(rotate_about_y); |
| 6052 back_facing->SetBounds(gfx::Size(50, 50)); |
| 6053 back_facing->Set3dSortingContextId(1); |
| 6054 back_facing->test_properties()->should_flatten_transform = false; |
| 6055 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 6056 render_surface1->Set3dSortingContextId(1); |
| 6057 render_surface1->test_properties()->should_flatten_transform = false; |
| 6172 render_surface1->test_properties()->double_sided = false; | 6058 render_surface1->test_properties()->double_sided = false; |
| 6059 render_surface1->test_properties()->force_render_surface = true; |
| 6060 render_surface2->SetBounds(gfx::Size(30, 30)); |
| 6061 render_surface2->Set3dSortingContextId(1); |
| 6062 render_surface2->test_properties()->should_flatten_transform = false; |
| 6173 render_surface2->test_properties()->double_sided = false; | 6063 render_surface2->test_properties()->double_sided = false; |
| 6174 | 6064 render_surface2->test_properties()->force_render_surface = true; |
| 6175 ExecuteCalculateDrawProperties(root); | 6065 ExecuteCalculateDrawProperties(root); |
| 6176 | 6066 |
| 6177 const EffectTree& tree = | 6067 const EffectTree& tree = |
| 6178 root->layer_tree_impl()->property_trees()->effect_tree; | 6068 root->layer_tree_impl()->property_trees()->effect_tree; |
| 6179 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) | 6069 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) |
| 6180 ->hidden_by_backface_visibility); | 6070 ->hidden_by_backface_visibility); |
| 6181 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6071 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
| 6182 ->hidden_by_backface_visibility); | 6072 ->hidden_by_backface_visibility); |
| 6183 | 6073 |
| 6184 back_facing->OnTransformAnimated(identity_transform); | 6074 back_facing->OnTransformAnimated(gfx::Transform()); |
| 6185 render_surface2->OnTransformAnimated(rotate_about_y); | 6075 render_surface2->OnTransformAnimated(rotate_about_y); |
| 6186 ExecuteCalculateDrawProperties(root); | 6076 ExecuteCalculateDrawProperties(root); |
| 6187 EXPECT_FALSE(tree.Node(render_surface1->effect_tree_index()) | 6077 EXPECT_FALSE(tree.Node(render_surface1->effect_tree_index()) |
| 6188 ->hidden_by_backface_visibility); | 6078 ->hidden_by_backface_visibility); |
| 6189 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) | 6079 EXPECT_TRUE(tree.Node(render_surface2->effect_tree_index()) |
| 6190 ->hidden_by_backface_visibility); | 6080 ->hidden_by_backface_visibility); |
| 6191 | 6081 |
| 6192 render_surface1->OnTransformAnimated(rotate_about_y); | 6082 render_surface1->OnTransformAnimated(rotate_about_y); |
| 6193 ExecuteCalculateDrawProperties(root); | 6083 ExecuteCalculateDrawProperties(root); |
| 6194 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) | 6084 EXPECT_TRUE(tree.Node(render_surface1->effect_tree_index()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6211 LayerImpl* scroll_parent_border = AddChildToRoot<LayerImpl>(); | 6101 LayerImpl* scroll_parent_border = AddChildToRoot<LayerImpl>(); |
| 6212 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); | 6102 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); |
| 6213 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); | 6103 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); |
| 6214 LayerImpl* scroll_child = AddChild<LayerImpl>(root); | 6104 LayerImpl* scroll_child = AddChild<LayerImpl>(root); |
| 6215 | 6105 |
| 6216 scroll_parent->SetDrawsContent(true); | 6106 scroll_parent->SetDrawsContent(true); |
| 6217 scroll_child->SetDrawsContent(true); | 6107 scroll_child->SetDrawsContent(true); |
| 6218 scroll_parent_clip->SetMasksToBounds(true); | 6108 scroll_parent_clip->SetMasksToBounds(true); |
| 6219 | 6109 |
| 6220 scroll_child->test_properties()->scroll_parent = scroll_parent; | 6110 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 6221 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | 6111 scroll_parent->test_properties()->scroll_children = |
| 6222 new std::set<LayerImpl*>); | 6112 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6223 scroll_children->insert(scroll_child); | 6113 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 6224 scroll_parent->test_properties()->scroll_children.reset( | |
| 6225 scroll_children.release()); | |
| 6226 | 6114 |
| 6227 gfx::Transform identity_transform; | 6115 root->SetBounds(gfx::Size(50, 50)); |
| 6228 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 6116 scroll_parent_border->SetBounds(gfx::Size(40, 40)); |
| 6229 gfx::PointF(), gfx::Size(50, 50), true, false, | 6117 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); |
| 6230 true); | 6118 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6231 SetLayerPropertiesForTesting(scroll_parent_border, identity_transform, | 6119 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6232 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | |
| 6233 true, false, false); | |
| 6234 SetLayerPropertiesForTesting(scroll_parent_clip, identity_transform, | |
| 6235 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6236 true, false, false); | |
| 6237 SetLayerPropertiesForTesting(scroll_parent, identity_transform, | |
| 6238 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6239 true, false, false); | |
| 6240 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | |
| 6241 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6242 false); | |
| 6243 | |
| 6244 ExecuteCalculateDrawProperties(root); | 6120 ExecuteCalculateDrawProperties(root); |
| 6245 | 6121 |
| 6246 EXPECT_TRUE(root->render_surface()); | 6122 EXPECT_TRUE(root->render_surface()); |
| 6247 | 6123 |
| 6248 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); | 6124 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); |
| 6249 EXPECT_TRUE(scroll_child->is_clipped()); | 6125 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6250 } | 6126 } |
| 6251 | 6127 |
| 6252 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { | 6128 TEST_F(LayerTreeHostCommonTest, ScrollChildAndScrollParentDifferentTargets) { |
| 6253 // Tests the computation of draw transform for the scroll child when its | 6129 // Tests the computation of draw transform for the scroll child when its |
| 6254 // target is different from its scroll parent's target. | 6130 // target is different from its scroll parent's target. |
| 6255 LayerImpl* root = root_layer_for_testing(); | 6131 LayerImpl* root = root_layer_for_testing(); |
| 6256 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>(); | 6132 LayerImpl* scroll_child_target = AddChildToRoot<LayerImpl>(); |
| 6257 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_child_target); | 6133 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_child_target); |
| 6258 LayerImpl* scroll_parent_target = AddChild<LayerImpl>(scroll_child_target); | 6134 LayerImpl* scroll_parent_target = AddChild<LayerImpl>(scroll_child_target); |
| 6259 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_target); | 6135 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_target); |
| 6260 | 6136 |
| 6261 scroll_parent->SetDrawsContent(true); | 6137 scroll_parent->SetDrawsContent(true); |
| 6262 scroll_child->SetDrawsContent(true); | 6138 scroll_child->SetDrawsContent(true); |
| 6263 | 6139 |
| 6264 scroll_child->test_properties()->scroll_parent = scroll_parent; | 6140 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 6265 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | 6141 scroll_parent->test_properties()->scroll_children = |
| 6266 new std::set<LayerImpl*>); | 6142 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6267 scroll_children->insert(scroll_child); | 6143 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 6268 scroll_parent->test_properties()->scroll_children.reset( | |
| 6269 scroll_children.release()); | |
| 6270 | 6144 |
| 6271 gfx::Transform identity_transform; | 6145 root->SetBounds(gfx::Size(50, 50)); |
| 6272 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 6146 scroll_child_target->SetBounds(gfx::Size(50, 50)); |
| 6273 gfx::PointF(), gfx::Size(50, 50), true, false, | 6147 scroll_child_target->test_properties()->force_render_surface = true; |
| 6274 true); | 6148 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6275 SetLayerPropertiesForTesting(scroll_child_target, identity_transform, | 6149 scroll_parent_target->SetPosition(gfx::PointF(10, 10)); |
| 6276 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | 6150 scroll_parent_target->SetBounds(gfx::Size(50, 50)); |
| 6277 true, false, true); | |
| 6278 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | |
| 6279 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6280 false); | |
| 6281 SetLayerPropertiesForTesting(scroll_parent_target, identity_transform, | |
| 6282 gfx::Point3F(), gfx::PointF(10, 10), | |
| 6283 gfx::Size(50, 50), true, false, true); | |
| 6284 SetLayerPropertiesForTesting(scroll_parent, identity_transform, | |
| 6285 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6286 true, false, false); | |
| 6287 scroll_parent_target->SetMasksToBounds(true); | 6151 scroll_parent_target->SetMasksToBounds(true); |
| 6152 scroll_parent_target->test_properties()->force_render_surface = true; |
| 6153 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6288 | 6154 |
| 6289 float device_scale_factor = 1.5f; | 6155 float device_scale_factor = 1.5f; |
| 6290 LayerImplList render_surface_layer_list_impl; | 6156 LayerImplList render_surface_layer_list_impl; |
| 6291 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6157 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 6292 root, root->bounds(), identity_transform, | 6158 root, root->bounds(), gfx::Transform(), &render_surface_layer_list_impl); |
| 6293 &render_surface_layer_list_impl); | |
| 6294 inputs.device_scale_factor = device_scale_factor; | 6159 inputs.device_scale_factor = device_scale_factor; |
| 6295 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 6160 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 6296 | 6161 |
| 6297 EXPECT_EQ(scroll_child->effect_tree_index(), | 6162 EXPECT_EQ(scroll_child->effect_tree_index(), |
| 6298 scroll_child_target->effect_tree_index()); | 6163 scroll_child_target->effect_tree_index()); |
| 6299 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40)); | 6164 EXPECT_EQ(scroll_child->visible_layer_rect(), gfx::Rect(10, 10, 40, 40)); |
| 6300 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75)); | 6165 EXPECT_EQ(scroll_child->clip_rect(), gfx::Rect(15, 15, 75, 75)); |
| 6301 gfx::Transform scale; | 6166 gfx::Transform scale; |
| 6302 scale.Scale(1.5f, 1.5f); | 6167 scale.Scale(1.5f, 1.5f); |
| 6303 EXPECT_TRANSFORMATION_MATRIX_EQ(scroll_child->DrawTransform(), scale); | 6168 EXPECT_TRANSFORMATION_MATRIX_EQ(scroll_child->DrawTransform(), scale); |
| 6304 } | 6169 } |
| 6305 | 6170 |
| 6306 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { | 6171 TEST_F(LayerTreeHostCommonTest, SingularTransformSubtreesDoNotDraw) { |
| 6307 LayerImpl* root = root_layer_for_testing(); | 6172 LayerImpl* root = root_layer_for_testing(); |
| 6173 LayerImpl* parent = AddChildToRoot<LayerImpl>(); |
| 6174 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 6175 |
| 6176 root->SetBounds(gfx::Size(50, 50)); |
| 6308 root->SetDrawsContent(true); | 6177 root->SetDrawsContent(true); |
| 6309 LayerImpl* parent = AddChildToRoot<LayerImpl>(); | 6178 root->Set3dSortingContextId(1); |
| 6179 parent->SetBounds(gfx::Size(30, 30)); |
| 6310 parent->SetDrawsContent(true); | 6180 parent->SetDrawsContent(true); |
| 6311 LayerImpl* child = AddChild<LayerImpl>(parent); | 6181 parent->Set3dSortingContextId(1); |
| 6182 parent->test_properties()->force_render_surface = true; |
| 6183 child->SetBounds(gfx::Size(20, 20)); |
| 6312 child->SetDrawsContent(true); | 6184 child->SetDrawsContent(true); |
| 6313 | 6185 child->Set3dSortingContextId(1); |
| 6314 gfx::Transform identity_transform; | 6186 child->test_properties()->force_render_surface = true; |
| 6315 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 6316 gfx::PointF(), gfx::Size(50, 50), true, true, | |
| 6317 true); | |
| 6318 SetLayerPropertiesForTesting(parent, identity_transform, gfx::Point3F(), | |
| 6319 gfx::PointF(), gfx::Size(30, 30), true, true, | |
| 6320 true); | |
| 6321 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | |
| 6322 gfx::PointF(), gfx::Size(20, 20), true, true, | |
| 6323 true); | |
| 6324 | |
| 6325 ExecuteCalculateDrawProperties(root); | 6187 ExecuteCalculateDrawProperties(root); |
| 6326 | 6188 |
| 6327 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); | 6189 EXPECT_EQ(3u, render_surface_layer_list_impl()->size()); |
| 6328 | 6190 |
| 6329 gfx::Transform singular_transform; | 6191 gfx::Transform singular_transform; |
| 6330 singular_transform.Scale3d( | 6192 singular_transform.Scale3d( |
| 6331 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); | 6193 SkDoubleToMScalar(1.0), SkDoubleToMScalar(1.0), SkDoubleToMScalar(0.0)); |
| 6332 | 6194 |
| 6333 child->SetTransform(singular_transform); | 6195 child->SetTransform(singular_transform); |
| 6334 | 6196 |
| 6335 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6197 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6336 ExecuteCalculateDrawProperties(root); | 6198 ExecuteCalculateDrawProperties(root); |
| 6337 | 6199 |
| 6338 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); | 6200 EXPECT_EQ(2u, render_surface_layer_list_impl()->size()); |
| 6339 | 6201 |
| 6340 // Ensure that the entire subtree under a layer with singular transform does | 6202 // Ensure that the entire subtree under a layer with singular transform does |
| 6341 // not get rendered. | 6203 // not get rendered. |
| 6342 parent->SetTransform(singular_transform); | 6204 parent->SetTransform(singular_transform); |
| 6343 child->SetTransform(identity_transform); | 6205 child->SetTransform(gfx::Transform()); |
| 6344 | 6206 |
| 6345 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6207 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 6346 ExecuteCalculateDrawProperties(root); | 6208 ExecuteCalculateDrawProperties(root); |
| 6347 | 6209 |
| 6348 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); | 6210 EXPECT_EQ(1u, render_surface_layer_list_impl()->size()); |
| 6349 } | 6211 } |
| 6350 | 6212 |
| 6351 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { | 6213 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollParent) { |
| 6352 // Checks that clipping by a scroll parent that follows you in paint order | 6214 // Checks that clipping by a scroll parent that follows you in paint order |
| 6353 // still results in correct clipping. | 6215 // still results in correct clipping. |
| 6354 // | 6216 // |
| 6355 // + root | 6217 // + root |
| 6356 // + scroll_parent_border | 6218 // + scroll_parent_border |
| 6357 // + scroll_parent_clip | 6219 // + scroll_parent_clip |
| 6358 // + scroll_parent | 6220 // + scroll_parent |
| 6359 // + scroll_child | 6221 // + scroll_child |
| 6360 // | 6222 // |
| 6361 LayerImpl* root = root_layer_for_testing(); | 6223 LayerImpl* root = root_layer_for_testing(); |
| 6362 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root); | 6224 LayerImpl* scroll_parent_border = AddChild<LayerImpl>(root); |
| 6363 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); | 6225 LayerImpl* scroll_parent_clip = AddChild<LayerImpl>(scroll_parent_border); |
| 6364 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); | 6226 LayerImpl* scroll_parent = AddChild<LayerImpl>(scroll_parent_clip); |
| 6365 LayerImpl* scroll_child = AddChild<LayerImpl>(root); | 6227 LayerImpl* scroll_child = AddChild<LayerImpl>(root); |
| 6366 | 6228 |
| 6367 scroll_parent->SetDrawsContent(true); | 6229 scroll_parent->SetDrawsContent(true); |
| 6368 scroll_child->SetDrawsContent(true); | 6230 scroll_child->SetDrawsContent(true); |
| 6369 | 6231 |
| 6232 root->SetBounds(gfx::Size(50, 50)); |
| 6233 scroll_parent_border->SetBounds(gfx::Size(40, 40)); |
| 6234 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); |
| 6370 scroll_parent_clip->SetMasksToBounds(true); | 6235 scroll_parent_clip->SetMasksToBounds(true); |
| 6236 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6237 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6371 | 6238 |
| 6372 scroll_child->test_properties()->scroll_parent = scroll_parent; | 6239 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 6373 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | 6240 scroll_parent->test_properties()->scroll_children = |
| 6374 new std::set<LayerImpl*>); | 6241 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6375 scroll_children->insert(scroll_child); | 6242 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 6376 scroll_parent->test_properties()->scroll_children.reset( | |
| 6377 scroll_children.release()); | |
| 6378 | |
| 6379 gfx::Transform identity_transform; | |
| 6380 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 6381 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6382 true); | |
| 6383 SetLayerPropertiesForTesting(scroll_parent_border, identity_transform, | |
| 6384 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | |
| 6385 true, false, false); | |
| 6386 SetLayerPropertiesForTesting(scroll_parent_clip, identity_transform, | |
| 6387 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6388 true, false, false); | |
| 6389 SetLayerPropertiesForTesting(scroll_parent, identity_transform, | |
| 6390 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6391 true, false, false); | |
| 6392 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | |
| 6393 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6394 false); | |
| 6395 | 6243 |
| 6396 ExecuteCalculateDrawProperties(root); | 6244 ExecuteCalculateDrawProperties(root); |
| 6397 | 6245 |
| 6398 EXPECT_TRUE(root->render_surface()); | 6246 EXPECT_TRUE(root->render_surface()); |
| 6399 | 6247 |
| 6400 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); | 6248 EXPECT_EQ(gfx::Rect(0, 0, 30, 30), scroll_child->clip_rect()); |
| 6401 EXPECT_TRUE(scroll_child->is_clipped()); | 6249 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6402 } | 6250 } |
| 6403 | 6251 |
| 6404 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) { | 6252 TEST_F(LayerTreeHostCommonTest, ClippedByOutOfOrderScrollGrandparent) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6425 LayerImpl* scroll_grandparent = AddChild<LayerImpl>(scroll_grandparent_clip); | 6273 LayerImpl* scroll_grandparent = AddChild<LayerImpl>(scroll_grandparent_clip); |
| 6426 | 6274 |
| 6427 scroll_parent->SetDrawsContent(true); | 6275 scroll_parent->SetDrawsContent(true); |
| 6428 scroll_grandparent->SetDrawsContent(true); | 6276 scroll_grandparent->SetDrawsContent(true); |
| 6429 scroll_child->SetDrawsContent(true); | 6277 scroll_child->SetDrawsContent(true); |
| 6430 | 6278 |
| 6431 scroll_parent_clip->SetMasksToBounds(true); | 6279 scroll_parent_clip->SetMasksToBounds(true); |
| 6432 scroll_grandparent_clip->SetMasksToBounds(true); | 6280 scroll_grandparent_clip->SetMasksToBounds(true); |
| 6433 | 6281 |
| 6434 scroll_child->test_properties()->scroll_parent = scroll_parent; | 6282 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 6435 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | 6283 scroll_parent->test_properties()->scroll_children = |
| 6436 new std::set<LayerImpl*>); | 6284 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6437 scroll_children->insert(scroll_child); | 6285 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 6438 scroll_parent->test_properties()->scroll_children.reset( | |
| 6439 scroll_children.release()); | |
| 6440 | 6286 |
| 6441 scroll_parent_border->test_properties()->scroll_parent = scroll_grandparent; | 6287 scroll_parent_border->test_properties()->scroll_parent = scroll_grandparent; |
| 6442 scroll_children.reset(new std::set<LayerImpl*>); | 6288 scroll_grandparent->test_properties()->scroll_children = |
| 6443 scroll_children->insert(scroll_parent_border); | 6289 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6444 scroll_grandparent->test_properties()->scroll_children.reset( | 6290 scroll_grandparent->test_properties()->scroll_children->insert( |
| 6445 scroll_children.release()); | 6291 scroll_parent_border); |
| 6446 | 6292 |
| 6447 gfx::Transform identity_transform; | 6293 root->SetBounds(gfx::Size(50, 50)); |
| 6448 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 6294 scroll_grandparent_border->SetBounds(gfx::Size(40, 40)); |
| 6449 gfx::PointF(), gfx::Size(50, 50), true, false, | 6295 scroll_grandparent_clip->SetBounds(gfx::Size(20, 20)); |
| 6450 true); | 6296 scroll_grandparent->SetBounds(gfx::Size(50, 50)); |
| 6451 SetLayerPropertiesForTesting(scroll_grandparent_border, identity_transform, | 6297 scroll_parent_border->SetBounds(gfx::Size(40, 40)); |
| 6452 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | 6298 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); |
| 6453 true, false, false); | 6299 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6454 SetLayerPropertiesForTesting(scroll_grandparent_clip, identity_transform, | 6300 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6455 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | |
| 6456 true, false, false); | |
| 6457 SetLayerPropertiesForTesting(scroll_grandparent, identity_transform, | |
| 6458 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6459 true, false, false); | |
| 6460 SetLayerPropertiesForTesting(scroll_parent_border, identity_transform, | |
| 6461 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | |
| 6462 true, false, false); | |
| 6463 SetLayerPropertiesForTesting(scroll_parent_clip, identity_transform, | |
| 6464 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6465 true, false, false); | |
| 6466 SetLayerPropertiesForTesting(scroll_parent, identity_transform, | |
| 6467 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6468 true, false, false); | |
| 6469 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | |
| 6470 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6471 false); | |
| 6472 | 6301 |
| 6473 ExecuteCalculateDrawProperties(root); | 6302 ExecuteCalculateDrawProperties(root); |
| 6474 | 6303 |
| 6475 EXPECT_TRUE(root->render_surface()); | 6304 EXPECT_TRUE(root->render_surface()); |
| 6476 | 6305 |
| 6477 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); | 6306 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); |
| 6478 EXPECT_TRUE(scroll_child->is_clipped()); | 6307 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6479 | 6308 |
| 6480 // Despite the fact that we visited the above layers out of order to get the | 6309 // Despite the fact that we visited the above layers out of order to get the |
| 6481 // correct clip, the layer lists should be unaffected. | 6310 // correct clip, the layer lists should be unaffected. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6517 | 6346 |
| 6518 scroll_parent->SetDrawsContent(true); | 6347 scroll_parent->SetDrawsContent(true); |
| 6519 render_surface1->SetDrawsContent(true); | 6348 render_surface1->SetDrawsContent(true); |
| 6520 scroll_grandparent->SetDrawsContent(true); | 6349 scroll_grandparent->SetDrawsContent(true); |
| 6521 render_surface2->SetDrawsContent(true); | 6350 render_surface2->SetDrawsContent(true); |
| 6522 | 6351 |
| 6523 scroll_parent_clip->SetMasksToBounds(true); | 6352 scroll_parent_clip->SetMasksToBounds(true); |
| 6524 scroll_grandparent_clip->SetMasksToBounds(true); | 6353 scroll_grandparent_clip->SetMasksToBounds(true); |
| 6525 | 6354 |
| 6526 scroll_child->test_properties()->scroll_parent = scroll_parent; | 6355 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 6527 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | 6356 scroll_parent->test_properties()->scroll_children = |
| 6528 new std::set<LayerImpl*>); | 6357 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6529 scroll_children->insert(scroll_child); | 6358 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 6530 scroll_parent->test_properties()->scroll_children.reset( | |
| 6531 scroll_children.release()); | |
| 6532 | 6359 |
| 6533 scroll_parent_border->test_properties()->scroll_parent = scroll_grandparent; | 6360 scroll_parent_border->test_properties()->scroll_parent = scroll_grandparent; |
| 6534 scroll_children.reset(new std::set<LayerImpl*>); | 6361 scroll_grandparent->test_properties()->scroll_children = |
| 6535 scroll_children->insert(scroll_parent_border); | 6362 base::MakeUnique<std::set<LayerImpl*>>(); |
| 6536 scroll_grandparent->test_properties()->scroll_children.reset( | 6363 scroll_grandparent->test_properties()->scroll_children->insert( |
| 6537 scroll_children.release()); | 6364 scroll_parent_border); |
| 6538 | 6365 |
| 6539 gfx::Transform identity_transform; | 6366 root->SetBounds(gfx::Size(50, 50)); |
| 6540 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 6367 scroll_grandparent_border->SetBounds(gfx::Size(40, 40)); |
| 6541 gfx::PointF(), gfx::Size(50, 50), true, false, | 6368 scroll_grandparent_clip->SetBounds(gfx::Size(20, 20)); |
| 6542 true); | 6369 scroll_grandparent->SetBounds(gfx::Size(50, 50)); |
| 6543 SetLayerPropertiesForTesting(scroll_grandparent_border, identity_transform, | 6370 render_surface1->SetBounds(gfx::Size(50, 50)); |
| 6544 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | 6371 render_surface1->test_properties()->force_render_surface = true; |
| 6545 true, false, false); | 6372 scroll_parent_border->SetBounds(gfx::Size(40, 40)); |
| 6546 SetLayerPropertiesForTesting(scroll_grandparent_clip, identity_transform, | 6373 scroll_parent_clip->SetBounds(gfx::Size(30, 30)); |
| 6547 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 6374 scroll_parent->SetBounds(gfx::Size(50, 50)); |
| 6548 true, false, false); | 6375 render_surface2->SetBounds(gfx::Size(50, 50)); |
| 6549 SetLayerPropertiesForTesting(scroll_grandparent, identity_transform, | 6376 render_surface2->test_properties()->force_render_surface = true; |
| 6550 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | 6377 scroll_child->SetBounds(gfx::Size(50, 50)); |
| 6551 true, false, false); | |
| 6552 SetLayerPropertiesForTesting(render_surface1, identity_transform, | |
| 6553 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6554 true, false, true); | |
| 6555 SetLayerPropertiesForTesting(scroll_parent_border, identity_transform, | |
| 6556 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | |
| 6557 true, false, false); | |
| 6558 SetLayerPropertiesForTesting(scroll_parent_clip, identity_transform, | |
| 6559 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 6560 true, false, false); | |
| 6561 SetLayerPropertiesForTesting(scroll_parent, identity_transform, | |
| 6562 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6563 true, false, false); | |
| 6564 SetLayerPropertiesForTesting(render_surface2, identity_transform, | |
| 6565 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 6566 true, false, true); | |
| 6567 SetLayerPropertiesForTesting(scroll_child, identity_transform, gfx::Point3F(), | |
| 6568 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6569 false); | |
| 6570 | 6378 |
| 6571 ExecuteCalculateDrawProperties(root); | 6379 ExecuteCalculateDrawProperties(root); |
| 6572 | 6380 |
| 6573 EXPECT_TRUE(root->render_surface()); | 6381 EXPECT_TRUE(root->render_surface()); |
| 6574 | 6382 |
| 6575 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); | 6383 EXPECT_EQ(gfx::Rect(0, 0, 20, 20), scroll_child->clip_rect()); |
| 6576 EXPECT_TRUE(scroll_child->is_clipped()); | 6384 EXPECT_TRUE(scroll_child->is_clipped()); |
| 6577 | 6385 |
| 6578 // Despite the fact that we had to process the layers out of order to get the | 6386 // Despite the fact that we had to process the layers out of order to get the |
| 6579 // right clip, our render_surface_layer_list's order should be unaffected. | 6387 // right clip, our render_surface_layer_list's order should be unaffected. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6595 // + root | 6403 // + root |
| 6596 // + render_surface | 6404 // + render_surface |
| 6597 // + fixed | 6405 // + fixed |
| 6598 // + child | 6406 // + child |
| 6599 // | 6407 // |
| 6600 LayerImpl* root = root_layer_for_testing(); | 6408 LayerImpl* root = root_layer_for_testing(); |
| 6601 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 6409 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 6602 LayerImpl* fixed = AddChild<LayerImpl>(render_surface); | 6410 LayerImpl* fixed = AddChild<LayerImpl>(render_surface); |
| 6603 LayerImpl* child = AddChild<LayerImpl>(fixed); | 6411 LayerImpl* child = AddChild<LayerImpl>(fixed); |
| 6604 | 6412 |
| 6605 render_surface->SetDrawsContent(true); | |
| 6606 fixed->SetDrawsContent(true); | |
| 6607 child->SetDrawsContent(true); | |
| 6608 | |
| 6609 render_surface->test_properties()->force_render_surface = true; | 6413 render_surface->test_properties()->force_render_surface = true; |
| 6610 root->test_properties()->is_container_for_fixed_position_layers = true; | 6414 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 6611 | 6415 |
| 6612 LayerPositionConstraint constraint; | 6416 LayerPositionConstraint constraint; |
| 6613 constraint.set_is_fixed_position(true); | 6417 constraint.set_is_fixed_position(true); |
| 6614 fixed->test_properties()->position_constraint = constraint; | 6418 fixed->test_properties()->position_constraint = constraint; |
| 6615 | 6419 |
| 6616 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), | 6420 root->SetBounds(gfx::Size(50, 50)); |
| 6617 gfx::PointF(), gfx::Size(50, 50), true, false); | 6421 render_surface->SetPosition(gfx::PointF(7.f, 9.f)); |
| 6618 SetLayerPropertiesForTesting(render_surface, gfx::Transform(), gfx::Point3F(), | 6422 render_surface->SetBounds(gfx::Size(50, 50)); |
| 6619 gfx::PointF(7.f, 9.f), gfx::Size(50, 50), true, | 6423 render_surface->SetDrawsContent(true); |
| 6620 false); | 6424 fixed->SetPosition(gfx::PointF(10.f, 15.f)); |
| 6621 SetLayerPropertiesForTesting(fixed, gfx::Transform(), gfx::Point3F(), | 6425 fixed->SetBounds(gfx::Size(50, 50)); |
| 6622 gfx::PointF(10.f, 15.f), gfx::Size(50, 50), true, | 6426 fixed->SetDrawsContent(true); |
| 6623 false); | 6427 child->SetPosition(gfx::PointF(1.f, 2.f)); |
| 6624 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), | 6428 child->SetBounds(gfx::Size(50, 50)); |
| 6625 gfx::PointF(1.f, 2.f), gfx::Size(50, 50), true, | 6429 child->SetDrawsContent(true); |
| 6626 false); | |
| 6627 | |
| 6628 ExecuteCalculateDrawProperties(root); | 6430 ExecuteCalculateDrawProperties(root); |
| 6629 | 6431 |
| 6630 TransformTree& transform_tree = | 6432 TransformTree& transform_tree = |
| 6631 host_impl()->active_tree()->property_trees()->transform_tree; | 6433 host_impl()->active_tree()->property_trees()->transform_tree; |
| 6632 EffectTree& effect_tree = | 6434 EffectTree& effect_tree = |
| 6633 host_impl()->active_tree()->property_trees()->effect_tree; | 6435 host_impl()->active_tree()->property_trees()->effect_tree; |
| 6634 | 6436 |
| 6635 gfx::Transform expected_fixed_draw_transform; | 6437 gfx::Transform expected_fixed_draw_transform; |
| 6636 expected_fixed_draw_transform.Translate(10.f, 15.f); | 6438 expected_fixed_draw_transform.Translate(10.f, 15.f); |
| 6637 EXPECT_TRANSFORMATION_MATRIX_EQ( | 6439 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6686 LayerImpl* fixed_layer = fixed.get(); | 6488 LayerImpl* fixed_layer = fixed.get(); |
| 6687 | 6489 |
| 6688 container->test_properties()->is_container_for_fixed_position_layers = true; | 6490 container->test_properties()->is_container_for_fixed_position_layers = true; |
| 6689 | 6491 |
| 6690 LayerPositionConstraint constraint; | 6492 LayerPositionConstraint constraint; |
| 6691 constraint.set_is_fixed_position(true); | 6493 constraint.set_is_fixed_position(true); |
| 6692 fixed->test_properties()->position_constraint = constraint; | 6494 fixed->test_properties()->position_constraint = constraint; |
| 6693 | 6495 |
| 6694 scroller->SetScrollClipLayer(container->id()); | 6496 scroller->SetScrollClipLayer(container->id()); |
| 6695 | 6497 |
| 6696 gfx::Transform identity_transform; | |
| 6697 gfx::Transform container_transform; | 6498 gfx::Transform container_transform; |
| 6698 container_transform.Translate3d(10.0, 20.0, 0.0); | 6499 container_transform.Translate3d(10.0, 20.0, 0.0); |
| 6699 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); | 6500 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); |
| 6700 | 6501 |
| 6701 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 6502 root->SetBounds(gfx::Size(50, 50)); |
| 6702 gfx::PointF(), gfx::Size(50, 50), true, false, | 6503 container->SetTransform(container_transform); |
| 6703 true); | 6504 container->SetBounds(gfx::Size(40, 40)); |
| 6704 SetLayerPropertiesForTesting(container.get(), container_transform, | 6505 container->SetDrawsContent(true); |
| 6705 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | 6506 scroller->SetBounds(gfx::Size(30, 30)); |
| 6706 true, false, false); | 6507 scroller->SetDrawsContent(true); |
| 6707 SetLayerPropertiesForTesting(scroller.get(), identity_transform, | 6508 fixed->SetBounds(gfx::Size(50, 50)); |
| 6708 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 6509 fixed->SetDrawsContent(true); |
| 6709 true, false, false); | |
| 6710 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), | |
| 6711 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6712 false); | |
| 6713 | 6510 |
| 6714 root->SetDrawsContent(true); | |
| 6715 container->SetDrawsContent(true); | |
| 6716 scroller->SetDrawsContent(true); | |
| 6717 fixed->SetDrawsContent(true); | |
| 6718 scroller->test_properties()->AddChild(std::move(fixed)); | 6511 scroller->test_properties()->AddChild(std::move(fixed)); |
| 6719 container->test_properties()->AddChild(std::move(scroller)); | 6512 container->test_properties()->AddChild(std::move(scroller)); |
| 6720 root->test_properties()->AddChild(std::move(container)); | 6513 root->test_properties()->AddChild(std::move(container)); |
| 6721 root->layer_tree_impl()->SetRootLayerForTesting(std::move(root_ptr)); | 6514 root->layer_tree_impl()->SetRootLayerForTesting(std::move(root_ptr)); |
| 6722 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | 6515 root->layer_tree_impl()->BuildPropertyTreesForTesting(); |
| 6723 | 6516 |
| 6724 // Rounded to integers already. | 6517 // Rounded to integers already. |
| 6725 { | 6518 { |
| 6726 gfx::Vector2dF scroll_delta(3.0, 5.0); | 6519 gfx::Vector2dF scroll_delta(3.0, 5.0); |
| 6727 SetScrollOffsetDelta(scroll_layer, scroll_delta); | 6520 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6805 // + animated layer | 6598 // + animated layer |
| 6806 // + surface | 6599 // + surface |
| 6807 // + container | 6600 // + container |
| 6808 // + scroller | 6601 // + scroller |
| 6809 // | 6602 // |
| 6810 LayerImpl* root = root_layer_for_testing(); | 6603 LayerImpl* root = root_layer_for_testing(); |
| 6811 LayerImpl* animated_layer = AddChildToRoot<FakePictureLayerImpl>(); | 6604 LayerImpl* animated_layer = AddChildToRoot<FakePictureLayerImpl>(); |
| 6812 LayerImpl* surface = AddChild<LayerImpl>(animated_layer); | 6605 LayerImpl* surface = AddChild<LayerImpl>(animated_layer); |
| 6813 LayerImpl* container = AddChild<LayerImpl>(surface); | 6606 LayerImpl* container = AddChild<LayerImpl>(surface); |
| 6814 LayerImpl* scroller = AddChild<LayerImpl>(container); | 6607 LayerImpl* scroller = AddChild<LayerImpl>(container); |
| 6608 |
| 6609 gfx::Transform start_scale; |
| 6610 start_scale.Scale(1.5f, 1.5f); |
| 6611 |
| 6612 root->SetBounds(gfx::Size(50, 50)); |
| 6613 animated_layer->SetTransform(start_scale); |
| 6614 animated_layer->SetBounds(gfx::Size(50, 50)); |
| 6615 surface->SetBounds(gfx::Size(50, 50)); |
| 6616 surface->test_properties()->force_render_surface = true; |
| 6617 container->SetBounds(gfx::Size(50, 50)); |
| 6618 scroller->SetBounds(gfx::Size(100, 100)); |
| 6815 scroller->SetScrollClipLayer(container->id()); | 6619 scroller->SetScrollClipLayer(container->id()); |
| 6816 scroller->SetDrawsContent(true); | 6620 scroller->SetDrawsContent(true); |
| 6817 | 6621 |
| 6818 gfx::Transform identity_transform; | |
| 6819 gfx::Transform start_scale; | |
| 6820 start_scale.Scale(1.5f, 1.5f); | |
| 6821 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 6822 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6823 true); | |
| 6824 SetLayerPropertiesForTesting(animated_layer, start_scale, gfx::Point3F(), | |
| 6825 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6826 false); | |
| 6827 SetLayerPropertiesForTesting(surface, identity_transform, gfx::Point3F(), | |
| 6828 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6829 true); | |
| 6830 SetLayerPropertiesForTesting(container, identity_transform, gfx::Point3F(), | |
| 6831 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 6832 false); | |
| 6833 SetLayerPropertiesForTesting(scroller, identity_transform, gfx::Point3F(), | |
| 6834 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 6835 false); | |
| 6836 | |
| 6837 gfx::Transform end_scale; | 6622 gfx::Transform end_scale; |
| 6838 end_scale.Scale(2.f, 2.f); | 6623 end_scale.Scale(2.f, 2.f); |
| 6839 TransformOperations start_operations; | 6624 TransformOperations start_operations; |
| 6840 start_operations.AppendMatrix(start_scale); | 6625 start_operations.AppendMatrix(start_scale); |
| 6841 TransformOperations end_operations; | 6626 TransformOperations end_operations; |
| 6842 end_operations.AppendMatrix(end_scale); | 6627 end_operations.AppendMatrix(end_scale); |
| 6843 SetElementIdsForTesting(); | 6628 SetElementIdsForTesting(); |
| 6844 | 6629 |
| 6845 AddAnimatedTransformToElementWithPlayer(animated_layer->element_id(), | 6630 AddAnimatedTransformToElementWithPlayer(animated_layer->element_id(), |
| 6846 timeline_impl(), 1.0, | 6631 timeline_impl(), 1.0, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 6875 }; | 6660 }; |
| 6876 | 6661 |
| 6877 TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { | 6662 TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { |
| 6878 FakeImplTaskRunnerProvider task_runner_provider; | 6663 FakeImplTaskRunnerProvider task_runner_provider; |
| 6879 TestSharedBitmapManager shared_bitmap_manager; | 6664 TestSharedBitmapManager shared_bitmap_manager; |
| 6880 TestTaskGraphRunner task_graph_runner; | 6665 TestTaskGraphRunner task_graph_runner; |
| 6881 LayerTreeSettings settings = host()->settings(); | 6666 LayerTreeSettings settings = host()->settings(); |
| 6882 settings.layer_transforms_should_scale_layer_contents = true; | 6667 settings.layer_transforms_should_scale_layer_contents = true; |
| 6883 FakeLayerTreeHostImpl host_impl(settings, &task_runner_provider, | 6668 FakeLayerTreeHostImpl host_impl(settings, &task_runner_provider, |
| 6884 &shared_bitmap_manager, &task_graph_runner); | 6669 &shared_bitmap_manager, &task_graph_runner); |
| 6885 gfx::Transform identity_matrix; | |
| 6886 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> grand_parent = | 6670 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> grand_parent = |
| 6887 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 1); | 6671 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 1); |
| 6888 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> parent = | 6672 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> parent = |
| 6889 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 2); | 6673 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 2); |
| 6890 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> child = | 6674 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> child = |
| 6891 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 3); | 6675 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 3); |
| 6892 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> grand_child = | 6676 std::unique_ptr<AnimationScaleFactorTrackingLayerImpl> grand_child = |
| 6893 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); | 6677 AnimationScaleFactorTrackingLayerImpl::Create(host_impl.active_tree(), 4); |
| 6894 | 6678 |
| 6895 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); | 6679 AnimationScaleFactorTrackingLayerImpl* parent_raw = parent.get(); |
| 6896 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); | 6680 AnimationScaleFactorTrackingLayerImpl* child_raw = child.get(); |
| 6897 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); | 6681 AnimationScaleFactorTrackingLayerImpl* grand_child_raw = grand_child.get(); |
| 6898 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get(); | 6682 AnimationScaleFactorTrackingLayerImpl* grand_parent_raw = grand_parent.get(); |
| 6899 | 6683 |
| 6684 grand_parent->SetBounds(gfx::Size(1, 2)); |
| 6685 parent->SetBounds(gfx::Size(1, 2)); |
| 6686 child->SetBounds(gfx::Size(1, 2)); |
| 6687 grand_child->SetBounds(gfx::Size(1, 2)); |
| 6688 |
| 6900 child->test_properties()->AddChild(std::move(grand_child)); | 6689 child->test_properties()->AddChild(std::move(grand_child)); |
| 6901 parent->test_properties()->AddChild(std::move(child)); | 6690 parent->test_properties()->AddChild(std::move(child)); |
| 6902 grand_parent->test_properties()->AddChild(std::move(parent)); | 6691 grand_parent->test_properties()->AddChild(std::move(parent)); |
| 6903 | |
| 6904 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, | |
| 6905 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), | |
| 6906 true, false, true); | |
| 6907 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), | |
| 6908 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 6909 false); | |
| 6910 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), | |
| 6911 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 6912 false); | |
| 6913 | |
| 6914 SetLayerPropertiesForTesting(grand_child_raw, identity_matrix, gfx::Point3F(), | |
| 6915 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 6916 false); | |
| 6917 | |
| 6918 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); | 6692 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); |
| 6919 | 6693 |
| 6920 ExecuteCalculateDrawProperties(grand_parent_raw); | 6694 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 6921 | 6695 |
| 6922 // No layers have animations. | 6696 // No layers have animations. |
| 6923 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); | 6697 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 6924 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); | 6698 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 6925 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); | 6699 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 6926 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); | 6700 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 6927 | 6701 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7085 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); | 6859 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7086 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); | 6860 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7087 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); | 6861 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7088 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); | 6862 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| 7089 | 6863 |
| 7090 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); | 6864 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_parent_raw)); |
| 7091 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); | 6865 EXPECT_EQ(0.f, GetStartingAnimationScale(parent_raw)); |
| 7092 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); | 6866 EXPECT_EQ(0.f, GetStartingAnimationScale(child_raw)); |
| 7093 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); | 6867 EXPECT_EQ(0.f, GetStartingAnimationScale(grand_child_raw)); |
| 7094 | 6868 |
| 7095 parent_raw->SetTransform(identity_matrix); | 6869 parent_raw->SetTransform(gfx::Transform()); |
| 7096 child_raw->SetTransform(identity_matrix); | 6870 child_raw->SetTransform(gfx::Transform()); |
| 7097 grand_parent_raw->SetTransform(perspective_matrix); | 6871 grand_parent_raw->SetTransform(perspective_matrix); |
| 7098 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 6872 grand_parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7099 | 6873 |
| 7100 ExecuteCalculateDrawProperties(grand_parent_raw); | 6874 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7101 | 6875 |
| 7102 // |grand_parent| has a transform that's neither a translation nor a scale. | 6876 // |grand_parent| has a transform that's neither a translation nor a scale. |
| 7103 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); | 6877 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_parent_raw)); |
| 7104 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); | 6878 EXPECT_EQ(0.f, GetMaximumAnimationScale(parent_raw)); |
| 7105 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); | 6879 EXPECT_EQ(0.f, GetMaximumAnimationScale(child_raw)); |
| 7106 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); | 6880 EXPECT_EQ(0.f, GetMaximumAnimationScale(grand_child_raw)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7129 drawn_layers->insert(layer->render_surface()->ReplicaMaskLayer()); | 6903 drawn_layers->insert(layer->render_surface()->ReplicaMaskLayer()); |
| 7130 } | 6904 } |
| 7131 } | 6905 } |
| 7132 | 6906 |
| 7133 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { | 6907 TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { |
| 7134 FakeImplTaskRunnerProvider task_runner_provider; | 6908 FakeImplTaskRunnerProvider task_runner_provider; |
| 7135 TestSharedBitmapManager shared_bitmap_manager; | 6909 TestSharedBitmapManager shared_bitmap_manager; |
| 7136 TestTaskGraphRunner task_graph_runner; | 6910 TestTaskGraphRunner task_graph_runner; |
| 7137 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 6911 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 7138 &task_graph_runner); | 6912 &task_graph_runner); |
| 7139 gfx::Transform identity_matrix; | |
| 7140 | 6913 |
| 7141 std::unique_ptr<LayerImpl> grand_parent = | 6914 std::unique_ptr<LayerImpl> grand_parent = |
| 7142 LayerImpl::Create(host_impl.active_tree(), 1); | 6915 LayerImpl::Create(host_impl.active_tree(), 1); |
| 7143 std::unique_ptr<LayerImpl> parent = | 6916 std::unique_ptr<LayerImpl> parent = |
| 7144 LayerImpl::Create(host_impl.active_tree(), 3); | 6917 LayerImpl::Create(host_impl.active_tree(), 3); |
| 7145 std::unique_ptr<LayerImpl> child = | 6918 std::unique_ptr<LayerImpl> child = |
| 7146 LayerImpl::Create(host_impl.active_tree(), 5); | 6919 LayerImpl::Create(host_impl.active_tree(), 5); |
| 7147 std::unique_ptr<LayerImpl> grand_child1 = | 6920 std::unique_ptr<LayerImpl> grand_child1 = |
| 7148 LayerImpl::Create(host_impl.active_tree(), 7); | 6921 LayerImpl::Create(host_impl.active_tree(), 7); |
| 7149 std::unique_ptr<LayerImpl> grand_child2 = | 6922 std::unique_ptr<LayerImpl> grand_child2 = |
| 7150 LayerImpl::Create(host_impl.active_tree(), 9); | 6923 LayerImpl::Create(host_impl.active_tree(), 9); |
| 7151 | 6924 |
| 7152 LayerImpl* grand_parent_raw = grand_parent.get(); | 6925 LayerImpl* grand_parent_raw = grand_parent.get(); |
| 7153 LayerImpl* parent_raw = parent.get(); | 6926 LayerImpl* parent_raw = parent.get(); |
| 7154 LayerImpl* child_raw = child.get(); | 6927 LayerImpl* child_raw = child.get(); |
| 7155 LayerImpl* grand_child1_raw = grand_child1.get(); | 6928 LayerImpl* grand_child1_raw = grand_child1.get(); |
| 7156 LayerImpl* grand_child2_raw = grand_child2.get(); | 6929 LayerImpl* grand_child2_raw = grand_child2.get(); |
| 7157 | 6930 |
| 6931 grand_parent->SetBounds(gfx::Size(1, 2)); |
| 6932 parent->SetBounds(gfx::Size(1, 2)); |
| 6933 child->SetBounds(gfx::Size(1, 2)); |
| 6934 grand_child1->SetBounds(gfx::Size(1, 2)); |
| 6935 grand_child2->SetBounds(gfx::Size(1, 2)); |
| 6936 |
| 7158 child->test_properties()->AddChild(std::move(grand_child1)); | 6937 child->test_properties()->AddChild(std::move(grand_child1)); |
| 7159 child->test_properties()->AddChild(std::move(grand_child2)); | 6938 child->test_properties()->AddChild(std::move(grand_child2)); |
| 7160 parent->test_properties()->AddChild(std::move(child)); | 6939 parent->test_properties()->AddChild(std::move(child)); |
| 7161 grand_parent->test_properties()->AddChild(std::move(parent)); | 6940 grand_parent->test_properties()->AddChild(std::move(parent)); |
| 7162 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); | 6941 host_impl.active_tree()->SetRootLayerForTesting(std::move(grand_parent)); |
| 7163 | 6942 |
| 7164 SetLayerPropertiesForTesting(grand_parent_raw, identity_matrix, | |
| 7165 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), | |
| 7166 true, false, true); | |
| 7167 SetLayerPropertiesForTesting(parent_raw, identity_matrix, gfx::Point3F(), | |
| 7168 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 7169 false); | |
| 7170 | |
| 7171 SetLayerPropertiesForTesting(child_raw, identity_matrix, gfx::Point3F(), | |
| 7172 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 7173 false); | |
| 7174 | |
| 7175 SetLayerPropertiesForTesting(grand_child1_raw, identity_matrix, | |
| 7176 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), | |
| 7177 true, false, false); | |
| 7178 | |
| 7179 SetLayerPropertiesForTesting(grand_child2_raw, identity_matrix, | |
| 7180 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 2), | |
| 7181 true, false, false); | |
| 7182 | |
| 7183 // Start with nothing being drawn. | 6943 // Start with nothing being drawn. |
| 7184 ExecuteCalculateDrawProperties(grand_parent_raw); | 6944 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 7185 | 6945 |
| 7186 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 6946 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); |
| 7187 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 6947 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); |
| 7188 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 6948 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); |
| 7189 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 6949 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); |
| 7190 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 6950 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); |
| 7191 | 6951 |
| 7192 std::set<LayerImpl*> expected; | 6952 std::set<LayerImpl*> expected; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7397 std::unique_ptr<LayerImpl> root = | 7157 std::unique_ptr<LayerImpl> root = |
| 7398 LayerImpl::Create(host_impl.active_tree(), 1); | 7158 LayerImpl::Create(host_impl.active_tree(), 1); |
| 7399 LayerImpl* root_layer = root.get(); | 7159 LayerImpl* root_layer = root.get(); |
| 7400 std::unique_ptr<LayerImpl> child1 = | 7160 std::unique_ptr<LayerImpl> child1 = |
| 7401 LayerImpl::Create(host_impl.active_tree(), 2); | 7161 LayerImpl::Create(host_impl.active_tree(), 2); |
| 7402 LayerImpl* child1_layer = child1.get(); | 7162 LayerImpl* child1_layer = child1.get(); |
| 7403 std::unique_ptr<LayerImpl> child2 = | 7163 std::unique_ptr<LayerImpl> child2 = |
| 7404 LayerImpl::Create(host_impl.active_tree(), 3); | 7164 LayerImpl::Create(host_impl.active_tree(), 3); |
| 7405 LayerImpl* child2_layer = child2.get(); | 7165 LayerImpl* child2_layer = child2.get(); |
| 7406 | 7166 |
| 7407 root->test_properties()->AddChild(std::move(child1)); | 7167 gfx::Transform scale_transform_child1, scale_transform_child2; |
| 7408 root->test_properties()->AddChild(std::move(child2)); | |
| 7409 root->test_properties()->force_render_surface = true; | |
| 7410 root->SetDrawsContent(true); | |
| 7411 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | |
| 7412 | |
| 7413 host_impl.active_tree()->SetElementIdsForTesting(); | |
| 7414 | |
| 7415 gfx::Transform identity_matrix, scale_transform_child1, | |
| 7416 scale_transform_child2; | |
| 7417 scale_transform_child1.Scale(2, 3); | 7168 scale_transform_child1.Scale(2, 3); |
| 7418 scale_transform_child2.Scale(4, 5); | 7169 scale_transform_child2.Scale(4, 5); |
| 7419 | 7170 |
| 7420 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7171 root->SetBounds(gfx::Size(1, 1)); |
| 7421 gfx::PointF(), gfx::Size(1, 1), true, false, | 7172 root->SetDrawsContent(true); |
| 7422 true); | 7173 child1_layer->SetTransform(scale_transform_child1); |
| 7423 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7174 child1_layer->SetBounds(gfx::Size(1, 1)); |
| 7424 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7175 child1_layer->SetDrawsContent(true); |
| 7425 true, false, false); | |
| 7426 | 7176 |
| 7427 child1_layer->test_properties()->SetMaskLayer( | 7177 child1_layer->test_properties()->SetMaskLayer( |
| 7428 LayerImpl::Create(host_impl.active_tree(), 4)); | 7178 LayerImpl::Create(host_impl.active_tree(), 4)); |
| 7429 child1_layer->SetDrawsContent(true); | |
| 7430 | 7179 |
| 7431 std::unique_ptr<LayerImpl> replica_layer = | 7180 std::unique_ptr<LayerImpl> replica_layer = |
| 7432 LayerImpl::Create(host_impl.active_tree(), 5); | 7181 LayerImpl::Create(host_impl.active_tree(), 5); |
| 7433 replica_layer->test_properties()->SetMaskLayer( | 7182 replica_layer->test_properties()->SetMaskLayer( |
| 7434 LayerImpl::Create(host_impl.active_tree(), 6)); | 7183 LayerImpl::Create(host_impl.active_tree(), 6)); |
| 7435 child1_layer->test_properties()->SetReplicaLayer(std::move(replica_layer)); | 7184 child1_layer->test_properties()->SetReplicaLayer(std::move(replica_layer)); |
| 7436 child1_layer->SetHasRenderSurface(true); | 7185 |
| 7186 root->test_properties()->AddChild(std::move(child1)); |
| 7187 root->test_properties()->AddChild(std::move(child2)); |
| 7188 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7189 host_impl.active_tree()->SetElementIdsForTesting(); |
| 7437 | 7190 |
| 7438 ExecuteCalculateDrawProperties(root_layer); | 7191 ExecuteCalculateDrawProperties(root_layer); |
| 7439 | 7192 |
| 7440 TransformOperations scale; | 7193 TransformOperations scale; |
| 7441 scale.AppendScale(5.f, 8.f, 3.f); | 7194 scale.AppendScale(5.f, 8.f, 3.f); |
| 7442 | 7195 |
| 7443 scoped_refptr<AnimationTimeline> timeline = | 7196 scoped_refptr<AnimationTimeline> timeline = |
| 7444 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7197 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7445 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7198 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7446 | 7199 |
| 7447 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, | 7200 child2_layer->SetTransform(scale_transform_child2); |
| 7448 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7201 child2_layer->SetBounds(gfx::Size(1, 1)); |
| 7449 true, false, false); | |
| 7450 child2_layer->SetDrawsContent(true); | 7202 child2_layer->SetDrawsContent(true); |
| 7451 | |
| 7452 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, | 7203 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, |
| 7453 1.0, TransformOperations(), scale); | 7204 1.0, TransformOperations(), scale); |
| 7454 | 7205 |
| 7455 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7206 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7456 ExecuteCalculateDrawProperties(root_layer); | 7207 ExecuteCalculateDrawProperties(root_layer); |
| 7457 | 7208 |
| 7458 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); | 7209 EXPECT_FLOAT_EQ(1.f, root_layer->GetIdealContentsScale()); |
| 7459 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); | 7210 EXPECT_FLOAT_EQ(3.f, child1_layer->GetIdealContentsScale()); |
| 7460 EXPECT_FLOAT_EQ( | 7211 EXPECT_FLOAT_EQ( |
| 7461 3.f, | 7212 3.f, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7539 std::unique_ptr<LayerImpl> child2 = | 7290 std::unique_ptr<LayerImpl> child2 = |
| 7540 LayerImpl::Create(host_impl.active_tree(), 3); | 7291 LayerImpl::Create(host_impl.active_tree(), 3); |
| 7541 LayerImpl* child2_layer = child2.get(); | 7292 LayerImpl* child2_layer = child2.get(); |
| 7542 | 7293 |
| 7543 root->test_properties()->AddChild(std::move(child1)); | 7294 root->test_properties()->AddChild(std::move(child1)); |
| 7544 child1_layer->test_properties()->AddChild(std::move(child2)); | 7295 child1_layer->test_properties()->AddChild(std::move(child2)); |
| 7545 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 7296 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7546 | 7297 |
| 7547 host_impl.active_tree()->SetElementIdsForTesting(); | 7298 host_impl.active_tree()->SetElementIdsForTesting(); |
| 7548 | 7299 |
| 7549 gfx::Transform identity_matrix, scale_transform_child1, | 7300 gfx::Transform scale_transform_child1, scale_transform_child2; |
| 7550 scale_transform_child2; | |
| 7551 scale_transform_child1.Scale(2, 3); | 7301 scale_transform_child1.Scale(2, 3); |
| 7552 scale_transform_child2.Scale(4, 5); | 7302 scale_transform_child2.Scale(4, 5); |
| 7553 | 7303 |
| 7554 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7304 root_layer->SetBounds(gfx::Size(1, 1)); |
| 7555 gfx::PointF(), gfx::Size(1, 1), true, false, | 7305 child1_layer->SetTransform(scale_transform_child1); |
| 7556 true); | 7306 child1_layer->SetBounds(gfx::Size(1, 1)); |
| 7557 SetLayerPropertiesForTesting(child1_layer, scale_transform_child1, | 7307 child2_layer->SetTransform(scale_transform_child2); |
| 7558 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | 7308 child2_layer->SetBounds(gfx::Size(1, 1)); |
| 7559 true, false, false); | |
| 7560 | 7309 |
| 7561 TransformOperations scale; | 7310 TransformOperations scale; |
| 7562 scale.AppendScale(5.f, 8.f, 3.f); | 7311 scale.AppendScale(5.f, 8.f, 3.f); |
| 7563 | 7312 |
| 7564 scoped_refptr<AnimationTimeline> timeline = | 7313 scoped_refptr<AnimationTimeline> timeline = |
| 7565 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7314 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7566 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7315 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7567 | 7316 |
| 7568 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, | 7317 AddAnimatedTransformToElementWithPlayer(child2_layer->element_id(), timeline, |
| 7569 1.0, TransformOperations(), scale); | 7318 1.0, TransformOperations(), scale); |
| 7570 | 7319 |
| 7571 SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, | |
| 7572 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | |
| 7573 true, false, false); | |
| 7574 | |
| 7575 // Correctly computes animation scale when rebuilding property trees. | 7320 // Correctly computes animation scale when rebuilding property trees. |
| 7576 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7321 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7577 ExecuteCalculateDrawProperties(root_layer); | 7322 ExecuteCalculateDrawProperties(root_layer); |
| 7578 | 7323 |
| 7579 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); | 7324 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
| 7580 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); | 7325 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child1_layer)); |
| 7581 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); | 7326 EXPECT_FLOAT_EQ(24.f, GetMaximumAnimationScale(child2_layer)); |
| 7582 | 7327 |
| 7583 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); | 7328 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); |
| 7584 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); | 7329 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child1_layer)); |
| 7585 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); | 7330 EXPECT_FLOAT_EQ(3.f, GetStartingAnimationScale(child2_layer)); |
| 7586 | 7331 |
| 7587 // Correctly updates animation scale when layer property changes. | 7332 // Correctly updates animation scale when layer property changes. |
| 7588 child1_layer->SetTransform(identity_matrix); | 7333 child1_layer->SetTransform(gfx::Transform()); |
| 7589 child1_layer->UpdatePropertyTreeTransform(); | 7334 child1_layer->UpdatePropertyTreeTransform(); |
| 7590 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; | 7335 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = false; |
| 7591 ExecuteCalculateDrawProperties(root_layer); | 7336 ExecuteCalculateDrawProperties(root_layer); |
| 7592 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); | 7337 EXPECT_FLOAT_EQ(8.f, GetMaximumAnimationScale(child2_layer)); |
| 7593 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); | 7338 EXPECT_FLOAT_EQ(1.f, GetStartingAnimationScale(child2_layer)); |
| 7594 | 7339 |
| 7595 // Do not update animation scale if already updated. | 7340 // Do not update animation scale if already updated. |
| 7596 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( | 7341 host_impl.active_tree()->property_trees()->SetAnimationScalesForTesting( |
| 7597 child2_layer->transform_tree_index(), 100.f, 100.f); | 7342 child2_layer->transform_tree_index(), 100.f, 100.f); |
| 7598 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); | 7343 EXPECT_FLOAT_EQ(100.f, GetMaximumAnimationScale(child2_layer)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7616 LayerImpl* root_layer = root.get(); | 7361 LayerImpl* root_layer = root.get(); |
| 7617 std::unique_ptr<LayerImpl> child = | 7362 std::unique_ptr<LayerImpl> child = |
| 7618 LayerImpl::Create(host_impl.active_tree(), 2); | 7363 LayerImpl::Create(host_impl.active_tree(), 2); |
| 7619 LayerImpl* child_layer = child.get(); | 7364 LayerImpl* child_layer = child.get(); |
| 7620 | 7365 |
| 7621 root->test_properties()->AddChild(std::move(child)); | 7366 root->test_properties()->AddChild(std::move(child)); |
| 7622 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 7367 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 7623 | 7368 |
| 7624 host_impl.active_tree()->SetElementIdsForTesting(); | 7369 host_impl.active_tree()->SetElementIdsForTesting(); |
| 7625 | 7370 |
| 7626 gfx::Transform identity_matrix, scale_transform_child; | 7371 gfx::Transform scale_transform_child; |
| 7627 scale_transform_child.Scale(4, 5); | 7372 scale_transform_child.Scale(4, 5); |
| 7628 | 7373 |
| 7629 SetLayerPropertiesForTesting(root_layer, identity_matrix, gfx::Point3F(), | 7374 root_layer->SetBounds(gfx::Size(1, 1)); |
| 7630 gfx::PointF(), gfx::Size(1, 1), true, false, | 7375 child_layer->SetTransform(scale_transform_child); |
| 7631 true); | 7376 child_layer->SetBounds(gfx::Size(1, 1)); |
| 7377 |
| 7632 TransformOperations scale; | 7378 TransformOperations scale; |
| 7633 scale.AppendScale(5.f, 8.f, 3.f); | 7379 scale.AppendScale(5.f, 8.f, 3.f); |
| 7634 | 7380 |
| 7635 scoped_refptr<AnimationTimeline> timeline = | 7381 scoped_refptr<AnimationTimeline> timeline = |
| 7636 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 7382 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 7637 host_impl.animation_host()->AddAnimationTimeline(timeline); | 7383 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 7638 | 7384 |
| 7639 AddAnimatedTransformToElementWithPlayer(child_layer->element_id(), timeline, | 7385 AddAnimatedTransformToElementWithPlayer(child_layer->element_id(), timeline, |
| 7640 1.0, TransformOperations(), scale); | 7386 1.0, TransformOperations(), scale); |
| 7641 | 7387 |
| 7642 SetLayerPropertiesForTesting(child_layer, scale_transform_child, | |
| 7643 gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), | |
| 7644 true, false, false); | |
| 7645 | |
| 7646 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7388 root_layer->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 7647 ExecuteCalculateDrawProperties(root_layer); | 7389 ExecuteCalculateDrawProperties(root_layer); |
| 7648 | 7390 |
| 7649 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); | 7391 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(root_layer)); |
| 7650 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child_layer)); | 7392 EXPECT_FLOAT_EQ(0.f, GetMaximumAnimationScale(child_layer)); |
| 7651 | 7393 |
| 7652 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); | 7394 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(root_layer)); |
| 7653 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child_layer)); | 7395 EXPECT_FLOAT_EQ(0.f, GetStartingAnimationScale(child_layer)); |
| 7654 } | 7396 } |
| 7655 | 7397 |
| 7656 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) { | 7398 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInChildRenderSurface) { |
| 7657 LayerImpl* root = root_layer_for_testing(); | 7399 LayerImpl* root = root_layer_for_testing(); |
| 7658 LayerImpl* clip = AddChild<LayerImpl>(root); | 7400 LayerImpl* clip = AddChild<LayerImpl>(root); |
| 7659 LayerImpl* content = AddChild<LayerImpl>(clip); | 7401 LayerImpl* content = AddChild<LayerImpl>(clip); |
| 7660 | 7402 |
| 7661 const gfx::Transform identity_matrix; | 7403 root->SetBounds(gfx::Size(768 / 2, 3000)); |
| 7662 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 7663 gfx::PointF(), gfx::Size(768 / 2, 3000), true, | |
| 7664 false, true); | |
| 7665 SetLayerPropertiesForTesting(clip, identity_matrix, gfx::Point3F(), | |
| 7666 gfx::PointF(), gfx::Size(768 / 2, 10000), true, | |
| 7667 false, false); | |
| 7668 SetLayerPropertiesForTesting(content, identity_matrix, gfx::Point3F(), | |
| 7669 gfx::PointF(), gfx::Size(768 / 2, 10000), true, | |
| 7670 false, true); | |
| 7671 root->SetDrawsContent(true); | 7404 root->SetDrawsContent(true); |
| 7405 clip->SetBounds(gfx::Size(768 / 2, 10000)); |
| 7672 clip->SetMasksToBounds(true); | 7406 clip->SetMasksToBounds(true); |
| 7407 content->SetBounds(gfx::Size(768 / 2, 10000)); |
| 7673 content->SetDrawsContent(true); | 7408 content->SetDrawsContent(true); |
| 7409 content->test_properties()->force_render_surface = true; |
| 7674 | 7410 |
| 7675 gfx::Size device_viewport_size(768, 582); | 7411 gfx::Size device_viewport_size(768, 582); |
| 7676 LayerImplList render_surface_layer_list_impl; | 7412 LayerImplList render_surface_layer_list_impl; |
| 7677 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7413 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 7678 root, device_viewport_size, identity_matrix, | 7414 root, device_viewport_size, gfx::Transform(), |
| 7679 &render_surface_layer_list_impl); | 7415 &render_surface_layer_list_impl); |
| 7680 inputs.device_scale_factor = 2.f; | 7416 inputs.device_scale_factor = 2.f; |
| 7681 inputs.page_scale_factor = 1.f; | 7417 inputs.page_scale_factor = 1.f; |
| 7682 inputs.page_scale_layer = NULL; | 7418 inputs.page_scale_layer = NULL; |
| 7683 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 7419 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 7684 | 7420 |
| 7685 // Layers in the root render surface have their visible content rect clipped | 7421 // Layers in the root render surface have their visible content rect clipped |
| 7686 // by the viewport. | 7422 // by the viewport. |
| 7687 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect()); | 7423 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_layer_rect()); |
| 7688 | 7424 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7701 // Set two layers: the root layer clips it's child, | 7437 // Set two layers: the root layer clips it's child, |
| 7702 // the child draws its content. | 7438 // the child draws its content. |
| 7703 | 7439 |
| 7704 gfx::Size root_size = gfx::Size(300, 500); | 7440 gfx::Size root_size = gfx::Size(300, 500); |
| 7705 | 7441 |
| 7706 // Sublayer should be bigger than the root enlarged by bounds_delta. | 7442 // Sublayer should be bigger than the root enlarged by bounds_delta. |
| 7707 gfx::Size sublayer_size = gfx::Size(300, 1000); | 7443 gfx::Size sublayer_size = gfx::Size(300, 1000); |
| 7708 | 7444 |
| 7709 // Device viewport accomidated the root and the top controls. | 7445 // Device viewport accomidated the root and the top controls. |
| 7710 gfx::Size device_viewport_size = gfx::Size(300, 600); | 7446 gfx::Size device_viewport_size = gfx::Size(300, 600); |
| 7711 gfx::Transform identity_matrix; | |
| 7712 | 7447 |
| 7713 host_impl.SetViewportSize(device_viewport_size); | 7448 host_impl.SetViewportSize(device_viewport_size); |
| 7714 host_impl.active_tree()->SetRootLayerForTesting( | 7449 host_impl.active_tree()->SetRootLayerForTesting( |
| 7715 LayerImpl::Create(host_impl.active_tree(), 1)); | 7450 LayerImpl::Create(host_impl.active_tree(), 1)); |
| 7716 | 7451 |
| 7717 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing(); | 7452 LayerImpl* root = host_impl.active_tree()->root_layer_for_testing(); |
| 7718 SetLayerPropertiesForTesting(root, | 7453 root->SetBounds(root_size); |
| 7719 identity_matrix, | |
| 7720 gfx::Point3F(), | |
| 7721 gfx::PointF(), | |
| 7722 root_size, | |
| 7723 false, | |
| 7724 false, | |
| 7725 true); | |
| 7726 root->SetMasksToBounds(true); | 7454 root->SetMasksToBounds(true); |
| 7727 | 7455 |
| 7728 root->test_properties()->AddChild( | 7456 root->test_properties()->AddChild( |
| 7729 LayerImpl::Create(host_impl.active_tree(), 2)); | 7457 LayerImpl::Create(host_impl.active_tree(), 2)); |
| 7730 | 7458 |
| 7731 LayerImpl* sublayer = root->test_properties()->children[0]; | 7459 LayerImpl* sublayer = root->test_properties()->children[0]; |
| 7732 SetLayerPropertiesForTesting(sublayer, | 7460 sublayer->SetBounds(sublayer_size); |
| 7733 identity_matrix, | |
| 7734 gfx::Point3F(), | |
| 7735 gfx::PointF(), | |
| 7736 sublayer_size, | |
| 7737 false, | |
| 7738 false, | |
| 7739 false); | |
| 7740 sublayer->SetDrawsContent(true); | 7461 sublayer->SetDrawsContent(true); |
| 7741 | 7462 |
| 7742 host_impl.active_tree()->BuildPropertyTreesForTesting(); | 7463 host_impl.active_tree()->BuildPropertyTreesForTesting(); |
| 7743 | 7464 |
| 7744 LayerImplList layer_impl_list; | 7465 LayerImplList layer_impl_list; |
| 7745 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7466 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 7746 root, device_viewport_size, &layer_impl_list); | 7467 root, device_viewport_size, &layer_impl_list); |
| 7747 | 7468 |
| 7748 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 7469 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 7749 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); | 7470 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7808 EXPECT_TRUE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta()); | 7529 EXPECT_TRUE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta()); |
| 7809 | 7530 |
| 7810 fixed_to_outer->SetPositionConstraint(fixed_to_left); | 7531 fixed_to_outer->SetPositionConstraint(fixed_to_left); |
| 7811 | 7532 |
| 7812 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7533 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 7813 EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta()); | 7534 EXPECT_FALSE(transform_tree.HasNodesAffectedByInnerViewportBoundsDelta()); |
| 7814 EXPECT_FALSE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta()); | 7535 EXPECT_FALSE(transform_tree.HasNodesAffectedByOuterViewportBoundsDelta()); |
| 7815 } | 7536 } |
| 7816 | 7537 |
| 7817 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { | 7538 TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { |
| 7818 const gfx::Transform identity_matrix; | |
| 7819 scoped_refptr<Layer> root = Layer::Create(); | 7539 scoped_refptr<Layer> root = Layer::Create(); |
| 7820 scoped_refptr<LayerWithForcedDrawsContent> animated = | 7540 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 7821 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 7541 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 7822 | 7542 |
| 7823 root->AddChild(animated); | 7543 root->AddChild(animated); |
| 7824 | |
| 7825 host()->SetRootLayer(root); | 7544 host()->SetRootLayer(root); |
| 7826 | |
| 7827 host()->SetElementIdsForTesting(); | 7545 host()->SetElementIdsForTesting(); |
| 7828 | 7546 |
| 7829 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 7547 root->SetBounds(gfx::Size(100, 100)); |
| 7830 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 7831 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | |
| 7832 gfx::PointF(), gfx::Size(20, 20), true, false); | |
| 7833 | |
| 7834 root->SetMasksToBounds(true); | 7548 root->SetMasksToBounds(true); |
| 7835 root->SetForceRenderSurfaceForTesting(true); | 7549 root->SetForceRenderSurfaceForTesting(true); |
| 7836 animated->SetOpacity(0.f); | 7550 animated->SetOpacity(0.f); |
| 7551 animated->SetBounds(gfx::Size(20, 20)); |
| 7837 | 7552 |
| 7838 AddOpacityTransitionToElementWithPlayer(animated->element_id(), timeline(), | 7553 AddOpacityTransitionToElementWithPlayer(animated->element_id(), timeline(), |
| 7839 10.0, 0.f, 1.f, false); | 7554 10.0, 0.f, 1.f, false); |
| 7840 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7555 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 7841 | 7556 |
| 7842 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); | 7557 EXPECT_FALSE(animated->visible_layer_rect_for_testing().IsEmpty()); |
| 7843 } | 7558 } |
| 7844 | 7559 |
| 7845 TEST_F(LayerTreeHostCommonTest, | 7560 TEST_F(LayerTreeHostCommonTest, |
| 7846 VisibleContentRectForAnimatedLayerWithSingularTransform) { | 7561 VisibleContentRectForAnimatedLayerWithSingularTransform) { |
| 7847 const gfx::Transform identity_matrix; | |
| 7848 scoped_refptr<Layer> root = Layer::Create(); | 7562 scoped_refptr<Layer> root = Layer::Create(); |
| 7849 scoped_refptr<Layer> clip = Layer::Create(); | 7563 scoped_refptr<Layer> clip = Layer::Create(); |
| 7850 scoped_refptr<LayerWithForcedDrawsContent> animated = | 7564 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 7851 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 7565 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 7852 scoped_refptr<LayerWithForcedDrawsContent> surface = | 7566 scoped_refptr<LayerWithForcedDrawsContent> surface = |
| 7853 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 7567 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 7854 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = | 7568 scoped_refptr<LayerWithForcedDrawsContent> descendant_of_animation = |
| 7855 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 7569 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 7856 | 7570 |
| 7857 root->AddChild(clip); | 7571 root->AddChild(clip); |
| 7858 clip->AddChild(animated); | 7572 clip->AddChild(animated); |
| 7859 animated->AddChild(surface); | 7573 animated->AddChild(surface); |
| 7860 surface->AddChild(descendant_of_animation); | 7574 surface->AddChild(descendant_of_animation); |
| 7861 | 7575 |
| 7862 clip->SetMasksToBounds(true); | |
| 7863 surface->SetForceRenderSurfaceForTesting(true); | |
| 7864 | |
| 7865 host()->SetRootLayer(root); | 7576 host()->SetRootLayer(root); |
| 7866 | |
| 7867 host()->SetElementIdsForTesting(); | 7577 host()->SetElementIdsForTesting(); |
| 7868 | 7578 |
| 7869 gfx::Transform uninvertible_matrix; | 7579 gfx::Transform uninvertible_matrix; |
| 7870 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); | 7580 uninvertible_matrix.Scale3d(6.f, 6.f, 0.f); |
| 7871 | 7581 |
| 7872 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 7582 root->SetBounds(gfx::Size(100, 100)); |
| 7873 gfx::PointF(), gfx::Size(100, 100), true, false); | 7583 clip->SetBounds(gfx::Size(10, 10)); |
| 7874 SetLayerPropertiesForTesting(clip.get(), identity_matrix, gfx::Point3F(), | 7584 clip->SetMasksToBounds(true); |
| 7875 gfx::PointF(), gfx::Size(10, 10), true, false); | 7585 animated->SetTransform(uninvertible_matrix); |
| 7876 SetLayerPropertiesForTesting(animated.get(), uninvertible_matrix, | 7586 animated->SetBounds(gfx::Size(120, 120)); |
| 7877 gfx::Point3F(), gfx::PointF(), | 7587 surface->SetBounds(gfx::Size(100, 100)); |
| 7878 gfx::Size(120, 120), true, false); | 7588 surface->SetForceRenderSurfaceForTesting(true); |
| 7879 SetLayerPropertiesForTesting(surface.get(), identity_matrix, gfx::Point3F(), | 7589 descendant_of_animation->SetBounds(gfx::Size(200, 200)); |
| 7880 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 7881 SetLayerPropertiesForTesting(descendant_of_animation.get(), identity_matrix, | |
| 7882 gfx::Point3F(), gfx::PointF(), | |
| 7883 gfx::Size(200, 200), true, false); | |
| 7884 | 7590 |
| 7885 TransformOperations start_transform_operations; | 7591 TransformOperations start_transform_operations; |
| 7886 start_transform_operations.AppendMatrix(uninvertible_matrix); | 7592 start_transform_operations.AppendMatrix(uninvertible_matrix); |
| 7887 TransformOperations end_transform_operations; | 7593 TransformOperations end_transform_operations; |
| 7888 | 7594 |
| 7889 SetElementIdsForTesting(); | 7595 SetElementIdsForTesting(); |
| 7890 AddAnimatedTransformToElementWithPlayer(animated->element_id(), timeline(), | 7596 AddAnimatedTransformToElementWithPlayer(animated->element_id(), timeline(), |
| 7891 10.0, start_transform_operations, | 7597 10.0, start_transform_operations, |
| 7892 end_transform_operations); | 7598 end_transform_operations); |
| 7893 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7599 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 7894 | 7600 |
| 7895 // The animated layer has a singular transform and maps to a non-empty rect in | 7601 // The animated layer has a singular transform and maps to a non-empty rect in |
| 7896 // clipped target space, so is treated as fully visible. | 7602 // clipped target space, so is treated as fully visible. |
| 7897 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); | 7603 EXPECT_EQ(gfx::Rect(120, 120), animated->visible_layer_rect_for_testing()); |
| 7898 | 7604 |
| 7899 // The singular transform on |animated| is flattened when inherited by | 7605 // The singular transform on |animated| is flattened when inherited by |
| 7900 // |surface|, and this happens to make it invertible. | 7606 // |surface|, and this happens to make it invertible. |
| 7901 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); | 7607 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect_for_testing()); |
| 7902 EXPECT_EQ(gfx::Rect(2, 2), | 7608 EXPECT_EQ(gfx::Rect(2, 2), |
| 7903 descendant_of_animation->visible_layer_rect_for_testing()); | 7609 descendant_of_animation->visible_layer_rect_for_testing()); |
| 7904 | 7610 |
| 7905 gfx::Transform zero_matrix; | 7611 gfx::Transform zero_matrix; |
| 7906 zero_matrix.Scale3d(0.f, 0.f, 0.f); | 7612 zero_matrix.Scale3d(0.f, 0.f, 0.f); |
| 7907 SetLayerPropertiesForTesting(animated.get(), zero_matrix, gfx::Point3F(), | 7613 animated->SetTransform(zero_matrix); |
| 7908 gfx::PointF(), gfx::Size(120, 120), true, false); | |
| 7909 | |
| 7910 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7614 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 7911 | 7615 |
| 7912 // The animated layer maps to the empty rect in clipped target space, so is | 7616 // The animated layer maps to the empty rect in clipped target space, so is |
| 7913 // treated as having an empty visible rect. | 7617 // treated as having an empty visible rect. |
| 7914 EXPECT_EQ(gfx::Rect(), animated->visible_layer_rect_for_testing()); | 7618 EXPECT_EQ(gfx::Rect(), animated->visible_layer_rect_for_testing()); |
| 7915 | 7619 |
| 7916 // This time, flattening does not make |animated|'s transform invertible. This | 7620 // This time, flattening does not make |animated|'s transform invertible. This |
| 7917 // means the clip cannot be projected into |surface|'s space, so we treat | 7621 // means the clip cannot be projected into |surface|'s space, so we treat |
| 7918 // |surface| and layers that draw into it as having empty visible rect. | 7622 // |surface| and layers that draw into it as having empty visible rect. |
| 7919 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing()); | 7623 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect_for_testing()); |
| 7920 EXPECT_EQ(gfx::Rect(), | 7624 EXPECT_EQ(gfx::Rect(), |
| 7921 descendant_of_animation->visible_layer_rect_for_testing()); | 7625 descendant_of_animation->visible_layer_rect_for_testing()); |
| 7922 } | 7626 } |
| 7923 | 7627 |
| 7924 // Verify that having animated opacity but current opacity 1 still creates | 7628 // Verify that having animated opacity but current opacity 1 still creates |
| 7925 // a render surface. | 7629 // a render surface. |
| 7926 TEST_F(LayerTreeHostCommonTest, AnimatedOpacityCreatesRenderSurface) { | 7630 TEST_F(LayerTreeHostCommonTest, AnimatedOpacityCreatesRenderSurface) { |
| 7927 LayerImpl* root = root_layer_for_testing(); | 7631 LayerImpl* root = root_layer_for_testing(); |
| 7928 LayerImpl* child = AddChild<LayerImpl>(root); | 7632 LayerImpl* child = AddChild<LayerImpl>(root); |
| 7929 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 7633 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 7634 |
| 7635 root->SetBounds(gfx::Size(50, 50)); |
| 7636 child->SetBounds(gfx::Size(50, 50)); |
| 7930 child->SetDrawsContent(true); | 7637 child->SetDrawsContent(true); |
| 7638 grandchild->SetBounds(gfx::Size(50, 50)); |
| 7931 grandchild->SetDrawsContent(true); | 7639 grandchild->SetDrawsContent(true); |
| 7932 | 7640 |
| 7933 gfx::Transform identity_transform; | |
| 7934 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 7935 gfx::PointF(), gfx::Size(50, 50), true, false); | |
| 7936 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | |
| 7937 gfx::PointF(), gfx::Size(50, 50), true, false); | |
| 7938 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | |
| 7939 gfx::PointF(), gfx::Size(50, 50), true, false); | |
| 7940 | |
| 7941 SetElementIdsForTesting(); | 7641 SetElementIdsForTesting(); |
| 7942 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(), | 7642 AddOpacityTransitionToElementWithPlayer(child->element_id(), timeline_impl(), |
| 7943 10.0, 1.f, 0.2f, false); | 7643 10.0, 1.f, 0.2f, false); |
| 7944 ExecuteCalculateDrawProperties(root); | 7644 ExecuteCalculateDrawProperties(root); |
| 7945 | 7645 |
| 7946 EXPECT_EQ(1.f, child->Opacity()); | 7646 EXPECT_EQ(1.f, child->Opacity()); |
| 7947 EXPECT_TRUE(root->has_render_surface()); | 7647 EXPECT_TRUE(root->has_render_surface()); |
| 7948 EXPECT_TRUE(child->has_render_surface()); | 7648 EXPECT_TRUE(child->has_render_surface()); |
| 7949 EXPECT_FALSE(grandchild->has_render_surface()); | 7649 EXPECT_FALSE(grandchild->has_render_surface()); |
| 7950 } | 7650 } |
| 7951 | 7651 |
| 7952 // Verify that having an animated filter (but no current filter, as these | 7652 // Verify that having an animated filter (but no current filter, as these |
| 7953 // are mutually exclusive) correctly creates a render surface. | 7653 // are mutually exclusive) correctly creates a render surface. |
| 7954 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { | 7654 TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { |
| 7955 LayerImpl* root = root_layer_for_testing(); | 7655 LayerImpl* root = root_layer_for_testing(); |
| 7956 LayerImpl* child = AddChild<LayerImpl>(root); | 7656 LayerImpl* child = AddChild<LayerImpl>(root); |
| 7957 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 7657 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 7958 | 7658 |
| 7959 gfx::Transform identity_transform; | 7659 root->SetBounds(gfx::Size(50, 50)); |
| 7960 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 7660 child->SetBounds(gfx::Size(50, 50)); |
| 7961 gfx::PointF(), gfx::Size(50, 50), true, false); | 7661 grandchild->SetBounds(gfx::Size(50, 50)); |
| 7962 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | |
| 7963 gfx::PointF(), gfx::Size(50, 50), true, false); | |
| 7964 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | |
| 7965 gfx::PointF(), gfx::Size(50, 50), true, false); | |
| 7966 | 7662 |
| 7967 SetElementIdsForTesting(); | 7663 SetElementIdsForTesting(); |
| 7968 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), | 7664 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), |
| 7969 10.0, 0.1f, 0.2f); | 7665 10.0, 0.1f, 0.2f); |
| 7970 ExecuteCalculateDrawProperties(root); | 7666 ExecuteCalculateDrawProperties(root); |
| 7971 | 7667 |
| 7972 EXPECT_TRUE(root->has_render_surface()); | 7668 EXPECT_TRUE(root->has_render_surface()); |
| 7973 EXPECT_TRUE(child->has_render_surface()); | 7669 EXPECT_TRUE(child->has_render_surface()); |
| 7974 EXPECT_FALSE(grandchild->has_render_surface()); | 7670 EXPECT_FALSE(grandchild->has_render_surface()); |
| 7975 | 7671 |
| 7976 EXPECT_TRUE(root->render_surface()->Filters().IsEmpty()); | 7672 EXPECT_TRUE(root->render_surface()->Filters().IsEmpty()); |
| 7977 EXPECT_TRUE(child->render_surface()->Filters().IsEmpty()); | 7673 EXPECT_TRUE(child->render_surface()->Filters().IsEmpty()); |
| 7978 | 7674 |
| 7979 EXPECT_FALSE(root->FilterIsAnimating()); | 7675 EXPECT_FALSE(root->FilterIsAnimating()); |
| 7980 EXPECT_TRUE(child->FilterIsAnimating()); | 7676 EXPECT_TRUE(child->FilterIsAnimating()); |
| 7981 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 7677 EXPECT_FALSE(grandchild->FilterIsAnimating()); |
| 7982 } | 7678 } |
| 7983 | 7679 |
| 7984 // Verify that having a filter animation with a delayed start time creates a | 7680 // Verify that having a filter animation with a delayed start time creates a |
| 7985 // render surface. | 7681 // render surface. |
| 7986 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { | 7682 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { |
| 7987 LayerImpl* root = root_layer_for_testing(); | 7683 LayerImpl* root = root_layer_for_testing(); |
| 7988 LayerImpl* child = AddChild<LayerImpl>(root); | 7684 LayerImpl* child = AddChild<LayerImpl>(root); |
| 7989 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 7685 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 7990 | 7686 |
| 7991 gfx::Transform identity_transform; | 7687 root->SetBounds(gfx::Size(50, 50)); |
| 7992 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 7688 child->SetBounds(gfx::Size(50, 50)); |
| 7993 gfx::PointF(), gfx::Size(50, 50), true, false); | 7689 grandchild->SetBounds(gfx::Size(50, 50)); |
| 7994 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | |
| 7995 gfx::PointF(), gfx::Size(50, 50), true, false); | |
| 7996 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | |
| 7997 gfx::PointF(), gfx::Size(50, 50), true, false); | |
| 7998 | 7690 |
| 7999 SetElementIdsForTesting(); | 7691 SetElementIdsForTesting(); |
| 8000 | 7692 |
| 8001 std::unique_ptr<KeyframedFilterAnimationCurve> curve( | 7693 std::unique_ptr<KeyframedFilterAnimationCurve> curve( |
| 8002 KeyframedFilterAnimationCurve::Create()); | 7694 KeyframedFilterAnimationCurve::Create()); |
| 8003 FilterOperations start_filters; | 7695 FilterOperations start_filters; |
| 8004 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); | 7696 start_filters.Append(FilterOperation::CreateBrightnessFilter(0.1f)); |
| 8005 FilterOperations end_filters; | 7697 FilterOperations end_filters; |
| 8006 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); | 7698 end_filters.Append(FilterOperation::CreateBrightnessFilter(0.3f)); |
| 8007 curve->AddKeyframe( | 7699 curve->AddKeyframe( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 8032 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); | 7724 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); |
| 8033 } | 7725 } |
| 8034 | 7726 |
| 8035 // Ensures that the property tree code accounts for offsets between fixed | 7727 // Ensures that the property tree code accounts for offsets between fixed |
| 8036 // position layers and their respective containers. | 7728 // position layers and their respective containers. |
| 8037 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) { | 7729 TEST_F(LayerTreeHostCommonTest, PropertyTreesAccountForFixedParentOffset) { |
| 8038 LayerImpl* root = root_layer_for_testing(); | 7730 LayerImpl* root = root_layer_for_testing(); |
| 8039 LayerImpl* child = AddChild<LayerImpl>(root); | 7731 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8040 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 7732 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8041 | 7733 |
| 8042 gfx::Transform identity_transform; | 7734 root->SetBounds(gfx::Size(50, 50)); |
| 8043 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | |
| 8044 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 8045 true); | |
| 8046 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | |
| 8047 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, | |
| 8048 false, false); | |
| 8049 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | |
| 8050 gfx::PointF(-1000, -1000), gfx::Size(50, 50), | |
| 8051 true, false, false); | |
| 8052 | |
| 8053 root->SetMasksToBounds(true); | 7735 root->SetMasksToBounds(true); |
| 8054 root->test_properties()->is_container_for_fixed_position_layers = true; | 7736 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 7737 child->SetPosition(gfx::PointF(1000, 1000)); |
| 7738 child->SetBounds(gfx::Size(50, 50)); |
| 7739 grandchild->SetPosition(gfx::PointF(-1000, -1000)); |
| 7740 grandchild->SetBounds(gfx::Size(50, 50)); |
| 7741 grandchild->SetDrawsContent(true); |
| 7742 |
| 8055 LayerPositionConstraint constraint; | 7743 LayerPositionConstraint constraint; |
| 8056 constraint.set_is_fixed_position(true); | 7744 constraint.set_is_fixed_position(true); |
| 8057 grandchild->test_properties()->position_constraint = constraint; | 7745 grandchild->test_properties()->position_constraint = constraint; |
| 8058 grandchild->SetDrawsContent(true); | |
| 8059 | |
| 8060 root->test_properties()->is_container_for_fixed_position_layers = true; | |
| 8061 | 7746 |
| 8062 ExecuteCalculateDrawProperties(root); | 7747 ExecuteCalculateDrawProperties(root); |
| 8063 | 7748 |
| 8064 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); | 7749 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); |
| 8065 } | 7750 } |
| 8066 | 7751 |
| 8067 // Ensures that the property tree code accounts for offsets between fixed | 7752 // Ensures that the property tree code accounts for offsets between fixed |
| 8068 // position containers and their transform tree parents, when a fixed position | 7753 // position containers and their transform tree parents, when a fixed position |
| 8069 // layer's container is its layer tree parent, but this parent doesn't have its | 7754 // layer's container is its layer tree parent, but this parent doesn't have its |
| 8070 // own transform tree node. | 7755 // own transform tree node. |
| 8071 TEST_F(LayerTreeHostCommonTest, | 7756 TEST_F(LayerTreeHostCommonTest, |
| 8072 PropertyTreesAccountForFixedParentOffsetWhenContainerIsParent) { | 7757 PropertyTreesAccountForFixedParentOffsetWhenContainerIsParent) { |
| 8073 LayerImpl* root = root_layer_for_testing(); | 7758 LayerImpl* root = root_layer_for_testing(); |
| 8074 LayerImpl* child = AddChild<LayerImpl>(root); | 7759 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8075 LayerImpl* grandchild = AddChild<LayerImpl>(child); | 7760 LayerImpl* grandchild = AddChild<LayerImpl>(child); |
| 8076 | 7761 |
| 8077 gfx::Transform identity_transform; | 7762 root->SetBounds(gfx::Size(50, 50)); |
| 8078 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 7763 root->SetMasksToBounds(true); |
| 8079 gfx::PointF(), gfx::Size(50, 50), true, false, | 7764 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8080 true); | 7765 child->SetPosition(gfx::PointF(1000, 1000)); |
| 8081 SetLayerPropertiesForTesting(child, identity_transform, gfx::Point3F(), | 7766 child->SetBounds(gfx::Size(50, 50)); |
| 8082 gfx::PointF(1000, 1000), gfx::Size(50, 50), true, | 7767 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 8083 false, false); | 7768 grandchild->SetPosition(gfx::PointF(-1000, -1000)); |
| 8084 SetLayerPropertiesForTesting(grandchild, identity_transform, gfx::Point3F(), | 7769 grandchild->SetBounds(gfx::Size(50, 50)); |
| 8085 gfx::PointF(-1000, -1000), gfx::Size(50, 50), | 7770 grandchild->SetDrawsContent(true); |
| 8086 true, false, false); | |
| 8087 | 7771 |
| 8088 root->SetMasksToBounds(true); | |
| 8089 child->test_properties()->is_container_for_fixed_position_layers = true; | |
| 8090 LayerPositionConstraint constraint; | 7772 LayerPositionConstraint constraint; |
| 8091 constraint.set_is_fixed_position(true); | 7773 constraint.set_is_fixed_position(true); |
| 8092 grandchild->test_properties()->position_constraint = constraint; | 7774 grandchild->test_properties()->position_constraint = constraint; |
| 8093 grandchild->SetDrawsContent(true); | |
| 8094 | |
| 8095 root->test_properties()->is_container_for_fixed_position_layers = true; | |
| 8096 | 7775 |
| 8097 ExecuteCalculateDrawProperties(root); | 7776 ExecuteCalculateDrawProperties(root); |
| 8098 | 7777 |
| 8099 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); | 7778 EXPECT_EQ(gfx::Rect(0, 0, 50, 50), grandchild->visible_layer_rect()); |
| 8100 } | 7779 } |
| 8101 | 7780 |
| 8102 TEST_F(LayerTreeHostCommonTest, CombineClipsUsingContentTarget) { | |
| 8103 // In the following layer tree, the layer |box|'s render target is |surface|. | |
| 8104 // |surface| also creates a transform node. We want to combine clips for |box| | |
| 8105 // in the space of its target (i.e., |surface|), not its target's target. This | |
| 8106 // test ensures that happens. | |
| 8107 | |
| 8108 gfx::Transform rotate; | |
| 8109 rotate.Rotate(5); | |
| 8110 gfx::Transform identity; | |
| 8111 | |
| 8112 scoped_refptr<Layer> root = Layer::Create(); | |
| 8113 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | |
| 8114 gfx::PointF(), gfx::Size(2500, 1500), true, | |
| 8115 false); | |
| 8116 | |
| 8117 scoped_refptr<Layer> frame_clip = Layer::Create(); | |
| 8118 SetLayerPropertiesForTesting(frame_clip.get(), identity, gfx::Point3F(), | |
| 8119 gfx::PointF(), gfx::Size(2500, 1500), true, | |
| 8120 false); | |
| 8121 frame_clip->SetMasksToBounds(true); | |
| 8122 | |
| 8123 scoped_refptr<Layer> rotated = Layer::Create(); | |
| 8124 SetLayerPropertiesForTesting(rotated.get(), rotate, | |
| 8125 gfx::Point3F(1250, 250, 0), gfx::PointF(), | |
| 8126 gfx::Size(2500, 500), true, false); | |
| 8127 | |
| 8128 scoped_refptr<Layer> surface = Layer::Create(); | |
| 8129 SetLayerPropertiesForTesting(surface.get(), rotate, gfx::Point3F(), | |
| 8130 gfx::PointF(), gfx::Size(2500, 500), true, | |
| 8131 false); | |
| 8132 surface->SetOpacity(0.5); | |
| 8133 | |
| 8134 scoped_refptr<LayerWithForcedDrawsContent> container = | |
| 8135 make_scoped_refptr(new LayerWithForcedDrawsContent()); | |
| 8136 SetLayerPropertiesForTesting(container.get(), identity, gfx::Point3F(), | |
| 8137 gfx::PointF(), gfx::Size(300, 300), true, false); | |
| 8138 | |
| 8139 scoped_refptr<LayerWithForcedDrawsContent> box = | |
| 8140 make_scoped_refptr(new LayerWithForcedDrawsContent()); | |
| 8141 SetLayerPropertiesForTesting(box.get(), identity, gfx::Point3F(), | |
| 8142 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 8143 | |
| 8144 root->AddChild(frame_clip); | |
| 8145 frame_clip->AddChild(rotated); | |
| 8146 rotated->AddChild(surface); | |
| 8147 surface->AddChild(container); | |
| 8148 surface->AddChild(box); | |
| 8149 | |
| 8150 host()->SetRootLayer(root); | |
| 8151 | |
| 8152 ExecuteCalculateDrawProperties(root.get()); | |
| 8153 } | |
| 8154 | |
| 8155 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) { | 7781 TEST_F(LayerTreeHostCommonTest, OnlyApplyFixedPositioningOnce) { |
| 8156 LayerImpl* root = root_layer_for_testing(); | 7782 LayerImpl* root = root_layer_for_testing(); |
| 8157 LayerImpl* frame_clip = AddChild<LayerImpl>(root); | 7783 LayerImpl* frame_clip = AddChild<LayerImpl>(root); |
| 8158 LayerImpl* fixed = AddChild<LayerImpl>(frame_clip); | 7784 LayerImpl* fixed = AddChild<LayerImpl>(frame_clip); |
| 8159 gfx::Transform identity; | |
| 8160 gfx::Transform translate_z; | 7785 gfx::Transform translate_z; |
| 8161 translate_z.Translate3d(0, 0, 10); | 7786 translate_z.Translate3d(0, 0, 10); |
| 8162 | 7787 |
| 8163 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 7788 root->SetBounds(gfx::Size(800, 800)); |
| 8164 gfx::Size(800, 800), true, false, true); | |
| 8165 root->test_properties()->is_container_for_fixed_position_layers = true; | 7789 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8166 | 7790 |
| 8167 SetLayerPropertiesForTesting(frame_clip, translate_z, gfx::Point3F(), | 7791 frame_clip->SetPosition(gfx::PointF(500, 100)); |
| 8168 gfx::PointF(500, 100), gfx::Size(100, 100), true, | 7792 frame_clip->SetBounds(gfx::Size(100, 100)); |
| 8169 false, false); | |
| 8170 frame_clip->SetMasksToBounds(true); | 7793 frame_clip->SetMasksToBounds(true); |
| 8171 | 7794 |
| 8172 SetLayerPropertiesForTesting(fixed, identity, gfx::Point3F(), gfx::PointF(), | 7795 fixed->SetBounds(gfx::Size(1000, 1000)); |
| 8173 gfx::Size(1000, 1000), true, false, false); | 7796 fixed->SetDrawsContent(true); |
| 8174 | 7797 |
| 8175 LayerPositionConstraint constraint; | 7798 LayerPositionConstraint constraint; |
| 8176 constraint.set_is_fixed_position(true); | 7799 constraint.set_is_fixed_position(true); |
| 8177 fixed->test_properties()->position_constraint = constraint; | 7800 fixed->test_properties()->position_constraint = constraint; |
| 8178 fixed->SetDrawsContent(true); | |
| 8179 | 7801 |
| 8180 ExecuteCalculateDrawProperties(root); | 7802 ExecuteCalculateDrawProperties(root); |
| 8181 | 7803 |
| 8182 gfx::Rect expected(0, 0, 100, 100); | 7804 gfx::Rect expected(0, 0, 100, 100); |
| 8183 EXPECT_EQ(expected, fixed->visible_layer_rect()); | 7805 EXPECT_EQ(expected, fixed->visible_layer_rect()); |
| 8184 } | 7806 } |
| 8185 | 7807 |
| 8186 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) { | 7808 TEST_F(LayerTreeHostCommonTest, FixedClipsShouldBeAssociatedWithTheRightNode) { |
| 8187 LayerImpl* root = root_layer_for_testing(); | 7809 LayerImpl* root = root_layer_for_testing(); |
| 8188 LayerImpl* frame_clip = AddChild<LayerImpl>(root); | 7810 LayerImpl* frame_clip = AddChild<LayerImpl>(root); |
| 8189 LayerImpl* scroller = AddChild<LayerImpl>(frame_clip); | 7811 LayerImpl* scroller = AddChild<LayerImpl>(frame_clip); |
| 8190 LayerImpl* fixed = AddChild<LayerImpl>(scroller); | 7812 LayerImpl* fixed = AddChild<LayerImpl>(scroller); |
| 8191 | 7813 |
| 8192 gfx::Transform identity; | 7814 root->SetBounds(gfx::Size(800, 800)); |
| 8193 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 7815 root->SetDrawsContent(true); |
| 8194 gfx::Size(800, 800), true, false, true); | |
| 8195 SetLayerPropertiesForTesting(frame_clip, identity, gfx::Point3F(), | |
| 8196 gfx::PointF(500, 100), gfx::Size(100, 100), true, | |
| 8197 false, false); | |
| 8198 SetLayerPropertiesForTesting(scroller, identity, gfx::Point3F(), | |
| 8199 gfx::PointF(), gfx::Size(1000, 1000), true, | |
| 8200 false, false); | |
| 8201 SetLayerPropertiesForTesting(fixed, identity, gfx::Point3F(), | |
| 8202 gfx::PointF(100, 100), gfx::Size(50, 50), true, | |
| 8203 false, true); | |
| 8204 | |
| 8205 root->test_properties()->is_container_for_fixed_position_layers = true; | 7816 root->test_properties()->is_container_for_fixed_position_layers = true; |
| 8206 root->SetDrawsContent(true); | 7817 frame_clip->SetPosition(gfx::PointF(500, 100)); |
| 8207 | 7818 frame_clip->SetBounds(gfx::Size(100, 100)); |
| 8208 frame_clip->SetMasksToBounds(true); | 7819 frame_clip->SetMasksToBounds(true); |
| 8209 frame_clip->SetDrawsContent(true); | 7820 frame_clip->SetDrawsContent(true); |
| 8210 | 7821 scroller->SetBounds(gfx::Size(1000, 1000)); |
| 8211 scroller->SetCurrentScrollOffset(gfx::ScrollOffset(100, 100)); | 7822 scroller->SetCurrentScrollOffset(gfx::ScrollOffset(100, 100)); |
| 8212 scroller->SetScrollClipLayer(frame_clip->id()); | 7823 scroller->SetScrollClipLayer(frame_clip->id()); |
| 8213 scroller->SetDrawsContent(true); | 7824 scroller->SetDrawsContent(true); |
| 7825 fixed->SetPosition(gfx::PointF(100, 100)); |
| 7826 fixed->SetBounds(gfx::Size(50, 50)); |
| 7827 fixed->SetMasksToBounds(true); |
| 7828 fixed->SetDrawsContent(true); |
| 7829 fixed->test_properties()->force_render_surface = true; |
| 8214 | 7830 |
| 8215 LayerPositionConstraint constraint; | 7831 LayerPositionConstraint constraint; |
| 8216 constraint.set_is_fixed_position(true); | 7832 constraint.set_is_fixed_position(true); |
| 8217 fixed->test_properties()->position_constraint = constraint; | 7833 fixed->test_properties()->position_constraint = constraint; |
| 8218 fixed->SetMasksToBounds(true); | |
| 8219 fixed->SetDrawsContent(true); | |
| 8220 | 7834 |
| 8221 ExecuteCalculateDrawProperties(root); | 7835 ExecuteCalculateDrawProperties(root); |
| 8222 | 7836 |
| 8223 gfx::Rect expected(0, 0, 50, 50); | 7837 gfx::Rect expected(0, 0, 50, 50); |
| 8224 EXPECT_EQ(expected, fixed->visible_layer_rect()); | 7838 EXPECT_EQ(expected, fixed->visible_layer_rect()); |
| 8225 } | 7839 } |
| 8226 | 7840 |
| 8227 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { | 7841 TEST_F(LayerTreeHostCommonTest, ChangingAxisAlignmentTriggersRebuild) { |
| 8228 gfx::Transform identity; | |
| 8229 gfx::Transform translate; | 7842 gfx::Transform translate; |
| 8230 gfx::Transform rotate; | 7843 gfx::Transform rotate; |
| 8231 | 7844 |
| 8232 translate.Translate(10, 10); | 7845 translate.Translate(10, 10); |
| 8233 rotate.Rotate(45); | 7846 rotate.Rotate(45); |
| 8234 | 7847 |
| 8235 scoped_refptr<Layer> root = Layer::Create(); | 7848 scoped_refptr<Layer> root = Layer::Create(); |
| 8236 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 7849 root->SetBounds(gfx::Size(800, 800)); |
| 8237 gfx::PointF(), gfx::Size(800, 800), true, false); | |
| 8238 root->SetIsContainerForFixedPositionLayers(true); | 7850 root->SetIsContainerForFixedPositionLayers(true); |
| 8239 | 7851 |
| 8240 host()->SetRootLayer(root); | 7852 host()->SetRootLayer(root); |
| 8241 | 7853 |
| 8242 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7854 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8243 EXPECT_FALSE(host()->property_trees()->needs_rebuild); | 7855 EXPECT_FALSE(host()->property_trees()->needs_rebuild); |
| 8244 | 7856 |
| 8245 root->SetTransform(translate); | 7857 root->SetTransform(translate); |
| 8246 EXPECT_FALSE(host()->property_trees()->needs_rebuild); | 7858 EXPECT_FALSE(host()->property_trees()->needs_rebuild); |
| 8247 | 7859 |
| 8248 root->SetTransform(rotate); | 7860 root->SetTransform(rotate); |
| 8249 EXPECT_TRUE(host()->property_trees()->needs_rebuild); | 7861 EXPECT_TRUE(host()->property_trees()->needs_rebuild); |
| 8250 } | 7862 } |
| 8251 | 7863 |
| 8252 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) { | 7864 TEST_F(LayerTreeHostCommonTest, ChangeTransformOrigin) { |
| 8253 LayerImpl* root = root_layer_for_testing(); | 7865 LayerImpl* root = root_layer_for_testing(); |
| 8254 LayerImpl* child = AddChild<LayerImpl>(root); | 7866 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8255 | 7867 |
| 8256 gfx::Transform identity_matrix; | |
| 8257 gfx::Transform scale_matrix; | 7868 gfx::Transform scale_matrix; |
| 8258 scale_matrix.Scale(2.f, 2.f); | 7869 scale_matrix.Scale(2.f, 2.f); |
| 8259 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 8260 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 8261 true); | |
| 8262 SetLayerPropertiesForTesting(child, scale_matrix, gfx::Point3F(), | |
| 8263 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8264 false); | |
| 8265 | 7870 |
| 7871 root->SetBounds(gfx::Size(100, 100)); |
| 8266 root->SetDrawsContent(true); | 7872 root->SetDrawsContent(true); |
| 7873 child->SetTransform(scale_matrix); |
| 7874 child->SetBounds(gfx::Size(10, 10)); |
| 8267 child->SetDrawsContent(true); | 7875 child->SetDrawsContent(true); |
| 8268 | 7876 |
| 8269 ExecuteCalculateDrawProperties(root); | 7877 ExecuteCalculateDrawProperties(root); |
| 8270 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 7878 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 8271 | 7879 |
| 8272 child->test_properties()->transform_origin = gfx::Point3F(10.f, 10.f, 10.f); | 7880 child->test_properties()->transform_origin = gfx::Point3F(10.f, 10.f, 10.f); |
| 8273 | 7881 |
| 8274 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7882 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8275 ExecuteCalculateDrawProperties(root); | 7883 ExecuteCalculateDrawProperties(root); |
| 8276 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_layer_rect()); | 7884 EXPECT_EQ(gfx::Rect(5, 5, 5, 5), child->visible_layer_rect()); |
| 8277 } | 7885 } |
| 8278 | 7886 |
| 8279 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) { | 7887 TEST_F(LayerTreeHostCommonTest, UpdateScrollChildPosition) { |
| 8280 LayerImpl* root = root_layer_for_testing(); | 7888 LayerImpl* root = root_layer_for_testing(); |
| 8281 LayerImpl* scroll_parent = AddChild<LayerImpl>(root); | 7889 LayerImpl* scroll_parent = AddChild<LayerImpl>(root); |
| 8282 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_parent); | 7890 LayerImpl* scroll_child = AddChild<LayerImpl>(scroll_parent); |
| 8283 | 7891 |
| 7892 gfx::Transform scale; |
| 7893 scale.Scale(2.f, 2.f); |
| 7894 |
| 7895 root->SetBounds(gfx::Size(50, 50)); |
| 7896 scroll_child->SetTransform(scale); |
| 7897 scroll_child->SetBounds(gfx::Size(40, 40)); |
| 8284 scroll_child->SetDrawsContent(true); | 7898 scroll_child->SetDrawsContent(true); |
| 8285 scroll_child->test_properties()->scroll_parent = scroll_parent; | 7899 scroll_parent->SetBounds(gfx::Size(30, 30)); |
| 8286 std::unique_ptr<std::set<LayerImpl*>> scroll_children( | |
| 8287 new std::set<LayerImpl*>); | |
| 8288 scroll_children->insert(scroll_child); | |
| 8289 scroll_parent->test_properties()->scroll_children.reset( | |
| 8290 scroll_children.release()); | |
| 8291 scroll_parent->SetDrawsContent(true); | 7900 scroll_parent->SetDrawsContent(true); |
| 8292 | 7901 |
| 8293 gfx::Transform identity_transform; | 7902 scroll_child->test_properties()->scroll_parent = scroll_parent; |
| 8294 gfx::Transform scale; | 7903 scroll_parent->test_properties()->scroll_children = |
| 8295 scale.Scale(2.f, 2.f); | 7904 base::MakeUnique<std::set<LayerImpl*>>(); |
| 8296 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), | 7905 scroll_parent->test_properties()->scroll_children->insert(scroll_child); |
| 8297 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 8298 true); | |
| 8299 SetLayerPropertiesForTesting(scroll_child, scale, gfx::Point3F(), | |
| 8300 gfx::PointF(), gfx::Size(40, 40), true, false, | |
| 8301 false); | |
| 8302 SetLayerPropertiesForTesting(scroll_parent, identity_transform, | |
| 8303 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 8304 true, false, false); | |
| 8305 | 7906 |
| 8306 ExecuteCalculateDrawProperties(root); | 7907 ExecuteCalculateDrawProperties(root); |
| 8307 EXPECT_EQ(gfx::Rect(25, 25), scroll_child->visible_layer_rect()); | 7908 EXPECT_EQ(gfx::Rect(25, 25), scroll_child->visible_layer_rect()); |
| 8308 | 7909 |
| 8309 scroll_child->SetPosition(gfx::PointF(0, -10.f)); | 7910 scroll_child->SetPosition(gfx::PointF(0, -10.f)); |
| 8310 scroll_parent->SetCurrentScrollOffset(gfx::ScrollOffset(0.f, 10.f)); | 7911 scroll_parent->SetCurrentScrollOffset(gfx::ScrollOffset(0.f, 10.f)); |
| 8311 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7912 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8312 ExecuteCalculateDrawProperties(root); | 7913 ExecuteCalculateDrawProperties(root); |
| 8313 EXPECT_EQ(gfx::Rect(0, 5, 25, 25), scroll_child->visible_layer_rect()); | 7914 EXPECT_EQ(gfx::Rect(0, 5, 25, 25), scroll_child->visible_layer_rect()); |
| 8314 } | 7915 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 8343 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7944 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8344 | 7945 |
| 8345 EXPECT_EQ(root->num_copy_requests_in_target_subtree(), 2); | 7946 EXPECT_EQ(root->num_copy_requests_in_target_subtree(), 2); |
| 8346 EXPECT_EQ(child1->num_copy_requests_in_target_subtree(), 2); | 7947 EXPECT_EQ(child1->num_copy_requests_in_target_subtree(), 2); |
| 8347 EXPECT_EQ(child2->num_copy_requests_in_target_subtree(), 0); | 7948 EXPECT_EQ(child2->num_copy_requests_in_target_subtree(), 0); |
| 8348 EXPECT_EQ(grandchild->num_copy_requests_in_target_subtree(), 2); | 7949 EXPECT_EQ(grandchild->num_copy_requests_in_target_subtree(), 2); |
| 8349 EXPECT_EQ(greatgrandchild->num_copy_requests_in_target_subtree(), 1); | 7950 EXPECT_EQ(greatgrandchild->num_copy_requests_in_target_subtree(), 1); |
| 8350 } | 7951 } |
| 8351 | 7952 |
| 8352 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { | 7953 TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { |
| 8353 gfx::Transform identity; | |
| 8354 scoped_refptr<Layer> root = Layer::Create(); | 7954 scoped_refptr<Layer> root = Layer::Create(); |
| 8355 FakeContentLayerClient client; | 7955 FakeContentLayerClient client; |
| 8356 client.set_bounds(root->bounds()); | 7956 client.set_bounds(root->bounds()); |
| 8357 scoped_refptr<LayerWithForcedDrawsContent> child = | 7957 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 8358 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 7958 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8359 scoped_refptr<LayerWithForcedDrawsContent> grandchild = | 7959 scoped_refptr<LayerWithForcedDrawsContent> grandchild = |
| 8360 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 7960 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 8361 scoped_refptr<FakePictureLayer> greatgrandchild( | 7961 scoped_refptr<FakePictureLayer> greatgrandchild( |
| 8362 FakePictureLayer::Create(&client)); | 7962 FakePictureLayer::Create(&client)); |
| 8363 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 7963 |
| 8364 gfx::PointF(), gfx::Size(100, 100), true, false); | 7964 root->SetBounds(gfx::Size(100, 100)); |
| 8365 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 7965 child->SetBounds(gfx::Size(10, 10)); |
| 8366 gfx::PointF(), gfx::Size(10, 10), true, false); | 7966 grandchild->SetBounds(gfx::Size(10, 10)); |
| 8367 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | 7967 greatgrandchild->SetBounds(gfx::Size(10, 10)); |
| 8368 gfx::PointF(), gfx::Size(10, 10), true, false); | |
| 8369 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), | |
| 8370 gfx::PointF(), gfx::Size(10, 10), true, false); | |
| 8371 | 7968 |
| 8372 root->AddChild(child); | 7969 root->AddChild(child); |
| 8373 child->AddChild(grandchild); | 7970 child->AddChild(grandchild); |
| 8374 grandchild->AddChild(greatgrandchild); | 7971 grandchild->AddChild(greatgrandchild); |
| 8375 | |
| 8376 host()->SetRootLayer(root); | 7972 host()->SetRootLayer(root); |
| 8377 | |
| 8378 host()->SetElementIdsForTesting(); | 7973 host()->SetElementIdsForTesting(); |
| 8379 | 7974 |
| 8380 // Check the non-skipped case. | 7975 // Check the non-skipped case. |
| 8381 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7976 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8382 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 7977 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8383 | 7978 |
| 8384 // Now we will reset the visible rect from property trees for the grandchild, | 7979 // Now we will reset the visible rect from property trees for the grandchild, |
| 8385 // and we will configure |child| in several ways that should force the subtree | 7980 // and we will configure |child| in several ways that should force the subtree |
| 8386 // to be skipped. The visible content rect for |grandchild| should, therefore, | 7981 // to be skipped. The visible content rect for |grandchild| should, therefore, |
| 8387 // remain empty. | 7982 // remain empty. |
| 8388 grandchild->set_visible_layer_rect(gfx::Rect()); | 7983 grandchild->set_visible_layer_rect(gfx::Rect()); |
| 8389 gfx::Transform singular; | 7984 gfx::Transform singular; |
| 8390 singular.matrix().set(0, 0, 0); | 7985 singular.matrix().set(0, 0, 0); |
| 8391 | 7986 |
| 8392 child->SetTransform(singular); | 7987 child->SetTransform(singular); |
| 8393 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7988 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8394 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 7989 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
| 8395 child->SetTransform(identity); | 7990 child->SetTransform(gfx::Transform()); |
| 8396 | 7991 |
| 8397 child->SetHideLayerAndSubtree(true); | 7992 child->SetHideLayerAndSubtree(true); |
| 8398 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 7993 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8399 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 7994 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
| 8400 child->SetHideLayerAndSubtree(false); | 7995 child->SetHideLayerAndSubtree(false); |
| 8401 | 7996 |
| 8402 gfx::Transform zero_z_scale; | 7997 gfx::Transform zero_z_scale; |
| 8403 zero_z_scale.Scale3d(1, 1, 0); | 7998 zero_z_scale.Scale3d(1, 1, 0); |
| 8404 child->SetTransform(zero_z_scale); | 7999 child->SetTransform(zero_z_scale); |
| 8405 | 8000 |
| 8406 // Add a transform animation with a start delay. Now, even though |child| has | 8001 // Add a transform animation with a start delay. Now, even though |child| has |
| 8407 // a singular transform, the subtree should still get processed. | 8002 // a singular transform, the subtree should still get processed. |
| 8408 int animation_id = 0; | 8003 int animation_id = 0; |
| 8409 std::unique_ptr<Animation> animation = Animation::Create( | 8004 std::unique_ptr<Animation> animation = Animation::Create( |
| 8410 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), | 8005 std::unique_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), |
| 8411 animation_id, 1, TargetProperty::TRANSFORM); | 8006 animation_id, 1, TargetProperty::TRANSFORM); |
| 8412 animation->set_fill_mode(Animation::FillMode::NONE); | 8007 animation->set_fill_mode(Animation::FillMode::NONE); |
| 8413 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8008 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8414 AddAnimationToElementWithPlayer(child->element_id(), timeline(), | 8009 AddAnimationToElementWithPlayer(child->element_id(), timeline(), |
| 8415 std::move(animation)); | 8010 std::move(animation)); |
| 8416 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8011 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8417 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8012 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8418 grandchild->set_visible_layer_rect(gfx::Rect()); | 8013 grandchild->set_visible_layer_rect(gfx::Rect()); |
| 8419 | 8014 |
| 8420 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), | 8015 RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(), |
| 8421 animation_id); | 8016 animation_id); |
| 8422 child->SetTransform(identity); | 8017 child->SetTransform(gfx::Transform()); |
| 8423 child->SetOpacity(0.f); | 8018 child->SetOpacity(0.f); |
| 8424 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8019 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8425 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); | 8020 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_layer_rect_for_testing()); |
| 8426 | 8021 |
| 8427 // Now, even though child has zero opacity, we will configure |grandchild| and | 8022 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8428 // |greatgrandchild| in several ways that should force the subtree to be | 8023 // |greatgrandchild| in several ways that should force the subtree to be |
| 8429 // processed anyhow. | 8024 // processed anyhow. |
| 8430 grandchild->RequestCopyOfOutput( | 8025 grandchild->RequestCopyOfOutput( |
| 8431 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8026 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
| 8432 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8027 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 8446 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); | 8041 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect_for_testing()); |
| 8447 } | 8042 } |
| 8448 | 8043 |
| 8449 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { | 8044 TEST_F(LayerTreeHostCommonTest, SkippingLayerImpl) { |
| 8450 FakeImplTaskRunnerProvider task_runner_provider; | 8045 FakeImplTaskRunnerProvider task_runner_provider; |
| 8451 TestSharedBitmapManager shared_bitmap_manager; | 8046 TestSharedBitmapManager shared_bitmap_manager; |
| 8452 TestTaskGraphRunner task_graph_runner; | 8047 TestTaskGraphRunner task_graph_runner; |
| 8453 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8048 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 8454 &task_graph_runner); | 8049 &task_graph_runner); |
| 8455 | 8050 |
| 8456 gfx::Transform identity; | |
| 8457 std::unique_ptr<LayerImpl> root = | 8051 std::unique_ptr<LayerImpl> root = |
| 8458 LayerImpl::Create(host_impl.active_tree(), 1); | 8052 LayerImpl::Create(host_impl.active_tree(), 1); |
| 8459 std::unique_ptr<LayerImpl> child = | 8053 std::unique_ptr<LayerImpl> child = |
| 8460 LayerImpl::Create(host_impl.active_tree(), 2); | 8054 LayerImpl::Create(host_impl.active_tree(), 2); |
| 8461 std::unique_ptr<LayerImpl> grandchild = | 8055 std::unique_ptr<LayerImpl> grandchild = |
| 8462 LayerImpl::Create(host_impl.active_tree(), 3); | 8056 LayerImpl::Create(host_impl.active_tree(), 3); |
| 8463 | 8057 |
| 8464 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( | 8058 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( |
| 8465 FakePictureLayerImpl::Create(host_impl.active_tree(), 4)); | 8059 FakePictureLayerImpl::Create(host_impl.active_tree(), 4)); |
| 8466 | 8060 |
| 8061 root->SetBounds(gfx::Size(100, 100)); |
| 8062 child->SetBounds(gfx::Size(10, 10)); |
| 8467 child->SetDrawsContent(true); | 8063 child->SetDrawsContent(true); |
| 8064 grandchild->SetBounds(gfx::Size(10, 10)); |
| 8468 grandchild->SetDrawsContent(true); | 8065 grandchild->SetDrawsContent(true); |
| 8469 greatgrandchild->SetDrawsContent(true); | 8066 greatgrandchild->SetDrawsContent(true); |
| 8470 | 8067 |
| 8471 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | |
| 8472 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 8473 true); | |
| 8474 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | |
| 8475 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8476 false); | |
| 8477 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | |
| 8478 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8479 false); | |
| 8480 | |
| 8481 LayerImpl* root_ptr = root.get(); | 8068 LayerImpl* root_ptr = root.get(); |
| 8482 LayerImpl* child_ptr = child.get(); | 8069 LayerImpl* child_ptr = child.get(); |
| 8483 LayerImpl* grandchild_ptr = grandchild.get(); | 8070 LayerImpl* grandchild_ptr = grandchild.get(); |
| 8484 | 8071 |
| 8485 child->test_properties()->AddChild(std::move(grandchild)); | 8072 child->test_properties()->AddChild(std::move(grandchild)); |
| 8486 root->test_properties()->AddChild(std::move(child)); | 8073 root->test_properties()->AddChild(std::move(child)); |
| 8487 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 8074 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8488 | 8075 |
| 8489 host_impl.active_tree()->SetElementIdsForTesting(); | 8076 host_impl.active_tree()->SetElementIdsForTesting(); |
| 8490 | 8077 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8508 rotate.Rotate(90); | 8095 rotate.Rotate(90); |
| 8509 | 8096 |
| 8510 gfx::Transform rotate_back_and_translate; | 8097 gfx::Transform rotate_back_and_translate; |
| 8511 rotate_back_and_translate.RotateAboutYAxis(180); | 8098 rotate_back_and_translate.RotateAboutYAxis(180); |
| 8512 rotate_back_and_translate.Translate(-10, 0); | 8099 rotate_back_and_translate.Translate(-10, 0); |
| 8513 | 8100 |
| 8514 child_ptr->SetTransform(singular); | 8101 child_ptr->SetTransform(singular); |
| 8515 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8102 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8516 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8103 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8517 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8104 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8518 child_ptr->SetTransform(identity); | 8105 child_ptr->SetTransform(gfx::Transform()); |
| 8519 | 8106 |
| 8520 child_ptr->test_properties()->hide_layer_and_subtree = true; | 8107 child_ptr->test_properties()->hide_layer_and_subtree = true; |
| 8521 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8108 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8522 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8109 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8523 child_ptr->test_properties()->hide_layer_and_subtree = false; | 8110 child_ptr->test_properties()->hide_layer_and_subtree = false; |
| 8524 | 8111 |
| 8525 child_ptr->OnOpacityAnimated(0.f); | 8112 child_ptr->OnOpacityAnimated(0.f); |
| 8526 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8113 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8527 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8114 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8528 child_ptr->test_properties()->opacity = 1.f; | 8115 child_ptr->test_properties()->opacity = 1.f; |
| 8529 | 8116 |
| 8530 root_ptr->SetTransform(singular); | 8117 root_ptr->SetTransform(singular); |
| 8531 // Force transform tree to have a node for child, so that ancestor's | 8118 // Force transform tree to have a node for child, so that ancestor's |
| 8532 // invertible transform can be tested. | 8119 // invertible transform can be tested. |
| 8533 child_ptr->SetTransform(rotate); | 8120 child_ptr->SetTransform(rotate); |
| 8534 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8121 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8535 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8122 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8536 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8123 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8537 root_ptr->SetTransform(identity); | 8124 root_ptr->SetTransform(gfx::Transform()); |
| 8538 child_ptr->SetTransform(identity); | 8125 child_ptr->SetTransform(gfx::Transform()); |
| 8539 | 8126 |
| 8540 root_ptr->test_properties()->opacity = 0.f; | 8127 root_ptr->test_properties()->opacity = 0.f; |
| 8541 child_ptr->test_properties()->opacity = 0.7f; | 8128 child_ptr->test_properties()->opacity = 0.7f; |
| 8542 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 8129 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 8543 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8130 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8544 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); | 8131 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); |
| 8545 root_ptr->test_properties()->opacity = 1.f; | 8132 root_ptr->test_properties()->opacity = 1.f; |
| 8546 | 8133 |
| 8547 child_ptr->test_properties()->opacity = 0.f; | 8134 child_ptr->test_properties()->opacity = 0.f; |
| 8548 // Now, even though child has zero opacity, we will configure |grandchild| and | 8135 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8549 // |greatgrandchild| in several ways that should force the subtree to be | 8136 // |greatgrandchild| in several ways that should force the subtree to be |
| 8550 // processed anyhow. | 8137 // processed anyhow. |
| 8551 grandchild_ptr->test_properties()->copy_requests.push_back( | 8138 grandchild_ptr->test_properties()->copy_requests.push_back( |
| 8552 CopyOutputRequest::CreateEmptyRequest()); | 8139 CopyOutputRequest::CreateEmptyRequest()); |
| 8553 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8140 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8554 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8141 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8555 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8142 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8556 | 8143 |
| 8557 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); | 8144 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); |
| 8558 child_ptr->test_properties()->opacity = 1.f; | 8145 child_ptr->test_properties()->opacity = 1.f; |
| 8559 | 8146 |
| 8560 // A double sided render surface with backface visible should not be skipped | 8147 // A double sided render surface with backface visible should not be skipped |
| 8561 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8148 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8562 child_ptr->SetHasRenderSurface(true); | 8149 child_ptr->SetHasRenderSurface(true); |
| 8563 child_ptr->test_properties()->double_sided = true; | 8150 child_ptr->test_properties()->double_sided = true; |
| 8564 child_ptr->SetTransform(rotate_back_and_translate); | 8151 child_ptr->SetTransform(rotate_back_and_translate); |
| 8565 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8152 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8566 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8153 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8567 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8154 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8568 child_ptr->SetTransform(identity); | 8155 child_ptr->SetTransform(gfx::Transform()); |
| 8569 | 8156 |
| 8570 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 8157 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 8571 KeyframedTransformAnimationCurve::Create()); | 8158 KeyframedTransformAnimationCurve::Create()); |
| 8572 TransformOperations start; | 8159 TransformOperations start; |
| 8573 start.AppendTranslate(1.f, 2.f, 3.f); | 8160 start.AppendTranslate(1.f, 2.f, 3.f); |
| 8574 gfx::Transform transform; | 8161 gfx::Transform transform; |
| 8575 transform.Scale3d(1.0, 2.0, 3.0); | 8162 transform.Scale3d(1.0, 2.0, 3.0); |
| 8576 TransformOperations operation; | 8163 TransformOperations operation; |
| 8577 operation.AppendMatrix(transform); | 8164 operation.AppendMatrix(transform); |
| 8578 curve->AddKeyframe( | 8165 curve->AddKeyframe( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 8598 | 8185 |
| 8599 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8186 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
| 8600 root_ptr->element_id(), player.get()); | 8187 root_ptr->element_id(), player.get()); |
| 8601 } | 8188 } |
| 8602 | 8189 |
| 8603 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { | 8190 TEST_F(LayerTreeHostCommonTest, LayerSkippingInSubtreeOfSingularTransform) { |
| 8604 LayerImpl* root = root_layer_for_testing(); | 8191 LayerImpl* root = root_layer_for_testing(); |
| 8605 LayerImpl* child = AddChild<LayerImpl>(root); | 8192 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8606 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 8193 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 8607 | 8194 |
| 8608 gfx::Transform identity; | |
| 8609 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | |
| 8610 gfx::Size(10, 10), true, false, true); | |
| 8611 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | |
| 8612 gfx::Size(10, 10), true, false, false); | |
| 8613 SetLayerPropertiesForTesting(grand_child, identity, gfx::Point3F(), | |
| 8614 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8615 false); | |
| 8616 SetElementIdsForTesting(); | 8195 SetElementIdsForTesting(); |
| 8617 | 8196 |
| 8618 gfx::Transform singular; | 8197 gfx::Transform singular; |
| 8619 singular.matrix().set(0, 0, 0); | 8198 singular.matrix().set(0, 0, 0); |
| 8620 singular.matrix().set(0, 1, 1); | 8199 singular.matrix().set(0, 1, 1); |
| 8621 | 8200 |
| 8201 root->SetBounds(gfx::Size(10, 10)); |
| 8622 child->SetTransform(singular); | 8202 child->SetTransform(singular); |
| 8203 child->SetBounds(gfx::Size(10, 10)); |
| 8623 child->SetDrawsContent(true); | 8204 child->SetDrawsContent(true); |
| 8205 grand_child->SetBounds(gfx::Size(10, 10)); |
| 8624 grand_child->SetDrawsContent(true); | 8206 grand_child->SetDrawsContent(true); |
| 8625 | 8207 |
| 8626 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 8208 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 8627 KeyframedTransformAnimationCurve::Create()); | 8209 KeyframedTransformAnimationCurve::Create()); |
| 8628 TransformOperations start; | 8210 TransformOperations start; |
| 8629 start.AppendTranslate(1.f, 2.f, 3.f); | 8211 start.AppendTranslate(1.f, 2.f, 3.f); |
| 8630 gfx::Transform transform; | 8212 gfx::Transform transform; |
| 8631 transform.Scale3d(1.0, 2.0, 3.0); | 8213 transform.Scale3d(1.0, 2.0, 3.0); |
| 8632 TransformOperations operation; | 8214 TransformOperations operation; |
| 8633 operation.AppendMatrix(transform); | 8215 operation.AppendMatrix(transform); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 8654 grand_child->element_id(), player.get()); | 8236 grand_child->element_id(), player.get()); |
| 8655 } | 8237 } |
| 8656 | 8238 |
| 8657 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { | 8239 TEST_F(LayerTreeHostCommonTest, SkippingPendingLayerImpl) { |
| 8658 FakeImplTaskRunnerProvider task_runner_provider; | 8240 FakeImplTaskRunnerProvider task_runner_provider; |
| 8659 TestSharedBitmapManager shared_bitmap_manager; | 8241 TestSharedBitmapManager shared_bitmap_manager; |
| 8660 TestTaskGraphRunner task_graph_runner; | 8242 TestTaskGraphRunner task_graph_runner; |
| 8661 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 8243 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 8662 &task_graph_runner); | 8244 &task_graph_runner); |
| 8663 | 8245 |
| 8664 gfx::Transform identity; | |
| 8665 host_impl.CreatePendingTree(); | 8246 host_impl.CreatePendingTree(); |
| 8666 std::unique_ptr<LayerImpl> root = | 8247 std::unique_ptr<LayerImpl> root = |
| 8667 LayerImpl::Create(host_impl.pending_tree(), 1); | 8248 LayerImpl::Create(host_impl.pending_tree(), 1); |
| 8668 std::unique_ptr<LayerImpl> child = | 8249 std::unique_ptr<LayerImpl> child = |
| 8669 LayerImpl::Create(host_impl.pending_tree(), 2); | 8250 LayerImpl::Create(host_impl.pending_tree(), 2); |
| 8670 std::unique_ptr<LayerImpl> grandchild = | 8251 std::unique_ptr<LayerImpl> grandchild = |
| 8671 LayerImpl::Create(host_impl.pending_tree(), 3); | 8252 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 8672 | 8253 |
| 8673 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( | 8254 std::unique_ptr<FakePictureLayerImpl> greatgrandchild( |
| 8674 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4)); | 8255 FakePictureLayerImpl::Create(host_impl.pending_tree(), 4)); |
| 8675 | 8256 |
| 8257 root->SetBounds(gfx::Size(100, 100)); |
| 8258 child->SetBounds(gfx::Size(10, 10)); |
| 8676 child->SetDrawsContent(true); | 8259 child->SetDrawsContent(true); |
| 8260 grandchild->SetBounds(gfx::Size(10, 10)); |
| 8677 grandchild->SetDrawsContent(true); | 8261 grandchild->SetDrawsContent(true); |
| 8678 greatgrandchild->SetDrawsContent(true); | 8262 greatgrandchild->SetDrawsContent(true); |
| 8679 | 8263 |
| 8680 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | |
| 8681 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 8682 true); | |
| 8683 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | |
| 8684 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8685 false); | |
| 8686 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | |
| 8687 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8688 false); | |
| 8689 | |
| 8690 LayerImpl* root_ptr = root.get(); | 8264 LayerImpl* root_ptr = root.get(); |
| 8691 LayerImpl* grandchild_ptr = grandchild.get(); | 8265 LayerImpl* grandchild_ptr = grandchild.get(); |
| 8692 | 8266 |
| 8693 child->test_properties()->AddChild(std::move(grandchild)); | 8267 child->test_properties()->AddChild(std::move(grandchild)); |
| 8694 root->test_properties()->AddChild(std::move(child)); | 8268 root->test_properties()->AddChild(std::move(child)); |
| 8695 | 8269 |
| 8696 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | 8270 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
| 8697 host_impl.pending_tree()->SetElementIdsForTesting(); | 8271 host_impl.pending_tree()->SetElementIdsForTesting(); |
| 8698 | 8272 |
| 8699 // Check the non-skipped case. | 8273 // Check the non-skipped case. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 8722 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 8296 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 8723 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8297 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8724 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); | 8298 ExecuteCalculateDrawPropertiesWithPropertyTrees(root_ptr); |
| 8725 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 8299 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 8726 | 8300 |
| 8727 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( | 8301 host_impl.active_tree()->animation_host()->UnregisterPlayerForElement( |
| 8728 root_ptr->element_id(), player.get()); | 8302 root_ptr->element_id(), player.get()); |
| 8729 } | 8303 } |
| 8730 | 8304 |
| 8731 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8305 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
| 8732 gfx::Transform identity; | |
| 8733 LayerImpl* root = root_layer_for_testing(); | 8306 LayerImpl* root = root_layer_for_testing(); |
| 8734 LayerImpl* child = AddChild<LayerImpl>(root); | 8307 LayerImpl* child = AddChild<LayerImpl>(root); |
| 8735 | 8308 |
| 8736 SetLayerPropertiesForTesting(root, identity, gfx::Point3F(), gfx::PointF(), | 8309 root->SetBounds(gfx::Size(100, 100)); |
| 8737 gfx::Size(100, 100), true, false, true); | 8310 child->SetBounds(gfx::Size(10, 10)); |
| 8738 SetLayerPropertiesForTesting(child, identity, gfx::Point3F(), gfx::PointF(), | |
| 8739 gfx::Size(10, 10), true, false, false); | |
| 8740 child->SetDrawsContent(true); | 8311 child->SetDrawsContent(true); |
| 8741 | 8312 |
| 8742 ExecuteCalculateDrawProperties(root); | 8313 ExecuteCalculateDrawProperties(root); |
| 8743 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 8314 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 8744 child->set_visible_layer_rect(gfx::Rect()); | 8315 child->set_visible_layer_rect(gfx::Rect()); |
| 8745 | 8316 |
| 8746 child->test_properties()->hide_layer_and_subtree = true; | 8317 child->test_properties()->hide_layer_and_subtree = true; |
| 8747 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8318 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8748 ExecuteCalculateDrawProperties(root); | 8319 ExecuteCalculateDrawProperties(root); |
| 8749 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8320 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8750 child->test_properties()->hide_layer_and_subtree = false; | 8321 child->test_properties()->hide_layer_and_subtree = false; |
| 8751 | 8322 |
| 8752 child->SetBounds(gfx::Size()); | 8323 child->SetBounds(gfx::Size()); |
| 8753 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8324 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8754 ExecuteCalculateDrawProperties(root); | 8325 ExecuteCalculateDrawProperties(root); |
| 8755 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8326 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8756 child->SetBounds(gfx::Size(10, 10)); | 8327 child->SetBounds(gfx::Size(10, 10)); |
| 8757 | 8328 |
| 8758 gfx::Transform rotate; | 8329 gfx::Transform rotate; |
| 8759 child->test_properties()->double_sided = false; | 8330 child->test_properties()->double_sided = false; |
| 8760 rotate.RotateAboutXAxis(180.f); | 8331 rotate.RotateAboutXAxis(180.f); |
| 8761 child->SetTransform(rotate); | 8332 child->SetTransform(rotate); |
| 8762 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8333 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8763 ExecuteCalculateDrawProperties(root); | 8334 ExecuteCalculateDrawProperties(root); |
| 8764 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8335 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8765 child->test_properties()->double_sided = true; | 8336 child->test_properties()->double_sided = true; |
| 8766 child->SetTransform(identity); | 8337 child->SetTransform(gfx::Transform()); |
| 8767 | 8338 |
| 8768 child->test_properties()->opacity = 0.f; | 8339 child->test_properties()->opacity = 0.f; |
| 8769 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8340 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8770 ExecuteCalculateDrawProperties(root); | 8341 ExecuteCalculateDrawProperties(root); |
| 8771 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); | 8342 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); |
| 8772 } | 8343 } |
| 8773 | 8344 |
| 8774 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { | 8345 TEST_F(LayerTreeHostCommonTest, LayerTreeRebuildTest) { |
| 8775 // Ensure that the treewalk in LayerTreeHostCommom:: | 8346 // Ensure that the treewalk in LayerTreeHostCommom:: |
| 8776 // PreCalculateMetaInformation happens when its required. | 8347 // PreCalculateMetaInformation happens when its required. |
| 8777 scoped_refptr<Layer> root = Layer::Create(); | 8348 scoped_refptr<Layer> root = Layer::Create(); |
| 8778 scoped_refptr<Layer> parent = Layer::Create(); | 8349 scoped_refptr<Layer> parent = Layer::Create(); |
| 8779 scoped_refptr<Layer> child = Layer::Create(); | 8350 scoped_refptr<Layer> child = Layer::Create(); |
| 8780 | 8351 |
| 8352 root->SetBounds(gfx::Size(100, 100)); |
| 8353 parent->SetBounds(gfx::Size(100, 100)); |
| 8354 child->SetBounds(gfx::Size(100, 100)); |
| 8355 child->SetClipParent(root.get()); |
| 8356 |
| 8781 root->AddChild(parent); | 8357 root->AddChild(parent); |
| 8782 parent->AddChild(child); | 8358 parent->AddChild(child); |
| 8783 | |
| 8784 child->SetClipParent(root.get()); | |
| 8785 | |
| 8786 gfx::Transform identity; | |
| 8787 | |
| 8788 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | |
| 8789 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 8790 SetLayerPropertiesForTesting(parent.get(), identity, gfx::Point3F(), | |
| 8791 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 8792 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | |
| 8793 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 8794 | |
| 8795 host()->SetRootLayer(root); | 8359 host()->SetRootLayer(root); |
| 8796 | 8360 |
| 8797 child->RequestCopyOfOutput( | 8361 child->RequestCopyOfOutput( |
| 8798 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 8362 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 8799 | 8363 |
| 8800 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8364 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8801 EXPECT_EQ(parent->num_unclipped_descendants(), 1u); | 8365 EXPECT_EQ(parent->num_unclipped_descendants(), 1u); |
| 8802 | 8366 |
| 8803 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 8367 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
| 8804 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8368 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8805 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 8369 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
| 8806 } | 8370 } |
| 8807 | 8371 |
| 8808 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { | 8372 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { |
| 8809 gfx::Transform identity; | 8373 scoped_refptr<Layer> root = Layer::Create(); |
| 8374 root->SetBounds(gfx::Size(800, 800)); |
| 8375 |
| 8810 gfx::Transform translate_z; | 8376 gfx::Transform translate_z; |
| 8811 translate_z.Translate3d(0, 0, 10); | 8377 translate_z.Translate3d(0, 0, 10); |
| 8812 | 8378 |
| 8813 scoped_refptr<Layer> root = Layer::Create(); | |
| 8814 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | |
| 8815 gfx::PointF(), gfx::Size(800, 800), true, false); | |
| 8816 | |
| 8817 scoped_refptr<Layer> child = Layer::Create(); | 8379 scoped_refptr<Layer> child = Layer::Create(); |
| 8818 SetLayerPropertiesForTesting(child.get(), translate_z, gfx::Point3F(), | 8380 child->SetTransform(translate_z); |
| 8819 gfx::PointF(), gfx::Size(100, 100), true, false); | 8381 child->SetBounds(gfx::Size(100, 100)); |
| 8820 | 8382 |
| 8821 root->AddChild(child); | 8383 root->AddChild(child); |
| 8822 | 8384 |
| 8823 host()->SetRootLayer(root); | 8385 host()->SetRootLayer(root); |
| 8824 | 8386 |
| 8825 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8387 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8826 EXPECT_NE(-1, child->transform_tree_index()); | 8388 EXPECT_NE(-1, child->transform_tree_index()); |
| 8827 | 8389 |
| 8828 child->RemoveFromParent(); | 8390 child->RemoveFromParent(); |
| 8829 | 8391 |
| 8830 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8392 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8831 EXPECT_EQ(-1, child->transform_tree_index()); | 8393 EXPECT_EQ(-1, child->transform_tree_index()); |
| 8832 } | 8394 } |
| 8833 | 8395 |
| 8834 TEST_F(LayerTreeHostCommonTest, RenderSurfaceClipsSubtree) { | 8396 TEST_F(LayerTreeHostCommonTest, RenderSurfaceClipsSubtree) { |
| 8835 // Ensure that a Clip Node is added when a render surface applies clip. | 8397 // Ensure that a Clip Node is added when a render surface applies clip. |
| 8836 LayerImpl* root = root_layer_for_testing(); | 8398 LayerImpl* root = root_layer_for_testing(); |
| 8837 LayerImpl* significant_transform = AddChildToRoot<LayerImpl>(); | 8399 LayerImpl* significant_transform = AddChildToRoot<LayerImpl>(); |
| 8838 LayerImpl* layer_clips_subtree = AddChild<LayerImpl>(significant_transform); | 8400 LayerImpl* layer_clips_subtree = AddChild<LayerImpl>(significant_transform); |
| 8839 LayerImpl* render_surface = AddChild<LayerImpl>(layer_clips_subtree); | 8401 LayerImpl* render_surface = AddChild<LayerImpl>(layer_clips_subtree); |
| 8840 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 8402 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 8841 | 8403 |
| 8842 const gfx::Transform identity_matrix; | |
| 8843 // This transform should be a significant one so that a transform node is | 8404 // This transform should be a significant one so that a transform node is |
| 8844 // formed for it. | 8405 // formed for it. |
| 8845 gfx::Transform transform1; | 8406 gfx::Transform transform1; |
| 8846 transform1.RotateAboutYAxis(45); | 8407 transform1.RotateAboutYAxis(45); |
| 8847 transform1.RotateAboutXAxis(30); | 8408 transform1.RotateAboutXAxis(30); |
| 8848 // This transform should be a 3d transform as we want the render surface | 8409 // This transform should be a 3d transform as we want the render surface |
| 8849 // to flatten the transform | 8410 // to flatten the transform |
| 8850 gfx::Transform transform2; | 8411 gfx::Transform transform2; |
| 8851 transform2.Translate3d(10, 10, 10); | 8412 transform2.Translate3d(10, 10, 10); |
| 8852 | 8413 |
| 8414 root->SetBounds(gfx::Size(30, 30)); |
| 8415 significant_transform->SetTransform(transform1); |
| 8416 significant_transform->SetBounds(gfx::Size(30, 30)); |
| 8417 layer_clips_subtree->SetBounds(gfx::Size(30, 30)); |
| 8853 layer_clips_subtree->SetMasksToBounds(true); | 8418 layer_clips_subtree->SetMasksToBounds(true); |
| 8419 layer_clips_subtree->test_properties()->force_render_surface = true; |
| 8420 render_surface->SetTransform(transform2); |
| 8421 render_surface->SetBounds(gfx::Size(30, 30)); |
| 8422 render_surface->test_properties()->force_render_surface = true; |
| 8423 test_layer->SetBounds(gfx::Size(30, 30)); |
| 8854 test_layer->SetDrawsContent(true); | 8424 test_layer->SetDrawsContent(true); |
| 8855 | 8425 |
| 8856 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 8857 gfx::PointF(), gfx::Size(30, 30), true, false); | |
| 8858 SetLayerPropertiesForTesting(significant_transform, transform1, | |
| 8859 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 8860 true, false); | |
| 8861 SetLayerPropertiesForTesting(layer_clips_subtree, identity_matrix, | |
| 8862 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 8863 true, false); | |
| 8864 SetLayerPropertiesForTesting(render_surface, transform2, gfx::Point3F(), | |
| 8865 gfx::PointF(), gfx::Size(30, 30), true, false); | |
| 8866 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | |
| 8867 gfx::PointF(), gfx::Size(30, 30), true, false); | |
| 8868 | |
| 8869 root->test_properties()->force_render_surface = true; | |
| 8870 significant_transform->test_properties()->force_render_surface = false; | |
| 8871 layer_clips_subtree->test_properties()->force_render_surface = true; | |
| 8872 render_surface->test_properties()->force_render_surface = true; | |
| 8873 test_layer->test_properties()->force_render_surface = false; | |
| 8874 ExecuteCalculateDrawProperties(root); | 8426 ExecuteCalculateDrawProperties(root); |
| 8875 | 8427 |
| 8876 TransformTree& transform_tree = | 8428 TransformTree& transform_tree = |
| 8877 root->layer_tree_impl()->property_trees()->transform_tree; | 8429 root->layer_tree_impl()->property_trees()->transform_tree; |
| 8878 TransformNode* transform_node = | 8430 TransformNode* transform_node = |
| 8879 transform_tree.Node(significant_transform->transform_tree_index()); | 8431 transform_tree.Node(significant_transform->transform_tree_index()); |
| 8880 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); | 8432 EXPECT_EQ(transform_node->owner_id, significant_transform->id()); |
| 8881 | 8433 |
| 8882 EXPECT_TRUE(root->has_render_surface()); | 8434 EXPECT_TRUE(root->has_render_surface()); |
| 8883 EXPECT_FALSE(significant_transform->has_render_surface()); | 8435 EXPECT_FALSE(significant_transform->has_render_surface()); |
| 8884 EXPECT_TRUE(layer_clips_subtree->has_render_surface()); | 8436 EXPECT_TRUE(layer_clips_subtree->has_render_surface()); |
| 8885 EXPECT_TRUE(render_surface->has_render_surface()); | 8437 EXPECT_TRUE(render_surface->has_render_surface()); |
| 8886 EXPECT_FALSE(test_layer->has_render_surface()); | 8438 EXPECT_FALSE(test_layer->has_render_surface()); |
| 8887 | 8439 |
| 8888 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; | 8440 ClipTree& clip_tree = root->layer_tree_impl()->property_trees()->clip_tree; |
| 8889 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); | 8441 ClipNode* clip_node = clip_tree.Node(render_surface->clip_tree_index()); |
| 8890 EXPECT_FALSE(clip_node->applies_local_clip); | 8442 EXPECT_FALSE(clip_node->applies_local_clip); |
| 8891 EXPECT_EQ(gfx::Rect(20, 20), test_layer->visible_layer_rect()); | 8443 EXPECT_EQ(gfx::Rect(20, 20), test_layer->visible_layer_rect()); |
| 8892 } | 8444 } |
| 8893 | 8445 |
| 8894 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { | 8446 TEST_F(LayerTreeHostCommonTest, TransformOfParentClipNodeAncestorOfTarget) { |
| 8895 // Ensure that when parent clip node's transform is an ancestor of current | 8447 // Ensure that when parent clip node's transform is an ancestor of current |
| 8896 // clip node's target, clip is 'projected' from parent space to current | 8448 // clip node's target, clip is 'projected' from parent space to current |
| 8897 // target space and visible rects are calculated correctly. | 8449 // target space and visible rects are calculated correctly. |
| 8898 LayerImpl* root = root_layer_for_testing(); | 8450 LayerImpl* root = root_layer_for_testing(); |
| 8899 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 8451 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 8900 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); | 8452 LayerImpl* target_layer = AddChild<LayerImpl>(clip_layer); |
| 8901 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); | 8453 LayerImpl* test_layer = AddChild<LayerImpl>(target_layer); |
| 8902 | 8454 |
| 8903 const gfx::Transform identity_matrix; | |
| 8904 gfx::Transform transform; | 8455 gfx::Transform transform; |
| 8905 transform.RotateAboutYAxis(45); | 8456 transform.RotateAboutYAxis(45); |
| 8457 |
| 8458 root->SetBounds(gfx::Size(30, 30)); |
| 8459 clip_layer->SetTransform(transform); |
| 8460 clip_layer->SetBounds(gfx::Size(30, 30)); |
| 8906 clip_layer->SetMasksToBounds(true); | 8461 clip_layer->SetMasksToBounds(true); |
| 8462 target_layer->SetTransform(transform); |
| 8463 target_layer->SetBounds(gfx::Size(30, 30)); |
| 8907 target_layer->SetMasksToBounds(true); | 8464 target_layer->SetMasksToBounds(true); |
| 8465 test_layer->SetBounds(gfx::Size(30, 30)); |
| 8908 test_layer->SetDrawsContent(true); | 8466 test_layer->SetDrawsContent(true); |
| 8909 | 8467 |
| 8910 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 8911 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8912 true); | |
| 8913 SetLayerPropertiesForTesting(clip_layer, transform, gfx::Point3F(), | |
| 8914 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8915 false); | |
| 8916 SetLayerPropertiesForTesting(target_layer, transform, gfx::Point3F(), | |
| 8917 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8918 true); | |
| 8919 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | |
| 8920 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8921 false); | |
| 8922 ExecuteCalculateDrawProperties(root); | 8468 ExecuteCalculateDrawProperties(root); |
| 8923 | 8469 |
| 8924 EXPECT_EQ(gfx::Rect(30, 30), test_layer->visible_layer_rect()); | 8470 EXPECT_EQ(gfx::Rect(30, 30), test_layer->visible_layer_rect()); |
| 8925 } | 8471 } |
| 8926 | 8472 |
| 8927 TEST_F(LayerTreeHostCommonTest, | 8473 TEST_F(LayerTreeHostCommonTest, |
| 8928 RenderSurfaceWithUnclippedDescendantsClipsSubtree) { | 8474 RenderSurfaceWithUnclippedDescendantsClipsSubtree) { |
| 8929 // Ensure clip rect is calculated correctly when render surface has unclipped | 8475 // Ensure clip rect is calculated correctly when render surface has unclipped |
| 8930 // descendants. | 8476 // descendants. |
| 8931 LayerImpl* root = root_layer_for_testing(); | 8477 LayerImpl* root = root_layer_for_testing(); |
| 8932 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 8478 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 8933 LayerImpl* between_clip_parent_and_child = AddChild<LayerImpl>(clip_parent); | 8479 LayerImpl* between_clip_parent_and_child = AddChild<LayerImpl>(clip_parent); |
| 8934 LayerImpl* render_surface = | 8480 LayerImpl* render_surface = |
| 8935 AddChild<LayerImpl>(between_clip_parent_and_child); | 8481 AddChild<LayerImpl>(between_clip_parent_and_child); |
| 8936 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 8482 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 8937 | 8483 |
| 8938 const gfx::Transform identity_matrix; | |
| 8939 gfx::Transform translate; | 8484 gfx::Transform translate; |
| 8940 translate.Translate(2.0, 2.0); | 8485 translate.Translate(2.0, 2.0); |
| 8941 | 8486 |
| 8487 root->SetBounds(gfx::Size(30, 30)); |
| 8488 clip_parent->SetTransform(translate); |
| 8489 clip_parent->SetBounds(gfx::Size(30, 30)); |
| 8942 clip_parent->SetMasksToBounds(true); | 8490 clip_parent->SetMasksToBounds(true); |
| 8491 between_clip_parent_and_child->SetTransform(translate); |
| 8492 between_clip_parent_and_child->SetBounds(gfx::Size(30, 30)); |
| 8493 render_surface->SetBounds(gfx::Size(30, 30)); |
| 8494 render_surface->test_properties()->force_render_surface = true; |
| 8495 test_layer->SetBounds(gfx::Size(30, 30)); |
| 8943 test_layer->SetDrawsContent(true); | 8496 test_layer->SetDrawsContent(true); |
| 8497 |
| 8944 render_surface->test_properties()->clip_parent = clip_parent; | 8498 render_surface->test_properties()->clip_parent = clip_parent; |
| 8945 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 8499 clip_parent->test_properties()->clip_children = |
| 8946 clip_children->insert(render_surface); | 8500 base::MakeUnique<std::set<LayerImpl*>>(); |
| 8947 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 8501 clip_parent->test_properties()->clip_children->insert(render_surface); |
| 8948 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 8949 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8950 true); | |
| 8951 SetLayerPropertiesForTesting(clip_parent, translate, gfx::Point3F(), | |
| 8952 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8953 false); | |
| 8954 SetLayerPropertiesForTesting(between_clip_parent_and_child, translate, | |
| 8955 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | |
| 8956 true, false, false); | |
| 8957 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | |
| 8958 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8959 true); | |
| 8960 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | |
| 8961 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8962 false); | |
| 8963 | 8502 |
| 8964 ExecuteCalculateDrawProperties(root); | 8503 ExecuteCalculateDrawProperties(root); |
| 8965 | 8504 |
| 8966 EXPECT_TRUE(test_layer->is_clipped()); | 8505 EXPECT_TRUE(test_layer->is_clipped()); |
| 8967 EXPECT_FALSE(test_layer->render_target()->is_clipped()); | 8506 EXPECT_FALSE(test_layer->render_target()->is_clipped()); |
| 8968 EXPECT_EQ(gfx::Rect(-2, -2, 30, 30), test_layer->clip_rect()); | 8507 EXPECT_EQ(gfx::Rect(-2, -2, 30, 30), test_layer->clip_rect()); |
| 8969 EXPECT_EQ(gfx::Rect(28, 28), test_layer->drawable_content_rect()); | 8508 EXPECT_EQ(gfx::Rect(28, 28), test_layer->drawable_content_rect()); |
| 8970 } | 8509 } |
| 8971 | 8510 |
| 8972 TEST_F(LayerTreeHostCommonTest, | 8511 TEST_F(LayerTreeHostCommonTest, |
| 8973 RenderSurfaceWithUnclippedDescendantsButDoesntApplyOwnClip) { | 8512 RenderSurfaceWithUnclippedDescendantsButDoesntApplyOwnClip) { |
| 8974 // Ensure that the visible layer rect of a descendant of a surface with | 8513 // Ensure that the visible layer rect of a descendant of a surface with |
| 8975 // unclipped descendants is computed correctly, when the surface doesn't apply | 8514 // unclipped descendants is computed correctly, when the surface doesn't apply |
| 8976 // a clip. | 8515 // a clip. |
| 8977 LayerImpl* root = root_layer_for_testing(); | 8516 LayerImpl* root = root_layer_for_testing(); |
| 8978 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 8517 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 8979 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 8518 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
| 8980 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 8519 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
| 8981 LayerImpl* child = AddChild<LayerImpl>(render_surface); | 8520 LayerImpl* child = AddChild<LayerImpl>(render_surface); |
| 8982 | 8521 |
| 8983 const gfx::Transform identity_matrix; | 8522 root->SetBounds(gfx::Size(30, 10)); |
| 8523 clip_parent->SetBounds(gfx::Size(30, 30)); |
| 8524 render_surface->SetBounds(gfx::Size(10, 15)); |
| 8525 render_surface->test_properties()->force_render_surface = true; |
| 8526 clip_child->SetBounds(gfx::Size(10, 10)); |
| 8527 clip_child->SetDrawsContent(true); |
| 8528 child->SetBounds(gfx::Size(40, 40)); |
| 8529 child->SetDrawsContent(true); |
| 8984 | 8530 |
| 8985 clip_child->SetDrawsContent(true); | |
| 8986 child->SetDrawsContent(true); | |
| 8987 clip_child->test_properties()->clip_parent = clip_parent; | 8531 clip_child->test_properties()->clip_parent = clip_parent; |
| 8988 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 8532 clip_parent->test_properties()->clip_children = |
| 8989 clip_children->insert(clip_child); | 8533 base::MakeUnique<std::set<LayerImpl*>>(); |
| 8990 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 8534 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 8991 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 8992 gfx::PointF(), gfx::Size(30, 10), true, false, | |
| 8993 true); | |
| 8994 SetLayerPropertiesForTesting(clip_parent, identity_matrix, gfx::Point3F(), | |
| 8995 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 8996 false); | |
| 8997 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | |
| 8998 gfx::PointF(), gfx::Size(10, 15), true, false, | |
| 8999 true); | |
| 9000 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9001 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 9002 false); | |
| 9003 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | |
| 9004 gfx::PointF(), gfx::Size(40, 40), true, false, | |
| 9005 false); | |
| 9006 | 8535 |
| 9007 ExecuteCalculateDrawProperties(root); | 8536 ExecuteCalculateDrawProperties(root); |
| 9008 EXPECT_EQ(gfx::Rect(40, 40), child->visible_layer_rect()); | 8537 EXPECT_EQ(gfx::Rect(40, 40), child->visible_layer_rect()); |
| 9009 } | 8538 } |
| 9010 | 8539 |
| 9011 TEST_F(LayerTreeHostCommonTest, | 8540 TEST_F(LayerTreeHostCommonTest, |
| 9012 RenderSurfaceClipsSubtreeAndHasUnclippedDescendants) { | 8541 RenderSurfaceClipsSubtreeAndHasUnclippedDescendants) { |
| 9013 LayerImpl* root = root_layer_for_testing(); | 8542 LayerImpl* root = root_layer_for_testing(); |
| 9014 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 8543 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 9015 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 8544 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
| 9016 LayerImpl* test_layer1 = AddChild<LayerImpl>(render_surface); | 8545 LayerImpl* test_layer1 = AddChild<LayerImpl>(render_surface); |
| 9017 LayerImpl* clip_child = AddChild<LayerImpl>(test_layer1); | 8546 LayerImpl* clip_child = AddChild<LayerImpl>(test_layer1); |
| 9018 LayerImpl* test_layer2 = AddChild<LayerImpl>(clip_child); | 8547 LayerImpl* test_layer2 = AddChild<LayerImpl>(clip_child); |
| 9019 | 8548 |
| 9020 const gfx::Transform identity_matrix; | 8549 root->SetBounds(gfx::Size(30, 30)); |
| 9021 root->SetMasksToBounds(true); | 8550 root->SetMasksToBounds(true); |
| 8551 clip_parent->SetBounds(gfx::Size(30, 30)); |
| 8552 render_surface->SetBounds(gfx::Size(50, 50)); |
| 9022 render_surface->SetMasksToBounds(true); | 8553 render_surface->SetMasksToBounds(true); |
| 9023 render_surface->SetDrawsContent(true); | 8554 render_surface->SetDrawsContent(true); |
| 8555 render_surface->test_properties()->force_render_surface = true; |
| 8556 test_layer1->SetBounds(gfx::Size(50, 50)); |
| 8557 test_layer1->SetDrawsContent(true); |
| 8558 clip_child->SetBounds(gfx::Size(50, 50)); |
| 9024 clip_child->SetDrawsContent(true); | 8559 clip_child->SetDrawsContent(true); |
| 9025 test_layer1->SetDrawsContent(true); | 8560 test_layer2->SetBounds(gfx::Size(50, 50)); |
| 9026 test_layer2->SetDrawsContent(true); | 8561 test_layer2->SetDrawsContent(true); |
| 8562 |
| 9027 clip_child->test_properties()->clip_parent = clip_parent; | 8563 clip_child->test_properties()->clip_parent = clip_parent; |
| 9028 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 8564 clip_parent->test_properties()->clip_children = |
| 9029 clip_children->insert(clip_child); | 8565 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9030 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 8566 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 9031 | |
| 9032 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 9033 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9034 true); | |
| 9035 SetLayerPropertiesForTesting(clip_parent, identity_matrix, gfx::Point3F(), | |
| 9036 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9037 false); | |
| 9038 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | |
| 9039 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9040 true); | |
| 9041 SetLayerPropertiesForTesting(test_layer1, identity_matrix, gfx::Point3F(), | |
| 9042 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9043 false); | |
| 9044 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9045 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9046 false); | |
| 9047 SetLayerPropertiesForTesting(test_layer2, identity_matrix, gfx::Point3F(), | |
| 9048 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9049 false); | |
| 9050 | 8567 |
| 9051 ExecuteCalculateDrawProperties(root); | 8568 ExecuteCalculateDrawProperties(root); |
| 9052 EXPECT_EQ(gfx::Rect(30, 30), render_surface->visible_layer_rect()); | 8569 EXPECT_EQ(gfx::Rect(30, 30), render_surface->visible_layer_rect()); |
| 9053 EXPECT_EQ(gfx::Rect(30, 30), test_layer1->visible_layer_rect()); | 8570 EXPECT_EQ(gfx::Rect(30, 30), test_layer1->visible_layer_rect()); |
| 9054 EXPECT_EQ(gfx::Rect(30, 30), clip_child->visible_layer_rect()); | 8571 EXPECT_EQ(gfx::Rect(30, 30), clip_child->visible_layer_rect()); |
| 9055 EXPECT_EQ(gfx::Rect(30, 30), test_layer2->visible_layer_rect()); | 8572 EXPECT_EQ(gfx::Rect(30, 30), test_layer2->visible_layer_rect()); |
| 9056 } | 8573 } |
| 9057 | 8574 |
| 9058 TEST_F(LayerTreeHostCommonTest, UnclippedClipParent) { | 8575 TEST_F(LayerTreeHostCommonTest, UnclippedClipParent) { |
| 9059 LayerImpl* root = root_layer_for_testing(); | 8576 LayerImpl* root = root_layer_for_testing(); |
| 9060 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 8577 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 9061 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 8578 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
| 9062 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 8579 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
| 9063 | 8580 |
| 9064 const gfx::Transform identity_matrix; | 8581 root->SetBounds(gfx::Size(50, 50)); |
| 8582 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 9065 clip_parent->SetDrawsContent(true); | 8583 clip_parent->SetDrawsContent(true); |
| 8584 render_surface->SetBounds(gfx::Size(30, 30)); |
| 8585 render_surface->test_properties()->force_render_surface = true; |
| 9066 render_surface->SetMasksToBounds(true); | 8586 render_surface->SetMasksToBounds(true); |
| 9067 render_surface->SetDrawsContent(true); | 8587 render_surface->SetDrawsContent(true); |
| 8588 clip_child->SetBounds(gfx::Size(50, 50)); |
| 9068 clip_child->SetDrawsContent(true); | 8589 clip_child->SetDrawsContent(true); |
| 9069 | 8590 |
| 9070 clip_child->test_properties()->clip_parent = clip_parent; | 8591 clip_child->test_properties()->clip_parent = clip_parent; |
| 9071 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 8592 clip_parent->test_properties()->clip_children = |
| 9072 clip_children->insert(clip_child); | 8593 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9073 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 8594 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 9074 | |
| 9075 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 9076 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9077 true); | |
| 9078 SetLayerPropertiesForTesting(clip_parent, identity_matrix, gfx::Point3F(), | |
| 9079 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9080 false); | |
| 9081 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | |
| 9082 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9083 true); | |
| 9084 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9085 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9086 false); | |
| 9087 | 8595 |
| 9088 ExecuteCalculateDrawProperties(root); | 8596 ExecuteCalculateDrawProperties(root); |
| 9089 | 8597 |
| 9090 // The clip child should inherit its clip parent's clipping state, not its | 8598 // The clip child should inherit its clip parent's clipping state, not its |
| 9091 // tree parent's clipping state. | 8599 // tree parent's clipping state. |
| 9092 EXPECT_FALSE(clip_parent->is_clipped()); | 8600 EXPECT_FALSE(clip_parent->is_clipped()); |
| 9093 EXPECT_TRUE(render_surface->is_clipped()); | 8601 EXPECT_TRUE(render_surface->is_clipped()); |
| 9094 EXPECT_FALSE(clip_child->is_clipped()); | 8602 EXPECT_FALSE(clip_child->is_clipped()); |
| 9095 } | 8603 } |
| 9096 | 8604 |
| 9097 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWithMultipleSurfaces) { | 8605 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWithMultipleSurfaces) { |
| 9098 // Tests the value of render surface content rect when we have multiple types | 8606 // Tests the value of render surface content rect when we have multiple types |
| 9099 // of surfaces : unclipped surfaces, surfaces with unclipped surfaces and | 8607 // of surfaces : unclipped surfaces, surfaces with unclipped surfaces and |
| 9100 // clipped surfaces. | 8608 // clipped surfaces. |
| 9101 LayerImpl* root = root_layer_for_testing(); | 8609 LayerImpl* root = root_layer_for_testing(); |
| 9102 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); | 8610 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); |
| 9103 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); | 8611 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); |
| 9104 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 8612 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); |
| 9105 LayerImpl* unclipped_desc_surface2 = | 8613 LayerImpl* unclipped_desc_surface2 = |
| 9106 AddChild<LayerImpl>(unclipped_desc_surface); | 8614 AddChild<LayerImpl>(unclipped_desc_surface); |
| 9107 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface2); | 8615 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface2); |
| 9108 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child); | 8616 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child); |
| 9109 | 8617 |
| 8618 root->SetBounds(gfx::Size(80, 80)); |
| 8619 unclipped_surface->SetBounds(gfx::Size(50, 50)); |
| 8620 unclipped_surface->SetMasksToBounds(true); |
| 9110 unclipped_surface->SetDrawsContent(true); | 8621 unclipped_surface->SetDrawsContent(true); |
| 8622 unclipped_surface->test_properties()->force_render_surface = true; |
| 8623 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 8624 clip_parent->SetMasksToBounds(true); |
| 8625 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 8626 unclipped_desc_surface->SetMasksToBounds(true); |
| 9111 unclipped_desc_surface->SetDrawsContent(true); | 8627 unclipped_desc_surface->SetDrawsContent(true); |
| 8628 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 8629 unclipped_desc_surface2->SetBounds(gfx::Size(60, 60)); |
| 9112 unclipped_desc_surface2->SetDrawsContent(true); | 8630 unclipped_desc_surface2->SetDrawsContent(true); |
| 8631 unclipped_desc_surface2->test_properties()->force_render_surface = true; |
| 8632 clip_child->SetBounds(gfx::Size(100, 100)); |
| 8633 clipped_surface->SetBounds(gfx::Size(70, 70)); |
| 9113 clipped_surface->SetDrawsContent(true); | 8634 clipped_surface->SetDrawsContent(true); |
| 8635 clipped_surface->test_properties()->force_render_surface = true; |
| 8636 |
| 9114 clip_child->test_properties()->clip_parent = clip_parent; | 8637 clip_child->test_properties()->clip_parent = clip_parent; |
| 9115 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 8638 clip_parent->test_properties()->clip_children = |
| 9116 clip_children->insert(clip_child); | 8639 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9117 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 8640 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 9118 | |
| 9119 gfx::Transform identity_matrix; | |
| 9120 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 9121 gfx::PointF(), gfx::Size(80, 80), true, false, | |
| 9122 true); | |
| 9123 SetLayerPropertiesForTesting(unclipped_surface, identity_matrix, | |
| 9124 gfx::Point3F(), gfx::PointF(), gfx::Size(50, 50), | |
| 9125 true, false, true); | |
| 9126 SetLayerPropertiesForTesting(clip_parent, identity_matrix, gfx::Point3F(), | |
| 9127 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9128 false); | |
| 9129 SetLayerPropertiesForTesting(unclipped_desc_surface, identity_matrix, | |
| 9130 gfx::Point3F(), gfx::PointF(), | |
| 9131 gfx::Size(100, 100), true, false, true); | |
| 9132 SetLayerPropertiesForTesting(unclipped_desc_surface2, identity_matrix, | |
| 9133 gfx::Point3F(), gfx::PointF(), gfx::Size(60, 60), | |
| 9134 true, false, true); | |
| 9135 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9136 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 9137 false); | |
| 9138 SetLayerPropertiesForTesting(clipped_surface, identity_matrix, gfx::Point3F(), | |
| 9139 gfx::PointF(), gfx::Size(70, 70), true, false, | |
| 9140 true); | |
| 9141 clip_parent->SetMasksToBounds(true); | |
| 9142 unclipped_surface->SetMasksToBounds(true); | |
| 9143 unclipped_desc_surface->SetMasksToBounds(true); | |
| 9144 | 8641 |
| 9145 ExecuteCalculateDrawProperties(root); | 8642 ExecuteCalculateDrawProperties(root); |
| 9146 EXPECT_EQ(gfx::Rect(50, 50), | 8643 EXPECT_EQ(gfx::Rect(50, 50), |
| 9147 unclipped_surface->render_surface()->content_rect()); | 8644 unclipped_surface->render_surface()->content_rect()); |
| 9148 EXPECT_EQ(gfx::Rect(50, 50), | 8645 EXPECT_EQ(gfx::Rect(50, 50), |
| 9149 unclipped_desc_surface->render_surface()->content_rect()); | 8646 unclipped_desc_surface->render_surface()->content_rect()); |
| 9150 EXPECT_EQ(gfx::Rect(50, 50), | 8647 EXPECT_EQ(gfx::Rect(50, 50), |
| 9151 unclipped_desc_surface2->render_surface()->content_rect()); | 8648 unclipped_desc_surface2->render_surface()->content_rect()); |
| 9152 EXPECT_EQ(gfx::Rect(50, 50), | 8649 EXPECT_EQ(gfx::Rect(50, 50), |
| 9153 clipped_surface->render_surface()->content_rect()); | 8650 clipped_surface->render_surface()->content_rect()); |
| 9154 } | 8651 } |
| 9155 | 8652 |
| 9156 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { | 8653 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { |
| 9157 // Tests the value of render surface content rect when we have a layer that | 8654 // Tests the value of render surface content rect when we have a layer that |
| 9158 // clips between the clip parent's target and clip child's target. | 8655 // clips between the clip parent's target and clip child's target. |
| 9159 LayerImpl* root = root_layer_for_testing(); | 8656 LayerImpl* root = root_layer_for_testing(); |
| 9160 LayerImpl* surface = AddChildToRoot<LayerImpl>(); | 8657 LayerImpl* surface = AddChildToRoot<LayerImpl>(); |
| 9161 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); | 8658 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); |
| 9162 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | 8659 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); |
| 9163 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 8660 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); |
| 9164 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); | 8661 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); |
| 9165 | 8662 |
| 9166 clip_child->SetDrawsContent(true); | |
| 9167 unclipped_desc_surface->SetDrawsContent(true); | |
| 9168 clip_child->test_properties()->clip_parent = clip_parent; | |
| 9169 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | |
| 9170 clip_children->insert(clip_child); | |
| 9171 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | |
| 9172 | |
| 9173 gfx::Transform identity_matrix; | |
| 9174 gfx::Transform translate; | 8663 gfx::Transform translate; |
| 9175 translate.Translate(10, 10); | 8664 translate.Translate(10, 10); |
| 9176 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8665 |
| 9177 gfx::PointF(), gfx::Size(100, 100), true, false, | 8666 root->SetBounds(gfx::Size(100, 100)); |
| 9178 true); | 8667 surface->SetBounds(gfx::Size(100, 100)); |
| 9179 SetLayerPropertiesForTesting(surface, identity_matrix, gfx::Point3F(), | |
| 9180 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 9181 true); | |
| 9182 SetLayerPropertiesForTesting(clip_layer, identity_matrix, gfx::Point3F(), | |
| 9183 gfx::PointF(), gfx::Size(20, 20), true, false, | |
| 9184 false); | |
| 9185 SetLayerPropertiesForTesting(clip_parent, identity_matrix, gfx::Point3F(), | |
| 9186 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9187 false); | |
| 9188 SetLayerPropertiesForTesting(unclipped_desc_surface, translate, | |
| 9189 gfx::Point3F(), gfx::PointF(), | |
| 9190 gfx::Size(100, 100), true, false, true); | |
| 9191 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9192 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 9193 false); | |
| 9194 surface->SetMasksToBounds(true); | 8668 surface->SetMasksToBounds(true); |
| 8669 surface->test_properties()->force_render_surface = true; |
| 8670 clip_layer->SetBounds(gfx::Size(20, 20)); |
| 9195 clip_layer->SetMasksToBounds(true); | 8671 clip_layer->SetMasksToBounds(true); |
| 8672 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 8673 unclipped_desc_surface->SetTransform(translate); |
| 8674 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 8675 unclipped_desc_surface->SetDrawsContent(true); |
| 8676 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 8677 clip_child->SetBounds(gfx::Size(100, 100)); |
| 8678 clip_child->SetDrawsContent(true); |
| 8679 |
| 8680 clip_child->test_properties()->clip_parent = clip_parent; |
| 8681 clip_parent->test_properties()->clip_children = |
| 8682 base::MakeUnique<std::set<LayerImpl*>>(); |
| 8683 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 9196 | 8684 |
| 9197 ExecuteCalculateDrawProperties(root); | 8685 ExecuteCalculateDrawProperties(root); |
| 9198 | 8686 |
| 9199 EXPECT_EQ(gfx::Rect(10, 10), | 8687 EXPECT_EQ(gfx::Rect(10, 10), |
| 9200 unclipped_desc_surface->render_surface()->content_rect()); | 8688 unclipped_desc_surface->render_surface()->content_rect()); |
| 9201 } | 8689 } |
| 9202 | 8690 |
| 9203 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) { | 8691 TEST_F(LayerTreeHostCommonTest, VisibleRectForDescendantOfScaledSurface) { |
| 9204 LayerImpl* root = root_layer_for_testing(); | 8692 LayerImpl* root = root_layer_for_testing(); |
| 9205 LayerImpl* surface = AddChildToRoot<LayerImpl>(); | 8693 LayerImpl* surface = AddChildToRoot<LayerImpl>(); |
| 9206 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); | 8694 LayerImpl* clip_layer = AddChild<LayerImpl>(surface); |
| 9207 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | 8695 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); |
| 9208 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 8696 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); |
| 9209 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); | 8697 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); |
| 9210 | 8698 |
| 9211 clip_child->SetDrawsContent(true); | |
| 9212 unclipped_desc_surface->SetDrawsContent(true); | |
| 9213 clip_child->test_properties()->clip_parent = clip_parent; | |
| 9214 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | |
| 9215 clip_children->insert(clip_child); | |
| 9216 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | |
| 9217 | 8699 |
| 9218 gfx::Transform identity_matrix; | |
| 9219 gfx::Transform scale; | 8700 gfx::Transform scale; |
| 9220 scale.Scale(2, 2); | 8701 scale.Scale(2, 2); |
| 9221 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8702 |
| 9222 gfx::PointF(), gfx::Size(100, 100), true, false, | 8703 root->SetBounds(gfx::Size(100, 100)); |
| 9223 true); | 8704 surface->SetTransform(scale); |
| 9224 SetLayerPropertiesForTesting(surface, scale, gfx::Point3F(), gfx::PointF(), | 8705 surface->SetBounds(gfx::Size(100, 100)); |
| 9225 gfx::Size(100, 100), true, false, true); | |
| 9226 SetLayerPropertiesForTesting(clip_layer, identity_matrix, gfx::Point3F(), | |
| 9227 gfx::PointF(), gfx::Size(20, 20), true, false, | |
| 9228 false); | |
| 9229 SetLayerPropertiesForTesting(clip_parent, identity_matrix, gfx::Point3F(), | |
| 9230 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9231 false); | |
| 9232 SetLayerPropertiesForTesting(unclipped_desc_surface, identity_matrix, | |
| 9233 gfx::Point3F(), gfx::PointF(), | |
| 9234 gfx::Size(100, 100), true, false, true); | |
| 9235 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9236 gfx::PointF(), gfx::Size(100, 100), true, false, | |
| 9237 false); | |
| 9238 surface->SetMasksToBounds(true); | 8706 surface->SetMasksToBounds(true); |
| 8707 surface->test_properties()->force_render_surface = true; |
| 8708 clip_layer->SetBounds(gfx::Size(20, 20)); |
| 9239 clip_layer->SetMasksToBounds(true); | 8709 clip_layer->SetMasksToBounds(true); |
| 8710 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 8711 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 8712 unclipped_desc_surface->SetDrawsContent(true); |
| 8713 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 8714 clip_child->SetBounds(gfx::Size(100, 100)); |
| 8715 clip_child->SetDrawsContent(true); |
| 8716 |
| 8717 clip_child->test_properties()->clip_parent = clip_parent; |
| 8718 clip_parent->test_properties()->clip_children = |
| 8719 base::MakeUnique<std::set<LayerImpl*>>(); |
| 8720 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 9240 | 8721 |
| 9241 ExecuteCalculateDrawProperties(root); | 8722 ExecuteCalculateDrawProperties(root); |
| 9242 | 8723 |
| 9243 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); | 8724 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); |
| 9244 } | 8725 } |
| 9245 | 8726 |
| 9246 TEST_F(LayerTreeHostCommonTest, LayerWithInputHandlerAndZeroOpacity) { | 8727 TEST_F(LayerTreeHostCommonTest, LayerWithInputHandlerAndZeroOpacity) { |
| 9247 LayerImpl* root = root_layer_for_testing(); | 8728 LayerImpl* root = root_layer_for_testing(); |
| 9248 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 8729 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 9249 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 8730 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 9250 | 8731 |
| 9251 const gfx::Transform identity_matrix; | |
| 9252 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 9253 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9254 true); | |
| 9255 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | |
| 9256 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9257 true); | |
| 9258 gfx::Transform translation; | 8732 gfx::Transform translation; |
| 9259 translation.Translate(10, 10); | 8733 translation.Translate(10, 10); |
| 9260 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), | |
| 9261 gfx::PointF(), gfx::Size(20, 20), true, false, | |
| 9262 false); | |
| 9263 | 8734 |
| 8735 root->SetBounds(gfx::Size(30, 30)); |
| 8736 render_surface->SetBounds(gfx::Size(30, 30)); |
| 9264 render_surface->SetMasksToBounds(true); | 8737 render_surface->SetMasksToBounds(true); |
| 8738 render_surface->test_properties()->force_render_surface = true; |
| 8739 test_layer->SetTransform(translation); |
| 8740 test_layer->SetBounds(gfx::Size(20, 20)); |
| 9265 test_layer->SetDrawsContent(true); | 8741 test_layer->SetDrawsContent(true); |
| 8742 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); |
| 9266 test_layer->test_properties()->opacity = 0.f; | 8743 test_layer->test_properties()->opacity = 0.f; |
| 9267 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); | |
| 9268 | 8744 |
| 9269 ExecuteCalculateDrawProperties(root); | 8745 ExecuteCalculateDrawProperties(root); |
| 9270 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, | 8746 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, |
| 9271 test_layer->ScreenSpaceTransform()); | 8747 test_layer->ScreenSpaceTransform()); |
| 9272 } | 8748 } |
| 9273 | 8749 |
| 9274 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 8750 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
| 9275 LayerImpl* root = root_layer_for_testing(); | 8751 LayerImpl* root = root_layer_for_testing(); |
| 9276 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 8752 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 9277 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 8753 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
| 9278 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 8754 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
| 9279 | 8755 |
| 9280 const gfx::Transform identity_matrix; | 8756 root->SetBounds(gfx::Size(30, 30)); |
| 8757 clip_parent->SetBounds(gfx::Size(40, 40)); |
| 9281 clip_parent->SetMasksToBounds(true); | 8758 clip_parent->SetMasksToBounds(true); |
| 8759 render_surface->SetBounds(gfx::Size(50, 50)); |
| 9282 render_surface->SetMasksToBounds(true); | 8760 render_surface->SetMasksToBounds(true); |
| 9283 render_surface->SetDrawsContent(true); | 8761 render_surface->SetDrawsContent(true); |
| 8762 render_surface->test_properties()->force_render_surface = true; |
| 8763 clip_child->SetBounds(gfx::Size(50, 50)); |
| 9284 clip_child->SetDrawsContent(true); | 8764 clip_child->SetDrawsContent(true); |
| 8765 |
| 9285 clip_child->test_properties()->clip_parent = clip_parent; | 8766 clip_child->test_properties()->clip_parent = clip_parent; |
| 9286 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 8767 clip_parent->test_properties()->clip_children = |
| 9287 clip_children->insert(clip_child); | 8768 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9288 clip_parent->test_properties()->clip_children.reset(clip_children.release()); | 8769 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 9289 | |
| 9290 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 9291 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9292 true); | |
| 9293 SetLayerPropertiesForTesting(clip_parent, identity_matrix, gfx::Point3F(), | |
| 9294 gfx::PointF(10.f, 10.f), gfx::Size(40, 40), true, | |
| 9295 false, false); | |
| 9296 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | |
| 9297 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9298 true); | |
| 9299 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9300 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9301 false); | |
| 9302 | 8770 |
| 9303 ExecuteCalculateDrawProperties(root); | 8771 ExecuteCalculateDrawProperties(root); |
| 9304 EXPECT_EQ(gfx::Rect(40, 40), clip_child->visible_layer_rect()); | 8772 EXPECT_EQ(gfx::Rect(40, 40), clip_child->visible_layer_rect()); |
| 9305 } | 8773 } |
| 9306 | 8774 |
| 9307 TEST_F(LayerTreeHostCommonTest, | 8775 TEST_F(LayerTreeHostCommonTest, |
| 9308 LayerClipRectLargerThanClippingRenderSurfaceRect) { | 8776 LayerClipRectLargerThanClippingRenderSurfaceRect) { |
| 9309 LayerImpl* root = root_layer_for_testing(); | 8777 LayerImpl* root = root_layer_for_testing(); |
| 9310 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 8778 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 9311 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 8779 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 9312 const gfx::Transform identity_matrix; | 8780 |
| 9313 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8781 root->SetBounds(gfx::Size(30, 30)); |
| 9314 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9315 true); | |
| 9316 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | |
| 9317 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9318 true); | |
| 9319 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | |
| 9320 gfx::PointF(), gfx::Size(50, 50), true, false, | |
| 9321 false); | |
| 9322 root->SetMasksToBounds(true); | 8782 root->SetMasksToBounds(true); |
| 9323 root->SetDrawsContent(true); | 8783 root->SetDrawsContent(true); |
| 8784 render_surface->SetBounds(gfx::Size(50, 50)); |
| 9324 render_surface->SetMasksToBounds(true); | 8785 render_surface->SetMasksToBounds(true); |
| 9325 render_surface->SetDrawsContent(true); | 8786 render_surface->SetDrawsContent(true); |
| 8787 render_surface->test_properties()->force_render_surface = true; |
| 8788 test_layer->SetBounds(gfx::Size(50, 50)); |
| 9326 test_layer->SetMasksToBounds(true); | 8789 test_layer->SetMasksToBounds(true); |
| 9327 test_layer->SetDrawsContent(true); | 8790 test_layer->SetDrawsContent(true); |
| 9328 ExecuteCalculateDrawProperties(root); | 8791 ExecuteCalculateDrawProperties(root); |
| 9329 | 8792 |
| 9330 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); | 8793 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); |
| 9331 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); | 8794 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); |
| 9332 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); | 8795 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); |
| 9333 } | 8796 } |
| 9334 | 8797 |
| 9335 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { | 8798 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { |
| 9336 // Tests that subtree is hidden is updated. | 8799 // Tests that subtree is hidden is updated. |
| 9337 LayerImpl* root = root_layer_for_testing(); | 8800 LayerImpl* root = root_layer_for_testing(); |
| 9338 LayerImpl* hidden = AddChild<LayerImpl>(root); | 8801 LayerImpl* hidden = AddChild<LayerImpl>(root); |
| 9339 LayerImpl* test = AddChild<LayerImpl>(hidden); | 8802 LayerImpl* test = AddChild<LayerImpl>(hidden); |
| 9340 | 8803 |
| 9341 const gfx::Transform identity_matrix; | 8804 root->SetBounds(gfx::Size(30, 30)); |
| 9342 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8805 hidden->SetBounds(gfx::Size(30, 30)); |
| 9343 gfx::PointF(), gfx::Size(30, 30), true, false, | 8806 hidden->test_properties()->force_render_surface = true; |
| 9344 true); | 8807 hidden->test_properties()->hide_layer_and_subtree = true; |
| 9345 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), | 8808 test->SetBounds(gfx::Size(30, 30)); |
| 9346 gfx::PointF(10, 10), gfx::Size(30, 30), true, | 8809 test->test_properties()->force_render_surface = true; |
| 9347 false, true); | |
| 9348 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), | |
| 9349 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9350 true); | |
| 9351 | 8810 |
| 9352 hidden->test_properties()->hide_layer_and_subtree = true; | |
| 9353 ExecuteCalculateDrawProperties(root); | 8811 ExecuteCalculateDrawProperties(root); |
| 9354 EXPECT_TRUE(test->IsHidden()); | 8812 EXPECT_TRUE(test->IsHidden()); |
| 9355 | 8813 |
| 9356 hidden->test_properties()->hide_layer_and_subtree = false; | 8814 hidden->test_properties()->hide_layer_and_subtree = false; |
| 9357 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8815 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9358 ExecuteCalculateDrawProperties(root); | 8816 ExecuteCalculateDrawProperties(root); |
| 9359 EXPECT_FALSE(test->IsHidden()); | 8817 EXPECT_FALSE(test->IsHidden()); |
| 9360 } | 8818 } |
| 9361 | 8819 |
| 9362 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 8820 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 9363 LayerImpl* root = root_layer_for_testing(); | 8821 LayerImpl* root = root_layer_for_testing(); |
| 9364 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 8822 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9365 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 8823 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 9366 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 8824 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 9367 | 8825 |
| 9368 const gfx::Transform identity_matrix; | 8826 root->SetBounds(gfx::Size(30, 30)); |
| 8827 root->SetMasksToBounds(true); |
| 8828 render_surface1->SetPosition(gfx::PointF(10, 10)); |
| 8829 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 8830 render_surface1->SetDrawsContent(true); |
| 8831 render_surface1->test_properties()->force_render_surface = true; |
| 8832 render_surface2->SetBounds(gfx::Size(30, 30)); |
| 8833 render_surface2->SetDrawsContent(true); |
| 8834 render_surface2->test_properties()->force_render_surface = true; |
| 8835 clip_child->SetBounds(gfx::Size(30, 30)); |
| 8836 |
| 9369 clip_child->test_properties()->clip_parent = root; | 8837 clip_child->test_properties()->clip_parent = root; |
| 9370 std::unique_ptr<std::set<LayerImpl*>> clip_children(new std::set<LayerImpl*>); | 8838 root->test_properties()->clip_children = |
| 9371 clip_children->insert(clip_child); | 8839 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9372 root->test_properties()->clip_children.reset(clip_children.release()); | 8840 root->test_properties()->clip_children->insert(clip_child); |
| 9373 root->SetMasksToBounds(true); | |
| 9374 render_surface1->SetDrawsContent(true); | |
| 9375 render_surface2->SetDrawsContent(true); | |
| 9376 | 8841 |
| 9377 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 9378 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9379 true); | |
| 9380 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), | |
| 9381 gfx::PointF(10, 10), gfx::Size(30, 30), true, | |
| 9382 false, true); | |
| 9383 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(), | |
| 9384 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9385 true); | |
| 9386 SetLayerPropertiesForTesting(clip_child, identity_matrix, gfx::Point3F(), | |
| 9387 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9388 false); | |
| 9389 ExecuteCalculateDrawProperties(root); | 8842 ExecuteCalculateDrawProperties(root); |
| 9390 | 8843 |
| 9391 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); | 8844 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); |
| 9392 // A clip node is created for every render surface and for layers that have | 8845 // A clip node is created for every render surface and for layers that have |
| 9393 // local clip. So, here it should be craeted for every layer. | 8846 // local clip. So, here it should be craeted for every layer. |
| 9394 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u); | 8847 EXPECT_EQ(root->layer_tree_impl()->property_trees()->clip_tree.size(), 5u); |
| 9395 } | 8848 } |
| 9396 | 8849 |
| 9397 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) { | 8850 TEST_F(LayerTreeHostCommonTest, MaskLayerDrawProperties) { |
| 9398 // Tests that a mask layer's draw properties are computed correctly. | 8851 // Tests that a mask layer's draw properties are computed correctly. |
| 9399 LayerImpl* root = root_layer_for_testing(); | 8852 LayerImpl* root = root_layer_for_testing(); |
| 9400 LayerImpl* child = AddChild<LayerImpl>(root); | 8853 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9401 child->test_properties()->SetMaskLayer( | 8854 child->test_properties()->SetMaskLayer( |
| 9402 LayerImpl::Create(root->layer_tree_impl(), 100)); | 8855 LayerImpl::Create(root->layer_tree_impl(), 100)); |
| 9403 LayerImpl* mask = child->test_properties()->mask_layer; | 8856 LayerImpl* mask = child->test_properties()->mask_layer; |
| 9404 | 8857 |
| 9405 const gfx::Transform identity_matrix; | |
| 9406 gfx::Transform transform; | 8858 gfx::Transform transform; |
| 9407 transform.Translate(10, 10); | 8859 transform.Translate(10, 10); |
| 9408 | 8860 |
| 9409 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8861 root->SetBounds(gfx::Size(40, 40)); |
| 9410 gfx::PointF(), gfx::Size(40, 40), true, false, | |
| 9411 true); | |
| 9412 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), | |
| 9413 gfx::Size(30, 30), true, false, false); | |
| 9414 SetLayerPropertiesForTesting(mask, identity_matrix, gfx::Point3F(), | |
| 9415 gfx::PointF(), gfx::Size(20, 20), true, false, | |
| 9416 false); | |
| 9417 root->SetDrawsContent(true); | 8862 root->SetDrawsContent(true); |
| 8863 child->SetTransform(transform); |
| 8864 child->SetBounds(gfx::Size(30, 30)); |
| 9418 child->SetDrawsContent(false); | 8865 child->SetDrawsContent(false); |
| 8866 mask->SetBounds(gfx::Size(20, 20)); |
| 9419 ExecuteCalculateDrawProperties(root); | 8867 ExecuteCalculateDrawProperties(root); |
| 9420 | 8868 |
| 9421 // The render surface created for the mask has no contributing content, so the | 8869 // The render surface created for the mask has no contributing content, so the |
| 9422 // mask isn't a drawn RSLL member. This means it has an empty visible rect, | 8870 // mask isn't a drawn RSLL member. This means it has an empty visible rect, |
| 9423 // but its screen space transform can still be computed correctly on-demand. | 8871 // but its screen space transform can still be computed correctly on-demand. |
| 9424 EXPECT_FALSE(mask->is_drawn_render_surface_layer_list_member()); | 8872 EXPECT_FALSE(mask->is_drawn_render_surface_layer_list_member()); |
| 9425 EXPECT_EQ(gfx::Rect(), mask->visible_layer_rect()); | 8873 EXPECT_EQ(gfx::Rect(), mask->visible_layer_rect()); |
| 9426 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); | 8874 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, mask->ScreenSpaceTransform()); |
| 9427 | 8875 |
| 9428 // Make the child's render surface have contributing content. | 8876 // Make the child's render surface have contributing content. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9446 LayerImpl* root = root_layer_for_testing(); | 8894 LayerImpl* root = root_layer_for_testing(); |
| 9447 LayerImpl* child = AddChild<LayerImpl>(root); | 8895 LayerImpl* child = AddChild<LayerImpl>(root); |
| 9448 child->test_properties()->SetReplicaLayer( | 8896 child->test_properties()->SetReplicaLayer( |
| 9449 LayerImpl::Create(root->layer_tree_impl(), 100)); | 8897 LayerImpl::Create(root->layer_tree_impl(), 100)); |
| 9450 LayerImpl* replica = child->test_properties()->replica_layer; | 8898 LayerImpl* replica = child->test_properties()->replica_layer; |
| 9451 replica->test_properties()->parent = child; | 8899 replica->test_properties()->parent = child; |
| 9452 replica->test_properties()->SetMaskLayer( | 8900 replica->test_properties()->SetMaskLayer( |
| 9453 LayerImpl::Create(root->layer_tree_impl(), 200)); | 8901 LayerImpl::Create(root->layer_tree_impl(), 200)); |
| 9454 LayerImpl* replica_mask = replica->test_properties()->mask_layer; | 8902 LayerImpl* replica_mask = replica->test_properties()->mask_layer; |
| 9455 | 8903 |
| 9456 const gfx::Transform identity_matrix; | |
| 9457 gfx::Transform transform; | 8904 gfx::Transform transform; |
| 9458 transform.Translate(10, 10); | 8905 transform.Translate(10, 10); |
| 9459 | 8906 |
| 9460 gfx::PointF replica_position(3.f, 3.f); | 8907 gfx::PointF replica_position(3.f, 3.f); |
| 9461 | 8908 |
| 9462 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8909 root->SetBounds(gfx::Size(40, 40)); |
| 9463 gfx::PointF(), gfx::Size(40, 40), true, false, | |
| 9464 true); | |
| 9465 SetLayerPropertiesForTesting(child, transform, gfx::Point3F(), gfx::PointF(), | |
| 9466 gfx::Size(30, 30), true, false, false); | |
| 9467 SetLayerPropertiesForTesting(replica, identity_matrix, gfx::Point3F(), | |
| 9468 replica_position, gfx::Size(30, 30), true, false, | |
| 9469 false); | |
| 9470 SetLayerPropertiesForTesting(replica_mask, identity_matrix, gfx::Point3F(), | |
| 9471 gfx::PointF(), gfx::Size(20, 20), true, false, | |
| 9472 false); | |
| 9473 root->SetDrawsContent(true); | 8910 root->SetDrawsContent(true); |
| 9474 child->SetDrawsContent(false); | 8911 child->SetTransform(transform); |
| 8912 child->SetBounds(gfx::Size(30, 30)); |
| 8913 replica->SetPosition(replica_position); |
| 8914 replica_mask->SetBounds(gfx::Size(20, 20)); |
| 8915 |
| 9475 ExecuteCalculateDrawProperties(root); | 8916 ExecuteCalculateDrawProperties(root); |
| 9476 | 8917 |
| 9477 // The render surface created for the replica has no contributing content, so | 8918 // The render surface created for the replica has no contributing content, so |
| 9478 // the replica's mask isn't a drawn RSLL member. This means it has an empty | 8919 // the replica's mask isn't a drawn RSLL member. This means it has an empty |
| 9479 // visible rect, but its screen space transform can still be computed | 8920 // visible rect, but its screen space transform can still be computed |
| 9480 // correctly on-demand. | 8921 // correctly on-demand. |
| 9481 EXPECT_FALSE(replica_mask->is_drawn_render_surface_layer_list_member()); | 8922 EXPECT_FALSE(replica_mask->is_drawn_render_surface_layer_list_member()); |
| 9482 EXPECT_EQ(gfx::Rect(), replica_mask->visible_layer_rect()); | 8923 EXPECT_EQ(gfx::Rect(), replica_mask->visible_layer_rect()); |
| 9483 | 8924 |
| 9484 gfx::Transform expected_screen_space_transform = transform; | 8925 gfx::Transform expected_screen_space_transform = transform; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 9498 replica_mask->ScreenSpaceTransform()); | 8939 replica_mask->ScreenSpaceTransform()); |
| 9499 } | 8940 } |
| 9500 | 8941 |
| 9501 TEST_F(LayerTreeHostCommonTest, | 8942 TEST_F(LayerTreeHostCommonTest, |
| 9502 SublayerScaleWithTransformNodeBetweenTwoTargets) { | 8943 SublayerScaleWithTransformNodeBetweenTwoTargets) { |
| 9503 LayerImpl* root = root_layer_for_testing(); | 8944 LayerImpl* root = root_layer_for_testing(); |
| 9504 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 8945 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9505 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); | 8946 LayerImpl* between_targets = AddChild<LayerImpl>(render_surface1); |
| 9506 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); | 8947 LayerImpl* render_surface2 = AddChild<LayerImpl>(between_targets); |
| 9507 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); | 8948 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface2); |
| 9508 const gfx::Transform identity_matrix; | |
| 9509 test_layer->SetDrawsContent(true); | |
| 9510 | 8949 |
| 9511 gfx::Transform scale; | 8950 gfx::Transform scale; |
| 9512 scale.Scale(2.f, 2.f); | 8951 scale.Scale(2.f, 2.f); |
| 9513 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8952 |
| 9514 gfx::PointF(), gfx::Size(30, 30), true, false, | 8953 root->SetBounds(gfx::Size(30, 30)); |
| 9515 true); | 8954 render_surface1->SetTransform(scale); |
| 9516 SetLayerPropertiesForTesting(render_surface1, scale, gfx::Point3F(), | 8955 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 9517 gfx::PointF(), gfx::Size(30, 30), true, false, | 8956 render_surface1->test_properties()->force_render_surface = true; |
| 9518 true); | 8957 between_targets->SetBounds(gfx::Size(30, 30)); |
| 9519 SetLayerPropertiesForTesting(between_targets, identity_matrix, gfx::Point3F(), | 8958 render_surface2->SetBounds(gfx::Size(30, 30)); |
| 9520 gfx::PointF(), gfx::Size(30, 30), true, false, | 8959 render_surface2->test_properties()->force_render_surface = true; |
| 9521 false); | 8960 test_layer->SetBounds(gfx::Size(30, 30)); |
| 9522 SetLayerPropertiesForTesting(render_surface2, identity_matrix, gfx::Point3F(), | 8961 test_layer->SetDrawsContent(true); |
| 9523 gfx::PointF(), gfx::Size(30, 30), true, false, | 8962 |
| 9524 true); | |
| 9525 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | |
| 9526 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9527 false); | |
| 9528 // We want layer between the two targets to create a clip node and transform | 8963 // We want layer between the two targets to create a clip node and transform |
| 9529 // node but it shouldn't create a render surface. | 8964 // node but it shouldn't create a render surface. |
| 9530 between_targets->SetMasksToBounds(true); | 8965 between_targets->SetMasksToBounds(true); |
| 9531 between_targets->Set3dSortingContextId(2); | 8966 between_targets->Set3dSortingContextId(2); |
| 9532 | 8967 |
| 9533 ExecuteCalculateDrawProperties(root); | 8968 ExecuteCalculateDrawProperties(root); |
| 9534 | 8969 |
| 9535 TransformTree& tree = | 8970 TransformTree& tree = |
| 9536 root->layer_tree_impl()->property_trees()->transform_tree; | 8971 root->layer_tree_impl()->property_trees()->transform_tree; |
| 9537 TransformNode* node = tree.Node(render_surface1->transform_tree_index()); | 8972 TransformNode* node = tree.Node(render_surface1->transform_tree_index()); |
| 9538 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(2.f, 2.f)); | 8973 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9539 | 8974 |
| 9540 node = tree.Node(between_targets->transform_tree_index()); | 8975 node = tree.Node(between_targets->transform_tree_index()); |
| 9541 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(1.f, 1.f)); | 8976 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(1.f, 1.f)); |
| 9542 | 8977 |
| 9543 node = tree.Node(render_surface2->transform_tree_index()); | 8978 node = tree.Node(render_surface2->transform_tree_index()); |
| 9544 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(2.f, 2.f)); | 8979 EXPECT_EQ(node->surface_contents_scale, gfx::Vector2dF(2.f, 2.f)); |
| 9545 | 8980 |
| 9546 EXPECT_EQ(gfx::Rect(15, 15), test_layer->visible_layer_rect()); | 8981 EXPECT_EQ(gfx::Rect(15, 15), test_layer->visible_layer_rect()); |
| 9547 } | 8982 } |
| 9548 | 8983 |
| 9549 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { | 8984 TEST_F(LayerTreeHostCommonTest, LargeTransformTest) { |
| 9550 LayerImpl* root = root_layer_for_testing(); | 8985 LayerImpl* root = root_layer_for_testing(); |
| 9551 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 8986 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9552 LayerImpl* child = AddChild<LayerImpl>(render_surface1); | 8987 LayerImpl* child = AddChild<LayerImpl>(render_surface1); |
| 9553 | 8988 |
| 9554 const gfx::Transform identity_matrix; | |
| 9555 child->SetDrawsContent(true); | 8989 child->SetDrawsContent(true); |
| 9556 child->SetMasksToBounds(true); | 8990 child->SetMasksToBounds(true); |
| 9557 | 8991 |
| 9558 gfx::Transform large_transform; | 8992 gfx::Transform large_transform; |
| 9559 large_transform.Scale(99999999999999999999.f, 99999999999999999999.f); | 8993 large_transform.Scale(99999999999999999999.f, 99999999999999999999.f); |
| 9560 large_transform.Scale(9999999999999999999.f, 9999999999999999999.f); | 8994 large_transform.Scale(9999999999999999999.f, 9999999999999999999.f); |
| 9561 EXPECT_TRUE(std::isinf(large_transform.matrix().get(0, 0))); | 8995 EXPECT_TRUE(std::isinf(large_transform.matrix().get(0, 0))); |
| 9562 EXPECT_TRUE(std::isinf(large_transform.matrix().get(1, 1))); | 8996 EXPECT_TRUE(std::isinf(large_transform.matrix().get(1, 1))); |
| 9563 | 8997 |
| 9564 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 8998 root->SetBounds(gfx::Size(30, 30)); |
| 9565 gfx::PointF(), gfx::Size(30, 30), true, false, | 8999 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 9566 true); | 9000 render_surface1->test_properties()->force_render_surface = true; |
| 9567 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), | 9001 |
| 9568 gfx::PointF(), gfx::Size(30, 30), true, false, | |
| 9569 true); | |
| 9570 // TODO(sunxd): we make child have no render surface, because if the | 9002 // TODO(sunxd): we make child have no render surface, because if the |
| 9571 // child has one, the large transform applied to child will result in NaNs in | 9003 // child has one, the large transform applied to child will result in NaNs in |
| 9572 // the draw_transform of the render_surface, thus make draw property updates | 9004 // the draw_transform of the render_surface, thus make draw property updates |
| 9573 // skip the child layer. We need further investigation into this to know | 9005 // skip the child layer. We need further investigation into this to know |
| 9574 // what exactly happens here. | 9006 // what exactly happens here. |
| 9575 SetLayerPropertiesForTesting(child, large_transform, gfx::Point3F(), | 9007 child->SetTransform(large_transform); |
| 9576 gfx::PointF(), gfx::Size(30, 30), true, false, | 9008 child->SetBounds(gfx::Size(30, 30)); |
| 9577 false); | |
| 9578 | 9009 |
| 9579 ExecuteCalculateDrawProperties(root); | 9010 ExecuteCalculateDrawProperties(root); |
| 9580 | 9011 |
| 9581 EXPECT_EQ(gfx::RectF(), | 9012 EXPECT_EQ(gfx::RectF(), |
| 9582 render_surface1->render_surface()->DrawableContentRect()); | 9013 render_surface1->render_surface()->DrawableContentRect()); |
| 9583 | 9014 |
| 9584 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || | 9015 bool is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(0, 0)) || |
| 9585 std::isnan(child->DrawTransform().matrix().get(0, 0)); | 9016 std::isnan(child->DrawTransform().matrix().get(0, 0)); |
| 9586 EXPECT_TRUE(is_inf_or_nan); | 9017 EXPECT_TRUE(is_inf_or_nan); |
| 9587 | 9018 |
| 9588 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || | 9019 is_inf_or_nan = std::isinf(child->DrawTransform().matrix().get(1, 1)) || |
| 9589 std::isnan(child->DrawTransform().matrix().get(1, 1)); | 9020 std::isnan(child->DrawTransform().matrix().get(1, 1)); |
| 9590 EXPECT_TRUE(is_inf_or_nan); | 9021 EXPECT_TRUE(is_inf_or_nan); |
| 9591 | 9022 |
| 9592 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); | 9023 std::vector<LayerImpl*>* rsll = render_surface_layer_list_impl(); |
| 9593 bool root_in_rsll = | 9024 bool root_in_rsll = |
| 9594 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); | 9025 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); |
| 9595 EXPECT_TRUE(root_in_rsll); | 9026 EXPECT_TRUE(root_in_rsll); |
| 9596 } | 9027 } |
| 9597 | 9028 |
| 9598 TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) { | 9029 TEST_F(LayerTreeHostCommonTest, PropertyTreesRebuildWithOpacityChanges) { |
| 9599 const gfx::Transform identity_matrix; | |
| 9600 scoped_refptr<Layer> root = Layer::Create(); | 9030 scoped_refptr<Layer> root = Layer::Create(); |
| 9601 scoped_refptr<LayerWithForcedDrawsContent> child = | 9031 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 9602 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9032 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9603 root->AddChild(child); | 9033 root->AddChild(child); |
| 9604 | |
| 9605 host()->SetRootLayer(root); | 9034 host()->SetRootLayer(root); |
| 9606 | 9035 |
| 9607 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9036 root->SetBounds(gfx::Size(100, 100)); |
| 9608 gfx::PointF(), gfx::Size(100, 100), true, false); | 9037 child->SetBounds(gfx::Size(20, 20)); |
| 9609 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | |
| 9610 gfx::PointF(), gfx::Size(20, 20), true, false); | |
| 9611 | |
| 9612 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9038 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9613 | 9039 |
| 9614 // Changing the opacity from 1 to non-1 value should trigger rebuild of | 9040 // Changing the opacity from 1 to non-1 value should trigger rebuild of |
| 9615 // property trees as a new effect node will be created. | 9041 // property trees as a new effect node will be created. |
| 9616 child->SetOpacity(0.5f); | 9042 child->SetOpacity(0.5f); |
| 9617 PropertyTrees* property_trees = host()->property_trees(); | 9043 PropertyTrees* property_trees = host()->property_trees(); |
| 9618 EXPECT_TRUE(property_trees->needs_rebuild); | 9044 EXPECT_TRUE(property_trees->needs_rebuild); |
| 9619 | 9045 |
| 9620 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9046 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9621 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), | 9047 EXPECT_NE(property_trees->effect_id_to_index_map.find(child->id()), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 9636 child->SetOpacity(1.f); | 9062 child->SetOpacity(1.f); |
| 9637 property_trees = host()->property_trees(); | 9063 property_trees = host()->property_trees(); |
| 9638 EXPECT_TRUE(property_trees->needs_rebuild); | 9064 EXPECT_TRUE(property_trees->needs_rebuild); |
| 9639 | 9065 |
| 9640 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 9066 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 9641 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), | 9067 EXPECT_EQ(property_trees->effect_id_to_index_map.find(child->id()), |
| 9642 property_trees->effect_id_to_index_map.end()); | 9068 property_trees->effect_id_to_index_map.end()); |
| 9643 } | 9069 } |
| 9644 | 9070 |
| 9645 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { | 9071 TEST_F(LayerTreeHostCommonTest, OpacityAnimationsTrackingTest) { |
| 9646 const gfx::Transform identity_matrix; | |
| 9647 scoped_refptr<Layer> root = Layer::Create(); | 9072 scoped_refptr<Layer> root = Layer::Create(); |
| 9648 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9073 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 9649 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9074 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9650 root->AddChild(animated); | 9075 root->AddChild(animated); |
| 9651 | |
| 9652 host()->SetRootLayer(root); | 9076 host()->SetRootLayer(root); |
| 9653 | |
| 9654 host()->SetElementIdsForTesting(); | 9077 host()->SetElementIdsForTesting(); |
| 9655 | 9078 |
| 9656 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9079 root->SetBounds(gfx::Size(100, 100)); |
| 9657 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 9658 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | |
| 9659 gfx::PointF(), gfx::Size(20, 20), true, false); | |
| 9660 | |
| 9661 root->SetForceRenderSurfaceForTesting(true); | 9080 root->SetForceRenderSurfaceForTesting(true); |
| 9081 animated->SetBounds(gfx::Size(20, 20)); |
| 9662 animated->SetOpacity(0.f); | 9082 animated->SetOpacity(0.f); |
| 9663 | 9083 |
| 9664 scoped_refptr<AnimationPlayer> player = | 9084 scoped_refptr<AnimationPlayer> player = |
| 9665 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9085 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 9666 timeline()->AttachPlayer(player); | 9086 timeline()->AttachPlayer(player); |
| 9667 | 9087 |
| 9668 player->AttachElement(animated->element_id()); | 9088 player->AttachElement(animated->element_id()); |
| 9669 | 9089 |
| 9670 int animation_id = 0; | 9090 int animation_id = 0; |
| 9671 std::unique_ptr<Animation> animation = Animation::Create( | 9091 std::unique_ptr<Animation> animation = Animation::Create( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 9691 EXPECT_TRUE(node->is_currently_animating_opacity); | 9111 EXPECT_TRUE(node->is_currently_animating_opacity); |
| 9692 EXPECT_TRUE(node->has_potential_opacity_animation); | 9112 EXPECT_TRUE(node->has_potential_opacity_animation); |
| 9693 | 9113 |
| 9694 player->AbortAnimations(TargetProperty::OPACITY, false /*needs_completion*/); | 9114 player->AbortAnimations(TargetProperty::OPACITY, false /*needs_completion*/); |
| 9695 node = tree.Node(animated->effect_tree_index()); | 9115 node = tree.Node(animated->effect_tree_index()); |
| 9696 EXPECT_FALSE(node->is_currently_animating_opacity); | 9116 EXPECT_FALSE(node->is_currently_animating_opacity); |
| 9697 EXPECT_FALSE(node->has_potential_opacity_animation); | 9117 EXPECT_FALSE(node->has_potential_opacity_animation); |
| 9698 } | 9118 } |
| 9699 | 9119 |
| 9700 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { | 9120 TEST_F(LayerTreeHostCommonTest, TransformAnimationsTrackingTest) { |
| 9701 const gfx::Transform identity_matrix; | |
| 9702 scoped_refptr<Layer> root = Layer::Create(); | 9121 scoped_refptr<Layer> root = Layer::Create(); |
| 9703 scoped_refptr<LayerWithForcedDrawsContent> animated = | 9122 scoped_refptr<LayerWithForcedDrawsContent> animated = |
| 9704 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 9123 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 9705 root->AddChild(animated); | 9124 root->AddChild(animated); |
| 9706 | |
| 9707 host()->SetRootLayer(root); | 9125 host()->SetRootLayer(root); |
| 9708 | |
| 9709 host()->SetElementIdsForTesting(); | 9126 host()->SetElementIdsForTesting(); |
| 9710 | 9127 |
| 9711 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 9128 root->SetBounds(gfx::Size(100, 100)); |
| 9712 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 9713 SetLayerPropertiesForTesting(animated.get(), identity_matrix, gfx::Point3F(), | |
| 9714 gfx::PointF(), gfx::Size(20, 20), true, false); | |
| 9715 | |
| 9716 root->SetForceRenderSurfaceForTesting(true); | 9129 root->SetForceRenderSurfaceForTesting(true); |
| 9130 animated->SetBounds(gfx::Size(20, 20)); |
| 9717 | 9131 |
| 9718 scoped_refptr<AnimationPlayer> player = | 9132 scoped_refptr<AnimationPlayer> player = |
| 9719 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 9133 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 9720 timeline()->AttachPlayer(player); | 9134 timeline()->AttachPlayer(player); |
| 9721 player->AttachElement(animated->element_id()); | 9135 player->AttachElement(animated->element_id()); |
| 9722 | 9136 |
| 9723 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 9137 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 9724 KeyframedTransformAnimationCurve::Create()); | 9138 KeyframedTransformAnimationCurve::Create()); |
| 9725 TransformOperations start; | 9139 TransformOperations start; |
| 9726 start.AppendTranslate(1.f, 2.f, 3.f); | 9140 start.AppendTranslate(1.f, 2.f, 3.f); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9986 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9400 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 9987 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9401 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 9988 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9402 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 9989 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9403 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 9990 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9404 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 9991 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9405 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 9992 } | 9406 } |
| 9993 | 9407 |
| 9994 } // namespace | 9408 } // namespace |
| 9995 } // namespace cc | 9409 } // namespace cc |
| OLD | NEW |