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 5631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5642 // We should have two render surface, as the others are clipped out. | 5642 // We should have two render surface, as the others are clipped out. |
5643 ASSERT_EQ(2u, render_surface_list.size()); | 5643 ASSERT_EQ(2u, render_surface_list.size()); |
5644 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); | 5644 EXPECT_EQ(root_layer->id(), render_surface_list.at(0)->id()); |
5645 | 5645 |
5646 // The root render surface should have only 2 contributing layer, since the | 5646 // The root render surface should have only 2 contributing layer, since the |
5647 // other layers are clipped away. | 5647 // other layers are clipped away. |
5648 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); | 5648 ASSERT_EQ(2, root_layer->GetRenderSurface()->num_contributors()); |
5649 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); | 5649 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); |
5650 } | 5650 } |
5651 | 5651 |
| 5652 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { |
| 5653 LayerImpl* root = root_layer_for_testing(); |
| 5654 root->SetBounds(gfx::Size(50, 50)); |
| 5655 root->SetDrawsContent(true); |
| 5656 |
| 5657 LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root); |
| 5658 singular_transform_layer->SetBounds(gfx::Size(100, 100)); |
| 5659 singular_transform_layer->SetDrawsContent(true); |
| 5660 gfx::Transform singular; |
| 5661 singular.Scale3d(6.f, 6.f, 0.f); |
| 5662 singular_transform_layer->test_properties()->transform = singular; |
| 5663 |
| 5664 LayerImpl* copy_layer = AddChild<LayerImpl>(singular_transform_layer); |
| 5665 copy_layer->SetBounds(gfx::Size(100, 100)); |
| 5666 copy_layer->SetDrawsContent(true); |
| 5667 copy_layer->test_properties()->copy_requests.push_back( |
| 5668 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 5669 |
| 5670 LayerImpl* copy_child = AddChild<LayerImpl>(copy_layer); |
| 5671 copy_child->SetBounds(gfx::Size(100, 100)); |
| 5672 copy_child->SetDrawsContent(true); |
| 5673 |
| 5674 LayerImpl* copy_grand_child = AddChild<LayerImpl>(copy_child); |
| 5675 copy_grand_child->SetBounds(gfx::Size(100, 100)); |
| 5676 copy_grand_child->SetDrawsContent(true); |
| 5677 copy_grand_child->test_properties()->transform = singular; |
| 5678 |
| 5679 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); |
| 5680 ExecuteCalculateDrawProperties(root); |
| 5681 DCHECK(copy_layer->test_properties()->copy_requests.empty()); |
| 5682 |
| 5683 // A layer with singular transform should not contribute to drawn render |
| 5684 // surface. |
| 5685 EXPECT_FALSE(singular_transform_layer->contributes_to_drawn_render_surface()); |
| 5686 // Even though copy_layer and copy_child have singular screen space transform, |
| 5687 // they still contribute to drawn render surface as their transform to the |
| 5688 // closest ancestor with copy request is not singular. |
| 5689 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); |
| 5690 EXPECT_TRUE(copy_child->contributes_to_drawn_render_surface()); |
| 5691 // copy_grand_child's transform to its closest ancestor with copy request is |
| 5692 // also singular. So, it doesn't contribute to drawn render surface. |
| 5693 EXPECT_FALSE(copy_grand_child->contributes_to_drawn_render_surface()); |
| 5694 } |
| 5695 |
5652 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { | 5696 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { |
5653 LayerImpl* root = root_layer_for_testing(); | 5697 LayerImpl* root = root_layer_for_testing(); |
5654 root->SetBounds(gfx::Size(50, 50)); | 5698 root->SetBounds(gfx::Size(50, 50)); |
5655 root->SetDrawsContent(true); | 5699 root->SetDrawsContent(true); |
5656 root->SetMasksToBounds(true); | 5700 root->SetMasksToBounds(true); |
5657 | 5701 |
5658 LayerImpl* copy_layer = AddChild<LayerImpl>(root); | 5702 LayerImpl* copy_layer = AddChild<LayerImpl>(root); |
5659 copy_layer->SetBounds(gfx::Size(100, 100)); | 5703 copy_layer->SetBounds(gfx::Size(100, 100)); |
5660 copy_layer->SetDrawsContent(true); | 5704 copy_layer->SetDrawsContent(true); |
5661 copy_layer->test_properties()->force_render_surface = true; | 5705 copy_layer->test_properties()->force_render_surface = true; |
(...skipping 5211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10873 | 10917 |
10874 // Check child layer draw properties. | 10918 // Check child layer draw properties. |
10875 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); | 10919 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
10876 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); | 10920 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
10877 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); | 10921 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
10878 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); | 10922 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
10879 } | 10923 } |
10880 | 10924 |
10881 } // namespace | 10925 } // namespace |
10882 } // namespace cc | 10926 } // namespace cc |
OLD | NEW |