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

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

Issue 2106273002: cc: Change how/when we build layer list/property tress in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
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 7154 matching lines...) Expand 10 before | Expand all | Expand 10 after
7165 gfx::PointF(), gfx::Size(50, 50), true, false, 7165 gfx::PointF(), gfx::Size(50, 50), true, false,
7166 false); 7166 false);
7167 7167
7168 root->SetDrawsContent(true); 7168 root->SetDrawsContent(true);
7169 container->SetDrawsContent(true); 7169 container->SetDrawsContent(true);
7170 scroller->SetDrawsContent(true); 7170 scroller->SetDrawsContent(true);
7171 fixed->SetDrawsContent(true); 7171 fixed->SetDrawsContent(true);
7172 scroller->test_properties()->AddChild(std::move(fixed)); 7172 scroller->test_properties()->AddChild(std::move(fixed));
7173 container->test_properties()->AddChild(std::move(scroller)); 7173 container->test_properties()->AddChild(std::move(scroller));
7174 root->test_properties()->AddChild(std::move(container)); 7174 root->test_properties()->AddChild(std::move(container));
7175 root->layer_tree_impl()->SetRootLayerForTesting(std::move(root_ptr));
7176 root->layer_tree_impl()->BuildPropertyTreesForTesting();
7175 7177
7176 // Rounded to integers already. 7178 // Rounded to integers already.
7177 { 7179 {
7178 root->layer_tree_impl()->SetRootLayerForTesting(std::move(root_ptr));
7179 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting();
7180
7181 gfx::Vector2dF scroll_delta(3.0, 5.0); 7180 gfx::Vector2dF scroll_delta(3.0, 5.0);
7182 SetScrollOffsetDelta(scroll_layer, scroll_delta); 7181 SetScrollOffsetDelta(scroll_layer, scroll_delta);
7183 7182
7184 LayerImplList render_surface_layer_list; 7183 LayerImplList render_surface_layer_list;
7185 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7184 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7186 root, root->bounds(), &render_surface_layer_list); 7185 root, root->bounds(), &render_surface_layer_list);
7187 root->layer_tree_impl() 7186 root->layer_tree_impl()
7188 ->property_trees() 7187 ->property_trees()
7189 ->transform_tree.set_source_to_parent_updates_allowed(false); 7188 ->transform_tree.set_source_to_parent_updates_allowed(false);
7190 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 7189 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7191 7190
7192 EXPECT_TRANSFORMATION_MATRIX_EQ( 7191 EXPECT_TRANSFORMATION_MATRIX_EQ(
7193 container_layer->draw_properties().screen_space_transform, 7192 container_layer->draw_properties().screen_space_transform,
7194 fixed_layer->draw_properties().screen_space_transform); 7193 fixed_layer->draw_properties().screen_space_transform);
7195 EXPECT_VECTOR_EQ( 7194 EXPECT_VECTOR_EQ(
7196 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 7195 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
7197 container_offset); 7196 container_offset);
7198 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() 7197 EXPECT_VECTOR_EQ(scroll_layer->draw_properties()
7199 .screen_space_transform.To2dTranslation(), 7198 .screen_space_transform.To2dTranslation(),
7200 container_offset - scroll_delta); 7199 container_offset - scroll_delta);
7201 } 7200 }
7202 7201
7203 // Scroll delta requiring rounding. 7202 // Scroll delta requiring rounding.
7204 { 7203 {
7205 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting();
7206
7207 gfx::Vector2dF scroll_delta(4.1f, 8.1f); 7204 gfx::Vector2dF scroll_delta(4.1f, 8.1f);
7208 SetScrollOffsetDelta(scroll_layer, scroll_delta); 7205 SetScrollOffsetDelta(scroll_layer, scroll_delta);
7209 7206
7210 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); 7207 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f);
7211 7208
7212 LayerImplList render_surface_layer_list; 7209 LayerImplList render_surface_layer_list;
7213 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7210 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7214 root, root->bounds(), &render_surface_layer_list); 7211 root, root->bounds(), &render_surface_layer_list);
7215 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 7212 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7216 7213
7217 EXPECT_TRANSFORMATION_MATRIX_EQ( 7214 EXPECT_TRANSFORMATION_MATRIX_EQ(
7218 container_layer->draw_properties().screen_space_transform, 7215 container_layer->draw_properties().screen_space_transform,
7219 fixed_layer->draw_properties().screen_space_transform); 7216 fixed_layer->draw_properties().screen_space_transform);
7220 EXPECT_VECTOR_EQ( 7217 EXPECT_VECTOR_EQ(
7221 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 7218 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
7222 container_offset); 7219 container_offset);
7223 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() 7220 EXPECT_VECTOR_EQ(scroll_layer->draw_properties()
7224 .screen_space_transform.To2dTranslation(), 7221 .screen_space_transform.To2dTranslation(),
7225 container_offset - rounded_scroll_delta); 7222 container_offset - rounded_scroll_delta);
7226 } 7223 }
7227 7224
7228 // Scale is applied earlier in the tree. 7225 // Scale is applied earlier in the tree.
7229 { 7226 {
7230 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); 7227 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF());
7231 gfx::Transform scaled_container_transform = container_transform; 7228 gfx::Transform scaled_container_transform = container_transform;
7232 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); 7229 scaled_container_transform.Scale3d(2.0, 2.0, 1.0);
7233 container_layer->SetTransform(scaled_container_transform); 7230 container_layer->SetTransform(scaled_container_transform);
7231
7234 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 7232 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
7235 root->layer_tree_impl()->BuildLayerListAndPropertyTreesForTesting();
7236 7233
7237 gfx::Vector2dF scroll_delta(4.5f, 8.5f); 7234 gfx::Vector2dF scroll_delta(4.5f, 8.5f);
7238 SetScrollOffsetDelta(scroll_layer, scroll_delta); 7235 SetScrollOffsetDelta(scroll_layer, scroll_delta);
7239 7236
7240 LayerImplList render_surface_layer_list; 7237 LayerImplList render_surface_layer_list;
7241 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 7238 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7242 root, root->bounds(), &render_surface_layer_list); 7239 root, root->bounds(), &render_surface_layer_list);
7243 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 7240 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
7244 7241
7245 EXPECT_TRANSFORMATION_MATRIX_EQ( 7242 EXPECT_TRANSFORMATION_MATRIX_EQ(
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
8168 SetLayerPropertiesForTesting(sublayer, 8165 SetLayerPropertiesForTesting(sublayer,
8169 identity_matrix, 8166 identity_matrix,
8170 gfx::Point3F(), 8167 gfx::Point3F(),
8171 gfx::PointF(), 8168 gfx::PointF(),
8172 sublayer_size, 8169 sublayer_size,
8173 false, 8170 false,
8174 false, 8171 false,
8175 false); 8172 false);
8176 sublayer->SetDrawsContent(true); 8173 sublayer->SetDrawsContent(true);
8177 8174
8175 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
8176
8178 LayerImplList layer_impl_list; 8177 LayerImplList layer_impl_list;
8179 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 8178 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
8180 root, device_viewport_size, &layer_impl_list); 8179 root, device_viewport_size, &layer_impl_list);
8181 8180
8182 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8181 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8183 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect()); 8182 EXPECT_EQ(gfx::Rect(root_size), sublayer->visible_layer_rect());
8184 8183
8185 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0)); 8184 root->SetBoundsDelta(gfx::Vector2dF(0.0, 50.0));
8186 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); 8185 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
8187 8186
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after
10395 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10394 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10396 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10395 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10397 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10396 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10398 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10397 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10399 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10398 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10400 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10399 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10401 } 10400 }
10402 10401
10403 } // namespace 10402 } // namespace
10404 } // namespace cc 10403 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698