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

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

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "cc/layers/heads_up_display_layer_impl.h" 7 #include "cc/layers/heads_up_display_layer_impl.h"
8 #include "cc/layers/layer.h" 8 #include "cc/layers/layer.h"
9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 gfx::PointF position; 109 gfx::PointF position;
110 gfx::Size bounds(100, 100); 110 gfx::Size bounds(100, 100);
111 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, 111 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin,
112 position, bounds, true, false, true); 112 position, bounds, true, false, true);
113 root->SetDrawsContent(true); 113 root->SetDrawsContent(true);
114 114
115 host_impl->SetViewportSize(root->bounds()); 115 host_impl->SetViewportSize(root->bounds());
116 host_impl->active_tree()->SetRootLayer(root.Pass()); 116 host_impl->active_tree()->SetRootLayer(root.Pass());
117 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); 117 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree();
118 EXPECT_EQ( 118 EXPECT_EQ(
119 gfx::RectF(bounds), 119 gfx::RectF(gfx::SizeF(bounds)),
120 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); 120 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip());
121 EXPECT_EQ(gfx::Rect(bounds), 121 EXPECT_EQ(gfx::Rect(bounds),
122 host_impl->RootLayer()->visible_rect_from_property_trees()); 122 host_impl->RootLayer()->visible_rect_from_property_trees());
123 123
124 gfx::Size new_bounds(50, 50); 124 gfx::Size new_bounds(50, 50);
125 host_impl->SetViewportSize(new_bounds); 125 host_impl->SetViewportSize(new_bounds);
126 gfx::Point test_point(51, 51); 126 gfx::Point test_point(51, 51);
127 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); 127 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point);
128 EXPECT_EQ( 128 EXPECT_EQ(
129 gfx::RectF(new_bounds), 129 gfx::RectF(gfx::SizeF(new_bounds)),
130 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); 130 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip());
131 EXPECT_EQ(gfx::Rect(new_bounds), 131 EXPECT_EQ(gfx::Rect(new_bounds),
132 host_impl->RootLayer()->visible_rect_from_property_trees()); 132 host_impl->RootLayer()->visible_rect_from_property_trees());
133 } 133 }
134 134
135 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { 135 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) {
136 scoped_ptr<LayerImpl> root = 136 scoped_ptr<LayerImpl> root =
137 LayerImpl::Create(host_impl().active_tree(), 12345); 137 LayerImpl::Create(host_impl().active_tree(), 12345);
138 scoped_ptr<HeadsUpDisplayLayerImpl> hud = 138 scoped_ptr<HeadsUpDisplayLayerImpl> hud =
139 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); 139 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111);
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 transform_origin, position, bounds, true, 1486 transform_origin, position, bounds, true,
1487 false, false); 1487 false, false);
1488 1488
1489 test_layer->SetDrawsContent(true); 1489 test_layer->SetDrawsContent(true);
1490 test_layer->SetTouchEventHandlerRegion(touch_handler_region); 1490 test_layer->SetTouchEventHandlerRegion(touch_handler_region);
1491 root->AddChild(test_layer.Pass()); 1491 root->AddChild(test_layer.Pass());
1492 } 1492 }
1493 1493
1494 float device_scale_factor = 3.f; 1494 float device_scale_factor = 3.f;
1495 float page_scale_factor = 5.f; 1495 float page_scale_factor = 5.f;
1496 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( 1496 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
1497 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); 1497 root->bounds(), device_scale_factor * page_scale_factor);
1498 host_impl().SetViewportSize(scaled_bounds_for_root); 1498 host_impl().SetViewportSize(scaled_bounds_for_root);
1499 1499
1500 host_impl().SetDeviceScaleFactor(device_scale_factor); 1500 host_impl().SetDeviceScaleFactor(device_scale_factor);
1501 host_impl().active_tree()->PushPageScaleFromMainThread( 1501 host_impl().active_tree()->PushPageScaleFromMainThread(
1502 page_scale_factor, page_scale_factor, page_scale_factor); 1502 page_scale_factor, page_scale_factor, page_scale_factor);
1503 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1503 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1504 host_impl().active_tree()->SetRootLayer(root.Pass()); 1504 host_impl().active_tree()->SetRootLayer(root.Pass());
1505 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, 1505 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1,
1506 Layer::INVALID_ID); 1506 Layer::INVALID_ID);
1507 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1507 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 gfx::Size bounds(50, 50); 1945 gfx::Size bounds(50, 50);
1946 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix, 1946 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix,
1947 transform_origin, position, bounds, true, 1947 transform_origin, position, bounds, true,
1948 false, false); 1948 false, false);
1949 sub_layer->SetDrawsContent(true); 1949 sub_layer->SetDrawsContent(true);
1950 root->AddChild(sub_layer.Pass()); 1950 root->AddChild(sub_layer.Pass());
1951 } 1951 }
1952 1952
1953 float device_scale_factor = 3.f; 1953 float device_scale_factor = 3.f;
1954 float page_scale_factor = 5.f; 1954 float page_scale_factor = 5.f;
1955 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( 1955 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize(
1956 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); 1956 root->bounds(), device_scale_factor * page_scale_factor);
1957 host_impl().SetViewportSize(scaled_bounds_for_root); 1957 host_impl().SetViewportSize(scaled_bounds_for_root);
1958 1958
1959 host_impl().SetDeviceScaleFactor(device_scale_factor); 1959 host_impl().SetDeviceScaleFactor(device_scale_factor);
1960 host_impl().active_tree()->PushPageScaleFromMainThread( 1960 host_impl().active_tree()->PushPageScaleFromMainThread(
1961 page_scale_factor, page_scale_factor, page_scale_factor); 1961 page_scale_factor, page_scale_factor, page_scale_factor);
1962 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); 1962 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor);
1963 host_impl().active_tree()->SetRootLayer(root.Pass()); 1963 host_impl().active_tree()->SetRootLayer(root.Pass());
1964 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, 1964 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1,
1965 Layer::INVALID_ID); 1965 Layer::INVALID_ID);
1966 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); 1966 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); 2078 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers());
2079 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); 2079 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1);
2080 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); 2080 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2));
2081 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); 2081 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3));
2082 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); 2082 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4));
2083 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); 2083 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers());
2084 } 2084 }
2085 2085
2086 } // namespace 2086 } // namespace
2087 } // namespace cc 2087 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698