| 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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 clip_layer->test_properties()->AddChild(std::move(scroll_layer_scoped_ptr)); | 556 clip_layer->test_properties()->AddChild(std::move(scroll_layer_scoped_ptr)); |
| 557 scroll_layer_raw_ptr->layer_tree_impl() | 557 scroll_layer_raw_ptr->layer_tree_impl() |
| 558 ->property_trees() | 558 ->property_trees() |
| 559 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), | 559 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), |
| 560 kScrollOffset); | 560 kScrollOffset); |
| 561 | 561 |
| 562 std::unique_ptr<LayerImpl> root( | 562 std::unique_ptr<LayerImpl> root( |
| 563 LayerImpl::Create(host_impl.active_tree(), 3)); | 563 LayerImpl::Create(host_impl.active_tree(), 3)); |
| 564 root->SetBounds(gfx::Size(3, 4)); | 564 root->SetBounds(gfx::Size(3, 4)); |
| 565 root->test_properties()->AddChild(std::move(clip_layer_scoped_ptr)); | 565 root->test_properties()->AddChild(std::move(clip_layer_scoped_ptr)); |
| 566 root->SetHasRenderSurface(true); | |
| 567 LayerImpl* root_layer = root.get(); | 566 LayerImpl* root_layer = root.get(); |
| 568 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); | 567 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 569 | 568 |
| 570 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, | 569 ExecuteCalculateDrawProperties(root_layer, kDeviceScale, page_scale, |
| 571 scroll_layer->test_properties()->parent, | 570 scroll_layer->test_properties()->parent, |
| 572 nullptr, nullptr); | 571 nullptr, nullptr); |
| 573 gfx::Transform expected_transform; | 572 gfx::Transform expected_transform; |
| 574 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; | 573 gfx::PointF sub_layer_screen_position = kScrollLayerPosition - kScrollDelta; |
| 575 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() * | 574 expected_transform.Translate(MathUtil::Round(sub_layer_screen_position.x() * |
| 576 page_scale * kDeviceScale), | 575 page_scale * kDeviceScale), |
| (...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3377 child2->SetDrawsContent(true); | 3376 child2->SetDrawsContent(true); |
| 3378 grand_child1->SetDrawsContent(true); | 3377 grand_child1->SetDrawsContent(true); |
| 3379 grand_child2->SetDrawsContent(true); | 3378 grand_child2->SetDrawsContent(true); |
| 3380 leaf_node1->SetDrawsContent(true); | 3379 leaf_node1->SetDrawsContent(true); |
| 3381 leaf_node2->SetDrawsContent(true); | 3380 leaf_node2->SetDrawsContent(true); |
| 3382 | 3381 |
| 3383 // Case 1: No layers clip. Visible rects are clipped by the viewport. | 3382 // Case 1: No layers clip. Visible rects are clipped by the viewport. |
| 3384 // Each layer's drawable content rect is its bounds in target space; the only | 3383 // Each layer's drawable content rect is its bounds in target space; the only |
| 3385 // thing that changes with surfaces disabled is that target space is always | 3384 // thing that changes with surfaces disabled is that target space is always |
| 3386 // screen space. | 3385 // screen space. |
| 3387 root->SetHasRenderSurface(true); | 3386 child1->test_properties()->force_render_surface = true; |
| 3388 child1->SetHasRenderSurface(true); | 3387 child2->test_properties()->force_render_surface = true; |
| 3389 child2->SetHasRenderSurface(true); | |
| 3390 ExecuteCalculateDrawProperties(root); | 3388 ExecuteCalculateDrawProperties(root); |
| 3391 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); | 3389 EXPECT_EQ(gfx::Rect(100, 100), root->visible_layer_rect()); |
| 3392 EXPECT_EQ(gfx::Rect(0, 0, 98, 98), parent->visible_layer_rect()); | 3390 EXPECT_EQ(gfx::Rect(0, 0, 98, 98), parent->visible_layer_rect()); |
| 3393 EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect()); | 3391 EXPECT_EQ(gfx::Rect(94, 94), child1->visible_layer_rect()); |
| 3394 EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect()); | 3392 EXPECT_EQ(gfx::Rect(95, 95), child2->visible_layer_rect()); |
| 3395 EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect()); | 3393 EXPECT_EQ(gfx::Rect(86, 86), grand_child1->visible_layer_rect()); |
| 3396 EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect()); | 3394 EXPECT_EQ(gfx::Rect(88, 88), grand_child2->visible_layer_rect()); |
| 3397 EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect()); | 3395 EXPECT_EQ(gfx::Rect(70, 70), leaf_node1->visible_layer_rect()); |
| 3398 EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect()); | 3396 EXPECT_EQ(gfx::Rect(79, 79), leaf_node2->visible_layer_rect()); |
| 3399 | 3397 |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5043 root->SetDrawsContent(true); | 5041 root->SetDrawsContent(true); |
| 5044 | 5042 |
| 5045 std::unique_ptr<LayerImpl> child = | 5043 std::unique_ptr<LayerImpl> child = |
| 5046 LayerImpl::Create(host_impl.pending_tree(), 2); | 5044 LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5047 child->SetBounds(gfx::Size(50, 50)); | 5045 child->SetBounds(gfx::Size(50, 50)); |
| 5048 child->SetDrawsContent(true); | 5046 child->SetDrawsContent(true); |
| 5049 child->test_properties()->opacity = 0.0f; | 5047 child->test_properties()->opacity = 0.0f; |
| 5050 | 5048 |
| 5051 const int child_id = child->id(); | 5049 const int child_id = child->id(); |
| 5052 root->test_properties()->AddChild(std::move(child)); | 5050 root->test_properties()->AddChild(std::move(child)); |
| 5053 root->SetHasRenderSurface(true); | |
| 5054 LayerImpl* root_layer = root.get(); | 5051 LayerImpl* root_layer = root.get(); |
| 5055 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | 5052 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
| 5056 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); | 5053 host_impl.pending_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 5057 | 5054 |
| 5058 // Add opacity animation. | 5055 // Add opacity animation. |
| 5059 scoped_refptr<AnimationTimeline> timeline = | 5056 scoped_refptr<AnimationTimeline> timeline = |
| 5060 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 5057 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 5061 host_impl.animation_host()->AddAnimationTimeline(timeline); | 5058 host_impl.animation_host()->AddAnimationTimeline(timeline); |
| 5062 host_impl.pending_tree()->SetElementIdsForTesting(); | 5059 host_impl.pending_tree()->SetElementIdsForTesting(); |
| 5063 | 5060 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5368 child->SetDrawsContent(true); | 5365 child->SetDrawsContent(true); |
| 5369 | 5366 |
| 5370 std::unique_ptr<LayerImpl> grand_child = | 5367 std::unique_ptr<LayerImpl> grand_child = |
| 5371 LayerImpl::Create(host_impl.pending_tree(), 3); | 5368 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 5372 grand_child->SetBounds(gfx::Size(30, 30)); | 5369 grand_child->SetBounds(gfx::Size(30, 30)); |
| 5373 grand_child->SetDrawsContent(true); | 5370 grand_child->SetDrawsContent(true); |
| 5374 grand_child->test_properties()->hide_layer_and_subtree = true; | 5371 grand_child->test_properties()->hide_layer_and_subtree = true; |
| 5375 | 5372 |
| 5376 child->test_properties()->AddChild(std::move(grand_child)); | 5373 child->test_properties()->AddChild(std::move(grand_child)); |
| 5377 root->test_properties()->AddChild(std::move(child)); | 5374 root->test_properties()->AddChild(std::move(child)); |
| 5378 root->SetHasRenderSurface(true); | |
| 5379 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); | 5375 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root)); |
| 5380 | 5376 |
| 5381 LayerImplList render_surface_layer_list; | 5377 LayerImplList render_surface_layer_list; |
| 5382 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5378 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5383 root_layer, root_layer->bounds(), &render_surface_layer_list); | 5379 root_layer, root_layer->bounds(), &render_surface_layer_list); |
| 5384 inputs.can_adjust_raster_scales = true; | 5380 inputs.can_adjust_raster_scales = true; |
| 5385 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 5381 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 5386 | 5382 |
| 5387 // We should have one render surface and two layers. The grand child has | 5383 // We should have one render surface and two layers. The grand child has |
| 5388 // hidden itself. | 5384 // hidden itself. |
| (...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8326 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8322 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); |
| 8327 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8323 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); |
| 8328 | 8324 |
| 8329 std::set<LayerImpl*> expected; | 8325 std::set<LayerImpl*> expected; |
| 8330 std::set<LayerImpl*> actual; | 8326 std::set<LayerImpl*> actual; |
| 8331 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 8327 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
| 8332 EXPECT_EQ(expected, actual); | 8328 EXPECT_EQ(expected, actual); |
| 8333 | 8329 |
| 8334 // If we force render surface, but none of the layers are in the layer list, | 8330 // If we force render surface, but none of the layers are in the layer list, |
| 8335 // then this layer should not appear in RSLL. | 8331 // then this layer should not appear in RSLL. |
| 8336 grand_child1_raw->SetHasRenderSurface(true); | 8332 grand_child1_raw->test_properties()->force_render_surface = true; |
| 8337 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8333 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8338 | 8334 |
| 8339 ExecuteCalculateDrawProperties(grand_parent_raw); | 8335 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8340 | 8336 |
| 8341 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8337 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); |
| 8342 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8338 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); |
| 8343 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8339 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); |
| 8344 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8340 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); |
| 8345 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8341 EXPECT_FALSE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); |
| 8346 | 8342 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8364 expected.clear(); | 8360 expected.clear(); |
| 8365 expected.insert(grand_child1_raw); | 8361 expected.insert(grand_child1_raw); |
| 8366 | 8362 |
| 8367 actual.clear(); | 8363 actual.clear(); |
| 8368 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); | 8364 GatherDrawnLayers(render_surface_layer_list_impl(), &actual); |
| 8369 EXPECT_EQ(expected, actual); | 8365 EXPECT_EQ(expected, actual); |
| 8370 | 8366 |
| 8371 // Now child is forced to have a render surface, and one if its children draws | 8367 // Now child is forced to have a render surface, and one if its children draws |
| 8372 // content. | 8368 // content. |
| 8373 grand_child1_raw->SetDrawsContent(false); | 8369 grand_child1_raw->SetDrawsContent(false); |
| 8374 grand_child1_raw->SetHasRenderSurface(false); | 8370 grand_child1_raw->test_properties()->force_render_surface = false; |
| 8375 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8371 grand_child1_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8376 child_raw->SetHasRenderSurface(true); | 8372 child_raw->test_properties()->force_render_surface = true; |
| 8377 grand_child2_raw->SetDrawsContent(true); | 8373 grand_child2_raw->SetDrawsContent(true); |
| 8378 | 8374 |
| 8379 ExecuteCalculateDrawProperties(grand_parent_raw); | 8375 ExecuteCalculateDrawProperties(grand_parent_raw); |
| 8380 | 8376 |
| 8381 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); | 8377 EXPECT_FALSE(grand_parent_raw->is_drawn_render_surface_layer_list_member()); |
| 8382 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); | 8378 EXPECT_FALSE(parent_raw->is_drawn_render_surface_layer_list_member()); |
| 8383 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); | 8379 EXPECT_FALSE(child_raw->is_drawn_render_surface_layer_list_member()); |
| 8384 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); | 8380 EXPECT_FALSE(grand_child1_raw->is_drawn_render_surface_layer_list_member()); |
| 8385 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); | 8381 EXPECT_TRUE(grand_child2_raw->is_drawn_render_surface_layer_list_member()); |
| 8386 | 8382 |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9504 CopyOutputRequest::CreateEmptyRequest()); | 9500 CopyOutputRequest::CreateEmptyRequest()); |
| 9505 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9501 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9506 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9502 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 9507 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 9503 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 9508 | 9504 |
| 9509 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); | 9505 host_impl.active_tree()->property_trees()->effect_tree.ClearCopyRequests(); |
| 9510 child_ptr->test_properties()->opacity = 1.f; | 9506 child_ptr->test_properties()->opacity = 1.f; |
| 9511 | 9507 |
| 9512 // A double sided render surface with backface visible should not be skipped | 9508 // A double sided render surface with backface visible should not be skipped |
| 9513 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); | 9509 grandchild_ptr->set_visible_layer_rect(gfx::Rect()); |
| 9514 child_ptr->SetHasRenderSurface(true); | 9510 child_ptr->test_properties()->force_render_surface = true; |
| 9515 child_ptr->test_properties()->double_sided = true; | 9511 child_ptr->test_properties()->double_sided = true; |
| 9516 child_ptr->test_properties()->transform = rotate_back_and_translate; | 9512 child_ptr->test_properties()->transform = rotate_back_and_translate; |
| 9517 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9513 root_ptr->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9518 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); | 9514 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); |
| 9519 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); | 9515 EXPECT_EQ(gfx::Rect(10, 10), grandchild_ptr->visible_layer_rect()); |
| 9520 child_ptr->test_properties()->transform = gfx::Transform(); | 9516 child_ptr->test_properties()->transform = gfx::Transform(); |
| 9521 | 9517 |
| 9522 std::unique_ptr<KeyframedTransformAnimationCurve> curve( | 9518 std::unique_ptr<KeyframedTransformAnimationCurve> curve( |
| 9523 KeyframedTransformAnimationCurve::Create()); | 9519 KeyframedTransformAnimationCurve::Create()); |
| 9524 TransformOperations start; | 9520 TransformOperations start; |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10758 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10754 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10759 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10755 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10760 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10756 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10761 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10757 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10762 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10758 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10763 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10759 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10764 } | 10760 } |
| 10765 | 10761 |
| 10766 } // namespace | 10762 } // namespace |
| 10767 } // namespace cc | 10763 } // namespace cc |
| OLD | NEW |