Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11348371: cc: Move WebCompositorOutputSurface and related classes into cc/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding6 Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); 204 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor);
205 void pinchZoomPanViewportTest(const float deviceScaleFactor); 205 void pinchZoomPanViewportTest(const float deviceScaleFactor);
206 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); 206 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor);
207 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor ); 207 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor );
208 208
209 protected: 209 protected:
210 scoped_ptr<OutputSurface> createOutputSurface() 210 scoped_ptr<OutputSurface> createOutputSurface()
211 { 211 {
212 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>(); 212 return FakeOutputSurface::Create3d(scoped_ptr<WebKit::WebGraphicsContext 3D>(new FakeWebGraphicsContext3D)).PassAs<OutputSurface>();
213 } 213 }
214 214
215 FakeProxy m_proxy; 215 FakeProxy m_proxy;
216 DebugScopedSetImplThread m_alwaysImplThread; 216 DebugScopedSetImplThread m_alwaysImplThread;
217 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; 217 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
218 218
219 scoped_ptr<LayerTreeHostImpl> m_hostImpl; 219 scoped_ptr<LayerTreeHostImpl> m_hostImpl;
220 bool m_onCanDrawStateChangedCalled; 220 bool m_onCanDrawStateChangedCalled;
221 bool m_didRequestCommit; 221 bool m_didRequestCommit;
222 bool m_didRequestRedraw; 222 bool m_didRequestRedraw;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // We should not crash when trying to scroll an empty layer tree. 371 // We should not crash when trying to scroll an empty layer tree.
372 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 372 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
373 } 373 }
374 374
375 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) 375 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer)
376 { 376 {
377 LayerTreeSettings settings; 377 LayerTreeSettings settings;
378 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); 378 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
379 379
380 // Initialization will fail here. 380 // Initialization will fail here.
381 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails) ).PassAs<OutputSurface>()); 381 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou tputSurface>());
382 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 382 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
383 383
384 setupScrollAndContentsLayers(gfx::Size(100, 100)); 384 setupScrollAndContentsLayers(gfx::Size(100, 100));
385 385
386 // We should not crash when trying to scroll after the renderer initializati on fails. 386 // We should not crash when trying to scroll after the renderer initializati on fails.
387 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 387 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
388 } 388 }
389 389
390 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling) 390 TEST_P(LayerTreeHostImplTest, replaceTreeWhileScrolling)
391 { 391 {
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id) { r eturn scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(hostImpl, id)); } 1992 static scoped_ptr<LayerImpl> create(LayerTreeHostImpl* hostImpl, int id) { r eturn scoped_ptr<LayerImpl>(new FakeDrawableLayerImpl(hostImpl, id)); }
1993 protected: 1993 protected:
1994 FakeDrawableLayerImpl(LayerTreeHostImpl* hostImpl, int id) : LayerImpl(hostI mpl, id) { } 1994 FakeDrawableLayerImpl(LayerTreeHostImpl* hostImpl, int id) : LayerImpl(hostI mpl, id) { }
1995 }; 1995 };
1996 1996
1997 // Only reshape when we know we are going to draw. Otherwise, the reshape 1997 // Only reshape when we know we are going to draw. Otherwise, the reshape
1998 // can leave the window at the wrong size if we never draw and the proper 1998 // can leave the window at the wrong size if we never draw and the proper
1999 // viewport size is never set. 1999 // viewport size is never set.
2000 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw) 2000 TEST_P(LayerTreeHostImplTest, reshapeNotCalledUntilDraw)
2001 { 2001 {
2002 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs <OutputSurface>(); 2002 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new ReshapeTrackerContext)).PassAs<OutputSurf ace>();
2003 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( outputSurface->context3D()); 2003 ReshapeTrackerContext* reshapeTracker = static_cast<ReshapeTrackerContext*>( outputSurface->Context3D());
2004 m_hostImpl->initializeRenderer(outputSurface.Pass()); 2004 m_hostImpl->initializeRenderer(outputSurface.Pass());
2005 2005
2006 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(), 1); 2006 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(), 1);
2007 root->setAnchorPoint(gfx::PointF(0, 0)); 2007 root->setAnchorPoint(gfx::PointF(0, 0));
2008 root->setBounds(gfx::Size(10, 10)); 2008 root->setBounds(gfx::Size(10, 10));
2009 root->setDrawsContent(true); 2009 root->setDrawsContent(true);
2010 m_hostImpl->setRootLayer(root.Pass()); 2010 m_hostImpl->setRootLayer(root.Pass());
2011 EXPECT_FALSE(reshapeTracker->reshapeCalled()); 2011 EXPECT_FALSE(reshapeTracker->reshapeCalled());
2012 2012
2013 LayerTreeHostImpl::FrameData frame; 2013 LayerTreeHostImpl::FrameData frame;
(...skipping 21 matching lines...) Expand all
2035 gfx::Rect partialSwapRect() const { return m_partialSwapRect; } 2035 gfx::Rect partialSwapRect() const { return m_partialSwapRect; }
2036 2036
2037 private: 2037 private:
2038 gfx::Rect m_partialSwapRect; 2038 gfx::Rect m_partialSwapRect;
2039 }; 2039 };
2040 2040
2041 // Make sure damage tracking propagates all the way to the graphics context, 2041 // Make sure damage tracking propagates all the way to the graphics context,
2042 // where it should request to swap only the subBuffer that is damaged. 2042 // where it should request to swap only the subBuffer that is damaged.
2043 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) 2043 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect)
2044 { 2044 {
2045 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).Pa ssAs<OutputSurface>(); 2045 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).PassAs<Output Surface>();
2046 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(outputSurface->context3D()); 2046 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack erContext*>(outputSurface->Context3D());
2047 2047
2048 // This test creates its own LayerTreeHostImpl, so 2048 // This test creates its own LayerTreeHostImpl, so
2049 // that we can force partial swap enabled. 2049 // that we can force partial swap enabled.
2050 LayerTreeSettings settings; 2050 LayerTreeSettings settings;
2051 settings.partialSwapEnabled = true; 2051 settings.partialSwapEnabled = true;
2052 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create( settings, this, &m_proxy); 2052 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create( settings, this, &m_proxy);
2053 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); 2053 layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
2054 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500)) ; 2054 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500)) ;
2055 2055
2056 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(), 1); 2056 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(m_hostImpl.get(), 1);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST)) 2250 EXPECT_CALL(*m_context, enable(GL_SCISSOR_TEST))
2251 .Times(0); 2251 .Times(0);
2252 2252
2253 EXPECT_CALL(*m_context, scissor(_, _, _, _)) 2253 EXPECT_CALL(*m_context, scissor(_, _, _, _))
2254 .Times(0); 2254 .Times(0);
2255 } 2255 }
2256 }; 2256 };
2257 2257
2258 TEST_P(LayerTreeHostImplTest, noPartialSwap) 2258 TEST_P(LayerTreeHostImplTest, noPartialSwap)
2259 { 2259 {
2260 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>(); 2260 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
2261 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3 D()); 2261 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3 D());
2262 MockContextHarness harness(mockContext); 2262 MockContextHarness harness(mockContext);
2263 2263
2264 // Run test case 2264 // Run test case
2265 createLayerTreeHost(false, outputSurface.Pass()); 2265 createLayerTreeHost(false, outputSurface.Pass());
2266 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl.get(), 1)); 2266 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl.get(), 1));
2267 2267
2268 // without partial swap, and no clipping, no scissor is set. 2268 // without partial swap, and no clipping, no scissor is set.
2269 harness.mustDrawSolidQuad(); 2269 harness.mustDrawSolidQuad();
2270 harness.mustSetNoScissor(); 2270 harness.mustSetNoScissor();
2271 { 2271 {
(...skipping 12 matching lines...) Expand all
2284 LayerTreeHostImpl::FrameData frame; 2284 LayerTreeHostImpl::FrameData frame;
2285 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2285 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2286 m_hostImpl->drawLayers(frame); 2286 m_hostImpl->drawLayers(frame);
2287 m_hostImpl->didDrawAllLayers(frame); 2287 m_hostImpl->didDrawAllLayers(frame);
2288 } 2288 }
2289 Mock::VerifyAndClearExpectations(&mockContext); 2289 Mock::VerifyAndClearExpectations(&mockContext);
2290 } 2290 }
2291 2291
2292 TEST_P(LayerTreeHostImplTest, partialSwap) 2292 TEST_P(LayerTreeHostImplTest, partialSwap)
2293 { 2293 {
2294 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSur face>(); 2294 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new MockContext)).PassAs<OutputSurface>();
2295 MockContext* mockContext = static_cast<MockContext*>(outputSurface->context3 D()); 2295 MockContext* mockContext = static_cast<MockContext*>(outputSurface->Context3 D());
2296 MockContextHarness harness(mockContext); 2296 MockContextHarness harness(mockContext);
2297 2297
2298 createLayerTreeHost(true, outputSurface.Pass()); 2298 createLayerTreeHost(true, outputSurface.Pass());
2299 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl.get(), 1)); 2299 setupRootLayerImpl(FakeLayerWithQuads::create(m_hostImpl.get(), 1));
2300 2300
2301 // The first frame is not a partially-swapped one. 2301 // The first frame is not a partially-swapped one.
2302 harness.mustSetScissor(0, 0, 10, 10); 2302 harness.mustSetScissor(0, 0, 10, 10);
2303 harness.mustDrawSolidQuad(); 2303 harness.mustDrawSolidQuad();
2304 { 2304 {
2305 LayerTreeHostImpl::FrameData frame; 2305 LayerTreeHostImpl::FrameData frame;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 // Unlimited texture size. 2341 // Unlimited texture size.
2342 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) 2342 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value)
2343 { 2343 {
2344 if (pname == GL_MAX_TEXTURE_SIZE) 2344 if (pname == GL_MAX_TEXTURE_SIZE)
2345 *value = 8192; 2345 *value = 8192;
2346 } 2346 }
2347 }; 2347 };
2348 2348
2349 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay erTreeHostImplClient* client, Proxy* proxy) 2349 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay erTreeHostImplClient* client, Proxy* proxy)
2350 { 2350 {
2351 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 2351 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
2352 2352
2353 LayerTreeSettings settings; 2353 LayerTreeSettings settings;
2354 settings.partialSwapEnabled = partialSwap; 2354 settings.partialSwapEnabled = partialSwap;
2355 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, client, proxy); 2355 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, client, proxy);
2356 myHostImpl->initializeRenderer(outputSurface.Pass()); 2356 myHostImpl->initializeRenderer(outputSurface.Pass());
2357 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); 2357 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
2358 2358
2359 /* 2359 /*
2360 Layers are created as follows: 2360 Layers are created as follows:
2361 2361
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled()); 2497 EXPECT_TRUE(layer1->didLoseOutputSurfaceCalled());
2498 EXPECT_TRUE(layer2->didLoseOutputSurfaceCalled()); 2498 EXPECT_TRUE(layer2->didLoseOutputSurfaceCalled());
2499 } 2499 }
2500 2500
2501 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) 2501 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost)
2502 { 2502 {
2503 LayerTreeSettings settings; 2503 LayerTreeSettings settings;
2504 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); 2504 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
2505 2505
2506 // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects. 2506 // The context initialization will fail, but we should still be able to call finishAllRendering() without any ill effects.
2507 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails) ).PassAs<OutputSurface>()); 2507 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)).PassAs<Ou tputSurface>());
2508 m_hostImpl->finishAllRendering(); 2508 m_hostImpl->finishAllRendering();
2509 } 2509 }
2510 2510
2511 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic sContext3D { 2511 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic sContext3D {
2512 public: 2512 public:
2513 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed Count) : m_succeedCount(succeedCount) { } 2513 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed Count) : m_succeedCount(succeedCount) { }
2514 virtual bool makeContextCurrent() { 2514 virtual bool makeContextCurrent() {
2515 if (!m_succeedCount) 2515 if (!m_succeedCount)
2516 return false; 2516 return false;
2517 --m_succeedCount; 2517 --m_succeedCount;
(...skipping 17 matching lines...) Expand all
2535 2535
2536 // We will make the context get lost after a numer of makeContextCurrent 2536 // We will make the context get lost after a numer of makeContextCurrent
2537 // calls. The exact number of calls to make it succeed is dependent on the 2537 // calls. The exact number of calls to make it succeed is dependent on the
2538 // implementation and doesn't really matter (i.e. can be changed to make the 2538 // implementation and doesn't really matter (i.e. can be changed to make the
2539 // tests pass after some refactoring). 2539 // tests pass after some refactoring).
2540 const unsigned kMakeCurrentSuccessesNeededForSuccessfulInitialization = 3; 2540 const unsigned kMakeCurrentSuccessesNeededForSuccessfulInitialization = 3;
2541 2541
2542 for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitializat ion; ++i) { 2542 for (unsigned i = 0; i < kMakeCurrentSuccessesNeededForSuccessfulInitializat ion; ++i) {
2543 // The context will get lost during initialization, we shouldn't crash. We 2543 // The context will get lost during initialization, we shouldn't crash. We
2544 // should also be in a consistent state. 2544 // should also be in a consistent state.
2545 EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurfa ce::create(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3D MakeCurrentFailsEventually(i))).PassAs<OutputSurface>())); 2545 EXPECT_FALSE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d( scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrent FailsEventually(i))).PassAs<OutputSurface>()));
2546 EXPECT_EQ(0, m_hostImpl->outputSurface()); 2546 EXPECT_EQ(0, m_hostImpl->outputSurface());
2547 EXPECT_EQ(0, m_hostImpl->renderer()); 2547 EXPECT_EQ(0, m_hostImpl->renderer());
2548 EXPECT_EQ(0, m_hostImpl->resourceProvider()); 2548 EXPECT_EQ(0, m_hostImpl->resourceProvider());
2549 EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface())); 2549 EXPECT_TRUE(m_hostImpl->initializeRenderer(createOutputSurface()));
2550 } 2550 }
2551 2551
2552 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::c reate(scoped_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeC urrentFailsEventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))). PassAs<OutputSurface>())); 2552 EXPECT_TRUE(m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scope d_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails Eventually(kMakeCurrentSuccessesNeededForSuccessfulInitialization))).PassAs<Outp utSurface>()));
2553 EXPECT_TRUE(m_hostImpl->outputSurface()); 2553 EXPECT_TRUE(m_hostImpl->outputSurface());
2554 EXPECT_TRUE(m_hostImpl->renderer()); 2554 EXPECT_TRUE(m_hostImpl->renderer());
2555 EXPECT_TRUE(m_hostImpl->resourceProvider()); 2555 EXPECT_TRUE(m_hostImpl->resourceProvider());
2556 } 2556 }
2557 2557
2558 // Fake WebGraphicsContext3D that will cause a failure if trying to use a 2558 // Fake WebGraphicsContext3D that will cause a failure if trying to use a
2559 // resource that wasn't created by it (resources created by 2559 // resource that wasn't created by it (resources created by
2560 // FakeWebGraphicsContext3D have an id of 1). 2560 // FakeWebGraphicsContext3D have an id of 1).
2561 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D { 2561 class StrictWebGraphicsContext3D : public FakeWebGraphicsContext3D {
2562 public: 2562 public:
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 delegatedRendererLayer->setBounds(gfx::Size(10, 10)); 2889 delegatedRendererLayer->setBounds(gfx::Size(10, 10));
2890 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10)); 2890 delegatedRendererLayer->setContentBounds(gfx::Size(10, 10));
2891 delegatedRendererLayer->setDrawsContent(true); 2891 delegatedRendererLayer->setDrawsContent(true);
2892 ScopedPtrVector<RenderPass> passList; 2892 ScopedPtrVector<RenderPass> passList;
2893 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) ); 2893 passList.append(createRenderPassWithResource(m_hostImpl->resourceProvider()) );
2894 delegatedRendererLayer->setRenderPasses(passList); 2894 delegatedRendererLayer->setRenderPasses(passList);
2895 EXPECT_TRUE(passList.isEmpty()); 2895 EXPECT_TRUE(passList.isEmpty());
2896 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>()); 2896 rootLayer->addChild(delegatedRendererLayer.PassAs<LayerImpl>());
2897 2897
2898 // Use a context that supports IOSurfaces 2898 // Use a context that supports IOSurfaces
2899 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).P assAs<OutputSurface>()); 2899 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new FakeWebGraphicsContext3DWithIOSurface)).PassAs<Outpu tSurface>());
2900 2900
2901 FakeVideoFrame hwVideoFrame( 2901 FakeVideoFrame hwVideoFrame(
2902 VideoFrame::WrapNativeTexture( 2902 VideoFrame::WrapNativeTexture(
2903 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture() , 2903 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture() ,
2904 GL_TEXTURE_2D, 2904 GL_TEXTURE_2D,
2905 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD elta(), 2905 gfx::Size(4, 4), gfx::Rect(0, 0, 4, 4), gfx::Size(4, 4), base::TimeD elta(),
2906 VideoFrame::ReadPixelsCB(), base::Closure())); 2906 VideoFrame::ReadPixelsCB(), base::Closure()));
2907 hwProvider.setFrame(&hwVideoFrame); 2907 hwProvider.setFrame(&hwVideoFrame);
2908 2908
2909 FakeVideoFrame videoFrameScaled( 2909 FakeVideoFrame videoFrameScaled(
2910 VideoFrame::WrapNativeTexture( 2910 VideoFrame::WrapNativeTexture(
2911 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture() , 2911 m_hostImpl->resourceProvider()->graphicsContext3D()->createTexture() ,
2912 GL_TEXTURE_2D, 2912 GL_TEXTURE_2D,
2913 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD elta(), 2913 gfx::Size(4, 4), gfx::Rect(0, 0, 3, 2), gfx::Size(4, 4), base::TimeD elta(),
2914 VideoFrame::ReadPixelsCB(), base::Closure())); 2914 VideoFrame::ReadPixelsCB(), base::Closure()));
2915 providerScaled.setFrame(&videoFrameScaled); 2915 providerScaled.setFrame(&videoFrameScaled);
2916 2916
2917 m_hostImpl->setRootLayer(rootLayer.Pass()); 2917 m_hostImpl->setRootLayer(rootLayer.Pass());
2918 2918
2919 LayerTreeHostImpl::FrameData frame; 2919 LayerTreeHostImpl::FrameData frame;
2920 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 2920 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
2921 m_hostImpl->drawLayers(frame); 2921 m_hostImpl->drawLayers(frame);
2922 m_hostImpl->didDrawAllLayers(frame); 2922 m_hostImpl->didDrawAllLayers(frame);
2923 m_hostImpl->swapBuffers(); 2923 m_hostImpl->swapBuffers();
2924 2924
2925 unsigned numResources = m_hostImpl->resourceProvider()->numResources(); 2925 unsigned numResources = m_hostImpl->resourceProvider()->numResources();
2926 2926
2927 // Lose the WebGraphicsContext3D, replacing it with a StrictWebGraphicsConte xt3DWithIOSurface, 2927 // Lose the WebGraphicsContext3D, replacing it with a StrictWebGraphicsConte xt3DWithIOSurface,
2928 // that will warn if any resource from the previous context gets used. 2928 // that will warn if any resource from the previous context gets used.
2929 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped _ptr<WebKit::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)) .PassAs<OutputSurface>()); 2929 m_hostImpl->initializeRenderer(FakeOutputSurface::Create3d(scoped_ptr<WebKit ::WebGraphicsContext3D>(new StrictWebGraphicsContext3DWithIOSurface)).PassAs<Out putSurface>());
2930 2930
2931 // Create dummy resources so that looking up an old resource will get an 2931 // Create dummy resources so that looking up an old resource will get an
2932 // invalid texture id mapping. 2932 // invalid texture id mapping.
2933 for (unsigned i = 0; i < numResources; ++i) 2933 for (unsigned i = 0; i < numResources; ++i)
2934 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict WebGraphicsContext3D::kExternalTextureId); 2934 m_hostImpl->resourceProvider()->createResourceFromExternalTexture(Strict WebGraphicsContext3D::kExternalTextureId);
2935 2935
2936 // The WebVideoFrameProvider is expected to recreate its textures after a 2936 // The WebVideoFrameProvider is expected to recreate its textures after a
2937 // lost output surface (or not serve a frame). 2937 // lost output surface (or not serve a frame).
2938 hwProvider.setFrame(0); 2938 hwProvider.setFrame(0);
2939 providerScaled.setFrame(0); 2939 providerScaled.setFrame(0);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 3036
3037 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m _hostImpl.get(), 5); 3037 scoped_ptr<IOSurfaceLayerImpl> ioSurfaceLayer = IOSurfaceLayerImpl::create(m _hostImpl.get(), 5);
3038 ioSurfaceLayer->setBounds(gfx::Size(10, 10)); 3038 ioSurfaceLayer->setBounds(gfx::Size(10, 10));
3039 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0)); 3039 ioSurfaceLayer->setAnchorPoint(gfx::PointF(0, 0));
3040 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10)); 3040 ioSurfaceLayer->setContentBounds(gfx::Size(10, 10));
3041 ioSurfaceLayer->setDrawsContent(true); 3041 ioSurfaceLayer->setDrawsContent(true);
3042 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10)); 3042 ioSurfaceLayer->setIOSurfaceProperties(1, gfx::Size(10, 10));
3043 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>()); 3043 rootLayer->addChild(ioSurfaceLayer.PassAs<LayerImpl>());
3044 3044
3045 // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon text3D (which the LayerTreeHostImpl takes ownership of). 3045 // Lose the WebGraphicsContext3D, replacing it with a TrackingWebGraphicsCon text3D (which the LayerTreeHostImpl takes ownership of).
3046 scoped_ptr<OutputSurface> outputSurface(FakeWebCompositorOutputSurface::crea te(scoped_ptr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D))); 3046 scoped_ptr<OutputSurface> outputSurface(FakeOutputSurface::Create3d(scoped_p tr<WebKit::WebGraphicsContext3D>(new TrackingWebGraphicsContext3D)));
3047 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra ckingWebGraphicsContext3D*>(outputSurface->context3D()); 3047 TrackingWebGraphicsContext3D* trackingWebGraphicsContext3D = static_cast<Tra ckingWebGraphicsContext3D*>(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(trackingWebGraphicsContext3D->numTextures(), 0u); 3058 EXPECT_GT(trackingWebGraphicsContext3D->numTextures(), 0u);
3059 3059
3060 // Kill the layer tree. 3060 // Kill the layer tree.
3061 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl.get(), 100)); 3061 m_hostImpl->setRootLayer(LayerImpl::create(m_hostImpl.get(), 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, trackingWebGraphicsContext3D->numTextures()); 3063 EXPECT_EQ(0u, trackingWebGraphicsContext3D->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<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenConte xt)).PassAs<OutputSurface>(); 3074 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new MockDrawQuadsToFillScreenContext)).PassAs <OutputSurface>();
3075 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(outputSurface->context3D()); 3075 MockDrawQuadsToFillScreenContext* mockContext = static_cast<MockDrawQuadsToF illScreenContext*>(outputSurface->Context3D());
3076 3076
3077 // Run test case 3077 // Run test case
3078 createLayerTreeHost(false, outputSurface.Pass()); 3078 createLayerTreeHost(false, outputSurface.Pass());
3079 setupRootLayerImpl(LayerImpl::create(m_hostImpl.get(), 1)); 3079 setupRootLayerImpl(LayerImpl::create(m_hostImpl.get(), 1));
3080 m_hostImpl->setBackgroundColor(SK_ColorWHITE); 3080 m_hostImpl->setBackgroundColor(SK_ColorWHITE);
3081 3081
3082 // Verify one quad is drawn when transparent background set is not set. 3082 // Verify one quad is drawn when transparent background set is not set.
3083 m_hostImpl->setHasTransparentBackground(false); 3083 m_hostImpl->setHasTransparentBackground(false);
3084 EXPECT_CALL(*mockContext, useProgram(_)) 3084 EXPECT_CALL(*mockContext, useProgram(_))
3085 .Times(1); 3085 .Times(1);
(...skipping 23 matching lines...) Expand all
3109 layerPtr->setContentBounds(layerRect.size()); 3109 layerPtr->setContentBounds(layerRect.size());
3110 layerPtr->setDrawsContent(true); // only children draw content 3110 layerPtr->setDrawsContent(true); // only children draw content
3111 layerPtr->setContentsOpaque(true); 3111 layerPtr->setContentsOpaque(true);
3112 parent->addChild(layer.Pass()); 3112 parent->addChild(layer.Pass());
3113 if (result) 3113 if (result)
3114 *result = layerPtr; 3114 *result = layerPtr;
3115 } 3115 }
3116 3116
3117 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt r, LayerImpl*& childPtr, const gfx::Size& rootSize) 3117 static void setupLayersForTextureCaching(LayerTreeHostImpl* layerTreeHostImpl, L ayerImpl*& rootPtr, LayerImpl*& intermediateLayerPtr, LayerImpl*& surfaceLayerPt r, LayerImpl*& childPtr, const gfx::Size& rootSize)
3118 { 3118 {
3119 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3119 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3120 3120
3121 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); 3121 layerTreeHostImpl->initializeRenderer(outputSurface.Pass());
3122 layerTreeHostImpl->setViewportSize(rootSize, rootSize); 3122 layerTreeHostImpl->setViewportSize(rootSize, rootSize);
3123 3123
3124 scoped_ptr<LayerImpl> root = LayerImpl::create(layerTreeHostImpl, 1); 3124 scoped_ptr<LayerImpl> root = LayerImpl::create(layerTreeHostImpl, 1);
3125 rootPtr = root.get(); 3125 rootPtr = root.get();
3126 3126
3127 root->setAnchorPoint(gfx::PointF(0, 0)); 3127 root->setAnchorPoint(gfx::PointF(0, 0));
3128 root->setPosition(gfx::PointF(0, 0)); 3128 root->setPosition(gfx::PointF(0, 0));
3129 root->setBounds(rootSize); 3129 root->setBounds(rootSize);
(...skipping 23 matching lines...) Expand all
3153 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) 3153 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
3154 { 3154 {
3155 LayerTreeSettings settings; 3155 LayerTreeSettings settings;
3156 settings.minimumOcclusionTrackingSize = gfx::Size(); 3156 settings.minimumOcclusionTrackingSize = gfx::Size();
3157 settings.partialSwapEnabled = true; 3157 settings.partialSwapEnabled = true;
3158 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this, &m_proxy); 3158 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this, &m_proxy);
3159 3159
3160 LayerImpl* rootPtr; 3160 LayerImpl* rootPtr;
3161 LayerImpl* surfaceLayerPtr; 3161 LayerImpl* surfaceLayerPtr;
3162 3162
3163 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3163 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3164 3164
3165 gfx::Size rootSize(100, 100); 3165 gfx::Size rootSize(100, 100);
3166 3166
3167 myHostImpl->initializeRenderer(outputSurface.Pass()); 3167 myHostImpl->initializeRenderer(outputSurface.Pass());
3168 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); 3168 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3169 3169
3170 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); 3170 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1);
3171 rootPtr = root.get(); 3171 rootPtr = root.get();
3172 3172
3173 root->setAnchorPoint(gfx::PointF(0, 0)); 3173 root->setAnchorPoint(gfx::PointF(0, 0));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3264 // 3264 //
3265 // Occlusion: 3265 // Occlusion:
3266 // L12 occludes L11 (internal) 3266 // L12 occludes L11 (internal)
3267 // L20 occludes L10 (external) 3267 // L20 occludes L10 (external)
3268 // L21 occludes L20 (internal) 3268 // L21 occludes L20 (internal)
3269 3269
3270 LayerImpl* rootPtr; 3270 LayerImpl* rootPtr;
3271 LayerImpl* layerS1Ptr; 3271 LayerImpl* layerS1Ptr;
3272 LayerImpl* layerS2Ptr; 3272 LayerImpl* layerS2Ptr;
3273 3273
3274 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3274 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3275 3275
3276 gfx::Size rootSize(1000, 1000); 3276 gfx::Size rootSize(1000, 1000);
3277 3277
3278 myHostImpl->initializeRenderer(outputSurface.Pass()); 3278 myHostImpl->initializeRenderer(outputSurface.Pass());
3279 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); 3279 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3280 3280
3281 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); 3281 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1);
3282 rootPtr = root.get(); 3282 rootPtr = root.get();
3283 3283
3284 root->setAnchorPoint(gfx::PointF(0, 0)); 3284 root->setAnchorPoint(gfx::PointF(0, 0));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3375 // | +- L13 (corner, unoccluded) 3375 // | +- L13 (corner, unoccluded)
3376 // | +- L14 (corner, entirely occluded) 3376 // | +- L14 (corner, entirely occluded)
3377 // | 3377 // |
3378 // +-- S2 +- L20 (owning, drawing) 3378 // +-- S2 +- L20 (owning, drawing)
3379 // 3379 //
3380 3380
3381 LayerImpl* rootPtr; 3381 LayerImpl* rootPtr;
3382 LayerImpl* layerS1Ptr; 3382 LayerImpl* layerS1Ptr;
3383 LayerImpl* layerS2Ptr; 3383 LayerImpl* layerS2Ptr;
3384 3384
3385 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3385 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3386 3386
3387 gfx::Size rootSize(1000, 1000); 3387 gfx::Size rootSize(1000, 1000);
3388 3388
3389 myHostImpl->initializeRenderer(outputSurface.Pass()); 3389 myHostImpl->initializeRenderer(outputSurface.Pass());
3390 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); 3390 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3391 3391
3392 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); 3392 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1);
3393 rootPtr = root.get(); 3393 rootPtr = root.get();
3394 3394
3395 root->setAnchorPoint(gfx::PointF(0, 0)); 3395 root->setAnchorPoint(gfx::PointF(0, 0));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3487 // | +- L11 (corner, occluded by L12) 3487 // | +- L11 (corner, occluded by L12)
3488 // | +- L12 (opposite corner) 3488 // | +- L12 (opposite corner)
3489 // | 3489 // |
3490 // +-- S2 +- L20 (owning, drawing) 3490 // +-- S2 +- L20 (owning, drawing)
3491 // 3491 //
3492 3492
3493 LayerImpl* rootPtr; 3493 LayerImpl* rootPtr;
3494 LayerImpl* layerS1Ptr; 3494 LayerImpl* layerS1Ptr;
3495 LayerImpl* layerS2Ptr; 3495 LayerImpl* layerS2Ptr;
3496 3496
3497 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3497 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3498 3498
3499 gfx::Size rootSize(1000, 1000); 3499 gfx::Size rootSize(1000, 1000);
3500 3500
3501 myHostImpl->initializeRenderer(outputSurface.Pass()); 3501 myHostImpl->initializeRenderer(outputSurface.Pass());
3502 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); 3502 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3503 3503
3504 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); 3504 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1);
3505 rootPtr = root.get(); 3505 rootPtr = root.get();
3506 3506
3507 root->setAnchorPoint(gfx::PointF(0, 0)); 3507 root->setAnchorPoint(gfx::PointF(0, 0));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3568 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this, &m_proxy); 3568 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting s, this, &m_proxy);
3569 3569
3570 // Layers are structured as follows: 3570 // Layers are structured as follows:
3571 // 3571 //
3572 // R +-- S1 +- L10 (rotated, drawing) 3572 // R +-- S1 +- L10 (rotated, drawing)
3573 // +- L11 (occupies half surface) 3573 // +- L11 (occupies half surface)
3574 3574
3575 LayerImpl* rootPtr; 3575 LayerImpl* rootPtr;
3576 LayerImpl* layerS1Ptr; 3576 LayerImpl* layerS1Ptr;
3577 3577
3578 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3578 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3579 3579
3580 gfx::Size rootSize(1000, 1000); 3580 gfx::Size rootSize(1000, 1000);
3581 3581
3582 myHostImpl->initializeRenderer(outputSurface.Pass()); 3582 myHostImpl->initializeRenderer(outputSurface.Pass());
3583 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); 3583 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3584 3584
3585 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); 3585 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1);
3586 rootPtr = root.get(); 3586 rootPtr = root.get();
3587 3587
3588 root->setAnchorPoint(gfx::PointF(0, 0)); 3588 root->setAnchorPoint(gfx::PointF(0, 0));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 // 3652 //
3653 // Occlusion: 3653 // Occlusion:
3654 // L12 occludes L11 (internal) 3654 // L12 occludes L11 (internal)
3655 // L20 occludes L10 (external) 3655 // L20 occludes L10 (external)
3656 // L21 occludes L20 (internal) 3656 // L21 occludes L20 (internal)
3657 3657
3658 LayerImpl* rootPtr; 3658 LayerImpl* rootPtr;
3659 LayerImpl* layerS1Ptr; 3659 LayerImpl* layerS1Ptr;
3660 LayerImpl* layerS2Ptr; 3660 LayerImpl* layerS2Ptr;
3661 3661
3662 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3662 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3663 3663
3664 gfx::Size rootSize(1000, 1000); 3664 gfx::Size rootSize(1000, 1000);
3665 3665
3666 myHostImpl->initializeRenderer(outputSurface.Pass()); 3666 myHostImpl->initializeRenderer(outputSurface.Pass());
3667 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height())); 3667 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()), gfx::Size(rootSize.width(), rootSize.height()));
3668 3668
3669 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); 3669 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1);
3670 rootPtr = root.get(); 3670 rootPtr = root.get();
3671 3671
3672 root->setAnchorPoint(gfx::PointF(0, 0)); 3672 root->setAnchorPoint(gfx::PointF(0, 0));
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3771 Layers 1, 2 have render surfaces 3771 Layers 1, 2 have render surfaces
3772 */ 3772 */
3773 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1); 3773 scoped_ptr<LayerImpl> root = LayerImpl::create(myHostImpl.get(), 1);
3774 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(myHostImpl.get(), 2); 3774 scoped_ptr<TiledLayerImpl> child = TiledLayerImpl::create(myHostImpl.get(), 2);
3775 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(myHostImpl.get(), 3); 3775 scoped_ptr<LayerImpl> grandChild = LayerImpl::create(myHostImpl.get(), 3);
3776 3776
3777 gfx::Rect rootRect(0, 0, 100, 100); 3777 gfx::Rect rootRect(0, 0, 100, 100);
3778 gfx::Rect childRect(10, 10, 50, 50); 3778 gfx::Rect childRect(10, 10, 50, 50);
3779 gfx::Rect grandChildRect(5, 5, 150, 150); 3779 gfx::Rect grandChildRect(5, 5, 150, 150);
3780 3780
3781 scoped_ptr<OutputSurface> outputSurface = FakeWebCompositorOutputSurface::cr eate(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Ou tputSurface>(); 3781 scoped_ptr<OutputSurface> outputSurface = FakeOutputSurface::Create3d(scoped _ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<OutputSurface >();
3782 myHostImpl->initializeRenderer(outputSurface.Pass()); 3782 myHostImpl->initializeRenderer(outputSurface.Pass());
3783 3783
3784 root->setAnchorPoint(gfx::PointF(0, 0)); 3784 root->setAnchorPoint(gfx::PointF(0, 0));
3785 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y())); 3785 root->setPosition(gfx::PointF(rootRect.x(), rootRect.y()));
3786 root->setBounds(gfx::Size(rootRect.width(), rootRect.height())); 3786 root->setBounds(gfx::Size(rootRect.width(), rootRect.height()));
3787 root->setContentBounds(root->bounds()); 3787 root->setContentBounds(root->bounds());
3788 root->setDrawsContent(true); 3788 root->setDrawsContent(true);
3789 root->setMasksToBounds(true); 3789 root->setMasksToBounds(true);
3790 3790
3791 child->setAnchorPoint(gfx::PointF(0, 0)); 3791 child->setAnchorPoint(gfx::PointF(0, 0));
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
4513 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa ta& testData) 4513 static void verifyRenderPassTestData(TestCase& testCase, RenderPassRemovalTestDa ta& testData)
4514 { 4514 {
4515 char actualResult[1024]; 4515 char actualResult[1024];
4516 dumpRenderPassTestData(testData, actualResult); 4516 dumpRenderPassTestData(testData, actualResult);
4517 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t estCase.name; 4517 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t estCase.name;
4518 } 4518 }
4519 4519
4520 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) 4520 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses)
4521 { 4521 {
4522 scoped_ptr<OutputSurface> outputSurface(createOutputSurface()); 4522 scoped_ptr<OutputSurface> outputSurface(createOutputSurface());
4523 ASSERT_TRUE(outputSurface->context3D()); 4523 ASSERT_TRUE(outputSurface->Context3D());
4524 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu tSurface.get())); 4524 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(outpu tSurface.get()));
4525 4525
4526 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get( ), &m_proxy)); 4526 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get( ), &m_proxy));
4527 4527
4528 int testCaseIndex = 0; 4528 int testCaseIndex = 0;
4529 while (removeRenderPassesCases[testCaseIndex].name) { 4529 while (removeRenderPassesCases[testCaseIndex].name) {
4530 RenderPassRemovalTestData testData; 4530 RenderPassRemovalTestData testData;
4531 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); 4531 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get());
4532 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse sWithCachedTextures(*renderer), testData); 4532 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse sWithCachedTextures(*renderer), testData);
4533 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); 4533 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a);
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
4891 { 4891 {
4892 pinchZoomPanViewportAndScrollBoundaryTest(2); 4892 pinchZoomPanViewportAndScrollBoundaryTest(2);
4893 } 4893 }
4894 4894
4895 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4895 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4896 LayerTreeHostImplTest, 4896 LayerTreeHostImplTest,
4897 ::testing::Values(false, true)); 4897 ::testing::Values(false, true));
4898 4898
4899 } // namespace 4899 } // namespace
4900 } // namespace cc 4900 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698