| OLD | NEW |
| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); | 891 EXPECT_EQ(host_impl_->HaveTouchEventHandlersAt(gfx::Point()), false); |
| 892 } | 892 } |
| 893 | 893 |
| 894 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 894 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
| 895 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 895 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 896 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 896 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 897 DrawFrame(); | 897 DrawFrame(); |
| 898 | 898 |
| 899 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 899 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); |
| 900 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 900 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
| 901 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 901 EXPECT_EQ(gfx::SizeF(50, 50), container_layer->bounds()); |
| 902 | 902 |
| 903 float min_page_scale = 1.f, max_page_scale = 4.f; | 903 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 904 float page_scale_factor = 1.f; | 904 float page_scale_factor = 1.f; |
| 905 | 905 |
| 906 // The impl-based pinch zoom should adjust the max scroll position. | 906 // The impl-based pinch zoom should adjust the max scroll position. |
| 907 { | 907 { |
| 908 host_impl_->active_tree()->SetPageScaleFactorAndLimits( | 908 host_impl_->active_tree()->SetPageScaleFactorAndLimits( |
| 909 page_scale_factor, min_page_scale, max_page_scale); | 909 page_scale_factor, min_page_scale, max_page_scale); |
| 910 host_impl_->active_tree()->SetPageScaleDelta(1.f); | 910 host_impl_->active_tree()->SetPageScaleDelta(1.f); |
| 911 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 911 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 922 // While the gesture is still active, the scroll layer should have a | 922 // While the gesture is still active, the scroll layer should have a |
| 923 // container size delta = container->bounds() * ((1.f - | 923 // container size delta = container->bounds() * ((1.f - |
| 924 // page_scale_delta)/()) | 924 // page_scale_delta)/()) |
| 925 EXPECT_EQ(expected_container_size_delta, | 925 EXPECT_EQ(expected_container_size_delta, |
| 926 scroll_layer->FixedContainerSizeDelta()); | 926 scroll_layer->FixedContainerSizeDelta()); |
| 927 host_impl_->PinchGestureEnd(); | 927 host_impl_->PinchGestureEnd(); |
| 928 host_impl_->ScrollEnd(); | 928 host_impl_->ScrollEnd(); |
| 929 EXPECT_FALSE(did_request_animate_); | 929 EXPECT_FALSE(did_request_animate_); |
| 930 EXPECT_TRUE(did_request_redraw_); | 930 EXPECT_TRUE(did_request_redraw_); |
| 931 EXPECT_TRUE(did_request_commit_); | 931 EXPECT_TRUE(did_request_commit_); |
| 932 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 932 EXPECT_EQ(gfx::SizeF(50, 50), container_layer->bounds()); |
| 933 | 933 |
| 934 scoped_ptr<ScrollAndScaleSet> scroll_info = | 934 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 935 host_impl_->ProcessScrollDeltas(); | 935 host_impl_->ProcessScrollDeltas(); |
| 936 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 936 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 937 | 937 |
| 938 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), | 938 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), |
| 939 scroll_layer->MaxScrollOffset().ToString()); | 939 scroll_layer->MaxScrollOffset().ToString()); |
| 940 } | 940 } |
| 941 | 941 |
| 942 // Scrolling after a pinch gesture should always be in local space. The | 942 // Scrolling after a pinch gesture should always be in local space. The |
| (...skipping 2867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3810 gfx::Rect opaque_content_rect_; | 3810 gfx::Rect opaque_content_rect_; |
| 3811 gfx::Rect quad_visible_rect_; | 3811 gfx::Rect quad_visible_rect_; |
| 3812 ResourceProvider::ResourceId resource_id_; | 3812 ResourceProvider::ResourceId resource_id_; |
| 3813 }; | 3813 }; |
| 3814 | 3814 |
| 3815 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { | 3815 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { |
| 3816 { | 3816 { |
| 3817 scoped_ptr<LayerImpl> root = | 3817 scoped_ptr<LayerImpl> root = |
| 3818 LayerImpl::Create(host_impl_->active_tree(), 1); | 3818 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3819 root->SetBounds(gfx::Size(10, 10)); | 3819 root->SetBounds(gfx::Size(10, 10)); |
| 3820 root->SetContentBounds(root->bounds()); | 3820 root->SetContentBounds(gfx::ToCeiledSize(root->bounds())); |
| 3821 root->SetDrawsContent(false); | 3821 root->SetDrawsContent(false); |
| 3822 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3822 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3823 } | 3823 } |
| 3824 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 3824 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 3825 | 3825 |
| 3826 root->AddChild( | 3826 root->AddChild( |
| 3827 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 3827 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 3828 2, | 3828 2, |
| 3829 host_impl_->resource_provider())); | 3829 host_impl_->resource_provider())); |
| 3830 BlendStateCheckLayer* layer1 = | 3830 BlendStateCheckLayer* layer1 = |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4727 scoped_ptr<LayerImpl> grand_child = | 4727 scoped_ptr<LayerImpl> grand_child = |
| 4728 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); | 4728 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); |
| 4729 | 4729 |
| 4730 gfx::Rect root_rect(0, 0, 100, 100); | 4730 gfx::Rect root_rect(0, 0, 100, 100); |
| 4731 gfx::Rect child_rect(10, 10, 50, 50); | 4731 gfx::Rect child_rect(10, 10, 50, 50); |
| 4732 gfx::Rect grand_child_rect(5, 5, 150, 150); | 4732 gfx::Rect grand_child_rect(5, 5, 150, 150); |
| 4733 | 4733 |
| 4734 root->CreateRenderSurface(); | 4734 root->CreateRenderSurface(); |
| 4735 root->SetPosition(root_rect.origin()); | 4735 root->SetPosition(root_rect.origin()); |
| 4736 root->SetBounds(root_rect.size()); | 4736 root->SetBounds(root_rect.size()); |
| 4737 root->SetContentBounds(root->bounds()); | 4737 root->SetContentBounds(gfx::ToCeiledSize(root->bounds())); |
| 4738 root->draw_properties().visible_content_rect = root_rect; | 4738 root->draw_properties().visible_content_rect = root_rect; |
| 4739 root->SetDrawsContent(false); | 4739 root->SetDrawsContent(false); |
| 4740 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); | 4740 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); |
| 4741 | 4741 |
| 4742 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); | 4742 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); |
| 4743 child->SetOpacity(0.5f); | 4743 child->SetOpacity(0.5f); |
| 4744 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); | 4744 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); |
| 4745 child->SetContentBounds(child->bounds()); | 4745 child->SetContentBounds(gfx::ToCeiledSize(child->bounds())); |
| 4746 child->draw_properties().visible_content_rect = child_rect; | 4746 child->draw_properties().visible_content_rect = child_rect; |
| 4747 child->SetDrawsContent(false); | 4747 child->SetDrawsContent(false); |
| 4748 child->SetForceRenderSurface(true); | 4748 child->SetForceRenderSurface(true); |
| 4749 | 4749 |
| 4750 grand_child->SetPosition(grand_child_rect.origin()); | 4750 grand_child->SetPosition(grand_child_rect.origin()); |
| 4751 grand_child->SetBounds(grand_child_rect.size()); | 4751 grand_child->SetBounds(grand_child_rect.size()); |
| 4752 grand_child->SetContentBounds(grand_child->bounds()); | 4752 grand_child->SetContentBounds(gfx::ToCeiledSize(grand_child->bounds())); |
| 4753 grand_child->draw_properties().visible_content_rect = grand_child_rect; | 4753 grand_child->draw_properties().visible_content_rect = grand_child_rect; |
| 4754 grand_child->SetDrawsContent(true); | 4754 grand_child->SetDrawsContent(true); |
| 4755 | 4755 |
| 4756 child->AddChild(grand_child.Pass()); | 4756 child->AddChild(grand_child.Pass()); |
| 4757 root->AddChild(child.Pass()); | 4757 root->AddChild(child.Pass()); |
| 4758 | 4758 |
| 4759 my_host_impl->active_tree()->SetRootLayer(root.Pass()); | 4759 my_host_impl->active_tree()->SetRootLayer(root.Pass()); |
| 4760 return my_host_impl.Pass(); | 4760 return my_host_impl.Pass(); |
| 4761 } | 4761 } |
| 4762 | 4762 |
| (...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7266 // surface. | 7266 // surface. |
| 7267 EXPECT_EQ(0, num_lost_surfaces_); | 7267 EXPECT_EQ(0, num_lost_surfaces_); |
| 7268 host_impl_->DidLoseOutputSurface(); | 7268 host_impl_->DidLoseOutputSurface(); |
| 7269 EXPECT_EQ(1, num_lost_surfaces_); | 7269 EXPECT_EQ(1, num_lost_surfaces_); |
| 7270 host_impl_->DidLoseOutputSurface(); | 7270 host_impl_->DidLoseOutputSurface(); |
| 7271 EXPECT_LE(1, num_lost_surfaces_); | 7271 EXPECT_LE(1, num_lost_surfaces_); |
| 7272 } | 7272 } |
| 7273 | 7273 |
| 7274 } // namespace | 7274 } // namespace |
| 7275 } // namespace cc | 7275 } // namespace cc |
| OLD | NEW |