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

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

Issue 2712053002: cc : Fix transform calculation bug while calculating clip rects (Closed)
Patch Set: clean_up Created 3 years, 10 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') | cc/trees/property_tree.h » ('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 10113 matching lines...) Expand 10 before | Expand all | Expand 10 after
10124 10124
10125 root->SetBounds(gfx::Size(100, 100)); 10125 root->SetBounds(gfx::Size(100, 100));
10126 clip_layer->SetBounds(gfx::Size(20, 20)); 10126 clip_layer->SetBounds(gfx::Size(20, 20));
10127 clip_layer->SetMasksToBounds(true); 10127 clip_layer->SetMasksToBounds(true);
10128 clip_parent->SetBounds(gfx::Size(50, 50)); 10128 clip_parent->SetBounds(gfx::Size(50, 50));
10129 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); 10129 unclipped_desc_surface->SetBounds(gfx::Size(100, 100));
10130 unclipped_desc_surface->SetDrawsContent(true); 10130 unclipped_desc_surface->SetDrawsContent(true);
10131 unclipped_desc_surface->test_properties()->force_render_surface = true; 10131 unclipped_desc_surface->test_properties()->force_render_surface = true;
10132 clip_child->SetBounds(gfx::Size(100, 100)); 10132 clip_child->SetBounds(gfx::Size(100, 100));
10133 clip_child->SetDrawsContent(true); 10133 clip_child->SetDrawsContent(true);
10134 gfx::Transform translate;
10135 translate.Translate(10, 10);
10136 unclipped_desc_surface->test_properties()->transform = translate;
10134 10137
10135 clip_child->test_properties()->clip_parent = clip_parent; 10138 clip_child->test_properties()->clip_parent = clip_parent;
10136 clip_parent->test_properties()->clip_children = 10139 clip_parent->test_properties()->clip_children =
10137 base::MakeUnique<std::set<LayerImpl*>>(); 10140 base::MakeUnique<std::set<LayerImpl*>>();
10138 clip_parent->test_properties()->clip_children->insert(clip_child); 10141 clip_parent->test_properties()->clip_children->insert(clip_child);
10139 10142
10140 float device_scale_factor = 1.f; 10143 float device_scale_factor = 1.f;
10141 ExecuteCalculateDrawProperties(root, device_scale_factor); 10144 ExecuteCalculateDrawProperties(root, device_scale_factor);
10142 EXPECT_EQ(gfx::Rect(20, 20), clip_child->clip_rect()); 10145 EXPECT_EQ(gfx::Rect(-10, -10, 20, 20), clip_child->clip_rect());
10143 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); 10146 EXPECT_EQ(gfx::Rect(10, 10), clip_child->visible_layer_rect());
10144 10147
10145 device_scale_factor = 2.f; 10148 device_scale_factor = 2.f;
10146 ExecuteCalculateDrawProperties(root, device_scale_factor); 10149 ExecuteCalculateDrawProperties(root, device_scale_factor);
10147 EXPECT_EQ(gfx::Rect(40, 40), clip_child->clip_rect()); 10150 EXPECT_EQ(gfx::Rect(-20, -20, 40, 40), clip_child->clip_rect());
10148 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); 10151 EXPECT_EQ(gfx::Rect(10, 10), clip_child->visible_layer_rect());
10149 } 10152 }
10150 10153
10151 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { 10154 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) {
10152 LayerImpl* root = root_layer_for_testing(); 10155 LayerImpl* root = root_layer_for_testing();
10153 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); 10156 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>();
10154 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); 10157 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent);
10155 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); 10158 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface);
10156 10159
10157 root->SetBounds(gfx::Size(30, 30)); 10160 root->SetBounds(gfx::Size(30, 30));
10158 clip_parent->SetBounds(gfx::Size(40, 40)); 10161 clip_parent->SetBounds(gfx::Size(40, 40));
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
10752 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); 10755 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index());
10753 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); 10756 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index());
10754 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); 10757 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index());
10755 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); 10758 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index());
10756 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); 10759 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index());
10757 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); 10760 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index());
10758 } 10761 }
10759 10762
10760 } // namespace 10763 } // namespace
10761 } // namespace cc 10764 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698