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

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

Issue 2140313004: cc: Fix non root copy request visible rect in HighDPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 3304 matching lines...) Expand 10 before | Expand all | Expand 10 after
4784 SetLayerPropertiesForTesting(scale_surface, scale_small_matrix, 4783 SetLayerPropertiesForTesting(scale_surface, scale_small_matrix,
4785 gfx::Point3F(), gfx::PointF(2.f, 2.f), 4784 gfx::Point3F(), gfx::PointF(2.f, 2.f),
4786 gfx::Size(10, 10), false, true, true); 4785 gfx::Size(10, 10), false, true, true);
4787 scale_surface->SetDrawsContent(true); 4786 scale_surface->SetDrawsContent(true);
4788 4787
4789 float device_scale_factor = 2.5f; 4788 float device_scale_factor = 2.5f;
4790 float page_scale_factor = 3.f; 4789 float page_scale_factor = 3.f;
4791 root->layer_tree_impl()->SetViewportLayersFromIds( 4790 root->layer_tree_impl()->SetViewportLayersFromIds(
4792 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID, 4791 Layer::INVALID_ID, page_scale->id(), Layer::INVALID_ID,
4793 Layer::INVALID_ID); 4792 Layer::INVALID_ID);
4794 root->layer_tree_impl()->SetDeviceScaleFactor(device_scale_factor);
4795 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting(); 4793 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting();
4796 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor); 4794 root->layer_tree_impl()->SetPageScaleOnActiveTree(page_scale_factor);
4797 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, 4795 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor,
4798 root); 4796 root);
4799 4797
4800 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent); 4798 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, parent);
4801 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor, 4799 EXPECT_IDEAL_SCALE_EQ(device_scale_factor * page_scale_factor,
4802 perspective_surface); 4800 perspective_surface);
4803 // Ideal scale is the max 2d scale component of the combined transform up to 4801 // Ideal scale is the max 2d scale component of the combined transform up to
4804 // the nearest render target. Here this includes the layer transform as well 4802 // the nearest render target. Here this includes the layer transform as well
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
5859 copy_layer->SetBounds(gfx::Size(50, 50)); 5857 copy_layer->SetBounds(gfx::Size(50, 50));
5860 copy_layer->SetMasksToBounds(true); 5858 copy_layer->SetMasksToBounds(true);
5861 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 5859 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
5862 5860
5863 ExecuteCalculateDrawProperties(root); 5861 ExecuteCalculateDrawProperties(root);
5864 5862
5865 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect()); 5863 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect());
5866 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect()); 5864 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect());
5867 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect()); 5865 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect());
5868 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect()); 5866 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect());
5867
5868 // Case 3: When there is device scale factor.
5869 float device_scale_factor = 2.f;
5870 copy_layer->test_properties()->copy_requests.push_back(
5871 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5872
5873 DCHECK(!copy_layer->test_properties()->copy_requests.empty());
5874 ExecuteCalculateDrawProperties(root, device_scale_factor);
5875 DCHECK(copy_layer->test_properties()->copy_requests.empty());
5876
5877 EXPECT_EQ(gfx::Rect(50, 50), copy_layer->visible_layer_rect());
5878 EXPECT_EQ(gfx::Rect(10, 10), copy_child->visible_layer_rect());
5879 EXPECT_EQ(gfx::Rect(10, 10), copy_clipped_child->visible_layer_rect());
5880 EXPECT_EQ(gfx::Rect(5, 5), copy_surface->visible_layer_rect());
5869 } 5881 }
5870 5882
5871 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) { 5883 TEST_F(LayerTreeHostCommonTest, VisibleContentRectInsideSurface) {
5872 LayerImpl* root = root_layer_for_testing(); 5884 LayerImpl* root = root_layer_for_testing();
5873 LayerImpl* surface = AddChild<LayerImpl>(root); 5885 LayerImpl* surface = AddChild<LayerImpl>(root);
5874 LayerImpl* surface_child = AddChild<LayerImpl>(surface); 5886 LayerImpl* surface_child = AddChild<LayerImpl>(surface);
5875 5887
5876 const gfx::Transform identity_matrix; 5888 const gfx::Transform identity_matrix;
5877 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), 5889 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(),
5878 gfx::PointF(), gfx::Size(50, 50), true, false, 5890 gfx::PointF(), gfx::Size(50, 50), true, false,
(...skipping 4536 matching lines...) Expand 10 before | Expand all | Expand 10 after
10415 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10427 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10416 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10428 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10417 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10429 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10418 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10430 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10419 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10431 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10420 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10432 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10421 } 10433 }
10422 10434
10423 } // namespace 10435 } // namespace
10424 } // namespace cc 10436 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698