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<GraphicsContext> createContext() | 208 scoped_ptr<GraphicsContext> createContext() |
209 { | 209 { |
210 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); | 210 return FakeOutputSurface::Create(scoped_ptr<WebKit::WebGraphicsContext3D
>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); |
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(FakeOutputSurface::Create(scoped_ptr<WebKit::
WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<Grap
hicsContext>()); |
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 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1985 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew FakeDrawableLayerImpl(id)); } | 1985 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew FakeDrawableLayerImpl(id)); } |
1986 protected: | 1986 protected: |
1987 explicit FakeDrawableLayerImpl(int id) : LayerImpl(id) { } | 1987 explicit FakeDrawableLayerImpl(int id) : LayerImpl(id) { } |
1988 }; | 1988 }; |
1989 | 1989 |
1990 // Only reshape when we know we are going to draw. Otherwise, the reshape | 1990 // Only reshape when we know we are going to draw. Otherwise, the reshape |
1991 // can leave the window at the wrong size if we never draw and the proper | 1991 // can leave the window at the wrong size if we never draw and the proper |
1992 // viewport size is never set. | 1992 // viewport size is never set. |
1993 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) | 1993 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) |
1994 { | 1994 { |
1995 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).Pass
As<GraphicsContext>(); | 1995 scoped_ptr<GraphicsContext> outputSurface = FakeOutputSurface::Create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<GraphicsCo
ntext>(); |
1996 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->context3D()); | 1996 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>(
outputSurface->Context3D()); |
1997 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 1997 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
1998 | 1998 |
1999 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 1999 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
2000 root->setAnchorPoint(gfx::PointF(0, 0)); | 2000 root->setAnchorPoint(gfx::PointF(0, 0)); |
2001 root->setBounds(gfx::Size(10, 10)); | 2001 root->setBounds(gfx::Size(10, 10)); |
2002 root->setDrawsContent(true); | 2002 root->setDrawsContent(true); |
2003 m_hostImpl->setRootLayer(root.Pass()); | 2003 m_hostImpl->setRootLayer(root.Pass()); |
2004 EXPECT_FALSE(reshapeTracker->reshapeCalled()); | 2004 EXPECT_FALSE(reshapeTracker->reshapeCalled()); |
2005 | 2005 |
2006 LayerTreeHostImpl::FrameData frame; | 2006 LayerTreeHostImpl::FrameData frame; |
(...skipping 21 matching lines...) Expand all Loading... |
2028 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } | 2028 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } |
2029 | 2029 |
2030 private: | 2030 private: |
2031 gfx::Rect m_partialSwapRect; | 2031 gfx::Rect m_partialSwapRect; |
2032 }; | 2032 }; |
2033 | 2033 |
2034 // Make sure damage tracking propagates all the way to the graphics context, | 2034 // Make sure damage tracking propagates all the way to the graphics context, |
2035 // where it should request to swap only the subBuffer that is damaged. | 2035 // where it should request to swap only the subBuffer that is damaged. |
2036 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) | 2036 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) |
2037 { | 2037 { |
2038 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); | 2038 scoped_ptr<GraphicsContext> outputSurface = FakeOutputSurface::Create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<Graphi
csContext>(); |
2039 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); | 2039 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->Context3D()); |
2040 | 2040 |
2041 // This test creates its own LayerTreeHostImpl, so | 2041 // This test creates its own LayerTreeHostImpl, so |
2042 // that we can force partial swap enabled. | 2042 // that we can force partial swap enabled. |
2043 LayerTreeSettings settings; | 2043 LayerTreeSettings settings; |
2044 settings.partialSwapEnabled = true; | 2044 settings.partialSwapEnabled = true; |
2045 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); | 2045 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); |
2046 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 2046 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
2047 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 2047 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
2048 | 2048 |
2049 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 2049 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST)) | 2243 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST)) |
2244 .Times(0); | 2244 .Times(0); |
2245 | 2245 |
2246 EXPECT_CALL(*m_context, scissor(_, _, _, _)) | 2246 EXPECT_CALL(*m_context, scissor(_, _, _, _)) |
2247 .Times(0); | 2247 .Times(0); |
2248 } | 2248 } |
2249 }; | 2249 }; |
2250 | 2250 |
2251 TEST_P(LayerTreeHostImplTest, noPartialSwap) | 2251 TEST_P(LayerTreeHostImplTest, noPartialSwap) |
2252 { | 2252 { |
2253 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<GraphicsContext>(); | 2253 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebGraphicsContext3D>(new MockContext)).PassAs<GraphicsContext>(); |
2254 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2254 MockContext* mockContext = static_cast<MockContext*>(context->Context3D()); |
2255 MockContextHarness harness(mockContext); | 2255 MockContextHarness harness(mockContext); |
2256 | 2256 |
2257 // Run test case | 2257 // Run test case |
2258 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, contex
t.Pass(), FakeLayerWithQuads::create(1)); | 2258 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, contex
t.Pass(), FakeLayerWithQuads::create(1)); |
2259 | 2259 |
2260 // without partial swap, and no clipping, no scissor is set. | 2260 // without partial swap, and no clipping, no scissor is set. |
2261 harness.mustDrawSolidQuad(); | 2261 harness.mustDrawSolidQuad(); |
2262 harness.mustSetNoScissor(); | 2262 harness.mustSetNoScissor(); |
2263 { | 2263 { |
2264 LayerTreeHostImpl::FrameData frame; | 2264 LayerTreeHostImpl::FrameData frame; |
(...skipping 11 matching lines...) Expand all Loading... |
2276 LayerTreeHostImpl::FrameData frame; | 2276 LayerTreeHostImpl::FrameData frame; |
2277 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2277 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
2278 myHostImpl->drawLayers(frame); | 2278 myHostImpl->drawLayers(frame); |
2279 myHostImpl->didDrawAllLayers(frame); | 2279 myHostImpl->didDrawAllLayers(frame); |
2280 } | 2280 } |
2281 Mock::VerifyAndClearExpectations(&mockContext); | 2281 Mock::VerifyAndClearExpectations(&mockContext); |
2282 } | 2282 } |
2283 | 2283 |
2284 TEST_P(LayerTreeHostImplTest, partialSwap) | 2284 TEST_P(LayerTreeHostImplTest, partialSwap) |
2285 { | 2285 { |
2286 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<GraphicsConte
xt>(); | 2286 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new MockContext)).PassAs<GraphicsContext>(); |
2287 MockContext* mockContext = static_cast<MockContext*>(context->context3D()); | 2287 MockContext* mockContext = static_cast<MockContext*>(context->Context3D()); |
2288 MockContextHarness harness(mockContext); | 2288 MockContextHarness harness(mockContext); |
2289 | 2289 |
2290 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context
.Pass(), FakeLayerWithQuads::create(1)); | 2290 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(true, context
.Pass(), FakeLayerWithQuads::create(1)); |
2291 | 2291 |
2292 // The first frame is not a partially-swapped one. | 2292 // The first frame is not a partially-swapped one. |
2293 harness.mustSetScissor(0, 0, 10, 10); | 2293 harness.mustSetScissor(0, 0, 10, 10); |
2294 harness.mustDrawSolidQuad(); | 2294 harness.mustDrawSolidQuad(); |
2295 { | 2295 { |
2296 LayerTreeHostImpl::FrameData frame; | 2296 LayerTreeHostImpl::FrameData frame; |
2297 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2297 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2332 // Unlimited texture size. | 2332 // Unlimited texture size. |
2333 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) | 2333 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) |
2334 { | 2334 { |
2335 if (pname == GL_MAX_TEXTURE_SIZE) | 2335 if (pname == GL_MAX_TEXTURE_SIZE) |
2336 *value = 8192; | 2336 *value = 8192; |
2337 } | 2337 } |
2338 }; | 2338 }; |
2339 | 2339 |
2340 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) | 2340 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) |
2341 { | 2341 { |
2342 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 2342 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
2343 | 2343 |
2344 LayerTreeSettings settings; | 2344 LayerTreeSettings settings; |
2345 settings.partialSwapEnabled = partialSwap; | 2345 settings.partialSwapEnabled = partialSwap; |
2346 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client, proxy); | 2346 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client, proxy); |
2347 myHostImpl->initializeRenderer(context.Pass()); | 2347 myHostImpl->initializeRenderer(context.Pass()); |
2348 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 2348 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
2349 | 2349 |
2350 /* | 2350 /* |
2351 Layers are created as follows: | 2351 Layers are created as follows: |
2352 | 2352 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2488 EXPECT_TRUE(layer1->didLoseContextCalled()); | 2488 EXPECT_TRUE(layer1->didLoseContextCalled()); |
2489 EXPECT_TRUE(layer2->didLoseContextCalled()); | 2489 EXPECT_TRUE(layer2->didLoseContextCalled()); |
2490 } | 2490 } |
2491 | 2491 |
2492 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) | 2492 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) |
2493 { | 2493 { |
2494 LayerTreeSettings settings; | 2494 LayerTreeSettings settings; |
2495 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); | 2495 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
2496 | 2496 |
2497 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. | 2497 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. |
2498 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); | 2498 m_hostImpl->initializeRenderer(FakeOutputSurface::Create(scoped_ptr<WebKit::
WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<Grap
hicsContext>()); |
2499 m_hostImpl->finishAllRendering(); | 2499 m_hostImpl->finishAllRendering(); |
2500 } | 2500 } |
2501 | 2501 |
2502 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { | 2502 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { |
2503 public: | 2503 public: |
2504 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } | 2504 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } |
2505 virtual bool makeContextCurrent() { | 2505 virtual bool makeContextCurrent() { |
2506 if (!m_succeedCount) | 2506 if (!m_succeedCount) |
2507 return false; | 2507 return false; |
2508 --m_succeedCount; | 2508 --m_succeedCount; |
(...skipping 17 matching lines...) Expand all Loading... |
2526 | 2526 |
2527 // We will make the context get lost after a numer of makeContextCurrent | 2527 // We will make the context get lost after a numer of makeContextCurrent |
2528 // calls. The exact number of calls to make it succeed is dependent on the | 2528 // calls. The exact number of calls to make it succeed is dependent on the |
2529 // implementation and doesn't really matter (i.e. can be changed to make the | 2529 // implementation and doesn't really matter (i.e. can be changed to make the |
2530 // tests pass after some refactoring). | 2530 // tests pass after some refactoring). |
2531 const unsigned kMakeCurrentSuccessesNeededForSuccessfulInitialization = 3; | 2531 const unsigned kMakeCurrentSuccessesNeededForSuccessfulInitialization = 3; |
2532 | 2532 |
2533 for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitializat
ion; ++i) { | 2533 for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitializat
ion; ++i) { |
2534 // The context will get lost during initialization, we shouldn't crash.
We | 2534 // The context will get lost during initialization, we shouldn't crash.
We |
2535 // should also be in a consistent state. | 2535 // should also be in a consistent state. |
2536 EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurfa
ce::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D
MakeCurrentFailsEventually(i))).PassAs<GraphicsContext>())); | 2536 EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create(sc
oped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFa
ilsEventually(i))).PassAs<GraphicsContext>())); |
2537 EXPECT_EQ(0, m_hostImpl->context()); | 2537 EXPECT_EQ(0, m_hostImpl->context()); |
2538 EXPECT_EQ(0, m_hostImpl->renderer()); | 2538 EXPECT_EQ(0, m_hostImpl->renderer()); |
2539 EXPECT_EQ(0, m_hostImpl->resourceProvider()); | 2539 EXPECT_EQ(0, m_hostImpl->resourceProvider()); |
2540 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); | 2540 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); |
2541 } | 2541 } |
2542 | 2542 |
2543 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::c
reate(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeC
urrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).
PassAs<GraphicsContext>())); | 2543 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create(scoped_
ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFailsEv
entually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<Graphi
csContext>())); |
2544 EXPECT_TRUE(m_hostImpl->context()); | 2544 EXPECT_TRUE(m_hostImpl->context()); |
2545 EXPECT_TRUE(m_hostImpl->renderer()); | 2545 EXPECT_TRUE(m_hostImpl->renderer()); |
2546 EXPECT_TRUE(m_hostImpl->resourceProvider()); | 2546 EXPECT_TRUE(m_hostImpl->resourceProvider()); |
2547 } | 2547 } |
2548 | 2548 |
2549 // Fake WebGraphicsContext3D that will cause a failure if trying to use a | 2549 // Fake WebGraphicsContext3D that will cause a failure if trying to use a |
2550 // resource that wasn't created by it (resources created by | 2550 // resource that wasn't created by it (resources created by |
2551 // FakeWebGraphicsContext3D have an id of 1). | 2551 // FakeWebGraphicsContext3D have an id of 1). |
2552 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { | 2552 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { |
2553 public: | 2553 public: |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); | 2887 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); |
2888 delegatedRendererLayer->setDrawsContent(true); | 2888 delegatedRendererLayer->setDrawsContent(true); |
2889 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 2889 delegatedRendererLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
2890 ScopedPtrVector<RenderPass> passList; | 2890 ScopedPtrVector<RenderPass> passList; |
2891 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); | 2891 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider())
); |
2892 delegatedRendererLayer->setRenderPasses(passList); | 2892 delegatedRendererLayer->setRenderPasses(passList); |
2893 EXPECT_TRUE(passList.isEmpty()); | 2893 EXPECT_TRUE(passList.isEmpty()); |
2894 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); | 2894 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); |
2895 | 2895 |
2896 // Use a context that supports IOSurfaces | 2896 // Use a context that supports IOSurfaces |
2897 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P
assAs<GraphicsContext>()); | 2897 m_hostImpl->initializeRenderer(FakeOutputSurface::Create(scoped_ptr<WebKit::
WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<Graphic
sContext>()); |
2898 | 2898 |
2899 FakeVideoFrame hwVideoFrame( | 2899 FakeVideoFrame hwVideoFrame( |
2900 VideoFrame::WrapNativeTexture( | 2900 VideoFrame::WrapNativeTexture( |
2901 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, | 2901 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
2902 GL_TEXTURE_2D, | 2902 GL_TEXTURE_2D, |
2903 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), | 2903 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD
elta(), |
2904 VideoFrame::ReadPixelsCB(), base::Closure())); | 2904 VideoFrame::ReadPixelsCB(), base::Closure())); |
2905 hwProvider.setFrame(&hwVideoFrame); | 2905 hwProvider.setFrame(&hwVideoFrame); |
2906 | 2906 |
2907 FakeVideoFrame videoFrameScaled( | 2907 FakeVideoFrame videoFrameScaled( |
2908 VideoFrame::WrapNativeTexture( | 2908 VideoFrame::WrapNativeTexture( |
2909 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, | 2909 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture()
, |
2910 GL_TEXTURE_2D, | 2910 GL_TEXTURE_2D, |
2911 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD
elta(), | 2911 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD
elta(), |
2912 VideoFrame::ReadPixelsCB(), base::Closure())); | 2912 VideoFrame::ReadPixelsCB(), base::Closure())); |
2913 providerScaled.setFrame(&videoFrameScaled); | 2913 providerScaled.setFrame(&videoFrameScaled); |
2914 | 2914 |
2915 m_hostImpl->setRootLayer(rootLayer.Pass()); | 2915 m_hostImpl->setRootLayer(rootLayer.Pass()); |
2916 | 2916 |
2917 LayerTreeHostImpl::FrameData frame; | 2917 LayerTreeHostImpl::FrameData frame; |
2918 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 2918 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
2919 m_hostImpl->drawLayers(frame); | 2919 m_hostImpl->drawLayers(frame); |
2920 m_hostImpl->didDrawAllLayers(frame); | 2920 m_hostImpl->didDrawAllLayers(frame); |
2921 m_hostImpl->swapBuffers(); | 2921 m_hostImpl->swapBuffers(); |
2922 | 2922 |
2923 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); | 2923 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); |
2924 | 2924 |
2925 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur
face, | 2925 // Lose the context, replacing it with a StrictWebGraphicsContext3DWithIOSur
face, |
2926 // that will warn if any resource from the previous context gets used. | 2926 // that will warn if any resource from the previous context gets used. |
2927 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface))
.PassAs<GraphicsContext>()); | 2927 m_hostImpl->initializeRenderer(FakeOutputSurface::Create(scoped_ptr<WebKit::
WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<Graph
icsContext>()); |
2928 | 2928 |
2929 // Create dummy resources so that looking up an old resource will get an | 2929 // Create dummy resources so that looking up an old resource will get an |
2930 // invalid texture id mapping. | 2930 // invalid texture id mapping. |
2931 for (unsigned i = 0; i < numResources; ++i) | 2931 for (unsigned i = 0; i < numResources; ++i) |
2932 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict
WebGraphicsContext3D::kExternalTextureId); | 2932 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict
WebGraphicsContext3D::kExternalTextureId); |
2933 | 2933 |
2934 // The WebVideoFrameProvider is expected to recreate its textures after a | 2934 // The WebVideoFrameProvider is expected to recreate its textures after a |
2935 // lost context (or not serve a frame). | 2935 // lost context (or not serve a frame). |
2936 hwProvider.setFrame(0); | 2936 hwProvider.setFrame(0); |
2937 providerScaled.setFrame(0); | 2937 providerScaled.setFrame(0); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5
); | 3036 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(5
); |
3037 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); | 3037 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); |
3038 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); | 3038 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); |
3039 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); | 3039 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); |
3040 ioSurfaceLayer->setDrawsContent(true); | 3040 ioSurfaceLayer->setDrawsContent(true); |
3041 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); | 3041 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); |
3042 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); | 3042 ioSurfaceLayer->setLayerTreeHostImpl(m_hostImpl.get()); |
3043 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); | 3043 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); |
3044 | 3044 |
3045 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which
the LayerTreeHostImpl takes ownership of). | 3045 // Lose the context, replacing it with a TrackingWebGraphicsContext3D (which
the LayerTreeHostImpl takes ownership of). |
3046 scoped_ptr<GraphicsContext> outputSurface(FakeWebCompositorOutputSurface::cr
eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))
); | 3046 scoped_ptr<GraphicsContext> outputSurface(FakeOutputSurface::Create(scoped_p
tr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); |
3047 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track
ingWebGraphicsContext3D*>(outputSurface->context3D()); | 3047 TrackingWebGraphicsContext3D* trackingWebGraphicsContext = static_cast<Track
ingWebGraphicsContext3D*>(outputSurface->Context3D()); |
3048 m_hostImpl->initializeRenderer(outputSurface.Pass()); | 3048 m_hostImpl->initializeRenderer(outputSurface.Pass()); |
3049 | 3049 |
3050 m_hostImpl->setRootLayer(rootLayer.Pass()); | 3050 m_hostImpl->setRootLayer(rootLayer.Pass()); |
3051 | 3051 |
3052 LayerTreeHostImpl::FrameData frame; | 3052 LayerTreeHostImpl::FrameData frame; |
3053 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 3053 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
3054 m_hostImpl->drawLayers(frame); | 3054 m_hostImpl->drawLayers(frame); |
3055 m_hostImpl->didDrawAllLayers(frame); | 3055 m_hostImpl->didDrawAllLayers(frame); |
3056 m_hostImpl->swapBuffers(); | 3056 m_hostImpl->swapBuffers(); |
3057 | 3057 |
3058 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); | 3058 EXPECT_GT(trackingWebGraphicsContext->numTextures(), 0u); |
3059 | 3059 |
3060 // Kill the layer tree. | 3060 // Kill the layer tree. |
3061 m_hostImpl->setRootLayer(LayerImpl::create(100)); | 3061 m_hostImpl->setRootLayer(LayerImpl::create(100)); |
3062 // There should be no textures left in use after. | 3062 // There should be no textures left in use after. |
3063 EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); | 3063 EXPECT_EQ(0u, trackingWebGraphicsContext->numTextures()); |
3064 } | 3064 } |
3065 | 3065 |
3066 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { | 3066 class MockDrawQuadsToFillScreenContext : public FakeWebGraphicsContext3D { |
3067 public: | 3067 public: |
3068 MOCK_METHOD1(useProgram, void(WebGLId program)); | 3068 MOCK_METHOD1(useProgram, void(WebGLId program)); |
3069 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); | 3069 MOCK_METHOD4(drawElements, void(WGC3Denum mode, WGC3Dsizei count, WGC3Denum
type, WGC3Dintptr offset)); |
3070 }; | 3070 }; |
3071 | 3071 |
3072 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) | 3072 TEST_P(LayerTreeHostImplTest, hasTransparentBackground) |
3073 { | 3073 { |
3074 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext))
.PassAs<GraphicsContext>(); | 3074 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs<Graph
icsContext>(); |
3075 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(context->context3D()); | 3075 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF
illScreenContext*>(context->Context3D()); |
3076 | 3076 |
3077 // Run test case | 3077 // Run test case |
3078 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, contex
t.Pass(), LayerImpl::create(1)); | 3078 scoped_ptr<LayerTreeHostImpl> myHostImpl = createLayerTreeHost(false, contex
t.Pass(), LayerImpl::create(1)); |
3079 myHostImpl->setBackgroundColor(SK_ColorWHITE); | 3079 myHostImpl->setBackgroundColor(SK_ColorWHITE); |
3080 | 3080 |
3081 // Verify one quad is drawn when transparent background set is not set. | 3081 // Verify one quad is drawn when transparent background set is not set. |
3082 myHostImpl->setHasTransparentBackground(false); | 3082 myHostImpl->setHasTransparentBackground(false); |
3083 EXPECT_CALL(*mockContext, useProgram(_)) | 3083 EXPECT_CALL(*mockContext, useProgram(_)) |
3084 .Times(1); | 3084 .Times(1); |
3085 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) | 3085 EXPECT_CALL(*mockContext, drawElements(_, _, _, _)) |
(...skipping 22 matching lines...) Expand all Loading... |
3108 layerPtr->setContentBounds(layerRect.size()); | 3108 layerPtr->setContentBounds(layerRect.size()); |
3109 layerPtr->setDrawsContent(true); // only children draw content | 3109 layerPtr->setDrawsContent(true); // only children draw content |
3110 layerPtr->setContentsOpaque(true); | 3110 layerPtr->setContentsOpaque(true); |
3111 parent->addChild(layer.Pass()); | 3111 parent->addChild(layer.Pass()); |
3112 if (result) | 3112 if (result) |
3113 *result = layerPtr; | 3113 *result = layerPtr; |
3114 } | 3114 } |
3115 | 3115 |
3116 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) | 3116 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L
ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt
r, LayerImpl*& childPtr, const gfx::Size& rootSize) |
3117 { | 3117 { |
3118 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3118 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3119 | 3119 |
3120 layerTreeHostImpl->initializeRenderer(context.Pass()); | 3120 layerTreeHostImpl->initializeRenderer(context.Pass()); |
3121 layerTreeHostImpl->setViewportSize(rootSize, rootSize); | 3121 layerTreeHostImpl->setViewportSize(rootSize, rootSize); |
3122 | 3122 |
3123 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3123 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3124 rootPtr = root.get(); | 3124 rootPtr = root.get(); |
3125 | 3125 |
3126 root->setAnchorPoint(gfx::PointF(0, 0)); | 3126 root->setAnchorPoint(gfx::PointF(0, 0)); |
3127 root->setPosition(gfx::PointF(0, 0)); | 3127 root->setPosition(gfx::PointF(0, 0)); |
3128 root->setBounds(rootSize); | 3128 root->setBounds(rootSize); |
(...skipping 23 matching lines...) Expand all Loading... |
3152 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) | 3152 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) |
3153 { | 3153 { |
3154 LayerTreeSettings settings; | 3154 LayerTreeSettings settings; |
3155 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3155 settings.minimumOcclusionTrackingSize = gfx::Size(); |
3156 settings.partialSwapEnabled = true; | 3156 settings.partialSwapEnabled = true; |
3157 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3157 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
3158 | 3158 |
3159 LayerImpl* rootPtr; | 3159 LayerImpl* rootPtr; |
3160 LayerImpl* surfaceLayerPtr; | 3160 LayerImpl* surfaceLayerPtr; |
3161 | 3161 |
3162 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3162 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3163 | 3163 |
3164 gfx::Size rootSize(100, 100); | 3164 gfx::Size rootSize(100, 100); |
3165 | 3165 |
3166 myHostImpl->initializeRenderer(context.Pass()); | 3166 myHostImpl->initializeRenderer(context.Pass()); |
3167 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3167 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3168 | 3168 |
3169 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3169 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3170 rootPtr = root.get(); | 3170 rootPtr = root.get(); |
3171 | 3171 |
3172 root->setAnchorPoint(gfx::PointF(0, 0)); | 3172 root->setAnchorPoint(gfx::PointF(0, 0)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3263 // | 3263 // |
3264 // Occlusion: | 3264 // Occlusion: |
3265 // L12 occludes L11 (internal) | 3265 // L12 occludes L11 (internal) |
3266 // L20 occludes L10 (external) | 3266 // L20 occludes L10 (external) |
3267 // L21 occludes L20 (internal) | 3267 // L21 occludes L20 (internal) |
3268 | 3268 |
3269 LayerImpl* rootPtr; | 3269 LayerImpl* rootPtr; |
3270 LayerImpl* layerS1Ptr; | 3270 LayerImpl* layerS1Ptr; |
3271 LayerImpl* layerS2Ptr; | 3271 LayerImpl* layerS2Ptr; |
3272 | 3272 |
3273 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3273 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3274 | 3274 |
3275 gfx::Size rootSize(1000, 1000); | 3275 gfx::Size rootSize(1000, 1000); |
3276 | 3276 |
3277 myHostImpl->initializeRenderer(context.Pass()); | 3277 myHostImpl->initializeRenderer(context.Pass()); |
3278 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3278 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3279 | 3279 |
3280 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3280 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3281 rootPtr = root.get(); | 3281 rootPtr = root.get(); |
3282 | 3282 |
3283 root->setAnchorPoint(gfx::PointF(0, 0)); | 3283 root->setAnchorPoint(gfx::PointF(0, 0)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3374 // | +- L13 (corner, unoccluded) | 3374 // | +- L13 (corner, unoccluded) |
3375 // | +- L14 (corner, entirely occluded) | 3375 // | +- L14 (corner, entirely occluded) |
3376 // | | 3376 // | |
3377 // +-- S2 +- L20 (owning, drawing) | 3377 // +-- S2 +- L20 (owning, drawing) |
3378 // | 3378 // |
3379 | 3379 |
3380 LayerImpl* rootPtr; | 3380 LayerImpl* rootPtr; |
3381 LayerImpl* layerS1Ptr; | 3381 LayerImpl* layerS1Ptr; |
3382 LayerImpl* layerS2Ptr; | 3382 LayerImpl* layerS2Ptr; |
3383 | 3383 |
3384 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3384 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3385 | 3385 |
3386 gfx::Size rootSize(1000, 1000); | 3386 gfx::Size rootSize(1000, 1000); |
3387 | 3387 |
3388 myHostImpl->initializeRenderer(context.Pass()); | 3388 myHostImpl->initializeRenderer(context.Pass()); |
3389 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3389 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3390 | 3390 |
3391 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3391 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3392 rootPtr = root.get(); | 3392 rootPtr = root.get(); |
3393 | 3393 |
3394 root->setAnchorPoint(gfx::PointF(0, 0)); | 3394 root->setAnchorPoint(gfx::PointF(0, 0)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3486 // | +- L11 (corner, occluded by L12) | 3486 // | +- L11 (corner, occluded by L12) |
3487 // | +- L12 (opposite corner) | 3487 // | +- L12 (opposite corner) |
3488 // | | 3488 // | |
3489 // +-- S2 +- L20 (owning, drawing) | 3489 // +-- S2 +- L20 (owning, drawing) |
3490 // | 3490 // |
3491 | 3491 |
3492 LayerImpl* rootPtr; | 3492 LayerImpl* rootPtr; |
3493 LayerImpl* layerS1Ptr; | 3493 LayerImpl* layerS1Ptr; |
3494 LayerImpl* layerS2Ptr; | 3494 LayerImpl* layerS2Ptr; |
3495 | 3495 |
3496 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3496 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3497 | 3497 |
3498 gfx::Size rootSize(1000, 1000); | 3498 gfx::Size rootSize(1000, 1000); |
3499 | 3499 |
3500 myHostImpl->initializeRenderer(context.Pass()); | 3500 myHostImpl->initializeRenderer(context.Pass()); |
3501 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3501 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3502 | 3502 |
3503 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3503 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3504 rootPtr = root.get(); | 3504 rootPtr = root.get(); |
3505 | 3505 |
3506 root->setAnchorPoint(gfx::PointF(0, 0)); | 3506 root->setAnchorPoint(gfx::PointF(0, 0)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3567 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); | 3567 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
3568 | 3568 |
3569 // Layers are structured as follows: | 3569 // Layers are structured as follows: |
3570 // | 3570 // |
3571 // R +-- S1 +- L10 (rotated, drawing) | 3571 // R +-- S1 +- L10 (rotated, drawing) |
3572 // +- L11 (occupies half surface) | 3572 // +- L11 (occupies half surface) |
3573 | 3573 |
3574 LayerImpl* rootPtr; | 3574 LayerImpl* rootPtr; |
3575 LayerImpl* layerS1Ptr; | 3575 LayerImpl* layerS1Ptr; |
3576 | 3576 |
3577 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3577 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3578 | 3578 |
3579 gfx::Size rootSize(1000, 1000); | 3579 gfx::Size rootSize(1000, 1000); |
3580 | 3580 |
3581 myHostImpl->initializeRenderer(context.Pass()); | 3581 myHostImpl->initializeRenderer(context.Pass()); |
3582 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3582 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3583 | 3583 |
3584 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3584 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3585 rootPtr = root.get(); | 3585 rootPtr = root.get(); |
3586 | 3586 |
3587 root->setAnchorPoint(gfx::PointF(0, 0)); | 3587 root->setAnchorPoint(gfx::PointF(0, 0)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3651 // | 3651 // |
3652 // Occlusion: | 3652 // Occlusion: |
3653 // L12 occludes L11 (internal) | 3653 // L12 occludes L11 (internal) |
3654 // L20 occludes L10 (external) | 3654 // L20 occludes L10 (external) |
3655 // L21 occludes L20 (internal) | 3655 // L21 occludes L20 (internal) |
3656 | 3656 |
3657 LayerImpl* rootPtr; | 3657 LayerImpl* rootPtr; |
3658 LayerImpl* layerS1Ptr; | 3658 LayerImpl* layerS1Ptr; |
3659 LayerImpl* layerS2Ptr; | 3659 LayerImpl* layerS2Ptr; |
3660 | 3660 |
3661 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3661 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3662 | 3662 |
3663 gfx::Size rootSize(1000, 1000); | 3663 gfx::Size rootSize(1000, 1000); |
3664 | 3664 |
3665 myHostImpl->initializeRenderer(context.Pass()); | 3665 myHostImpl->initializeRenderer(context.Pass()); |
3666 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3666 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
3667 | 3667 |
3668 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3668 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3669 rootPtr = root.get(); | 3669 rootPtr = root.get(); |
3670 | 3670 |
3671 root->setAnchorPoint(gfx::PointF(0, 0)); | 3671 root->setAnchorPoint(gfx::PointF(0, 0)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3770 Layers 1, 2 have render surfaces | 3770 Layers 1, 2 have render surfaces |
3771 */ | 3771 */ |
3772 scoped_ptr<LayerImpl> root = LayerImpl::create(1); | 3772 scoped_ptr<LayerImpl> root = LayerImpl::create(1); |
3773 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2); | 3773 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(2); |
3774 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); | 3774 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(3); |
3775 | 3775 |
3776 gfx::Rect rootRect(0, 0, 100, 100); | 3776 gfx::Rect rootRect(0, 0, 100, 100); |
3777 gfx::Rect childRect(10, 10, 50, 50); | 3777 gfx::Rect childRect(10, 10, 50, 50); |
3778 gfx::Rect grandChildRect(5, 5, 150, 150); | 3778 gfx::Rect grandChildRect(5, 5, 150, 150); |
3779 | 3779 |
3780 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3780 scoped_ptr<GraphicsContext> context = FakeOutputSurface::Create(scoped_ptr<W
ebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<GraphicsContext>(); |
3781 myHostImpl->initializeRenderer(context.Pass()); | 3781 myHostImpl->initializeRenderer(context.Pass()); |
3782 | 3782 |
3783 root->setAnchorPoint(gfx::PointF(0, 0)); | 3783 root->setAnchorPoint(gfx::PointF(0, 0)); |
3784 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); | 3784 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); |
3785 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); | 3785 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); |
3786 root->setContentBounds(root->bounds()); | 3786 root->setContentBounds(root->bounds()); |
3787 root->setDrawsContent(true); | 3787 root->setDrawsContent(true); |
3788 root->setMasksToBounds(true); | 3788 root->setMasksToBounds(true); |
3789 | 3789 |
3790 child->setAnchorPoint(gfx::PointF(0, 0)); | 3790 child->setAnchorPoint(gfx::PointF(0, 0)); |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4512 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) | 4512 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa
ta& testData) |
4513 { | 4513 { |
4514 char actualResult[1024]; | 4514 char actualResult[1024]; |
4515 dumpRenderPassTestData(testData, actualResult); | 4515 dumpRenderPassTestData(testData, actualResult); |
4516 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; | 4516 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; |
4517 } | 4517 } |
4518 | 4518 |
4519 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) | 4519 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) |
4520 { | 4520 { |
4521 scoped_ptr<GraphicsContext> context(createContext()); | 4521 scoped_ptr<GraphicsContext> context(createContext()); |
4522 ASSERT_TRUE(context->context3D()); | 4522 ASSERT_TRUE(context->Context3D()); |
4523 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); | 4523 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); |
4524 | 4524 |
4525 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), &m_proxy)); | 4525 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), &m_proxy)); |
4526 | 4526 |
4527 int testCaseIndex = 0; | 4527 int testCaseIndex = 0; |
4528 while (removeRenderPassesCases[testCaseIndex].name) { | 4528 while (removeRenderPassesCases[testCaseIndex].name) { |
4529 RenderPassRemovalTestData testData; | 4529 RenderPassRemovalTestData testData; |
4530 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); | 4530 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); |
4531 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); | 4531 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); |
4532 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4532 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4890 { | 4890 { |
4891 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4891 pinchZoomPanViewportAndScrollBoundaryTest(2); |
4892 } | 4892 } |
4893 | 4893 |
4894 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4894 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4895 LayerTreeHostImplTest, | 4895 LayerTreeHostImplTest, |
4896 ::testing::Values(false, true)); | 4896 ::testing::Values(false, true)); |
4897 | 4897 |
4898 } // namespace | 4898 } // namespace |
4899 } // namespace cc | 4899 } // namespace cc |
OLD | NEW |