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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 m_hostImpl->drawLayers(frame); | 200 m_hostImpl->drawLayers(frame); |
201 m_hostImpl->didDrawAllLayers(frame); | 201 m_hostImpl->didDrawAllLayers(frame); |
202 } | 202 } |
203 | 203 |
204 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); | 204 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); |
205 void pinchZoomPanViewportTest(const float deviceScaleFactor); | 205 void pinchZoomPanViewportTest(const float deviceScaleFactor); |
206 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); | 206 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); |
207 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); | 207 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); |
208 | 208 |
209 protected: | 209 protected: |
210 scoped_ptr<OutputSurface> createOutputSurface() | 210 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO
utputSurface(); } |
211 { | |
212 return FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext
3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); | |
213 } | |
214 | 211 |
215 FakeProxy m_proxy; | 212 FakeProxy m_proxy; |
216 DebugScopedSetImplThread m_alwaysImplThread; | 213 DebugScopedSetImplThread m_alwaysImplThread; |
217 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 214 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
218 | 215 |
219 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 216 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
220 bool m_onCanDrawStateChangedCalled; | 217 bool m_onCanDrawStateChangedCalled; |
221 bool m_didRequestCommit; | 218 bool m_didRequestCommit; |
222 bool m_didRequestRedraw; | 219 bool m_didRequestRedraw; |
223 bool m_reduceMemoryResult; | 220 bool m_reduceMemoryResult; |
(...skipping 4661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4885 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor) | 4882 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor) |
4886 { | 4883 { |
4887 pinchZoomPanViewportAndScrollBoundaryTest(1); | 4884 pinchZoomPanViewportAndScrollBoundaryTest(1); |
4888 } | 4885 } |
4889 | 4886 |
4890 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor2) | 4887 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor2) |
4891 { | 4888 { |
4892 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4889 pinchZoomPanViewportAndScrollBoundaryTest(2); |
4893 } | 4890 } |
4894 | 4891 |
| 4892 class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest
{ |
| 4893 protected: |
| 4894 virtual scoped_ptr<OutputSurface> createOutputSurface() |
| 4895 { |
| 4896 // Creates an output surface with a parent to use a delegating renderer. |
| 4897 WebKit::WebGraphicsContext3D::Attributes attrs; |
| 4898 return FakeOutputSurface::CreateDelegating3d(WebKit::CompositorFakeWebGr
aphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<Ou
tputSurface>(); |
| 4899 } |
| 4900 |
| 4901 void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) { |
| 4902 LayerTreeHostImpl::FrameData frame; |
| 4903 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 4904 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 4905 |
| 4906 // Verify the damage rect for the root render pass. |
| 4907 const RenderPass* rootRenderPass = frame.renderPasses.back(); |
| 4908 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); |
| 4909 |
| 4910 // Verify the root layer's quad is generated and not being culled. |
| 4911 ASSERT_EQ(1u, rootRenderPass->quad_list.size()); |
| 4912 gfx::Rect expectedVisibleRect(m_hostImpl->rootLayer()->contentBounds()); |
| 4913 EXPECT_RECT_EQ(expectedVisibleRect, rootRenderPass->quad_list[0]->visibl
e_rect); |
| 4914 |
| 4915 m_hostImpl->drawLayers(frame); |
| 4916 m_hostImpl->didDrawAllLayers(frame); |
| 4917 } |
| 4918 }; |
| 4919 |
| 4920 TEST_P(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) |
| 4921 { |
| 4922 // Draw a frame. In the first frame, the entire viewport should be damaged. |
| 4923 gfx::Rect fullFrameDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
| 4924 drawFrameAndTestDamage(fullFrameDamage); |
| 4925 |
| 4926 // The second frame should have no damage, but the quads should still be gen
erated. |
| 4927 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
| 4928 drawFrameAndTestDamage(noDamage); |
| 4929 } |
| 4930 |
4895 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4931 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4896 LayerTreeHostImplTest, | 4932 LayerTreeHostImplTest, |
4897 ::testing::Values(false, true)); | 4933 ::testing::Values(false, true)); |
4898 | 4934 |
4899 } // namespace | 4935 } // namespace |
4900 } // namespace cc | 4936 } // namespace cc |
OLD | NEW |