| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 gfx::PointF position; | 111 gfx::PointF position; |
| 112 gfx::Size bounds(100, 100); | 112 gfx::Size bounds(100, 100); |
| 113 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, | 113 SetLayerPropertiesForTesting(root.get(), identity_matrix, transform_origin, |
| 114 position, bounds, true, false, true); | 114 position, bounds, true, false, true); |
| 115 root->SetDrawsContent(true); | 115 root->SetDrawsContent(true); |
| 116 | 116 |
| 117 host_impl->SetViewportSize(root->bounds()); | 117 host_impl->SetViewportSize(root->bounds()); |
| 118 host_impl->active_tree()->SetRootLayer(root.Pass()); | 118 host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 119 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 119 host_impl->UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| 120 EXPECT_EQ( | 120 EXPECT_EQ( |
| 121 gfx::RectF(bounds), | 121 gfx::RectF(gfx::SizeF(bounds)), |
| 122 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 122 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); |
| 123 EXPECT_EQ(gfx::Rect(bounds), | 123 EXPECT_EQ(gfx::Rect(bounds), |
| 124 host_impl->RootLayer()->visible_rect_from_property_trees()); | 124 host_impl->RootLayer()->visible_rect_from_property_trees()); |
| 125 | 125 |
| 126 gfx::Size new_bounds(50, 50); | 126 gfx::Size new_bounds(50, 50); |
| 127 host_impl->SetViewportSize(new_bounds); | 127 host_impl->SetViewportSize(new_bounds); |
| 128 gfx::Point test_point(51, 51); | 128 gfx::Point test_point(51, 51); |
| 129 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); | 129 host_impl->active_tree()->FindLayerThatIsHitByPoint(test_point); |
| 130 EXPECT_EQ( | 130 EXPECT_EQ( |
| 131 gfx::RectF(new_bounds), | 131 gfx::RectF(gfx::SizeF(new_bounds)), |
| 132 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); | 132 host_impl->active_tree()->property_trees()->clip_tree.ViewportClip()); |
| 133 EXPECT_EQ(gfx::Rect(new_bounds), | 133 EXPECT_EQ(gfx::Rect(new_bounds), |
| 134 host_impl->RootLayer()->visible_rect_from_property_trees()); | 134 host_impl->RootLayer()->visible_rect_from_property_trees()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { | 137 TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { |
| 138 scoped_ptr<LayerImpl> root = | 138 scoped_ptr<LayerImpl> root = |
| 139 LayerImpl::Create(host_impl().active_tree(), 12345); | 139 LayerImpl::Create(host_impl().active_tree(), 12345); |
| 140 scoped_ptr<HeadsUpDisplayLayerImpl> hud = | 140 scoped_ptr<HeadsUpDisplayLayerImpl> hud = |
| 141 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); | 141 HeadsUpDisplayLayerImpl::Create(host_impl().active_tree(), 11111); |
| (...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 transform_origin, position, bounds, true, | 1488 transform_origin, position, bounds, true, |
| 1489 false, false); | 1489 false, false); |
| 1490 | 1490 |
| 1491 test_layer->SetDrawsContent(true); | 1491 test_layer->SetDrawsContent(true); |
| 1492 test_layer->SetTouchEventHandlerRegion(touch_handler_region); | 1492 test_layer->SetTouchEventHandlerRegion(touch_handler_region); |
| 1493 root->AddChild(test_layer.Pass()); | 1493 root->AddChild(test_layer.Pass()); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 float device_scale_factor = 3.f; | 1496 float device_scale_factor = 3.f; |
| 1497 float page_scale_factor = 5.f; | 1497 float page_scale_factor = 5.f; |
| 1498 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( | 1498 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( |
| 1499 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); | 1499 root->bounds(), device_scale_factor * page_scale_factor); |
| 1500 host_impl().SetViewportSize(scaled_bounds_for_root); | 1500 host_impl().SetViewportSize(scaled_bounds_for_root); |
| 1501 | 1501 |
| 1502 host_impl().SetDeviceScaleFactor(device_scale_factor); | 1502 host_impl().SetDeviceScaleFactor(device_scale_factor); |
| 1503 host_impl().active_tree()->PushPageScaleFromMainThread( | 1503 host_impl().active_tree()->PushPageScaleFromMainThread( |
| 1504 page_scale_factor, page_scale_factor, page_scale_factor); | 1504 page_scale_factor, page_scale_factor, page_scale_factor); |
| 1505 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1505 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1506 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1506 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 1507 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 1507 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
| 1508 Layer::INVALID_ID); | 1508 Layer::INVALID_ID); |
| 1509 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1509 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 gfx::Size bounds(50, 50); | 1947 gfx::Size bounds(50, 50); |
| 1948 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix, | 1948 SetLayerPropertiesForTesting(sub_layer.get(), identity_matrix, |
| 1949 transform_origin, position, bounds, true, | 1949 transform_origin, position, bounds, true, |
| 1950 false, false); | 1950 false, false); |
| 1951 sub_layer->SetDrawsContent(true); | 1951 sub_layer->SetDrawsContent(true); |
| 1952 root->AddChild(sub_layer.Pass()); | 1952 root->AddChild(sub_layer.Pass()); |
| 1953 } | 1953 } |
| 1954 | 1954 |
| 1955 float device_scale_factor = 3.f; | 1955 float device_scale_factor = 3.f; |
| 1956 float page_scale_factor = 5.f; | 1956 float page_scale_factor = 5.f; |
| 1957 gfx::Size scaled_bounds_for_root = gfx::ToCeiledSize( | 1957 gfx::Size scaled_bounds_for_root = gfx::ScaleToCeiledSize( |
| 1958 gfx::ScaleSize(root->bounds(), device_scale_factor * page_scale_factor)); | 1958 root->bounds(), device_scale_factor * page_scale_factor); |
| 1959 host_impl().SetViewportSize(scaled_bounds_for_root); | 1959 host_impl().SetViewportSize(scaled_bounds_for_root); |
| 1960 | 1960 |
| 1961 host_impl().SetDeviceScaleFactor(device_scale_factor); | 1961 host_impl().SetDeviceScaleFactor(device_scale_factor); |
| 1962 host_impl().active_tree()->PushPageScaleFromMainThread( | 1962 host_impl().active_tree()->PushPageScaleFromMainThread( |
| 1963 page_scale_factor, page_scale_factor, page_scale_factor); | 1963 page_scale_factor, page_scale_factor, page_scale_factor); |
| 1964 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1964 host_impl().active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1965 host_impl().active_tree()->SetRootLayer(root.Pass()); | 1965 host_impl().active_tree()->SetRootLayer(root.Pass()); |
| 1966 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, | 1966 host_impl().active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 1, |
| 1967 Layer::INVALID_ID); | 1967 Layer::INVALID_ID); |
| 1968 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 1968 host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); | 2080 EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); |
| 2081 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); | 2081 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); |
| 2082 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); | 2082 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); |
| 2083 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); | 2083 root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); |
| 2084 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); | 2084 root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); |
| 2085 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); | 2085 EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); |
| 2086 } | 2086 } |
| 2087 | 2087 |
| 2088 } // namespace | 2088 } // namespace |
| 2089 } // namespace cc | 2089 } // namespace cc |
| OLD | NEW |