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

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

Issue 2454203002: Revert of cc : Move screen space scale factor to root transform node (Closed)
Patch Set: Created 4 years, 1 month 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/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | 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 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 float device_scale_factor = 1.5f; 1274 float device_scale_factor = 1.5f;
1275 1275
1276 { 1276 {
1277 LayerImplList render_surface_layer_list_impl; 1277 LayerImplList render_surface_layer_list_impl;
1278 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1278 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1279 root, root->bounds(), translate, &render_surface_layer_list_impl); 1279 root, root->bounds(), translate, &render_surface_layer_list_impl);
1280 inputs.device_scale_factor = device_scale_factor; 1280 inputs.device_scale_factor = device_scale_factor;
1281 inputs.property_trees->needs_rebuild = true; 1281 inputs.property_trees->needs_rebuild = true;
1282 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1282 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1283 gfx::Transform device_scaled_translate = translate; 1283 gfx::Transform device_scaled_translate = translate;
1284 device_scaled_translate.matrix().postScale(device_scale_factor, 1284 device_scaled_translate.Scale(device_scale_factor, device_scale_factor);
1285 device_scale_factor, 1.f);
1286 EXPECT_TRANSFORMATION_MATRIX_EQ( 1285 EXPECT_TRANSFORMATION_MATRIX_EQ(
1287 device_scaled_translate, 1286 device_scaled_translate,
1288 root->draw_properties().target_space_transform); 1287 root->draw_properties().target_space_transform);
1289 EXPECT_TRANSFORMATION_MATRIX_EQ( 1288 EXPECT_TRANSFORMATION_MATRIX_EQ(
1290 device_scaled_translate, 1289 device_scaled_translate,
1291 child->draw_properties().target_space_transform); 1290 child->draw_properties().target_space_transform);
1292 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1291 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1293 root->render_surface()->draw_transform()); 1292 root->render_surface()->draw_transform());
1294 } 1293 }
1295 1294
1296 // Verify it composes correctly with page scale. 1295 // Verify it composes correctly with page scale.
1297 float page_scale_factor = 2.f; 1296 float page_scale_factor = 2.f;
1298 1297
1299 { 1298 {
1300 LayerImplList render_surface_layer_list_impl; 1299 LayerImplList render_surface_layer_list_impl;
1301 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 1300 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
1302 root, root->bounds(), translate, &render_surface_layer_list_impl); 1301 root, root->bounds(), translate, &render_surface_layer_list_impl);
1303 inputs.page_scale_factor = page_scale_factor; 1302 inputs.page_scale_factor = page_scale_factor;
1304 inputs.page_scale_layer = root; 1303 inputs.page_scale_layer = root;
1305 inputs.property_trees->needs_rebuild = true; 1304 inputs.property_trees->needs_rebuild = true;
1306 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 1305 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
1307 gfx::Transform page_scaled_translate = translate; 1306 gfx::Transform page_scaled_translate = translate;
1308 page_scaled_translate.matrix().postScale(page_scale_factor, 1307 page_scaled_translate.Scale(page_scale_factor, page_scale_factor);
1309 page_scale_factor, 1.f);
1310 EXPECT_TRANSFORMATION_MATRIX_EQ( 1308 EXPECT_TRANSFORMATION_MATRIX_EQ(
1311 page_scaled_translate, root->draw_properties().target_space_transform); 1309 page_scaled_translate, root->draw_properties().target_space_transform);
1312 EXPECT_TRANSFORMATION_MATRIX_EQ( 1310 EXPECT_TRANSFORMATION_MATRIX_EQ(
1313 page_scaled_translate, child->draw_properties().target_space_transform); 1311 page_scaled_translate, child->draw_properties().target_space_transform);
1314 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), 1312 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(),
1315 root->render_surface()->draw_transform()); 1313 root->render_surface()->draw_transform());
1316 } 1314 }
1317 1315
1318 // Verify that it composes correctly with transforms directly on root layer. 1316 // Verify that it composes correctly with transforms directly on root layer.
1319 root->test_properties()->transform = composite; 1317 root->test_properties()->transform = composite;
(...skipping 8151 matching lines...) Expand 10 before | Expand all | Expand 10 after
9471 test_layer->SetBounds(gfx::Size(20, 20)); 9469 test_layer->SetBounds(gfx::Size(20, 20));
9472 test_layer->SetDrawsContent(true); 9470 test_layer->SetDrawsContent(true);
9473 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); 9471 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20));
9474 test_layer->test_properties()->opacity = 0.f; 9472 test_layer->test_properties()->opacity = 0.f;
9475 9473
9476 ExecuteCalculateDrawProperties(root); 9474 ExecuteCalculateDrawProperties(root);
9477 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, 9475 EXPECT_TRANSFORMATION_MATRIX_EQ(translation,
9478 test_layer->ScreenSpaceTransform()); 9476 test_layer->ScreenSpaceTransform());
9479 } 9477 }
9480 9478
9481 TEST_F(LayerTreeHostCommonTest, ClipParentDrawsIntoScaledRootSurface) {
9482 LayerImpl* root = root_layer_for_testing();
9483 LayerImpl* clip_layer = AddChild<LayerImpl>(root);
9484 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer);
9485 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent);
9486 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface);
9487
9488 root->SetBounds(gfx::Size(100, 100));
9489 clip_layer->SetBounds(gfx::Size(20, 20));
9490 clip_layer->SetMasksToBounds(true);
9491 clip_parent->SetBounds(gfx::Size(50, 50));
9492 unclipped_desc_surface->SetBounds(gfx::Size(100, 100));
9493 unclipped_desc_surface->SetDrawsContent(true);
9494 unclipped_desc_surface->test_properties()->force_render_surface = true;
9495 clip_child->SetBounds(gfx::Size(100, 100));
9496 clip_child->SetDrawsContent(true);
9497
9498 clip_child->test_properties()->clip_parent = clip_parent;
9499 clip_parent->test_properties()->clip_children =
9500 base::MakeUnique<std::set<LayerImpl*>>();
9501 clip_parent->test_properties()->clip_children->insert(clip_child);
9502
9503 float device_scale_factor = 1.f;
9504 ExecuteCalculateDrawProperties(root, device_scale_factor);
9505 EXPECT_EQ(gfx::Rect(20, 20), clip_child->clip_rect());
9506 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect());
9507
9508 device_scale_factor = 2.f;
9509 ExecuteCalculateDrawProperties(root, device_scale_factor);
9510 EXPECT_EQ(gfx::Rect(40, 40), clip_child->clip_rect());
9511 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect());
9512 }
9513
9514 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { 9479 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) {
9515 LayerImpl* root = root_layer_for_testing(); 9480 LayerImpl* root = root_layer_for_testing();
9516 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 9481 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
9517 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 9482 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
9518 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); 9483 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface);
9519 9484
9520 root->SetBounds(gfx::Size(30, 30)); 9485 root->SetBounds(gfx::Size(30, 30));
9521 clip_parent->SetBounds(gfx::Size(40, 40)); 9486 clip_parent->SetBounds(gfx::Size(40, 40));
9522 clip_parent->SetMasksToBounds(true); 9487 clip_parent->SetMasksToBounds(true);
9523 render_surface->SetBounds(gfx::Size(50, 50)); 9488 render_surface->SetBounds(gfx::Size(50, 50));
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
10154 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10119 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10155 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10120 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10156 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10121 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10157 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10122 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10158 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10123 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10159 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10124 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10160 } 10125 }
10161 10126
10162 } // namespace 10127 } // namespace
10163 } // namespace cc 10128 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.cc ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698