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 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 protected: | 2100 protected: |
2101 FakeDrawableLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl,
id) { } | 2101 FakeDrawableLayerImpl(LayerTreeImpl* treeImpl, int id) : LayerImpl(treeImpl,
id) { } |
2102 }; | 2102 }; |
2103 | 2103 |
2104 // Only reshape when we know we are going to draw. Otherwise, the reshape | 2104 // Only reshape when we know we are going to draw. Otherwise, the reshape |
2105 // can leave the window at the wrong size if we never draw and the proper | 2105 // can leave the window at the wrong size if we never draw and the proper |
2106 // viewport size is never set. | 2106 // viewport size is never set. |
2107 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 2107 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
2108 { | 2108 { |
2109 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); | 2109 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); |
2110 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->Context3D()); | 2110 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3d()); |
2111 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 2111 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
2112 | 2112 |
2113 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); | 2113 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl->activ
eTree(), 1); |
2114 root->setAnchorPoint(gfx::PointF(0, 0)); | 2114 root->setAnchorPoint(gfx::PointF(0, 0)); |
2115 root->setBounds(gfx::Size(10, 10)); | 2115 root->setBounds(gfx::Size(10, 10)); |
2116 root->setDrawsContent(true); | 2116 root->setDrawsContent(true); |
2117 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 2117 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
2118 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 2118 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
2119 | 2119 |
2120 LayerTreeHostImpl::FrameData frame; | 2120 LayerTreeHostImpl::FrameData frame; |
(...skipping 22 matching lines...) Expand all Loading... |
2143 | 2143 |
2144 private: | 2144 private: |
2145 gfx::Rect m_partialSwapRect; | 2145 gfx::Rect m_partialSwapRect; |
2146 }; | 2146 }; |
2147 | 2147 |
2148 // Make sure damage tracking propagates all the way to the graphics context, | 2148 // Make sure damage tracking propagates all the way to the graphics context, |
2149 // where it should request to swap only the subBuffer that is damaged. | 2149 // where it should request to swap only the subBuffer that is damaged. |
2150 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) | 2150 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) |
2151 { | 2151 { |
2152 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<Output
Surface>(); | 2152 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<Output
Surface>(); |
2153 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->Context3D()); | 2153 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3d()); |
2154 | 2154 |
2155 // This test creates its own LayerTreeHostImpl, so | 2155 // This test creates its own LayerTreeHostImpl, so |
2156 // that we can force partial swap enabled. | 2156 // that we can force partial swap enabled. |
2157 LayerTreeSettings settings; | 2157 LayerTreeSettings settings; |
2158 settings.partialSwapEnabled = true; | 2158 settings.partialSwapEnabled = true; |
2159 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); | 2159 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); |
2160 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 2160 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
2161 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 2161 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
2162 | 2162 |
2163 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(layerTreeHostImpl
->activeTree(), 1); | 2163 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(layerTreeHostImpl
->activeTree(), 1); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2353 .Times(0); | 2353 .Times(0); |
2354 | 2354 |
2355 EXPECT_CALL(*m_context, scissor(_, _, _, _)) | 2355 EXPECT_CALL(*m_context, scissor(_, _, _, _)) |
2356 .Times(0); | 2356 .Times(0); |
2357 } | 2357 } |
2358 }; | 2358 }; |
2359 | 2359 |
2360 TEST_P(LayerTreeHostImplTest, noPartialSwap) | 2360 TEST_P(LayerTreeHostImplTest, noPartialSwap) |
2361 { | 2361 { |
2362 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2362 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
2363 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); | 2363 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
d()); |
2364 MockContextHarness harness(mockContext); | 2364 MockContextHarness harness(mockContext); |
2365 | 2365 |
2366 // Run test case | 2366 // Run test case |
2367 createLayerTreeHost(false, outputSurface.Pass()); | 2367 createLayerTreeHost(false, outputSurface.Pass()); |
2368 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); | 2368 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); |
2369 | 2369 |
2370 // without partial swap, and no clipping, no scissor is set. | 2370 // without partial swap, and no clipping, no scissor is set. |
2371 harness.mustDrawSolidQuad(); | 2371 harness.mustDrawSolidQuad(); |
2372 harness.mustSetNoScissor(); | 2372 harness.mustSetNoScissor(); |
2373 { | 2373 { |
(...skipping 13 matching lines...) Expand all Loading... |
2387 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2387 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2388 m_hostImpl->drawLayers(frame); | 2388 m_hostImpl->drawLayers(frame); |
2389 m_hostImpl->didDrawAllLayers(frame); | 2389 m_hostImpl->didDrawAllLayers(frame); |
2390 } | 2390 } |
2391 Mock::VerifyAndClearExpectations(&mockContext); | 2391 Mock::VerifyAndClearExpectations(&mockContext); |
2392 } | 2392 } |
2393 | 2393 |
2394 TEST_P(LayerTreeHostImplTest, partialSwap) | 2394 TEST_P(LayerTreeHostImplTest, partialSwap) |
2395 { | 2395 { |
2396 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2396 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
2397 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3
D()); | 2397 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
d()); |
2398 MockContextHarness harness(mockContext); | 2398 MockContextHarness harness(mockContext); |
2399 | 2399 |
2400 createLayerTreeHost(true, outputSurface.Pass()); | 2400 createLayerTreeHost(true, outputSurface.Pass()); |
2401 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); | 2401 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl->activeTree(), 1)); |
2402 | 2402 |
2403 // The first frame is not a partially-swapped one. | 2403 // The first frame is not a partially-swapped one. |
2404 harness.mustSetScissor(0, 0, 10, 10); | 2404 harness.mustSetScissor(0, 0, 10, 10); |
2405 harness.mustDrawSolidQuad(); | 2405 harness.mustDrawSolidQuad(); |
2406 { | 2406 { |
2407 LayerTreeHostImpl::FrameData frame; | 2407 LayerTreeHostImpl::FrameData frame; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2663 | 2663 |
2664 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 2664 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
2665 public: | 2665 public: |
2666 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); | 2666 MOCK_METHOD1(useProgram, void(WebKit::WebGLId program)); |
2667 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); | 2667 MOCK_METHOD4(drawElements, void(WebKit::WGC3Denum mode, WebKit::WGC3Dsizei c
ount, WebKit::WGC3Denum type, WebKit::WGC3Dintptr offset)); |
2668 }; | 2668 }; |
2669 | 2669 |
2670 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) | 2670 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) |
2671 { | 2671 { |
2672 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); | 2672 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); |
2673 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->Context3D()); | 2673 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->context3d()); |
2674 | 2674 |
2675 // Run test case | 2675 // Run test case |
2676 createLayerTreeHost(false, outputSurface.Pass()); | 2676 createLayerTreeHost(false, outputSurface.Pass()); |
2677 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); | 2677 setupRootLayerImpl(LayerImpl::create(m_hostImpl->activeTree(), 1)); |
2678 m_hostImpl->activeTree()->set_background_color(SK_ColorWHITE); | 2678 m_hostImpl->activeTree()->set_background_color(SK_ColorWHITE); |
2679 | 2679 |
2680 // Verify one quad is drawn when transparent background set is not set. | 2680 // Verify one quad is drawn when transparent background set is not set. |
2681 m_hostImpl->activeTree()->set_has_transparent_background(false); | 2681 m_hostImpl->activeTree()->set_has_transparent_background(false); |
2682 EXPECT_CALL(*mockContext, useProgram(_)) | 2682 EXPECT_CALL(*mockContext, useProgram(_)) |
2683 .Times(1); | 2683 .Times(1); |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4024 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) | 4024 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) |
4025 { | 4025 { |
4026 char actualResult[1024]; | 4026 char actualResult[1024]; |
4027 dumpRenderPassTestData(testData, actualResult); | 4027 dumpRenderPassTestData(testData, actualResult); |
4028 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; | 4028 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; |
4029 } | 4029 } |
4030 | 4030 |
4031 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) | 4031 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) |
4032 { | 4032 { |
4033 scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); | 4033 scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); |
4034 ASSERT_TRUE(outputSurface->Context3D()); | 4034 ASSERT_TRUE(outputSurface->context3d()); |
4035 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); | 4035 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
4036 | 4036 |
4037 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), outputSurface.get(), &m_proxy)); | 4037 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), outputSurface.get(), &m_proxy)); |
4038 | 4038 |
4039 int testCaseIndex = 0; | 4039 int testCaseIndex = 0; |
4040 while (removeRenderPassesCases[testCaseIndex].name) { | 4040 while (removeRenderPassesCases[testCaseIndex].name) { |
4041 RenderPassRemovalTestData testData; | 4041 RenderPassRemovalTestData testData; |
4042 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); | 4042 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); |
4043 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); | 4043 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); |
4044 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4044 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4342 m_hostImpl->didDrawAllLayers(frame); | 4342 m_hostImpl->didDrawAllLayers(frame); |
4343 } | 4343 } |
4344 } | 4344 } |
4345 | 4345 |
4346 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4346 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4347 LayerTreeHostImplTest, | 4347 LayerTreeHostImplTest, |
4348 ::testing::Values(false, true)); | 4348 ::testing::Values(false, true)); |
4349 | 4349 |
4350 } // namespace | 4350 } // namespace |
4351 } // namespace cc | 4351 } // namespace cc |
OLD | NEW |