| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 media::InitializeMediaLibraryForTesting(); | 75 media::InitializeMediaLibraryForTesting(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 virtual void SetUp() | 78 virtual void SetUp() |
| 79 { | 79 { |
| 80 LayerTreeSettings settings; | 80 LayerTreeSettings settings; |
| 81 settings.minimumOcclusionTrackingSize = gfx::Size(); | 81 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 82 settings.pageScalePinchZoomEnabled = GetParam(); | 82 settings.pageScalePinchZoomEnabled = GetParam(); |
| 83 | 83 |
| 84 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 84 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 85 m_hostImpl->initializeRenderer(createContext()); | 85 m_hostImpl->initializeRenderer(createOutputSurface()); |
| 86 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 86 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void TearDown() | 89 virtual void TearDown() |
| 90 { | 90 { |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual void didLoseContextOnImplThread() OVERRIDE { } | 93 virtual void didLoseOutputSurfaceOnImplThread() OVERRIDE { } |
| 94 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 94 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
| 95 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } | 95 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } |
| 96 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } | 96 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } |
| 97 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 97 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
| 98 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 98 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
| 99 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } | 99 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } |
| 100 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } | 100 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } |
| 101 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } | 101 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } |
| 102 virtual void sendManagedMemoryStats() OVERRIDE { } | 102 virtual void sendManagedMemoryStats() OVERRIDE { } |
| 103 | 103 |
| 104 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } | 104 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } |
| 105 | 105 |
| 106 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) | 106 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<OutputSurface> outputSurface, scoped_ptr<LayerImpl> root) |
| 107 { | 107 { |
| 108 LayerTreeSettings settings; | 108 LayerTreeSettings settings; |
| 109 settings.minimumOcclusionTrackingSize = gfx::Size(); | 109 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 110 settings.partialSwapEnabled = partialSwap; | 110 settings.partialSwapEnabled = partialSwap; |
| 111 | 111 |
| 112 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this, &m_proxy); | 112 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this, &m_proxy); |
| 113 | 113 |
| 114 myHostImpl->initializeRenderer(graphicsContext.Pass()); | 114 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 115 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 115 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 116 | 116 |
| 117 root->setAnchorPoint(gfx::PointF(0, 0)); | 117 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 118 root->setPosition(gfx::PointF(0, 0)); | 118 root->setPosition(gfx::PointF(0, 0)); |
| 119 root->setBounds(gfx::Size(10, 10)); | 119 root->setBounds(gfx::Size(10, 10)); |
| 120 root->setContentBounds(gfx::Size(10, 10)); | 120 root->setContentBounds(gfx::Size(10, 10)); |
| 121 root->setVisibleContentRect(gfx::Rect(0, 0, 10, 10)); | 121 root->setVisibleContentRect(gfx::Rect(0, 0, 10, 10)); |
| 122 root->setDrawsContent(true); | 122 root->setDrawsContent(true); |
| 123 myHostImpl->setRootLayer(root.Pass()); | 123 myHostImpl->setRootLayer(root.Pass()); |
| 124 return myHostImpl.Pass(); | 124 return myHostImpl.Pass(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 layer->setScrollable(true); | 185 layer->setScrollable(true); |
| 186 layer->setDrawsContent(true); | 186 layer->setDrawsContent(true); |
| 187 layer->setBounds(size); | 187 layer->setBounds(size); |
| 188 layer->setContentBounds(size); | 188 layer->setContentBounds(size); |
| 189 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); | 189 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height()
* 2)); |
| 190 return layer.Pass(); | 190 return layer.Pass(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void initializeRendererAndDrawFrame() | 193 void initializeRendererAndDrawFrame() |
| 194 { | 194 { |
| 195 m_hostImpl->initializeRenderer(createContext()); | 195 m_hostImpl->initializeRenderer(createOutputSurface()); |
| 196 LayerTreeHostImpl::FrameData frame; | 196 LayerTreeHostImpl::FrameData frame; |
| 197 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 197 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 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<GraphicsContext> createContext() | 208 scoped_ptr<OutputSurface> createOutputSurface() |
| 209 { | 209 { |
| 210 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); | 210 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 FakeProxy m_proxy; | 213 FakeProxy m_proxy; |
| 214 DebugScopedSetImplThread m_alwaysImplThread; | 214 DebugScopedSetImplThread m_alwaysImplThread; |
| 215 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 215 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
| 216 | 216 |
| 217 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 217 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
| 218 bool m_onCanDrawStateChangedCalled; | 218 bool m_onCanDrawStateChangedCalled; |
| 219 bool m_didRequestCommit; | 219 bool m_didRequestCommit; |
| 220 bool m_didRequestRedraw; | 220 bool m_didRequestRedraw; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // We should not crash when trying to scroll an empty layer tree. | 369 // We should not crash when trying to scroll an empty layer tree. |
| 370 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 370 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
| 371 } | 371 } |
| 372 | 372 |
| 373 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) | 373 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) |
| 374 { | 374 { |
| 375 LayerTreeSettings settings; | 375 LayerTreeSettings settings; |
| 376 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 376 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 377 | 377 |
| 378 // Initialization will fail here. | 378 // Initialization will fail here. |
| 379 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); | 379 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<OutputSurface>()); |
| 380 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 380 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 381 | 381 |
| 382 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 382 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 383 | 383 |
| 384 // We should not crash when trying to scroll after the renderer initializati
on fails. | 384 // We should not crash when trying to scroll after the renderer initializati
on fails. |
| 385 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 385 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
| 386 } | 386 } |
| 387 | 387 |
| 388 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) | 388 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) |
| 389 { | 389 { |
| (...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 layer1->setExpectation(false, false); | 1878 layer1->setExpectation(false, false); |
| 1879 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1879 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 1880 m_hostImpl->drawLayers(frame); | 1880 m_hostImpl->drawLayers(frame); |
| 1881 EXPECT_TRUE(layer1->quadsAppended()); | 1881 EXPECT_TRUE(layer1->quadsAppended()); |
| 1882 m_hostImpl->didDrawAllLayers(frame); | 1882 m_hostImpl->didDrawAllLayers(frame); |
| 1883 | 1883 |
| 1884 } | 1884 } |
| 1885 | 1885 |
| 1886 TEST_P(LayerTreeHostImplTest, viewportCovered) | 1886 TEST_P(LayerTreeHostImplTest, viewportCovered) |
| 1887 { | 1887 { |
| 1888 m_hostImpl->initializeRenderer(createContext()); | 1888 m_hostImpl->initializeRenderer(createOutputSurface()); |
| 1889 m_hostImpl->setBackgroundColor(SK_ColorGRAY); | 1889 m_hostImpl->setBackgroundColor(SK_ColorGRAY); |
| 1890 | 1890 |
| 1891 gfx::Size viewportSize(1000, 1000); | 1891 gfx::Size viewportSize(1000, 1000); |
| 1892 m_hostImpl->setViewportSize(viewportSize, viewportSize); | 1892 m_hostImpl->setViewportSize(viewportSize, viewportSize); |
| 1893 | 1893 |
| 1894 m_hostImpl->setRootLayer(LayerImpl::create(1)); | 1894 m_hostImpl->setRootLayer(LayerImpl::create(1)); |
| 1895 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(2, m_hostImpl
->resourceProvider())); | 1895 m_hostImpl->rootLayer()->addChild(BlendStateCheckLayer::create(2, m_hostImpl
->resourceProvider())); |
| 1896 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); | 1896 BlendStateCheckLayer* child = static_cast<BlendStateCheckLayer*>(m_hostImpl-
>rootLayer()->children()[0]); |
| 1897 child->setExpectation(false, false); | 1897 child->setExpectation(false, false); |
| 1898 child->setContentsOpaque(true); | 1898 child->setContentsOpaque(true); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew FakeDrawableLayerImpl(id)); } | 1990 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew FakeDrawableLayerImpl(id)); } |
| 1991 protected: | 1991 protected: |
| 1992 explicit FakeDrawableLayerImpl(int id) : LayerImpl(id) { } | 1992 explicit FakeDrawableLayerImpl(int id) : LayerImpl(id) { } |
| 1993 }; | 1993 }; |
| 1994 | 1994 |
| 1995 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1995 // Only reshape when we know we are going to draw. Otherwise, the reshape |
| 1996 // can leave the window at the wrong size if we never draw and the proper | 1996 // can leave the window at the wrong size if we never draw and the proper |
| 1997 // viewport size is never set. | 1997 // viewport size is never set. |
| 1998 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1998 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
| 1999 { | 1999 { |
| 2000 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).Pass
As<GraphicsContext>(); | 2000 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs
<OutputSurface>(); |
| 2001 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3D()); | 2001 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3D()); |
| 2002 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 2002 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
| 2003 | 2003 |
| 2004 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 2004 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
| 2005 root->setAnchorPoint(gfx::PointF(0, 0)); | 2005 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 2006 root->setBounds(gfx::Size(10, 10)); | 2006 root->setBounds(gfx::Size(10, 10)); |
| 2007 root->setDrawsContent(true); | 2007 root->setDrawsContent(true); |
| 2008 m_hostImpl->setRootLayer(root.Pass()); | 2008 m_hostImpl->setRootLayer(root.Pass()); |
| 2009 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 2009 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
| 2010 | 2010 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2033 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } | 2033 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } |
| 2034 | 2034 |
| 2035 private: | 2035 private: |
| 2036 gfx::Rect m_partialSwapRect; | 2036 gfx::Rect m_partialSwapRect; |
| 2037 }; | 2037 }; |
| 2038 | 2038 |
| 2039 // Make sure damage tracking propagates all the way to the graphics context, | 2039 // Make sure damage tracking propagates all the way to the graphics context, |
| 2040 // where it should request to swap only the subBuffer that is damaged. | 2040 // where it should request to swap only the subBuffer that is damaged. |
| 2041 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) | 2041 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) |
| 2042 { | 2042 { |
| 2043 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); | 2043 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).Pa
ssAs<OutputSurface>(); |
| 2044 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); | 2044 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); |
| 2045 | 2045 |
| 2046 // This test creates its own LayerTreeHostImpl, so | 2046 // This test creates its own LayerTreeHostImpl, so |
| 2047 // that we can force partial swap enabled. | 2047 // that we can force partial swap enabled. |
| 2048 LayerTreeSettings settings; | 2048 LayerTreeSettings settings; |
| 2049 settings.partialSwapEnabled = true; | 2049 settings.partialSwapEnabled = true; |
| 2050 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); | 2050 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); |
| 2051 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 2051 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
| 2052 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 2052 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
| 2053 | 2053 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST)) | 2248 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST)) |
| 2249 .Times(0); | 2249 .Times(0); |
| 2250 | 2250 |
| 2251 EXPECT_CALL(*m_context, scissor(_, _, _, _)) | 2251 EXPECT_CALL(*m_context, scissor(_, _, _, _)) |
| 2252 .Times(0); | 2252 .Times(0); |
| 2253 } | 2253 } |
| 2254 }; | 2254 }; |
| 2255 | 2255 |
| 2256 TEST_P(LayerTreeHostImplTest, noPartialSwap) | 2256 TEST_P(LayerTreeHostImplTest, noPartialSwap) |
| 2257 { | 2257 { |
| 2258 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<GraphicsContext>(); | 2258 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
| 2259 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2259 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
D()); |
| 2260 MockContextHarness harness(mockContext); | 2260 MockContextHarness harness(mockContext); |
| 2261 | 2261 |
| 2262 // Run test case | 2262 // Run test case |
| 2263 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, contex
t.Pass(), FakeLayerWithQuads::create(1)); | 2263 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, output
Surface.Pass(), FakeLayerWithQuads::create(1)); |
| 2264 | 2264 |
| 2265 // without partial swap, and no clipping, no scissor is set. | 2265 // without partial swap, and no clipping, no scissor is set. |
| 2266 harness.mustDrawSolidQuad(); | 2266 harness.mustDrawSolidQuad(); |
| 2267 harness.mustSetNoScissor(); | 2267 harness.mustSetNoScissor(); |
| 2268 { | 2268 { |
| 2269 LayerTreeHostImpl::FrameData frame; | 2269 LayerTreeHostImpl::FrameData frame; |
| 2270 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2270 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2271 myHostImpl->drawLayers(frame); | 2271 myHostImpl->drawLayers(frame); |
| 2272 myHostImpl->didDrawAllLayers(frame); | 2272 myHostImpl->didDrawAllLayers(frame); |
| 2273 } | 2273 } |
| 2274 Mock::VerifyAndClearExpectations(&mockContext); | 2274 Mock::VerifyAndClearExpectations(&mockContext); |
| 2275 | 2275 |
| 2276 // without partial swap, but a layer does clip its subtree, one scissor is s
et. | 2276 // without partial swap, but a layer does clip its subtree, one scissor is s
et. |
| 2277 myHostImpl->rootLayer()->setMasksToBounds(true); | 2277 myHostImpl->rootLayer()->setMasksToBounds(true); |
| 2278 harness.mustDrawSolidQuad(); | 2278 harness.mustDrawSolidQuad(); |
| 2279 harness.mustSetScissor(0, 0, 10, 10); | 2279 harness.mustSetScissor(0, 0, 10, 10); |
| 2280 { | 2280 { |
| 2281 LayerTreeHostImpl::FrameData frame; | 2281 LayerTreeHostImpl::FrameData frame; |
| 2282 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2282 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2283 myHostImpl->drawLayers(frame); | 2283 myHostImpl->drawLayers(frame); |
| 2284 myHostImpl->didDrawAllLayers(frame); | 2284 myHostImpl->didDrawAllLayers(frame); |
| 2285 } | 2285 } |
| 2286 Mock::VerifyAndClearExpectations(&mockContext); | 2286 Mock::VerifyAndClearExpectations(&mockContext); |
| 2287 } | 2287 } |
| 2288 | 2288 |
| 2289 TEST_P(LayerTreeHostImplTest, partialSwap) | 2289 TEST_P(LayerTreeHostImplTest, partialSwap) |
| 2290 { | 2290 { |
| 2291 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<GraphicsConte
xt>(); | 2291 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSur
face>(); |
| 2292 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2292 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
D()); |
| 2293 MockContextHarness harness(mockContext); | 2293 MockContextHarness harness(mockContext); |
| 2294 | 2294 |
| 2295 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context
.Pass(), FakeLayerWithQuads::create(1)); | 2295 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, outputS
urface.Pass(), FakeLayerWithQuads::create(1)); |
| 2296 | 2296 |
| 2297 // The first frame is not a partially-swapped one. | 2297 // The first frame is not a partially-swapped one. |
| 2298 harness.mustSetScissor(0, 0, 10, 10); | 2298 harness.mustSetScissor(0, 0, 10, 10); |
| 2299 harness.mustDrawSolidQuad(); | 2299 harness.mustDrawSolidQuad(); |
| 2300 { | 2300 { |
| 2301 LayerTreeHostImpl::FrameData frame; | 2301 LayerTreeHostImpl::FrameData frame; |
| 2302 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2302 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2303 myHostImpl->drawLayers(frame); | 2303 myHostImpl->drawLayers(frame); |
| 2304 myHostImpl->didDrawAllLayers(frame); | 2304 myHostImpl->didDrawAllLayers(frame); |
| 2305 } | 2305 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2337 // Unlimited texture size. | 2337 // Unlimited texture size. |
| 2338 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) | 2338 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) |
| 2339 { | 2339 { |
| 2340 if (pname == GL_MAX_TEXTURE_SIZE) | 2340 if (pname == GL_MAX_TEXTURE_SIZE) |
| 2341 *value = 8192; | 2341 *value = 8192; |
| 2342 } | 2342 } |
| 2343 }; | 2343 }; |
| 2344 | 2344 |
| 2345 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) | 2345 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) |
| 2346 { | 2346 { |
| 2347 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 2347 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 2348 | 2348 |
| 2349 LayerTreeSettings settings; | 2349 LayerTreeSettings settings; |
| 2350 settings.partialSwapEnabled = partialSwap; | 2350 settings.partialSwapEnabled = partialSwap; |
| 2351 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client, proxy); | 2351 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client, proxy); |
| 2352 myHostImpl->initializeRenderer(context.Pass()); | 2352 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 2353 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 2353 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
| 2354 | 2354 |
| 2355 /* | 2355 /* |
| 2356 Layers are created as follows: | 2356 Layers are created as follows: |
| 2357 | 2357 |
| 2358 +--------------------+ | 2358 +--------------------+ |
| 2359 | 1 | | 2359 | 1 | |
| 2360 | +-----------+ | | 2360 | +-----------+ | |
| 2361 | | 2 | | | 2361 | | 2 | | |
| 2362 | | +-------------------+ | 2362 | | +-------------------+ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 ASSERT_EQ(1U, frame.renderPasses[0]->quad_list.size()); | 2443 ASSERT_EQ(1U, frame.renderPasses[0]->quad_list.size()); |
| 2444 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size()); | 2444 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size()); |
| 2445 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma
terial); | 2445 EXPECT_EQ(DrawQuad::SOLID_COLOR, frame.renderPasses[0]->quad_list[0]->ma
terial); |
| 2446 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); | 2446 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma
terial); |
| 2447 | 2447 |
| 2448 myHostImpl->drawLayers(frame); | 2448 myHostImpl->drawLayers(frame); |
| 2449 myHostImpl->didDrawAllLayers(frame); | 2449 myHostImpl->didDrawAllLayers(frame); |
| 2450 } | 2450 } |
| 2451 } | 2451 } |
| 2452 | 2452 |
| 2453 // Make sure that context lost notifications are propagated through the tree. | 2453 // Make sure that output surface lost notifications are propagated through the t
ree. |
| 2454 class ContextLostNotificationCheckLayer : public LayerImpl { | 2454 class OutputSurfaceLostNotificationCheckLayer : public LayerImpl { |
| 2455 public: | 2455 public: |
| 2456 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew ContextLostNotificationCheckLayer(id)); } | 2456 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew OutputSurfaceLostNotificationCheckLayer(id)); } |
| 2457 | 2457 |
| 2458 virtual void didLoseContext() OVERRIDE | 2458 virtual void didLoseOutputSurface() OVERRIDE |
| 2459 { | 2459 { |
| 2460 m_didLoseContextCalled = true; | 2460 m_didLoseOutputSurfaceCalled = true; |
| 2461 } | 2461 } |
| 2462 | 2462 |
| 2463 bool didLoseContextCalled() const { return m_didLoseContextCalled; } | 2463 bool didLoseOutputSurfaceCalled() const { return m_didLoseOutputSurfaceCalle
d; } |
| 2464 | 2464 |
| 2465 private: | 2465 private: |
| 2466 explicit ContextLostNotificationCheckLayer(int id) | 2466 explicit OutputSurfaceLostNotificationCheckLayer(int id) |
| 2467 : LayerImpl(id) | 2467 : LayerImpl(id) |
| 2468 , m_didLoseContextCalled(false) | 2468 , m_didLoseOutputSurfaceCalled(false) |
| 2469 { | 2469 { |
| 2470 } | 2470 } |
| 2471 | 2471 |
| 2472 bool m_didLoseContextCalled; | 2472 bool m_didLoseOutputSurfaceCalled; |
| 2473 }; | 2473 }; |
| 2474 | 2474 |
| 2475 TEST_P(LayerTreeHostImplTest, contextLostAndRestoredNotificationSentToAllLayers) | 2475 TEST_P(LayerTreeHostImplTest, outputSurfaceLostAndRestoredNotificationSentToAllL
ayers) |
| 2476 { | 2476 { |
| 2477 m_hostImpl->setRootLayer(ContextLostNotificationCheckLayer::create(1)); | 2477 m_hostImpl->setRootLayer(OutputSurfaceLostNotificationCheckLayer::create(1))
; |
| 2478 ContextLostNotificationCheckLayer* root = static_cast<ContextLostNotificatio
nCheckLayer*>(m_hostImpl->rootLayer()); | 2478 OutputSurfaceLostNotificationCheckLayer* root = static_cast<OutputSurfaceLos
tNotificationCheckLayer*>(m_hostImpl->rootLayer()); |
| 2479 | 2479 |
| 2480 root->addChild(ContextLostNotificationCheckLayer::create(1)); | 2480 root->addChild(OutputSurfaceLostNotificationCheckLayer::create(1)); |
| 2481 ContextLostNotificationCheckLayer* layer1 = static_cast<ContextLostNotificat
ionCheckLayer*>(root->children()[0]); | 2481 OutputSurfaceLostNotificationCheckLayer* layer1 = static_cast<OutputSurfaceL
ostNotificationCheckLayer*>(root->children()[0]); |
| 2482 | 2482 |
| 2483 layer1->addChild(ContextLostNotificationCheckLayer::create(2)); | 2483 layer1->addChild(OutputSurfaceLostNotificationCheckLayer::create(2)); |
| 2484 ContextLostNotificationCheckLayer* layer2 = static_cast<ContextLostNotificat
ionCheckLayer*>(layer1->children()[0]); | 2484 OutputSurfaceLostNotificationCheckLayer* layer2 = static_cast<OutputSurfaceL
ostNotificationCheckLayer*>(layer1->children()[0]); |
| 2485 | 2485 |
| 2486 EXPECT_FALSE(root->didLoseContextCalled()); | 2486 EXPECT_FALSE(root->didLoseOutputSurfaceCalled()); |
| 2487 EXPECT_FALSE(layer1->didLoseContextCalled()); | 2487 EXPECT_FALSE(layer1->didLoseOutputSurfaceCalled()); |
| 2488 EXPECT_FALSE(layer2->didLoseContextCalled()); | 2488 EXPECT_FALSE(layer2->didLoseOutputSurfaceCalled()); |
| 2489 | 2489 |
| 2490 m_hostImpl->initializeRenderer(createContext()); | 2490 m_hostImpl->initializeRenderer(createOutputSurface()); |
| 2491 | 2491 |
| 2492 EXPECT_TRUE(root->didLoseContextCalled()); | 2492 EXPECT_TRUE(root->didLoseOutputSurfaceCalled()); |
| 2493 EXPECT_TRUE(layer1->didLoseContextCalled()); | 2493 EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled()); |
| 2494 EXPECT_TRUE(layer2->didLoseContextCalled()); | 2494 EXPECT_TRUE(layer2->didLoseOutputSurfaceCalled()); |
| 2495 } | 2495 } |
| 2496 | 2496 |
| 2497 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) | 2497 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) |
| 2498 { | 2498 { |
| 2499 LayerTreeSettings settings; | 2499 LayerTreeSettings settings; |
| 2500 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 2500 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 2501 | 2501 |
| 2502 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. | 2502 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. |
| 2503 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); | 2503 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<OutputSurface>()); |
| 2504 m_hostImpl->finishAllRendering(); | 2504 m_hostImpl->finishAllRendering(); |
| 2505 } | 2505 } |
| 2506 | 2506 |
| 2507 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { | 2507 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { |
| 2508 public: | 2508 public: |
| 2509 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } | 2509 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } |
| 2510 virtual bool makeContextCurrent() { | 2510 virtual bool makeContextCurrent() { |
| 2511 if (!m_succeedCount) | 2511 if (!m_succeedCount) |
| 2512 return false; | 2512 return false; |
| 2513 --m_succeedCount; | 2513 --m_succeedCount; |
| 2514 return true; | 2514 return true; |
| 2515 } | 2515 } |
| 2516 | 2516 |
| 2517 private: | 2517 private: |
| 2518 unsigned m_succeedCount; | 2518 unsigned m_succeedCount; |
| 2519 }; | 2519 }; |
| 2520 | 2520 |
| 2521 TEST_P(LayerTreeHostImplTest, contextLostDuringInitialize) | 2521 TEST_P(LayerTreeHostImplTest, context3DLostDuringInitialize) |
| 2522 { | 2522 { |
| 2523 LayerTreeSettings settings; | 2523 LayerTreeSettings settings; |
| 2524 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 2524 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 2525 | 2525 |
| 2526 // Initialize into a known successful state. | 2526 // Initialize into a known successful state. |
| 2527 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); | 2527 EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface())); |
| 2528 EXPECT_TRUE(m_hostImpl->context()); | 2528 EXPECT_TRUE(m_hostImpl->outputSurface()); |
| 2529 EXPECT_TRUE(m_hostImpl->renderer()); | 2529 EXPECT_TRUE(m_hostImpl->renderer()); |
| 2530 EXPECT_TRUE(m_hostImpl->resourceProvider()); | 2530 EXPECT_TRUE(m_hostImpl->resourceProvider()); |
| 2531 | 2531 |
| 2532 // We will make the context get lost after a numer of makeContextCurrent | 2532 // We will make the context get lost after a numer of makeContextCurrent |
| 2533 // calls. The exact number of calls to make it succeed is dependent on the | 2533 // calls. The exact number of calls to make it succeed is dependent on the |
| 2534 // implementation and doesn't really matter (i.e. can be changed to make the | 2534 // implementation and doesn't really matter (i.e. can be changed to make the |
| 2535 // tests pass after some refactoring). | 2535 // tests pass after some refactoring). |
| 2536 const unsigned kMakeCurrentSuccessesNeededForSuccessfulInitialization = 3; | 2536 const unsigned kMakeCurrentSuccessesNeededForSuccessfulInitialization = 3; |
| 2537 | 2537 |
| 2538 for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitializat
ion; ++i) { | 2538 for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitializat
ion; ++i) { |
| 2539 // The context will get lost during initialization, we shouldn't crash.
We | 2539 // The context will get lost during initialization, we shouldn't crash.
We |
| 2540 // should also be in a consistent state. | 2540 // should also be in a consistent state. |
| 2541 EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurfa
ce::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D
MakeCurrentFailsEventually(i))).PassAs<GraphicsContext>())); | 2541 EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurfa
ce::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D
MakeCurrentFailsEventually(i))).PassAs<OutputSurface>())); |
| 2542 EXPECT_EQ(0, m_hostImpl->context()); | 2542 EXPECT_EQ(0, m_hostImpl->outputSurface()); |
| 2543 EXPECT_EQ(0, m_hostImpl->renderer()); | 2543 EXPECT_EQ(0, m_hostImpl->renderer()); |
| 2544 EXPECT_EQ(0, m_hostImpl->resourceProvider()); | 2544 EXPECT_EQ(0, m_hostImpl->resourceProvider()); |
| 2545 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); | 2545 EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface())); |
| 2546 } | 2546 } |
| 2547 | 2547 |
| 2548 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::c
reate(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeC
urrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).
PassAs<GraphicsContext>())); | 2548 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::c
reate(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeC
urrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).
PassAs<OutputSurface>())); |
| 2549 EXPECT_TRUE(m_hostImpl->context()); | 2549 EXPECT_TRUE(m_hostImpl->outputSurface()); |
| 2550 EXPECT_TRUE(m_hostImpl->renderer()); | 2550 EXPECT_TRUE(m_hostImpl->renderer()); |
| 2551 EXPECT_TRUE(m_hostImpl->resourceProvider()); | 2551 EXPECT_TRUE(m_hostImpl->resourceProvider()); |
| 2552 } | 2552 } |
| 2553 | 2553 |
| 2554 // Fake WebGraphicsContext3D that will cause a failure if trying to use a | 2554 // Fake WebGraphicsContext3D that will cause a failure if trying to use a |
| 2555 // resource that wasn't created by it (resources created by | 2555 // resource that wasn't created by it (resources created by |
| 2556 // FakeWebGraphicsContext3D have an id of 1). | 2556 // FakeWebGraphicsContext3D have an id of 1). |
| 2557 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { | 2557 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
| 2558 public: | 2558 public: |
| 2559 StrictWebGraphicsContext3D() | 2559 StrictWebGraphicsContext3D() |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2776 sharedState->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0,
1, 1), gfx::Rect(0, 0, 1, 1), false, 1); | 2776 sharedState->SetAll(gfx::Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0,
1, 1), gfx::Rect(0, 0, 1, 1), false, 1); |
| 2777 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); | 2777 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); |
| 2778 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)
, resourceId, false, gfx::RectF(0, 0, 1, 1), false); | 2778 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1)
, resourceId, false, gfx::RectF(0, 0, 1, 1), false); |
| 2779 | 2779 |
| 2780 pass->AppendSharedQuadState(sharedState.Pass()); | 2780 pass->AppendSharedQuadState(sharedState.Pass()); |
| 2781 pass->AppendQuad(quad.PassAs<DrawQuad>()); | 2781 pass->AppendQuad(quad.PassAs<DrawQuad>()); |
| 2782 | 2782 |
| 2783 return pass.PassAs<RenderPass>(); | 2783 return pass.PassAs<RenderPass>(); |
| 2784 } | 2784 } |
| 2785 | 2785 |
| 2786 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) | 2786 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostOutputSurface) |
| 2787 { | 2787 { |
| 2788 int layerId = 1; | 2788 int layerId = 1; |
| 2789 | 2789 |
| 2790 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++)); | 2790 scoped_ptr<LayerImpl> rootLayer(LayerImpl::create(layerId++)); |
| 2791 rootLayer->setBounds(gfx::Size(10, 10)); | 2791 rootLayer->setBounds(gfx::Size(10, 10)); |
| 2792 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2792 rootLayer->setAnchorPoint(gfx::PointF(0, 0)); |
| 2793 | 2793 |
| 2794 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++); | 2794 scoped_ptr<TiledLayerImpl> tileLayer = TiledLayerImpl::create(layerId++); |
| 2795 tileLayer->setBounds(gfx::Size(10, 10)); | 2795 tileLayer->setBounds(gfx::Size(10, 10)); |
| 2796 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); | 2796 tileLayer->setAnchorPoint(gfx::PointF(0, 0)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2892 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); | 2892 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); |
| 2893 delegatedRendererLayer->setDrawsContent(true); | 2893 delegatedRendererLayer->setDrawsContent(true); |
| 2894 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2894 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 2895 ScopedPtrVector<RenderPass> passList; | 2895 ScopedPtrVector<RenderPass> passList; |
| 2896 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); | 2896 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); |
| 2897 delegatedRendererLayer->setRenderPasses(passList); | 2897 delegatedRendererLayer->setRenderPasses(passList); |
| 2898 EXPECT_TRUE(passList.isEmpty()); | 2898 EXPECT_TRUE(passList.isEmpty()); |
| 2899 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2899 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
| 2900 | 2900 |
| 2901 // Use a context that supports IOSurfaces | 2901 // Use a context that supports IOSurfaces |
| 2902 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); | 2902 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<OutputSurface>()); |
| 2903 | 2903 |
| 2904 FakeVideoFrame hwVideoFrame( | 2904 FakeVideoFrame hwVideoFrame( |
| 2905 VideoFrame::WrapNativeTexture( | 2905 VideoFrame::WrapNativeTexture( |
| 2906 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, | 2906 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
| 2907 GL_TEXTURE_2D, | 2907 GL_TEXTURE_2D, |
| 2908 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), | 2908 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), |
| 2909 VideoFrame::ReadPixelsCB(), base::Closure())); | 2909 VideoFrame::ReadPixelsCB(), base::Closure())); |
| 2910 hwProvider.setFrame(&hwVideoFrame); | 2910 hwProvider.setFrame(&hwVideoFrame); |
| 2911 | 2911 |
| 2912 FakeVideoFrame videoFrameScaled( | 2912 FakeVideoFrame videoFrameScaled( |
| 2913 VideoFrame::WrapNativeTexture( | 2913 VideoFrame::WrapNativeTexture( |
| 2914 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, | 2914 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
| 2915 GL_TEXTURE_2D, | 2915 GL_TEXTURE_2D, |
| 2916 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD
elta(), | 2916 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD
elta(), |
| 2917 VideoFrame::ReadPixelsCB(), base::Closure())); | 2917 VideoFrame::ReadPixelsCB(), base::Closure())); |
| 2918 providerScaled.setFrame(&videoFrameScaled); | 2918 providerScaled.setFrame(&videoFrameScaled); |
| 2919 | 2919 |
| 2920 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2920 m_hostImpl->setRootLayer(rootLayer.Pass()); |
| 2921 | 2921 |
| 2922 LayerTreeHostImpl::FrameData frame; | 2922 LayerTreeHostImpl::FrameData frame; |
| 2923 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2923 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2924 m_hostImpl->drawLayers(frame); | 2924 m_hostImpl->drawLayers(frame); |
| 2925 m_hostImpl->didDrawAllLayers(frame); | 2925 m_hostImpl->didDrawAllLayers(frame); |
| 2926 m_hostImpl->swapBuffers(); | 2926 m_hostImpl->swapBuffers(); |
| 2927 | 2927 |
| 2928 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); | 2928 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); |
| 2929 | 2929 |
| 2930 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur
face, | 2930 // Lose the WebGraphicsContext3D, replacing it with a StrictWebGraphicsConte
xt3DWithIOSurface, |
| 2931 // that will warn if any resource from the previous context gets used. | 2931 // that will warn if any resource from the previous context gets used. |
| 2932 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface))
.PassAs<GraphicsContext>()); | 2932 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface))
.PassAs<OutputSurface>()); |
| 2933 | 2933 |
| 2934 // Create dummy resources so that looking up an old resource will get an | 2934 // Create dummy resources so that looking up an old resource will get an |
| 2935 // invalid texture id mapping. | 2935 // invalid texture id mapping. |
| 2936 for (unsigned i = 0; i < numResources; ++i) | 2936 for (unsigned i = 0; i < numResources; ++i) |
| 2937 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict
WebGraphicsContext3D::kExternalTextureId); | 2937 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict
WebGraphicsContext3D::kExternalTextureId); |
| 2938 | 2938 |
| 2939 // The WebVideoFrameProvider is expected to recreate its textures after a | 2939 // The WebVideoFrameProvider is expected to recreate its textures after a |
| 2940 // lost context (or not serve a frame). | 2940 // lost output surface (or not serve a frame). |
| 2941 hwProvider.setFrame(0); | 2941 hwProvider.setFrame(0); |
| 2942 providerScaled.setFrame(0); | 2942 providerScaled.setFrame(0); |
| 2943 | 2943 |
| 2944 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2944 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 2945 m_hostImpl->drawLayers(frame); | 2945 m_hostImpl->drawLayers(frame); |
| 2946 m_hostImpl->didDrawAllLayers(frame); | 2946 m_hostImpl->didDrawAllLayers(frame); |
| 2947 m_hostImpl->swapBuffers(); | 2947 m_hostImpl->swapBuffers(); |
| 2948 | 2948 |
| 2949 FakeVideoFrame hwVideoFrame2( | 2949 FakeVideoFrame hwVideoFrame2( |
| 2950 VideoFrame::WrapNativeTexture( | 2950 VideoFrame::WrapNativeTexture( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3040 | 3040 |
| 3041 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5
); | 3041 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5
); |
| 3042 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 3042 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
| 3043 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3043 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
| 3044 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 3044 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
| 3045 ioSurfaceLayer->setDrawsContent(true); | 3045 ioSurfaceLayer->setDrawsContent(true); |
| 3046 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 3046 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
| 3047 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 3047 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
| 3048 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 3048 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
| 3049 | 3049 |
| 3050 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which
the LayerTreeHostImpl takes ownership of). | 3050 // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon
text3D (which the LayerTreeHostImpl takes ownership of). |
| 3051 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))
); | 3051 scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::crea
te(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); |
| 3052 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track
ingWebGraphicsContext3D*>(outputSurface->context3D()); | 3052 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra
ckingWebGraphicsContext3D*>(outputSurface->context3D()); |
| 3053 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 3053 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
| 3054 | 3054 |
| 3055 m_hostImpl->setRootLayer(rootLayer.Pass()); | 3055 m_hostImpl->setRootLayer(rootLayer.Pass()); |
| 3056 | 3056 |
| 3057 LayerTreeHostImpl::FrameData frame; | 3057 LayerTreeHostImpl::FrameData frame; |
| 3058 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 3058 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
| 3059 m_hostImpl->drawLayers(frame); | 3059 m_hostImpl->drawLayers(frame); |
| 3060 m_hostImpl->didDrawAllLayers(frame); | 3060 m_hostImpl->didDrawAllLayers(frame); |
| 3061 m_hostImpl->swapBuffers(); | 3061 m_hostImpl->swapBuffers(); |
| 3062 | 3062 |
| 3063 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); | 3063 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u); |
| 3064 | 3064 |
| 3065 // Kill the layer tree. | 3065 // Kill the layer tree. |
| 3066 m_hostImpl->setRootLayer(LayerImpl::create(100)); | 3066 m_hostImpl->setRootLayer(LayerImpl::create(100)); |
| 3067 // There should be no textures left in use after. | 3067 // There should be no textures left in use after. |
| 3068 EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); | 3068 EXPECT_EQ(0u, trackingWebGraphicsContext3D->numTextures()); |
| 3069 } | 3069 } |
| 3070 | 3070 |
| 3071 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { | 3071 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { |
| 3072 public: | 3072 public: |
| 3073 MOCK_METHOD1(useProgram, void(WebGLId program)); | 3073 MOCK_METHOD1(useProgram, void(WebGLId program)); |
| 3074 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 3074 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); |
| 3075 }; | 3075 }; |
| 3076 | 3076 |
| 3077 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) | 3077 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) |
| 3078 { | 3078 { |
| 3079 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext))
.PassAs<GraphicsContext>(); | 3079 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenConte
xt)).PassAs<OutputSurface>(); |
| 3080 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(context->context3D()); | 3080 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->context3D()); |
| 3081 | 3081 |
| 3082 // Run test case | 3082 // Run test case |
| 3083 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, contex
t.Pass(), LayerImpl::create(1)); | 3083 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, output
Surface.Pass(), LayerImpl::create(1)); |
| 3084 myHostImpl->setBackgroundColor(SK_ColorWHITE); | 3084 myHostImpl->setBackgroundColor(SK_ColorWHITE); |
| 3085 | 3085 |
| 3086 // Verify one quad is drawn when transparent background set is not set. | 3086 // Verify one quad is drawn when transparent background set is not set. |
| 3087 myHostImpl->setHasTransparentBackground(false); | 3087 myHostImpl->setHasTransparentBackground(false); |
| 3088 EXPECT_CALL(*mockContext, useProgram(_)) | 3088 EXPECT_CALL(*mockContext, useProgram(_)) |
| 3089 .Times(1); | 3089 .Times(1); |
| 3090 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) | 3090 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) |
| 3091 .Times(1); | 3091 .Times(1); |
| 3092 LayerTreeHostImpl::FrameData frame; | 3092 LayerTreeHostImpl::FrameData frame; |
| 3093 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 3093 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3113 layerPtr->setContentBounds(layerRect.size()); | 3113 layerPtr->setContentBounds(layerRect.size()); |
| 3114 layerPtr->setDrawsContent(true); // only children draw content | 3114 layerPtr->setDrawsContent(true); // only children draw content |
| 3115 layerPtr->setContentsOpaque(true); | 3115 layerPtr->setContentsOpaque(true); |
| 3116 parent->addChild(layer.Pass()); | 3116 parent->addChild(layer.Pass()); |
| 3117 if (result) | 3117 if (result) |
| 3118 *result = layerPtr; | 3118 *result = layerPtr; |
| 3119 } | 3119 } |
| 3120 | 3120 |
| 3121 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) | 3121 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) |
| 3122 { | 3122 { |
| 3123 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3123 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3124 | 3124 |
| 3125 layerTreeHostImpl->initializeRenderer(context.Pass()); | 3125 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3126 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 3126 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
| 3127 | 3127 |
| 3128 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3128 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3129 rootPtr = root.get(); | 3129 rootPtr = root.get(); |
| 3130 | 3130 |
| 3131 root->setAnchorPoint(gfx::PointF(0, 0)); | 3131 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3132 root->setPosition(gfx::PointF(0, 0)); | 3132 root->setPosition(gfx::PointF(0, 0)); |
| 3133 root->setBounds(rootSize); | 3133 root->setBounds(rootSize); |
| 3134 root->setContentBounds(rootSize); | 3134 root->setContentBounds(rootSize); |
| 3135 root->setDrawsContent(true); | 3135 root->setDrawsContent(true); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3157 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) | 3157 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) |
| 3158 { | 3158 { |
| 3159 LayerTreeSettings settings; | 3159 LayerTreeSettings settings; |
| 3160 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3160 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3161 settings.partialSwapEnabled = true; | 3161 settings.partialSwapEnabled = true; |
| 3162 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3162 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3163 | 3163 |
| 3164 LayerImpl* rootPtr; | 3164 LayerImpl* rootPtr; |
| 3165 LayerImpl* surfaceLayerPtr; | 3165 LayerImpl* surfaceLayerPtr; |
| 3166 | 3166 |
| 3167 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3167 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3168 | 3168 |
| 3169 gfx::Size rootSize(100, 100); | 3169 gfx::Size rootSize(100, 100); |
| 3170 | 3170 |
| 3171 myHostImpl->initializeRenderer(context.Pass()); | 3171 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3172 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3172 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3173 | 3173 |
| 3174 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3174 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3175 rootPtr = root.get(); | 3175 rootPtr = root.get(); |
| 3176 | 3176 |
| 3177 root->setAnchorPoint(gfx::PointF(0, 0)); | 3177 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3178 root->setPosition(gfx::PointF(0, 0)); | 3178 root->setPosition(gfx::PointF(0, 0)); |
| 3179 root->setBounds(rootSize); | 3179 root->setBounds(rootSize); |
| 3180 root->setContentBounds(rootSize); | 3180 root->setContentBounds(rootSize); |
| 3181 root->setDrawsContent(true); | 3181 root->setDrawsContent(true); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3268 // | 3268 // |
| 3269 // Occlusion: | 3269 // Occlusion: |
| 3270 // L12 occludes L11 (internal) | 3270 // L12 occludes L11 (internal) |
| 3271 // L20 occludes L10 (external) | 3271 // L20 occludes L10 (external) |
| 3272 // L21 occludes L20 (internal) | 3272 // L21 occludes L20 (internal) |
| 3273 | 3273 |
| 3274 LayerImpl* rootPtr; | 3274 LayerImpl* rootPtr; |
| 3275 LayerImpl* layerS1Ptr; | 3275 LayerImpl* layerS1Ptr; |
| 3276 LayerImpl* layerS2Ptr; | 3276 LayerImpl* layerS2Ptr; |
| 3277 | 3277 |
| 3278 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3278 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3279 | 3279 |
| 3280 gfx::Size rootSize(1000, 1000); | 3280 gfx::Size rootSize(1000, 1000); |
| 3281 | 3281 |
| 3282 myHostImpl->initializeRenderer(context.Pass()); | 3282 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3283 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3283 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3284 | 3284 |
| 3285 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3285 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3286 rootPtr = root.get(); | 3286 rootPtr = root.get(); |
| 3287 | 3287 |
| 3288 root->setAnchorPoint(gfx::PointF(0, 0)); | 3288 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3289 root->setPosition(gfx::PointF(0, 0)); | 3289 root->setPosition(gfx::PointF(0, 0)); |
| 3290 root->setBounds(rootSize); | 3290 root->setBounds(rootSize); |
| 3291 root->setContentBounds(rootSize); | 3291 root->setContentBounds(rootSize); |
| 3292 root->setDrawsContent(true); | 3292 root->setDrawsContent(true); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3379 // | +- L13 (corner, unoccluded) | 3379 // | +- L13 (corner, unoccluded) |
| 3380 // | +- L14 (corner, entirely occluded) | 3380 // | +- L14 (corner, entirely occluded) |
| 3381 // | | 3381 // | |
| 3382 // +-- S2 +- L20 (owning, drawing) | 3382 // +-- S2 +- L20 (owning, drawing) |
| 3383 // | 3383 // |
| 3384 | 3384 |
| 3385 LayerImpl* rootPtr; | 3385 LayerImpl* rootPtr; |
| 3386 LayerImpl* layerS1Ptr; | 3386 LayerImpl* layerS1Ptr; |
| 3387 LayerImpl* layerS2Ptr; | 3387 LayerImpl* layerS2Ptr; |
| 3388 | 3388 |
| 3389 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3389 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3390 | 3390 |
| 3391 gfx::Size rootSize(1000, 1000); | 3391 gfx::Size rootSize(1000, 1000); |
| 3392 | 3392 |
| 3393 myHostImpl->initializeRenderer(context.Pass()); | 3393 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3394 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3394 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3395 | 3395 |
| 3396 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3396 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3397 rootPtr = root.get(); | 3397 rootPtr = root.get(); |
| 3398 | 3398 |
| 3399 root->setAnchorPoint(gfx::PointF(0, 0)); | 3399 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3400 root->setPosition(gfx::PointF(0, 0)); | 3400 root->setPosition(gfx::PointF(0, 0)); |
| 3401 root->setBounds(rootSize); | 3401 root->setBounds(rootSize); |
| 3402 root->setContentBounds(rootSize); | 3402 root->setContentBounds(rootSize); |
| 3403 root->setDrawsContent(true); | 3403 root->setDrawsContent(true); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3491 // | +- L11 (corner, occluded by L12) | 3491 // | +- L11 (corner, occluded by L12) |
| 3492 // | +- L12 (opposite corner) | 3492 // | +- L12 (opposite corner) |
| 3493 // | | 3493 // | |
| 3494 // +-- S2 +- L20 (owning, drawing) | 3494 // +-- S2 +- L20 (owning, drawing) |
| 3495 // | 3495 // |
| 3496 | 3496 |
| 3497 LayerImpl* rootPtr; | 3497 LayerImpl* rootPtr; |
| 3498 LayerImpl* layerS1Ptr; | 3498 LayerImpl* layerS1Ptr; |
| 3499 LayerImpl* layerS2Ptr; | 3499 LayerImpl* layerS2Ptr; |
| 3500 | 3500 |
| 3501 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3501 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3502 | 3502 |
| 3503 gfx::Size rootSize(1000, 1000); | 3503 gfx::Size rootSize(1000, 1000); |
| 3504 | 3504 |
| 3505 myHostImpl->initializeRenderer(context.Pass()); | 3505 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3506 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3506 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3507 | 3507 |
| 3508 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3508 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3509 rootPtr = root.get(); | 3509 rootPtr = root.get(); |
| 3510 | 3510 |
| 3511 root->setAnchorPoint(gfx::PointF(0, 0)); | 3511 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3512 root->setPosition(gfx::PointF(0, 0)); | 3512 root->setPosition(gfx::PointF(0, 0)); |
| 3513 root->setBounds(rootSize); | 3513 root->setBounds(rootSize); |
| 3514 root->setContentBounds(rootSize); | 3514 root->setContentBounds(rootSize); |
| 3515 root->setDrawsContent(true); | 3515 root->setDrawsContent(true); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3572 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3572 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3573 | 3573 |
| 3574 // Layers are structured as follows: | 3574 // Layers are structured as follows: |
| 3575 // | 3575 // |
| 3576 // R +-- S1 +- L10 (rotated, drawing) | 3576 // R +-- S1 +- L10 (rotated, drawing) |
| 3577 // +- L11 (occupies half surface) | 3577 // +- L11 (occupies half surface) |
| 3578 | 3578 |
| 3579 LayerImpl* rootPtr; | 3579 LayerImpl* rootPtr; |
| 3580 LayerImpl* layerS1Ptr; | 3580 LayerImpl* layerS1Ptr; |
| 3581 | 3581 |
| 3582 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3582 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3583 | 3583 |
| 3584 gfx::Size rootSize(1000, 1000); | 3584 gfx::Size rootSize(1000, 1000); |
| 3585 | 3585 |
| 3586 myHostImpl->initializeRenderer(context.Pass()); | 3586 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3587 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3587 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3588 | 3588 |
| 3589 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3589 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3590 rootPtr = root.get(); | 3590 rootPtr = root.get(); |
| 3591 | 3591 |
| 3592 root->setAnchorPoint(gfx::PointF(0, 0)); | 3592 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3593 root->setPosition(gfx::PointF(0, 0)); | 3593 root->setPosition(gfx::PointF(0, 0)); |
| 3594 root->setBounds(rootSize); | 3594 root->setBounds(rootSize); |
| 3595 root->setContentBounds(rootSize); | 3595 root->setContentBounds(rootSize); |
| 3596 root->setDrawsContent(true); | 3596 root->setDrawsContent(true); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3656 // | 3656 // |
| 3657 // Occlusion: | 3657 // Occlusion: |
| 3658 // L12 occludes L11 (internal) | 3658 // L12 occludes L11 (internal) |
| 3659 // L20 occludes L10 (external) | 3659 // L20 occludes L10 (external) |
| 3660 // L21 occludes L20 (internal) | 3660 // L21 occludes L20 (internal) |
| 3661 | 3661 |
| 3662 LayerImpl* rootPtr; | 3662 LayerImpl* rootPtr; |
| 3663 LayerImpl* layerS1Ptr; | 3663 LayerImpl* layerS1Ptr; |
| 3664 LayerImpl* layerS2Ptr; | 3664 LayerImpl* layerS2Ptr; |
| 3665 | 3665 |
| 3666 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3666 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3667 | 3667 |
| 3668 gfx::Size rootSize(1000, 1000); | 3668 gfx::Size rootSize(1000, 1000); |
| 3669 | 3669 |
| 3670 myHostImpl->initializeRenderer(context.Pass()); | 3670 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3671 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3671 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| 3672 | 3672 |
| 3673 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3673 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3674 rootPtr = root.get(); | 3674 rootPtr = root.get(); |
| 3675 | 3675 |
| 3676 root->setAnchorPoint(gfx::PointF(0, 0)); | 3676 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3677 root->setPosition(gfx::PointF(0, 0)); | 3677 root->setPosition(gfx::PointF(0, 0)); |
| 3678 root->setBounds(rootSize); | 3678 root->setBounds(rootSize); |
| 3679 root->setContentBounds(rootSize); | 3679 root->setContentBounds(rootSize); |
| 3680 root->setDrawsContent(true); | 3680 root->setDrawsContent(true); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3775 Layers 1, 2 have render surfaces | 3775 Layers 1, 2 have render surfaces |
| 3776 */ | 3776 */ |
| 3777 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3777 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
| 3778 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2); | 3778 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2); |
| 3779 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); | 3779 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); |
| 3780 | 3780 |
| 3781 gfx::Rect rootRect(0, 0, 100, 100); | 3781 gfx::Rect rootRect(0, 0, 100, 100); |
| 3782 gfx::Rect childRect(10, 10, 50, 50); | 3782 gfx::Rect childRect(10, 10, 50, 50); |
| 3783 gfx::Rect grandChildRect(5, 5, 150, 150); | 3783 gfx::Rect grandChildRect(5, 5, 150, 150); |
| 3784 | 3784 |
| 3785 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3785 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); |
| 3786 myHostImpl->initializeRenderer(context.Pass()); | 3786 myHostImpl->initializeRenderer(outputSurface.Pass()); |
| 3787 | 3787 |
| 3788 root->setAnchorPoint(gfx::PointF(0, 0)); | 3788 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 3789 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 3789 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
| 3790 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); | 3790 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); |
| 3791 root->setContentBounds(root->bounds()); | 3791 root->setContentBounds(root->bounds()); |
| 3792 root->setDrawsContent(true); | 3792 root->setDrawsContent(true); |
| 3793 root->setMasksToBounds(true); | 3793 root->setMasksToBounds(true); |
| 3794 | 3794 |
| 3795 child->setAnchorPoint(gfx::PointF(0, 0)); | 3795 child->setAnchorPoint(gfx::PointF(0, 0)); |
| 3796 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); | 3796 child->setPosition(gfx::PointF(childRect.x(), childRect.y())); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4221 } | 4221 } |
| 4222 | 4222 |
| 4223 void clearCachedTextures() { m_textures.clear(); } | 4223 void clearCachedTextures() { m_textures.clear(); } |
| 4224 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } | 4224 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } |
| 4225 | 4225 |
| 4226 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } | 4226 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } |
| 4227 | 4227 |
| 4228 // RendererClient implementation. | 4228 // RendererClient implementation. |
| 4229 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } | 4229 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } |
| 4230 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } | 4230 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } |
| 4231 virtual void didLoseContext() OVERRIDE { } | 4231 virtual void didLoseOutputSurface() OVERRIDE { } |
| 4232 virtual void onSwapBuffersComplete() OVERRIDE { } | 4232 virtual void onSwapBuffersComplete() OVERRIDE { } |
| 4233 virtual void setFullRootLayerDamage() OVERRIDE { } | 4233 virtual void setFullRootLayerDamage() OVERRIDE { } |
| 4234 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } | 4234 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } |
| 4235 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } | 4235 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } |
| 4236 virtual bool hasImplThread() const OVERRIDE { return false; } | 4236 virtual bool hasImplThread() const OVERRIDE { return false; } |
| 4237 | 4237 |
| 4238 protected: | 4238 protected: |
| 4239 TestRenderer(ResourceProvider* resourceProvider, Proxy* proxy) : GLRenderer(
this, resourceProvider) { } | 4239 TestRenderer(ResourceProvider* resourceProvider, Proxy* proxy) : GLRenderer(
this, resourceProvider) { } |
| 4240 | 4240 |
| 4241 private: | 4241 private: |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4516 | 4516 |
| 4517 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) | 4517 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) |
| 4518 { | 4518 { |
| 4519 char actualResult[1024]; | 4519 char actualResult[1024]; |
| 4520 dumpRenderPassTestData(testData, actualResult); | 4520 dumpRenderPassTestData(testData, actualResult); |
| 4521 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; | 4521 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; |
| 4522 } | 4522 } |
| 4523 | 4523 |
| 4524 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) | 4524 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) |
| 4525 { | 4525 { |
| 4526 scoped_ptr<GraphicsContext> context(createContext()); | 4526 scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); |
| 4527 ASSERT_TRUE(context->context3D()); | 4527 ASSERT_TRUE(outputSurface->context3D()); |
| 4528 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); | 4528 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.get())); |
| 4529 | 4529 |
| 4530 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), &m_proxy)); | 4530 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), &m_proxy)); |
| 4531 | 4531 |
| 4532 int testCaseIndex = 0; | 4532 int testCaseIndex = 0; |
| 4533 while (removeRenderPassesCases[testCaseIndex].name) { | 4533 while (removeRenderPassesCases[testCaseIndex].name) { |
| 4534 RenderPassRemovalTestData testData; | 4534 RenderPassRemovalTestData testData; |
| 4535 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); | 4535 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); |
| 4536 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); | 4536 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); |
| 4537 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4537 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
| 4538 testCaseIndex++; | 4538 testCaseIndex++; |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4895 { | 4895 { |
| 4896 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4896 pinchZoomPanViewportAndScrollBoundaryTest(2); |
| 4897 } | 4897 } |
| 4898 | 4898 |
| 4899 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4899 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4900 LayerTreeHostImplTest, | 4900 LayerTreeHostImplTest, |
| 4901 ::testing::Values(false, true)); | 4901 ::testing::Values(false, true)); |
| 4902 | 4902 |
| 4903 } // namespace | 4903 } // namespace |
| 4904 } // namespace cc | 4904 } // namespace cc |
| OLD | NEW |