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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 m_hostImpl->drawLayers(frame); | 198 m_hostImpl->drawLayers(frame); |
199 m_hostImpl->didDrawAllLayers(frame); | 199 m_hostImpl->didDrawAllLayers(frame); |
200 } | 200 } |
201 | 201 |
202 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); | 202 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); |
203 void pinchZoomPanViewportTest(const float deviceScaleFactor); | 203 void pinchZoomPanViewportTest(const float deviceScaleFactor); |
204 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); | 204 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); |
205 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); | 205 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); |
206 | 206 |
207 protected: | 207 protected: |
208 scoped_ptr<OutputSurface> createOutputSurface() | 208 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO
utputSurface(); } |
209 { | |
210 return FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext
3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); | |
211 } | |
212 | 209 |
213 FakeProxy m_proxy; | 210 FakeProxy m_proxy; |
214 DebugScopedSetImplThread m_alwaysImplThread; | 211 DebugScopedSetImplThread m_alwaysImplThread; |
215 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 212 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
216 | 213 |
217 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 214 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
218 bool m_onCanDrawStateChangedCalled; | 215 bool m_onCanDrawStateChangedCalled; |
219 bool m_didRequestCommit; | 216 bool m_didRequestCommit; |
220 bool m_didRequestRedraw; | 217 bool m_didRequestRedraw; |
221 bool m_reduceMemoryResult; | 218 bool m_reduceMemoryResult; |
(...skipping 3985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4207 struct RenderPassRemovalTestData : public LayerTreeHostImpl::FrameData { | 4204 struct RenderPassRemovalTestData : public LayerTreeHostImpl::FrameData { |
4208 ScopedPtrHashMap<RenderPass::Id, TestRenderPass> renderPassCache; | 4205 ScopedPtrHashMap<RenderPass::Id, TestRenderPass> renderPassCache; |
4209 scoped_ptr<SharedQuadState> sharedQuadState; | 4206 scoped_ptr<SharedQuadState> sharedQuadState; |
4210 }; | 4207 }; |
4211 | 4208 |
4212 class TestRenderer : public GLRenderer, public RendererClient { | 4209 class TestRenderer : public GLRenderer, public RendererClient { |
4213 public: | 4210 public: |
4214 static scoped_ptr<TestRenderer> create(ResourceProvider* resourceProvider, P
roxy* proxy) | 4211 static scoped_ptr<TestRenderer> create(ResourceProvider* resourceProvider, P
roxy* proxy) |
4215 { | 4212 { |
4216 scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider, pro
xy)); | 4213 scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider, pro
xy)); |
4217 if (!renderer->initialize()) | 4214 if (!renderer->initialize(resourceProvider)) |
4218 return scoped_ptr<TestRenderer>(); | 4215 return scoped_ptr<TestRenderer>(); |
4219 | 4216 |
4220 return renderer.Pass(); | 4217 return renderer.Pass(); |
4221 } | 4218 } |
4222 | 4219 |
4223 void clearCachedTextures() { m_textures.clear(); } | 4220 void clearCachedTextures() { m_textures.clear(); } |
4224 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } | 4221 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } |
4225 | 4222 |
4226 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } | 4223 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } |
4227 | 4224 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4889 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor) | 4886 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor) |
4890 { | 4887 { |
4891 pinchZoomPanViewportAndScrollBoundaryTest(1); | 4888 pinchZoomPanViewportAndScrollBoundaryTest(1); |
4892 } | 4889 } |
4893 | 4890 |
4894 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor2) | 4891 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca
leFactor2) |
4895 { | 4892 { |
4896 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4893 pinchZoomPanViewportAndScrollBoundaryTest(2); |
4897 } | 4894 } |
4898 | 4895 |
| 4896 class LayerTreeHostImplTestWithDelegatingRenderer : public LayerTreeHostImplTest
{ |
| 4897 protected: |
| 4898 virtual scoped_ptr<OutputSurface> createOutputSurface() |
| 4899 { |
| 4900 // Creates an output surface with a parent to use a delegating renderer. |
| 4901 WebKit::WebGraphicsContext3D::Attributes attrs; |
| 4902 return FakeOutputSurface::CreateDelegating3d(WebKit::CompositorFakeWebGr
aphicsContext3D::create(attrs).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<Ou
tputSurface>(); |
| 4903 } |
| 4904 |
| 4905 void drawFrameAndTestDamage(const gfx::RectF& expectedDamage) { |
| 4906 LayerTreeHostImpl::FrameData frame; |
| 4907 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 4908 ASSERT_EQ(1u, frame.renderPasses.size()); |
| 4909 |
| 4910 // Verify the damage rect for the root render pass. |
| 4911 const RenderPass* rootRenderPass = frame.renderPasses.back(); |
| 4912 EXPECT_RECT_EQ(expectedDamage, rootRenderPass->damage_rect); |
| 4913 |
| 4914 // Verify the root layer's quad is generated and not being culled. |
| 4915 ASSERT_EQ(1u, rootRenderPass->quad_list.size()); |
| 4916 gfx::Rect expectedVisibleRect(m_hostImpl->rootLayer()->contentBounds()); |
| 4917 EXPECT_RECT_EQ(expectedVisibleRect, rootRenderPass->quad_list[0]->visibl
e_rect); |
| 4918 |
| 4919 m_hostImpl->drawLayers(frame); |
| 4920 m_hostImpl->didDrawAllLayers(frame); |
| 4921 } |
| 4922 }; |
| 4923 |
| 4924 TEST_P(LayerTreeHostImplTestWithDelegatingRenderer, FrameIncludesDamageRect) |
| 4925 { |
| 4926 // Draw a frame. In the first frame, the entire viewport should be damaged. |
| 4927 gfx::Rect fullFrameDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
| 4928 drawFrameAndTestDamage(fullFrameDamage); |
| 4929 |
| 4930 // The second frame should have no damage, but the quads should still be gen
erated. |
| 4931 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
| 4932 drawFrameAndTestDamage(noDamage); |
| 4933 } |
| 4934 |
4899 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4935 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4900 LayerTreeHostImplTest, | 4936 LayerTreeHostImplTest, |
4901 ::testing::Values(false, true)); | 4937 ::testing::Values(false, true)); |
4902 | 4938 |
4903 } // namespace | 4939 } // namespace |
4904 } // namespace cc | 4940 } // namespace cc |
OLD | NEW |