| 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 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 // contents (at the new offset). | 1459 // contents (at the new offset). |
| 1460 ASSERT_TRUE(child->render_surface()); | 1460 ASSERT_TRUE(child->render_surface()); |
| 1461 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), | 1461 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), |
| 1462 child->render_surface()->DrawableContentRect()); | 1462 child->render_surface()->DrawableContentRect()); |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { | 1465 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { |
| 1466 const float device_scale_factor = 2.0f; | 1466 const float device_scale_factor = 2.0f; |
| 1467 | 1467 |
| 1468 LayerImpl* root = root_layer_for_testing(); | 1468 LayerImpl* root = root_layer_for_testing(); |
| 1469 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); | |
| 1470 LayerImpl* child = AddChild<LayerImpl>(root); | 1469 LayerImpl* child = AddChild<LayerImpl>(root); |
| 1471 child->SetDrawsContent(true); | 1470 child->SetDrawsContent(true); |
| 1472 | 1471 |
| 1473 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), | 1472 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), |
| 1474 gfx::PointF(), gfx::Size(100, 100), true, false, | 1473 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 1475 true); | 1474 true); |
| 1476 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), | 1475 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), |
| 1477 gfx::PointF(), gfx::Size(25, 25), true, false, | 1476 gfx::PointF(), gfx::Size(25, 25), true, false, |
| 1478 true); | 1477 true); |
| 1479 | 1478 |
| (...skipping 3298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4778 SetLayerPropertiesForTesting(scale_surface, scale_small_matrix, | 4777 SetLayerPropertiesForTesting(scale_surface, scale_small_matrix, |
| 4779 gfx::Point3F(), gfx::PointF(2.f, 2.f), | 4778 gfx::Point3F(), gfx::PointF(2.f, 2.f), |
| 4780 gfx::Size(10, 10), false, true, true); | 4779 gfx::Size(10, 10), false, true, true); |
| 4781 scale_surface->SetDrawsContent(true); | 4780 scale_surface->SetDrawsContent(true); |
| 4782 | 4781 |
| 4783 float device_scale_factor = 2.5f; | 4782 float device_scale_factor = 2.5f; |
| 4784 float page_scale_factor = 3.f; | 4783 float page_scale_factor = 3.f; |
| 4785 root->layer_tree_impl()->SetViewportLayersFromIds( | 4784 root->layer_tree_impl()->SetViewportLayersFromIds( |
| 4786 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID, | 4785 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID, |
| 4787 Layer::INVALID_ID); | 4786 Layer::INVALID_ID); |
| 4788 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor); | |
| 4789 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); | 4787 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); |
| 4790 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor); | 4788 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor); |
| 4791 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, | 4789 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, |
| 4792 root); | 4790 root); |
| 4793 | 4791 |
| 4794 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent); | 4792 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent); |
| 4795 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, | 4793 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, |
| 4796 perspective_surface); | 4794 perspective_surface); |
| 4797 // Ideal scale is the max 2d scale component of the combined transform up to | 4795 // Ideal scale is the max 2d scale component of the combined transform up to |
| 4798 // the nearest render target. Here this includes the layer transform as well | 4796 // the nearest render target. Here this includes the layer transform as well |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5848 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 5846 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 5849 | 5847 |
| 5850 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); | 5848 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); |
| 5851 ExecuteCalculateDrawProperties(root); | 5849 ExecuteCalculateDrawProperties(root); |
| 5852 DCHECK(copy_layer->test_properties()->copy_requests.empty()); | 5850 DCHECK(copy_layer->test_properties()->copy_requests.empty()); |
| 5853 | 5851 |
| 5854 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect()); | 5852 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect()); |
| 5855 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect()); | 5853 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect()); |
| 5856 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect()); | 5854 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect()); |
| 5857 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect()); | 5855 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect()); |
| 5856 |
| 5857 // Case 3: When there is device scale factor. |
| 5858 float device_scale_factor = 2.f; |
| 5859 copy_layer->test_properties()->copy_requests.push_back( |
| 5860 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 5861 |
| 5862 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); |
| 5863 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 5864 DCHECK(copy_layer->test_properties()->copy_requests.empty()); |
| 5865 |
| 5866 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect()); |
| 5867 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect()); |
| 5868 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect()); |
| 5869 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect()); |
| 5858 } | 5870 } |
| 5859 | 5871 |
| 5860 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { | 5872 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { |
| 5861 LayerImpl* root = root_layer_for_testing(); | 5873 LayerImpl* root = root_layer_for_testing(); |
| 5862 LayerImpl* surface = AddChild<LayerImpl>(root); | 5874 LayerImpl* surface = AddChild<LayerImpl>(root); |
| 5863 LayerImpl* surface_child = AddChild<LayerImpl>(surface); | 5875 LayerImpl* surface_child = AddChild<LayerImpl>(surface); |
| 5864 | 5876 |
| 5865 const gfx::Transform identity_matrix; | 5877 const gfx::Transform identity_matrix; |
| 5866 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 5878 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 5867 gfx::PointF(), gfx::Size(50, 50), true, false, | 5879 gfx::PointF(), gfx::Size(50, 50), true, false, |
| (...skipping 4487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10355 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10367 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10356 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10368 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10357 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10369 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10358 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10370 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10359 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10371 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10360 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10372 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10361 } | 10373 } |
| 10362 | 10374 |
| 10363 } // namespace | 10375 } // namespace |
| 10364 } // namespace cc | 10376 } // namespace cc |
| OLD | NEW |