| 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" |
| 11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 12 #include "cc/delegated_renderer_layer_impl.h" | 12 #include "cc/delegated_renderer_layer_impl.h" |
| 13 #include "cc/gl_renderer.h" | 13 #include "cc/gl_renderer.h" |
| 14 #include "cc/heads_up_display_layer_impl.h" | 14 #include "cc/heads_up_display_layer_impl.h" |
| 15 #include "cc/io_surface_layer_impl.h" | 15 #include "cc/io_surface_layer_impl.h" |
| 16 #include "cc/layer_impl.h" | 16 #include "cc/layer_impl.h" |
| 17 #include "cc/layer_tiling_data.h" | 17 #include "cc/layer_tiling_data.h" |
| 18 #include "cc/math_util.h" | 18 #include "cc/math_util.h" |
| 19 #include "cc/quad_sink.h" | 19 #include "cc/quad_sink.h" |
| 20 #include "cc/render_pass_draw_quad.h" | 20 #include "cc/render_pass_draw_quad.h" |
| 21 #include "cc/scrollbar_geometry_fixed_thumb.h" | 21 #include "cc/scrollbar_geometry_fixed_thumb.h" |
| 22 #include "cc/scrollbar_layer_impl.h" | 22 #include "cc/scrollbar_layer_impl.h" |
| 23 #include "cc/single_thread_proxy.h" | 23 #include "cc/single_thread_proxy.h" |
| 24 #include "cc/solid_color_draw_quad.h" | 24 #include "cc/solid_color_draw_quad.h" |
| 25 #include "cc/test/animation_test_common.h" | 25 #include "cc/test/animation_test_common.h" |
| 26 #include "cc/test/fake_output_surface.h" |
| 26 #include "cc/test/fake_proxy.h" | 27 #include "cc/test/fake_proxy.h" |
| 27 #include "cc/test/fake_web_compositor_output_surface.h" | |
| 28 #include "cc/test/fake_web_graphics_context_3d.h" | 28 #include "cc/test/fake_web_graphics_context_3d.h" |
| 29 #include "cc/test/fake_web_scrollbar_theme_geometry.h" | 29 #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
| 30 #include "cc/test/geometry_test_utils.h" | 30 #include "cc/test/geometry_test_utils.h" |
| 31 #include "cc/test/layer_test_common.h" | 31 #include "cc/test/layer_test_common.h" |
| 32 #include "cc/test/render_pass_test_common.h" | 32 #include "cc/test/render_pass_test_common.h" |
| 33 #include "cc/texture_draw_quad.h" | 33 #include "cc/texture_draw_quad.h" |
| 34 #include "cc/texture_layer_impl.h" | 34 #include "cc/texture_layer_impl.h" |
| 35 #include "cc/tile_draw_quad.h" | 35 #include "cc/tile_draw_quad.h" |
| 36 #include "cc/tiled_layer_impl.h" | 36 #include "cc/tiled_layer_impl.h" |
| 37 #include "cc/video_layer_impl.h" | 37 #include "cc/video_layer_impl.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 scoped_ptr<OutputSurface> createOutputSurface() |
| 209 { | 209 { |
| 210 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); | 210 return FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext
3D>(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<OutputSurface>()); | 379 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit
::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou
tputSurface>()); |
| 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 1600 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs
<OutputSurface>(); | 2000 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf
ace>(); |
| 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 |
| 2011 LayerTreeHostImpl::FrameData frame; | 2011 LayerTreeHostImpl::FrameData frame; |
| (...skipping 21 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).Pa
ssAs<OutputSurface>(); | 2043 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<Output
Surface>(); |
| 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 |
| 2054 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 2054 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
| (...skipping 193 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); | 2258 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
| 2259 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
D()); | 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, output
Surface.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; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSur
face>(); | 2291 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); |
| 2292 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3
D()); | 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, outputS
urface.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)); |
| (...skipping 34 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 2347 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 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(outputSurface.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 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled()); | 2493 EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled()); |
| 2494 EXPECT_TRUE(layer2->didLoseOutputSurfaceCalled()); | 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<OutputSurface>()); | 2503 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit
::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou
tputSurface>()); |
| 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; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 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<OutputSurface>())); | 2541 EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(
scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrent
FailsEventually(i))).PassAs<OutputSurface>())); |
| 2542 EXPECT_EQ(0, m_hostImpl->outputSurface()); | 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(createOutputSurface())); | 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<OutputSurface>())); | 2548 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scope
d_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails
Eventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<Outp
utSurface>())); |
| 2549 EXPECT_TRUE(m_hostImpl->outputSurface()); | 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: |
| (...skipping 333 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<OutputSurface>()); | 2902 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit
::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<Outpu
tSurface>()); |
| 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 WebGraphicsContext3D, replacing it with a StrictWebGraphicsConte
xt3DWithIOSurface, | 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<OutputSurface>()); | 2932 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit
::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<Out
putSurface>()); |
| 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 output surface (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); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon
text3D (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<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::crea
te(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); | 3051 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); |
| 3052 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra
ckingWebGraphicsContext3D*>(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(trackingWebGraphicsContext3D->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, trackingWebGraphicsContext3D->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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenConte
xt)).PassAs<OutputSurface>(); | 3079 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs
<OutputSurface>(); |
| 3080 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(outputSurface->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, output
Surface.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(_, _, _, _)) |
| (...skipping 22 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3123 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3124 | 3124 |
| 3125 layerTreeHostImpl->initializeRenderer(outputSurface.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); |
| (...skipping 23 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3167 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3168 | 3168 |
| 3169 gfx::Size rootSize(100, 100); | 3169 gfx::Size rootSize(100, 100); |
| 3170 | 3170 |
| 3171 myHostImpl->initializeRenderer(outputSurface.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)); |
| (...skipping 90 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3278 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3279 | 3279 |
| 3280 gfx::Size rootSize(1000, 1000); | 3280 gfx::Size rootSize(1000, 1000); |
| 3281 | 3281 |
| 3282 myHostImpl->initializeRenderer(outputSurface.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)); |
| (...skipping 90 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3389 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3390 | 3390 |
| 3391 gfx::Size rootSize(1000, 1000); | 3391 gfx::Size rootSize(1000, 1000); |
| 3392 | 3392 |
| 3393 myHostImpl->initializeRenderer(outputSurface.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)); |
| (...skipping 91 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3501 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3502 | 3502 |
| 3503 gfx::Size rootSize(1000, 1000); | 3503 gfx::Size rootSize(1000, 1000); |
| 3504 | 3504 |
| 3505 myHostImpl->initializeRenderer(outputSurface.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)); |
| (...skipping 60 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3582 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3583 | 3583 |
| 3584 gfx::Size rootSize(1000, 1000); | 3584 gfx::Size rootSize(1000, 1000); |
| 3585 | 3585 |
| 3586 myHostImpl->initializeRenderer(outputSurface.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)); |
| (...skipping 63 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3666 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3667 | 3667 |
| 3668 gfx::Size rootSize(1000, 1000); | 3668 gfx::Size rootSize(1000, 1000); |
| 3669 | 3669 |
| 3670 myHostImpl->initializeRenderer(outputSurface.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)); |
| (...skipping 98 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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou
tputSurface>(); | 3785 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface
>(); |
| 3786 myHostImpl->initializeRenderer(outputSurface.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)); |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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<OutputSurface> outputSurface(createOutputSurface()); | 4526 scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); |
| 4527 ASSERT_TRUE(outputSurface->context3D()); | 4527 ASSERT_TRUE(outputSurface->Context3D()); |
| 4528 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu
tSurface.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); |
| (...skipping 357 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 |