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

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

Issue 637913003: Revert of "Converted LayerImpl::bounds() to return SizeF." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('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_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
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::SizeF(50, 50), container_layer->bounds()); 901 EXPECT_EQ(gfx::Size(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
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::SizeF(50, 50), container_layer->bounds()); 932 EXPECT_EQ(gfx::Size(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 2869 matching lines...) Expand 10 before | Expand all | Expand 10 after
3812 gfx::Rect opaque_content_rect_; 3812 gfx::Rect opaque_content_rect_;
3813 gfx::Rect quad_visible_rect_; 3813 gfx::Rect quad_visible_rect_;
3814 ResourceProvider::ResourceId resource_id_; 3814 ResourceProvider::ResourceId resource_id_;
3815 }; 3815 };
3816 3816
3817 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { 3817 TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
3818 { 3818 {
3819 scoped_ptr<LayerImpl> root = 3819 scoped_ptr<LayerImpl> root =
3820 LayerImpl::Create(host_impl_->active_tree(), 1); 3820 LayerImpl::Create(host_impl_->active_tree(), 1);
3821 root->SetBounds(gfx::Size(10, 10)); 3821 root->SetBounds(gfx::Size(10, 10));
3822 root->SetContentBounds(gfx::ToCeiledSize(root->bounds())); 3822 root->SetContentBounds(root->bounds());
3823 root->SetDrawsContent(false); 3823 root->SetDrawsContent(false);
3824 host_impl_->active_tree()->SetRootLayer(root.Pass()); 3824 host_impl_->active_tree()->SetRootLayer(root.Pass());
3825 } 3825 }
3826 LayerImpl* root = host_impl_->active_tree()->root_layer(); 3826 LayerImpl* root = host_impl_->active_tree()->root_layer();
3827 3827
3828 root->AddChild( 3828 root->AddChild(
3829 BlendStateCheckLayer::Create(host_impl_->active_tree(), 3829 BlendStateCheckLayer::Create(host_impl_->active_tree(),
3830 2, 3830 2,
3831 host_impl_->resource_provider())); 3831 host_impl_->resource_provider()));
3832 BlendStateCheckLayer* layer1 = 3832 BlendStateCheckLayer* layer1 =
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
4728 scoped_ptr<LayerImpl> grand_child = 4728 scoped_ptr<LayerImpl> grand_child =
4729 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3); 4729 FakeLayerWithQuads::Create(my_host_impl->active_tree(), 3);
4730 4730
4731 gfx::Rect root_rect(0, 0, 100, 100); 4731 gfx::Rect root_rect(0, 0, 100, 100);
4732 gfx::Rect child_rect(10, 10, 50, 50); 4732 gfx::Rect child_rect(10, 10, 50, 50);
4733 gfx::Rect grand_child_rect(5, 5, 150, 150); 4733 gfx::Rect grand_child_rect(5, 5, 150, 150);
4734 4734
4735 root->CreateRenderSurface(); 4735 root->CreateRenderSurface();
4736 root->SetPosition(root_rect.origin()); 4736 root->SetPosition(root_rect.origin());
4737 root->SetBounds(root_rect.size()); 4737 root->SetBounds(root_rect.size());
4738 root->SetContentBounds(gfx::ToCeiledSize(root->bounds())); 4738 root->SetContentBounds(root->bounds());
4739 root->draw_properties().visible_content_rect = root_rect; 4739 root->draw_properties().visible_content_rect = root_rect;
4740 root->SetDrawsContent(false); 4740 root->SetDrawsContent(false);
4741 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size())); 4741 root->render_surface()->SetContentRect(gfx::Rect(root_rect.size()));
4742 4742
4743 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y())); 4743 child->SetPosition(gfx::PointF(child_rect.x(), child_rect.y()));
4744 child->SetOpacity(0.5f); 4744 child->SetOpacity(0.5f);
4745 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height())); 4745 child->SetBounds(gfx::Size(child_rect.width(), child_rect.height()));
4746 child->SetContentBounds(gfx::ToCeiledSize(child->bounds())); 4746 child->SetContentBounds(child->bounds());
4747 child->draw_properties().visible_content_rect = child_rect; 4747 child->draw_properties().visible_content_rect = child_rect;
4748 child->SetDrawsContent(false); 4748 child->SetDrawsContent(false);
4749 child->SetForceRenderSurface(true); 4749 child->SetForceRenderSurface(true);
4750 4750
4751 grand_child->SetPosition(grand_child_rect.origin()); 4751 grand_child->SetPosition(grand_child_rect.origin());
4752 grand_child->SetBounds(grand_child_rect.size()); 4752 grand_child->SetBounds(grand_child_rect.size());
4753 grand_child->SetContentBounds(gfx::ToCeiledSize(grand_child->bounds())); 4753 grand_child->SetContentBounds(grand_child->bounds());
4754 grand_child->draw_properties().visible_content_rect = grand_child_rect; 4754 grand_child->draw_properties().visible_content_rect = grand_child_rect;
4755 grand_child->SetDrawsContent(true); 4755 grand_child->SetDrawsContent(true);
4756 4756
4757 child->AddChild(grand_child.Pass()); 4757 child->AddChild(grand_child.Pass());
4758 root->AddChild(child.Pass()); 4758 root->AddChild(child.Pass());
4759 4759
4760 my_host_impl->active_tree()->SetRootLayer(root.Pass()); 4760 my_host_impl->active_tree()->SetRootLayer(root.Pass());
4761 return my_host_impl.Pass(); 4761 return my_host_impl.Pass();
4762 } 4762 }
4763 4763
(...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after
7267 // surface. 7267 // surface.
7268 EXPECT_EQ(0, num_lost_surfaces_); 7268 EXPECT_EQ(0, num_lost_surfaces_);
7269 host_impl_->DidLoseOutputSurface(); 7269 host_impl_->DidLoseOutputSurface();
7270 EXPECT_EQ(1, num_lost_surfaces_); 7270 EXPECT_EQ(1, num_lost_surfaces_);
7271 host_impl_->DidLoseOutputSurface(); 7271 host_impl_->DidLoseOutputSurface();
7272 EXPECT_LE(1, num_lost_surfaces_); 7272 EXPECT_LE(1, num_lost_surfaces_);
7273 } 7273 }
7274 7274
7275 } // namespace 7275 } // namespace
7276 } // namespace cc 7276 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698