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/layer_tree_host_impl.h" | 5 #include "cc/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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 m_hostImpl->scrollEnd(); | 875 m_hostImpl->scrollEnd(); |
876 | 876 |
877 // The final page scale and scroll deltas should match what we got | 877 // The final page scale and scroll deltas should match what we got |
878 // earlier. | 878 // earlier. |
879 m_hostImpl->animate(endTime, base::Time()); | 879 m_hostImpl->animate(endTime, base::Time()); |
880 scrollInfo = m_hostImpl->processScrollDeltas(); | 880 scrollInfo = m_hostImpl->processScrollDeltas(); |
881 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 881 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
882 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); | 882 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); |
883 } | 883 } |
884 | 884 |
885 TEST_P(LayerTreeHostImplTest, compositorFrameMetadata) | |
886 { | |
887 setupScrollAndContentsLayers(gfx::Size(100, 100)); | |
888 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | |
889 m_hostImpl->setPageScaleFactorAndLimits(1, 0.5f, 4); | |
890 initializeRendererAndDrawFrame(); | |
891 | |
892 { | |
893 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); | |
894 EXPECT_EQ(gfx::Vector2dF(0, 0), metadata.root_scroll_offset); | |
danakj
2013/01/07 19:40:24
might as well style nit this now since we'll just
| |
895 EXPECT_EQ(1, metadata.page_scale_factor); | |
896 EXPECT_EQ(gfx::SizeF(50, 50), metadata.viewport_size); | |
897 EXPECT_EQ(gfx::SizeF(100, 100), metadata.root_layer_size); | |
898 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | |
899 EXPECT_EQ(4, metadata.max_page_scale_factor); | |
900 } | |
901 | |
902 // Scrolling should update metadata immediately. | |
903 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); | |
904 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | |
905 { | |
906 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); | |
907 EXPECT_EQ(gfx::Vector2dF(0, 10), metadata.root_scroll_offset); | |
908 } | |
909 m_hostImpl->scrollEnd(); | |
910 | |
911 { | |
912 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); | |
913 EXPECT_EQ(gfx::Vector2dF(0, 10), metadata.root_scroll_offset); | |
914 } | |
915 | |
916 // Page scale should update metadata correctly (shrinking only the viewport) . | |
917 m_hostImpl->pinchGestureBegin(); | |
918 m_hostImpl->pinchGestureUpdate(2, gfx::Point(0, 0)); | |
919 m_hostImpl->pinchGestureEnd(); | |
920 | |
921 { | |
922 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); | |
923 EXPECT_EQ(gfx::Vector2dF(0, 10), metadata.root_scroll_offset); | |
924 EXPECT_EQ(2, metadata.page_scale_factor); | |
925 EXPECT_EQ(gfx::SizeF(25, 25), metadata.viewport_size); | |
926 EXPECT_EQ(gfx::SizeF(100, 100), metadata.root_layer_size); | |
927 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | |
928 EXPECT_EQ(4, metadata.max_page_scale_factor); | |
929 } | |
930 | |
931 // Likewise if set from the main thread. | |
932 m_hostImpl->processScrollDeltas(); | |
933 m_hostImpl->setPageScaleFactorAndLimits(4, 0.5f, 4); | |
934 { | |
935 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada ta(); | |
936 EXPECT_EQ(gfx::Vector2dF(0, 10), metadata.root_scroll_offset); | |
937 EXPECT_EQ(4, metadata.page_scale_factor); | |
938 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size); | |
939 EXPECT_EQ(gfx::SizeF(100, 100), metadata.root_layer_size); | |
940 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | |
941 EXPECT_EQ(4, metadata.max_page_scale_factor); | |
942 } | |
943 } | |
944 | |
885 class DidDrawCheckLayer : public TiledLayerImpl { | 945 class DidDrawCheckLayer : public TiledLayerImpl { |
886 public: | 946 public: |
887 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur n scoped_ptr<LayerImpl>(new DidDrawCheckLayer(treeImpl, id)); } | 947 static scoped_ptr<LayerImpl> create(LayerTreeImpl* treeImpl, int id) { retur n scoped_ptr<LayerImpl>(new DidDrawCheckLayer(treeImpl, id)); } |
888 | 948 |
889 virtual void didDraw(ResourceProvider*) OVERRIDE | 949 virtual void didDraw(ResourceProvider*) OVERRIDE |
890 { | 950 { |
891 m_didDrawCalled = true; | 951 m_didDrawCalled = true; |
892 } | 952 } |
893 | 953 |
894 virtual void willDraw(ResourceProvider*) OVERRIDE | 954 virtual void willDraw(ResourceProvider*) OVERRIDE |
(...skipping 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4340 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4400 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4341 drawFrameAndTestDamage(noDamage); | 4401 drawFrameAndTestDamage(noDamage); |
4342 } | 4402 } |
4343 | 4403 |
4344 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4404 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4345 LayerTreeHostImplTest, | 4405 LayerTreeHostImplTest, |
4346 ::testing::Values(false, true)); | 4406 ::testing::Values(false, true)); |
4347 | 4407 |
4348 } // namespace | 4408 } // namespace |
4349 } // namespace cc | 4409 } // namespace cc |
OLD | NEW |