| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
| 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/geometry.h" | 13 #include "cc/geometry.h" |
| 14 #include "cc/gl_renderer.h" | 14 #include "cc/gl_renderer.h" |
| 15 #include "cc/heads_up_display_layer_impl.h" | 15 #include "cc/heads_up_display_layer_impl.h" |
| 16 #include "cc/io_surface_layer_impl.h" | 16 #include "cc/io_surface_layer_impl.h" |
| 17 #include "cc/layer_impl.h" | 17 #include "cc/layer_impl.h" |
| 18 #include "cc/layer_tiling_data.h" | 18 #include "cc/layer_tiling_data.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/settings.h" | 23 #include "cc/settings.h" |
| 24 #include "cc/single_thread_proxy.h" | 24 #include "cc/single_thread_proxy.h" |
| 25 #include "cc/solid_color_draw_quad.h" | 25 #include "cc/solid_color_draw_quad.h" |
| 26 #include "cc/test/animation_test_common.h" | 26 #include "cc/test/animation_test_common.h" |
| 27 #include "cc/test/fake_proxy.h" |
| 27 #include "cc/test/fake_web_compositor_output_surface.h" | 28 #include "cc/test/fake_web_compositor_output_surface.h" |
| 28 #include "cc/test/fake_web_graphics_context_3d.h" | 29 #include "cc/test/fake_web_graphics_context_3d.h" |
| 29 #include "cc/test/fake_web_scrollbar_theme_geometry.h" | 30 #include "cc/test/fake_web_scrollbar_theme_geometry.h" |
| 30 #include "cc/test/geometry_test_utils.h" | 31 #include "cc/test/geometry_test_utils.h" |
| 31 #include "cc/test/layer_test_common.h" | 32 #include "cc/test/layer_test_common.h" |
| 32 #include "cc/test/render_pass_test_common.h" | 33 #include "cc/test/render_pass_test_common.h" |
| 33 #include "cc/test/test_common.h" | 34 #include "cc/test/test_common.h" |
| 34 #include "cc/texture_draw_quad.h" | 35 #include "cc/texture_draw_quad.h" |
| 35 #include "cc/texture_layer_impl.h" | 36 #include "cc/texture_layer_impl.h" |
| 36 #include "cc/tile_draw_quad.h" | 37 #include "cc/tile_draw_quad.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 using ::testing::_; | 59 using ::testing::_; |
| 59 | 60 |
| 60 namespace { | 61 namespace { |
| 61 | 62 |
| 62 // This test is parametrized to run all tests with the | 63 // This test is parametrized to run all tests with the |
| 63 // Settings::pageScalePinchZoomEnabled field enabled and disabled. | 64 // Settings::pageScalePinchZoomEnabled field enabled and disabled. |
| 64 class LayerTreeHostImplTest : public testing::TestWithParam<bool>, | 65 class LayerTreeHostImplTest : public testing::TestWithParam<bool>, |
| 65 public LayerTreeHostImplClient { | 66 public LayerTreeHostImplClient { |
| 66 public: | 67 public: |
| 67 LayerTreeHostImplTest() | 68 LayerTreeHostImplTest() |
| 68 : m_onCanDrawStateChangedCalled(false) | 69 : m_proxy(scoped_ptr<Thread>(NULL)) |
| 70 , m_alwaysImplThread(&m_proxy) |
| 71 , m_alwaysMainThreadBlocked(&m_proxy) |
| 72 , m_onCanDrawStateChangedCalled(false) |
| 69 , m_didRequestCommit(false) | 73 , m_didRequestCommit(false) |
| 70 , m_didRequestRedraw(false) | 74 , m_didRequestRedraw(false) |
| 71 , m_reduceMemoryResult(true) | 75 , m_reduceMemoryResult(true) |
| 72 { | 76 { |
| 73 media::InitializeMediaLibraryForTesting(); | 77 media::InitializeMediaLibraryForTesting(); |
| 74 } | 78 } |
| 75 | 79 |
| 76 virtual void SetUp() | 80 virtual void SetUp() |
| 77 { | 81 { |
| 78 Settings::setPageScalePinchZoomEnabled(GetParam()); | 82 Settings::setPageScalePinchZoomEnabled(GetParam()); |
| 79 LayerTreeSettings settings; | 83 LayerTreeSettings settings; |
| 80 settings.minimumOcclusionTrackingSize = gfx::Size(); | 84 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 81 | 85 |
| 82 m_hostImpl = LayerTreeHostImpl::create(settings, this); | 86 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 83 m_hostImpl->initializeRenderer(createContext()); | 87 m_hostImpl->initializeRenderer(createContext()); |
| 84 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 88 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 85 } | 89 } |
| 86 | 90 |
| 87 virtual void TearDown() | 91 virtual void TearDown() |
| 88 { | 92 { |
| 89 } | 93 } |
| 90 | 94 |
| 91 virtual void didLoseContextOnImplThread() OVERRIDE { } | 95 virtual void didLoseContextOnImplThread() OVERRIDE { } |
| 92 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } | 96 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } |
| 93 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } | 97 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER
RIDE { } |
| 94 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } | 98 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState
ChangedCalled = true; } |
| 95 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } | 99 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr
ue; } |
| 96 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } | 100 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr
ue; } |
| 97 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } | 101 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio
nEventsVector>, base::Time wallClockTime) OVERRIDE { } |
| 98 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } | 102 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int
priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } |
| 99 virtual void sendManagedMemoryStats() OVERRIDE { } | 103 virtual void sendManagedMemoryStats() OVERRIDE { } |
| 100 | 104 |
| 101 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } | 105 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult =
reduceMemoryResult; } |
| 102 | 106 |
| 103 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) | 107 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p
tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) |
| 104 { | 108 { |
| 105 Settings::setPartialSwapEnabled(partialSwap); | 109 Settings::setPartialSwapEnabled(partialSwap); |
| 106 | 110 |
| 107 LayerTreeSettings settings; | 111 LayerTreeSettings settings; |
| 108 settings.minimumOcclusionTrackingSize = gfx::Size(); | 112 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 109 | 113 |
| 110 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this); | 114 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(set
tings, this, &m_proxy); |
| 111 | 115 |
| 112 myHostImpl->initializeRenderer(graphicsContext.Pass()); | 116 myHostImpl->initializeRenderer(graphicsContext.Pass()); |
| 113 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 117 myHostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 114 | 118 |
| 115 root->setAnchorPoint(gfx::PointF(0, 0)); | 119 root->setAnchorPoint(gfx::PointF(0, 0)); |
| 116 root->setPosition(gfx::PointF(0, 0)); | 120 root->setPosition(gfx::PointF(0, 0)); |
| 117 root->setBounds(gfx::Size(10, 10)); | 121 root->setBounds(gfx::Size(10, 10)); |
| 118 root->setContentBounds(gfx::Size(10, 10)); | 122 root->setContentBounds(gfx::Size(10, 10)); |
| 119 root->setVisibleContentRect(gfx::Rect(0, 0, 10, 10)); | 123 root->setVisibleContentRect(gfx::Rect(0, 0, 10, 10)); |
| 120 root->setDrawsContent(true); | 124 root->setDrawsContent(true); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 m_hostImpl->drawLayers(frame); | 187 m_hostImpl->drawLayers(frame); |
| 184 m_hostImpl->didDrawAllLayers(frame); | 188 m_hostImpl->didDrawAllLayers(frame); |
| 185 } | 189 } |
| 186 | 190 |
| 187 protected: | 191 protected: |
| 188 scoped_ptr<GraphicsContext> createContext() | 192 scoped_ptr<GraphicsContext> createContext() |
| 189 { | 193 { |
| 190 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); | 194 return FakeWebCompositorOutputSurface::create(scoped_ptr<WebKit::WebGrap
hicsContext3D>(new FakeWebGraphicsContext3D)).PassAs<GraphicsContext>(); |
| 191 } | 195 } |
| 192 | 196 |
| 197 FakeProxy m_proxy; |
| 193 DebugScopedSetImplThread m_alwaysImplThread; | 198 DebugScopedSetImplThread m_alwaysImplThread; |
| 194 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 199 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
| 195 | 200 |
| 196 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 201 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
| 197 bool m_onCanDrawStateChangedCalled; | 202 bool m_onCanDrawStateChangedCalled; |
| 198 bool m_didRequestCommit; | 203 bool m_didRequestCommit; |
| 199 bool m_didRequestRedraw; | 204 bool m_didRequestRedraw; |
| 200 bool m_reduceMemoryResult; | 205 bool m_reduceMemoryResult; |
| 201 ScopedSettings m_scopedSettings; | 206 ScopedSettings m_scopedSettings; |
| 202 }; | 207 }; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 351 |
| 347 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) | 352 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) |
| 348 { | 353 { |
| 349 // We should not crash when trying to scroll an empty layer tree. | 354 // We should not crash when trying to scroll an empty layer tree. |
| 350 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); | 355 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee
l), InputHandlerClient::ScrollIgnored); |
| 351 } | 356 } |
| 352 | 357 |
| 353 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) | 358 TEST_P(LayerTreeHostImplTest, scrollWithoutRenderer) |
| 354 { | 359 { |
| 355 LayerTreeSettings settings; | 360 LayerTreeSettings settings; |
| 356 m_hostImpl = LayerTreeHostImpl::create(settings, this); | 361 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 357 | 362 |
| 358 // Initialization will fail here. | 363 // Initialization will fail here. |
| 359 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); | 364 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); |
| 360 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 365 m_hostImpl->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
| 361 | 366 |
| 362 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 367 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 363 | 368 |
| 364 // We should not crash when trying to scroll after the renderer initializati
on fails. | 369 // We should not crash when trying to scroll after the renderer initializati
on fails. |
| 365 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); |
| 366 } | 371 } |
| (...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 // where it should request to swap only the subBuffer that is damaged. | 1951 // where it should request to swap only the subBuffer that is damaged. |
| 1947 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) | 1952 TEST_P(LayerTreeHostImplTest, partialSwapReceivesDamageRect) |
| 1948 { | 1953 { |
| 1949 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); | 1954 scoped_ptr<GraphicsContext> outputSurface = FakeWebCompositorOutputSurface::
create(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapTrackerContext)).
PassAs<GraphicsContext>(); |
| 1950 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); | 1955 PartialSwapTrackerContext* partialSwapTracker = static_cast<PartialSwapTrack
erContext*>(outputSurface->context3D()); |
| 1951 | 1956 |
| 1952 // This test creates its own LayerTreeHostImpl, so | 1957 // This test creates its own LayerTreeHostImpl, so |
| 1953 // that we can force partial swap enabled. | 1958 // that we can force partial swap enabled. |
| 1954 LayerTreeSettings settings; | 1959 LayerTreeSettings settings; |
| 1955 Settings::setPartialSwapEnabled(true); | 1960 Settings::setPartialSwapEnabled(true); |
| 1956 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this); | 1961 scoped_ptr<LayerTreeHostImpl> layerTreeHostImpl = LayerTreeHostImpl::create(
settings, this, &m_proxy); |
| 1957 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); | 1962 layerTreeHostImpl->initializeRenderer(outputSurface.Pass()); |
| 1958 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; | 1963 layerTreeHostImpl->setViewportSize(gfx::Size(500, 500), gfx::Size(500, 500))
; |
| 1959 | 1964 |
| 1960 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); | 1965 scoped_ptr<LayerImpl> root = FakeDrawableLayerImpl::create(1); |
| 1961 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); | 1966 scoped_ptr<LayerImpl> child = FakeDrawableLayerImpl::create(2); |
| 1962 child->setPosition(gfx::PointF(12, 13)); | 1967 child->setPosition(gfx::PointF(12, 13)); |
| 1963 child->setAnchorPoint(gfx::PointF(0, 0)); | 1968 child->setAnchorPoint(gfx::PointF(0, 0)); |
| 1964 child->setBounds(gfx::Size(14, 15)); | 1969 child->setBounds(gfx::Size(14, 15)); |
| 1965 child->setContentBounds(gfx::Size(14, 15)); | 1970 child->setContentBounds(gfx::Size(14, 15)); |
| 1966 child->setDrawsContent(true); | 1971 child->setDrawsContent(true); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 } | 2231 } |
| 2227 | 2232 |
| 2228 // Unlimited texture size. | 2233 // Unlimited texture size. |
| 2229 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) | 2234 virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value) |
| 2230 { | 2235 { |
| 2231 if (pname == GL_MAX_TEXTURE_SIZE) | 2236 if (pname == GL_MAX_TEXTURE_SIZE) |
| 2232 *value = 8192; | 2237 *value = 8192; |
| 2233 } | 2238 } |
| 2234 }; | 2239 }; |
| 2235 | 2240 |
| 2236 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client) | 2241 static scoped_ptr<LayerTreeHostImpl> setupLayersForOpacity(bool partialSwap, Lay
erTreeHostImplClient* client, Proxy* proxy) |
| 2237 { | 2242 { |
| 2238 Settings::setPartialSwapEnabled(partialSwap); | 2243 Settings::setPartialSwapEnabled(partialSwap); |
| 2239 | 2244 |
| 2240 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 2245 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
| 2241 | 2246 |
| 2242 LayerTreeSettings settings; | 2247 LayerTreeSettings settings; |
| 2243 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client); | 2248 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, client, proxy); |
| 2244 myHostImpl->initializeRenderer(context.Pass()); | 2249 myHostImpl->initializeRenderer(context.Pass()); |
| 2245 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); | 2250 myHostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
| 2246 | 2251 |
| 2247 /* | 2252 /* |
| 2248 Layers are created as follows: | 2253 Layers are created as follows: |
| 2249 | 2254 |
| 2250 +--------------------+ | 2255 +--------------------+ |
| 2251 | 1 | | 2256 | 1 | |
| 2252 | +-----------+ | | 2257 | +-----------+ | |
| 2253 | | 2 | | | 2258 | | 2 | | |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2296 | 2301 |
| 2297 child->addChild(grandChild.Pass()); | 2302 child->addChild(grandChild.Pass()); |
| 2298 root->addChild(child.Pass()); | 2303 root->addChild(child.Pass()); |
| 2299 | 2304 |
| 2300 myHostImpl->setRootLayer(root.Pass()); | 2305 myHostImpl->setRootLayer(root.Pass()); |
| 2301 return myHostImpl.Pass(); | 2306 return myHostImpl.Pass(); |
| 2302 } | 2307 } |
| 2303 | 2308 |
| 2304 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) | 2309 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorPartialSwap) |
| 2305 { | 2310 { |
| 2306 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this)
; | 2311 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(true, this,
&m_proxy); |
| 2307 | 2312 |
| 2308 { | 2313 { |
| 2309 LayerTreeHostImpl::FrameData frame; | 2314 LayerTreeHostImpl::FrameData frame; |
| 2310 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2315 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2311 | 2316 |
| 2312 // Just for consistency, the most interesting stuff already happened | 2317 // Just for consistency, the most interesting stuff already happened |
| 2313 myHostImpl->drawLayers(frame); | 2318 myHostImpl->drawLayers(frame); |
| 2314 myHostImpl->didDrawAllLayers(frame); | 2319 myHostImpl->didDrawAllLayers(frame); |
| 2315 | 2320 |
| 2316 // Verify all quads have been computed | 2321 // Verify all quads have been computed |
| 2317 ASSERT_EQ(2U, frame.renderPasses.size()); | 2322 ASSERT_EQ(2U, frame.renderPasses.size()); |
| 2318 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); | 2323 ASSERT_EQ(1U, frame.renderPasses[0]->quadList().size()); |
| 2319 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); | 2324 ASSERT_EQ(1U, frame.renderPasses[1]->quadList().size()); |
| 2320 EXPECT_EQ(DrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]->ma
terial()); | 2325 EXPECT_EQ(DrawQuad::SolidColor, frame.renderPasses[0]->quadList()[0]->ma
terial()); |
| 2321 EXPECT_EQ(DrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->ma
terial()); | 2326 EXPECT_EQ(DrawQuad::RenderPass, frame.renderPasses[1]->quadList()[0]->ma
terial()); |
| 2322 } | 2327 } |
| 2323 } | 2328 } |
| 2324 | 2329 |
| 2325 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) | 2330 TEST_P(LayerTreeHostImplTest, contributingLayerEmptyScissorNoPartialSwap) |
| 2326 { | 2331 { |
| 2327 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this
); | 2332 scoped_ptr<LayerTreeHostImpl> myHostImpl = setupLayersForOpacity(false, this
, &m_proxy); |
| 2328 | 2333 |
| 2329 { | 2334 { |
| 2330 LayerTreeHostImpl::FrameData frame; | 2335 LayerTreeHostImpl::FrameData frame; |
| 2331 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); | 2336 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); |
| 2332 | 2337 |
| 2333 // Just for consistency, the most interesting stuff already happened | 2338 // Just for consistency, the most interesting stuff already happened |
| 2334 myHostImpl->drawLayers(frame); | 2339 myHostImpl->drawLayers(frame); |
| 2335 myHostImpl->didDrawAllLayers(frame); | 2340 myHostImpl->didDrawAllLayers(frame); |
| 2336 | 2341 |
| 2337 // Verify all quads have been computed | 2342 // Verify all quads have been computed |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2383 m_hostImpl->initializeRenderer(createContext()); | 2388 m_hostImpl->initializeRenderer(createContext()); |
| 2384 | 2389 |
| 2385 EXPECT_TRUE(root->didLoseContextCalled()); | 2390 EXPECT_TRUE(root->didLoseContextCalled()); |
| 2386 EXPECT_TRUE(layer1->didLoseContextCalled()); | 2391 EXPECT_TRUE(layer1->didLoseContextCalled()); |
| 2387 EXPECT_TRUE(layer2->didLoseContextCalled()); | 2392 EXPECT_TRUE(layer2->didLoseContextCalled()); |
| 2388 } | 2393 } |
| 2389 | 2394 |
| 2390 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) | 2395 TEST_P(LayerTreeHostImplTest, finishAllRenderingAfterContextLost) |
| 2391 { | 2396 { |
| 2392 LayerTreeSettings settings; | 2397 LayerTreeSettings settings; |
| 2393 m_hostImpl = LayerTreeHostImpl::create(settings, this); | 2398 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 2394 | 2399 |
| 2395 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. | 2400 // The context initialization will fail, but we should still be able to call
finishAllRendering() without any ill effects. |
| 2396 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); | 2401 m_hostImpl->initializeRenderer(FakeWebCompositorOutputSurface::create(scoped
_ptr<WebKit::WebGraphicsContext3D>(new FakeWebGraphicsContext3DMakeCurrentFails)
).PassAs<GraphicsContext>()); |
| 2397 m_hostImpl->finishAllRendering(); | 2402 m_hostImpl->finishAllRendering(); |
| 2398 } | 2403 } |
| 2399 | 2404 |
| 2400 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { | 2405 class FakeWebGraphicsContext3DMakeCurrentFailsEventually : public FakeWebGraphic
sContext3D { |
| 2401 public: | 2406 public: |
| 2402 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } | 2407 explicit FakeWebGraphicsContext3DMakeCurrentFailsEventually(unsigned succeed
Count) : m_succeedCount(succeedCount) { } |
| 2403 virtual bool makeContextCurrent() { | 2408 virtual bool makeContextCurrent() { |
| 2404 if (!m_succeedCount) | 2409 if (!m_succeedCount) |
| 2405 return false; | 2410 return false; |
| 2406 --m_succeedCount; | 2411 --m_succeedCount; |
| 2407 return true; | 2412 return true; |
| 2408 } | 2413 } |
| 2409 | 2414 |
| 2410 private: | 2415 private: |
| 2411 unsigned m_succeedCount; | 2416 unsigned m_succeedCount; |
| 2412 }; | 2417 }; |
| 2413 | 2418 |
| 2414 TEST_P(LayerTreeHostImplTest, contextLostDuringInitialize) | 2419 TEST_P(LayerTreeHostImplTest, contextLostDuringInitialize) |
| 2415 { | 2420 { |
| 2416 LayerTreeSettings settings; | 2421 LayerTreeSettings settings; |
| 2417 m_hostImpl = LayerTreeHostImpl::create(settings, this); | 2422 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); |
| 2418 | 2423 |
| 2419 // Initialize into a known successful state. | 2424 // Initialize into a known successful state. |
| 2420 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); | 2425 EXPECT_TRUE(m_hostImpl->initializeRenderer(createContext())); |
| 2421 EXPECT_TRUE(m_hostImpl->context()); | 2426 EXPECT_TRUE(m_hostImpl->context()); |
| 2422 EXPECT_TRUE(m_hostImpl->renderer()); | 2427 EXPECT_TRUE(m_hostImpl->renderer()); |
| 2423 EXPECT_TRUE(m_hostImpl->resourceProvider()); | 2428 EXPECT_TRUE(m_hostImpl->resourceProvider()); |
| 2424 | 2429 |
| 2425 // We will make the context get lost after a numer of makeContextCurrent | 2430 // We will make the context get lost after a numer of makeContextCurrent |
| 2426 // calls. The exact number of calls to make it succeed is dependent on the | 2431 // calls. The exact number of calls to make it succeed is dependent on the |
| 2427 // implementation and doesn't really matter (i.e. can be changed to make the | 2432 // implementation and doesn't really matter (i.e. can be changed to make the |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3018 public: | 3023 public: |
| 3019 using GLRenderer::releaseRenderPassTextures; | 3024 using GLRenderer::releaseRenderPassTextures; |
| 3020 }; | 3025 }; |
| 3021 | 3026 |
| 3022 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) | 3027 TEST_P(LayerTreeHostImplTest, textureCachingWithClipping) |
| 3023 { | 3028 { |
| 3024 Settings::setPartialSwapEnabled(true); | 3029 Settings::setPartialSwapEnabled(true); |
| 3025 | 3030 |
| 3026 LayerTreeSettings settings; | 3031 LayerTreeSettings settings; |
| 3027 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3032 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3028 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3033 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3029 | 3034 |
| 3030 LayerImpl* rootPtr; | 3035 LayerImpl* rootPtr; |
| 3031 LayerImpl* surfaceLayerPtr; | 3036 LayerImpl* surfaceLayerPtr; |
| 3032 | 3037 |
| 3033 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3038 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
| 3034 | 3039 |
| 3035 gfx::Size rootSize(100, 100); | 3040 gfx::Size rootSize(100, 100); |
| 3036 | 3041 |
| 3037 myHostImpl->initializeRenderer(context.Pass()); | 3042 myHostImpl->initializeRenderer(context.Pass()); |
| 3038 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); | 3043 myHostImpl->setViewportSize(gfx::Size(rootSize.width(), rootSize.height()),
gfx::Size(rootSize.width(), rootSize.height())); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3115 myHostImpl->didDrawAllLayers(frame); | 3120 myHostImpl->didDrawAllLayers(frame); |
| 3116 } | 3121 } |
| 3117 } | 3122 } |
| 3118 | 3123 |
| 3119 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) | 3124 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion) |
| 3120 { | 3125 { |
| 3121 Settings::setPartialSwapEnabled(false); | 3126 Settings::setPartialSwapEnabled(false); |
| 3122 | 3127 |
| 3123 LayerTreeSettings settings; | 3128 LayerTreeSettings settings; |
| 3124 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3129 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3125 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3130 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3126 | 3131 |
| 3127 // Layers are structure as follows: | 3132 // Layers are structure as follows: |
| 3128 // | 3133 // |
| 3129 // R +-- S1 +- L10 (owning) | 3134 // R +-- S1 +- L10 (owning) |
| 3130 // | +- L11 | 3135 // | +- L11 |
| 3131 // | +- L12 | 3136 // | +- L12 |
| 3132 // | | 3137 // | |
| 3133 // +-- S2 +- L20 (owning) | 3138 // +-- S2 +- L20 (owning) |
| 3134 // +- L21 | 3139 // +- L21 |
| 3135 // | 3140 // |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3231 } | 3236 } |
| 3232 | 3237 |
| 3233 } | 3238 } |
| 3234 | 3239 |
| 3235 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) | 3240 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut) |
| 3236 { | 3241 { |
| 3237 Settings::setPartialSwapEnabled(false); | 3242 Settings::setPartialSwapEnabled(false); |
| 3238 | 3243 |
| 3239 LayerTreeSettings settings; | 3244 LayerTreeSettings settings; |
| 3240 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3245 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3241 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3246 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3242 | 3247 |
| 3243 // Layers are structure as follows: | 3248 // Layers are structure as follows: |
| 3244 // | 3249 // |
| 3245 // R +-- S1 +- L10 (owning, non drawing) | 3250 // R +-- S1 +- L10 (owning, non drawing) |
| 3246 // | +- L11 (corner, unoccluded) | 3251 // | +- L11 (corner, unoccluded) |
| 3247 // | +- L12 (corner, unoccluded) | 3252 // | +- L12 (corner, unoccluded) |
| 3248 // | +- L13 (corner, unoccluded) | 3253 // | +- L13 (corner, unoccluded) |
| 3249 // | +- L14 (corner, entirely occluded) | 3254 // | +- L14 (corner, entirely occluded) |
| 3250 // | | 3255 // | |
| 3251 // +-- S2 +- L20 (owning, drawing) | 3256 // +-- S2 +- L20 (owning, drawing) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3347 myHostImpl->didDrawAllLayers(frame); | 3352 myHostImpl->didDrawAllLayers(frame); |
| 3348 } | 3353 } |
| 3349 } | 3354 } |
| 3350 | 3355 |
| 3351 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) | 3356 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal) |
| 3352 { | 3357 { |
| 3353 Settings::setPartialSwapEnabled(false); | 3358 Settings::setPartialSwapEnabled(false); |
| 3354 | 3359 |
| 3355 LayerTreeSettings settings; | 3360 LayerTreeSettings settings; |
| 3356 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3361 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3357 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3362 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3358 | 3363 |
| 3359 // Layers are structured as follows: | 3364 // Layers are structured as follows: |
| 3360 // | 3365 // |
| 3361 // R +-- S1 +- L10 (owning, drawing) | 3366 // R +-- S1 +- L10 (owning, drawing) |
| 3362 // | +- L11 (corner, occluded by L12) | 3367 // | +- L11 (corner, occluded by L12) |
| 3363 // | +- L12 (opposite corner) | 3368 // | +- L12 (opposite corner) |
| 3364 // | | 3369 // | |
| 3365 // +-- S2 +- L20 (owning, drawing) | 3370 // +-- S2 +- L20 (owning, drawing) |
| 3366 // | 3371 // |
| 3367 | 3372 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3435 myHostImpl->drawLayers(frame); | 3440 myHostImpl->drawLayers(frame); |
| 3436 myHostImpl->didDrawAllLayers(frame); | 3441 myHostImpl->didDrawAllLayers(frame); |
| 3437 } | 3442 } |
| 3438 } | 3443 } |
| 3439 | 3444 |
| 3440 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) | 3445 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned) |
| 3441 { | 3446 { |
| 3442 Settings::setPartialSwapEnabled(false); | 3447 Settings::setPartialSwapEnabled(false); |
| 3443 | 3448 |
| 3444 LayerTreeSettings settings; | 3449 LayerTreeSettings settings; |
| 3445 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3450 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3446 | 3451 |
| 3447 // Layers are structured as follows: | 3452 // Layers are structured as follows: |
| 3448 // | 3453 // |
| 3449 // R +-- S1 +- L10 (rotated, drawing) | 3454 // R +-- S1 +- L10 (rotated, drawing) |
| 3450 // +- L11 (occupies half surface) | 3455 // +- L11 (occupies half surface) |
| 3451 | 3456 |
| 3452 LayerImpl* rootPtr; | 3457 LayerImpl* rootPtr; |
| 3453 LayerImpl* layerS1Ptr; | 3458 LayerImpl* layerS1Ptr; |
| 3454 | 3459 |
| 3455 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); | 3460 scoped_ptr<GraphicsContext> context = FakeWebCompositorOutputSurface::create
(scoped_ptr<WebKit::WebGraphicsContext3D>(new PartialSwapContext)).PassAs<Graphi
csContext>(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3510 myHostImpl->didDrawAllLayers(frame); | 3515 myHostImpl->didDrawAllLayers(frame); |
| 3511 } | 3516 } |
| 3512 } | 3517 } |
| 3513 | 3518 |
| 3514 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) | 3519 TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap) |
| 3515 { | 3520 { |
| 3516 Settings::setPartialSwapEnabled(true); | 3521 Settings::setPartialSwapEnabled(true); |
| 3517 | 3522 |
| 3518 LayerTreeSettings settings; | 3523 LayerTreeSettings settings; |
| 3519 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3524 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3520 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3525 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3521 | 3526 |
| 3522 // Layers are structure as follows: | 3527 // Layers are structure as follows: |
| 3523 // | 3528 // |
| 3524 // R +-- S1 +- L10 (owning) | 3529 // R +-- S1 +- L10 (owning) |
| 3525 // | +- L11 | 3530 // | +- L11 |
| 3526 // | +- L12 | 3531 // | +- L12 |
| 3527 // | | 3532 // | |
| 3528 // +-- S2 +- L20 (owning) | 3533 // +-- S2 +- L20 (owning) |
| 3529 // +- L21 | 3534 // +- L21 |
| 3530 // | 3535 // |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3623 myHostImpl->didDrawAllLayers(frame); | 3628 myHostImpl->didDrawAllLayers(frame); |
| 3624 } | 3629 } |
| 3625 } | 3630 } |
| 3626 | 3631 |
| 3627 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) | 3632 TEST_P(LayerTreeHostImplTest, textureCachingWithScissor) |
| 3628 { | 3633 { |
| 3629 Settings::setPartialSwapEnabled(false); | 3634 Settings::setPartialSwapEnabled(false); |
| 3630 | 3635 |
| 3631 LayerTreeSettings settings; | 3636 LayerTreeSettings settings; |
| 3632 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3637 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3633 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3638 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3634 | 3639 |
| 3635 /* | 3640 /* |
| 3636 Layers are created as follows: | 3641 Layers are created as follows: |
| 3637 | 3642 |
| 3638 +--------------------+ | 3643 +--------------------+ |
| 3639 | 1 | | 3644 | 1 | |
| 3640 | +-----------+ | | 3645 | +-----------+ | |
| 3641 | | 2 | | | 3646 | | 2 | | |
| 3642 | | +-------------------+ | 3647 | | +-------------------+ |
| 3643 | | | 3 | | 3648 | | | 3 | |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3730 // We should have a cached texture for surface 2 again even though it was da
maged. | 3735 // We should have a cached texture for surface 2 again even though it was da
maged. |
| 3731 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); | 3736 EXPECT_TRUE(myHostImpl->renderer()->haveCachedResourcesForRenderPassId(child
PassId)); |
| 3732 } | 3737 } |
| 3733 | 3738 |
| 3734 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) | 3739 TEST_P(LayerTreeHostImplTest, surfaceTextureCaching) |
| 3735 { | 3740 { |
| 3736 Settings::setPartialSwapEnabled(true); | 3741 Settings::setPartialSwapEnabled(true); |
| 3737 | 3742 |
| 3738 LayerTreeSettings settings; | 3743 LayerTreeSettings settings; |
| 3739 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3744 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3740 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3745 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3741 | 3746 |
| 3742 LayerImpl* rootPtr; | 3747 LayerImpl* rootPtr; |
| 3743 LayerImpl* intermediateLayerPtr; | 3748 LayerImpl* intermediateLayerPtr; |
| 3744 LayerImpl* surfaceLayerPtr; | 3749 LayerImpl* surfaceLayerPtr; |
| 3745 LayerImpl* childPtr; | 3750 LayerImpl* childPtr; |
| 3746 | 3751 |
| 3747 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); | 3752 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); |
| 3748 | 3753 |
| 3749 { | 3754 { |
| 3750 LayerTreeHostImpl::FrameData frame; | 3755 LayerTreeHostImpl::FrameData frame; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3891 myHostImpl->didDrawAllLayers(frame); | 3896 myHostImpl->didDrawAllLayers(frame); |
| 3892 } | 3897 } |
| 3893 } | 3898 } |
| 3894 | 3899 |
| 3895 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) | 3900 TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap) |
| 3896 { | 3901 { |
| 3897 Settings::setPartialSwapEnabled(false); | 3902 Settings::setPartialSwapEnabled(false); |
| 3898 | 3903 |
| 3899 LayerTreeSettings settings; | 3904 LayerTreeSettings settings; |
| 3900 settings.minimumOcclusionTrackingSize = gfx::Size(); | 3905 settings.minimumOcclusionTrackingSize = gfx::Size(); |
| 3901 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this); | 3906 scoped_ptr<LayerTreeHostImpl> myHostImpl = LayerTreeHostImpl::create(setting
s, this, &m_proxy); |
| 3902 | 3907 |
| 3903 LayerImpl* rootPtr; | 3908 LayerImpl* rootPtr; |
| 3904 LayerImpl* intermediateLayerPtr; | 3909 LayerImpl* intermediateLayerPtr; |
| 3905 LayerImpl* surfaceLayerPtr; | 3910 LayerImpl* surfaceLayerPtr; |
| 3906 LayerImpl* childPtr; | 3911 LayerImpl* childPtr; |
| 3907 | 3912 |
| 3908 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); | 3913 setupLayersForTextureCaching(myHostImpl.get(), rootPtr, intermediateLayerPtr
, surfaceLayerPtr, childPtr, gfx::Size(100, 100)); |
| 3909 | 3914 |
| 3910 { | 3915 { |
| 3911 LayerTreeHostImpl::FrameData frame; | 3916 LayerTreeHostImpl::FrameData frame; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4083 EXPECT_FALSE(m_didRequestCommit); | 4088 EXPECT_FALSE(m_didRequestCommit); |
| 4084 } | 4089 } |
| 4085 | 4090 |
| 4086 struct RenderPassRemovalTestData : public LayerTreeHostImpl::FrameData { | 4091 struct RenderPassRemovalTestData : public LayerTreeHostImpl::FrameData { |
| 4087 ScopedPtrHashMap<RenderPass::Id, TestRenderPass> renderPassCache; | 4092 ScopedPtrHashMap<RenderPass::Id, TestRenderPass> renderPassCache; |
| 4088 scoped_ptr<SharedQuadState> sharedQuadState; | 4093 scoped_ptr<SharedQuadState> sharedQuadState; |
| 4089 }; | 4094 }; |
| 4090 | 4095 |
| 4091 class TestRenderer : public GLRenderer, public RendererClient { | 4096 class TestRenderer : public GLRenderer, public RendererClient { |
| 4092 public: | 4097 public: |
| 4093 static scoped_ptr<TestRenderer> create(ResourceProvider* resourceProvider) | 4098 static scoped_ptr<TestRenderer> create(ResourceProvider* resourceProvider, P
roxy* proxy) |
| 4094 { | 4099 { |
| 4095 scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider)); | 4100 scoped_ptr<TestRenderer> renderer(new TestRenderer(resourceProvider, pro
xy)); |
| 4096 if (!renderer->initialize()) | 4101 if (!renderer->initialize()) |
| 4097 return scoped_ptr<TestRenderer>(); | 4102 return scoped_ptr<TestRenderer>(); |
| 4098 | 4103 |
| 4099 return renderer.Pass(); | 4104 return renderer.Pass(); |
| 4100 } | 4105 } |
| 4101 | 4106 |
| 4102 void clearCachedTextures() { m_textures.clear(); } | 4107 void clearCachedTextures() { m_textures.clear(); } |
| 4103 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } | 4108 void setHaveCachedResourcesForRenderPassId(RenderPass::Id id) { m_textures.i
nsert(id); } |
| 4104 | 4109 |
| 4105 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } | 4110 virtual bool haveCachedResourcesForRenderPassId(RenderPass::Id id) const OVE
RRIDE { return m_textures.count(id); } |
| 4106 | 4111 |
| 4107 // RendererClient implementation. | 4112 // RendererClient implementation. |
| 4108 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } | 4113 virtual const gfx::Size& deviceViewportSize() const OVERRIDE { return m_view
portSize; } |
| 4109 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } | 4114 virtual const LayerTreeSettings& settings() const OVERRIDE { return m_settin
gs; } |
| 4110 virtual void didLoseContext() OVERRIDE { } | 4115 virtual void didLoseContext() OVERRIDE { } |
| 4111 virtual void onSwapBuffersComplete() OVERRIDE { } | 4116 virtual void onSwapBuffersComplete() OVERRIDE { } |
| 4112 virtual void setFullRootLayerDamage() OVERRIDE { } | 4117 virtual void setFullRootLayerDamage() OVERRIDE { } |
| 4113 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } | 4118 virtual void setManagedMemoryPolicy(const ManagedMemoryPolicy& policy) OVERR
IDE { } |
| 4114 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } | 4119 virtual void enforceManagedMemoryPolicy(const ManagedMemoryPolicy& policy) O
VERRIDE { } |
| 4120 virtual bool hasImplThread() const OVERRIDE { return false; } |
| 4115 | 4121 |
| 4116 protected: | 4122 protected: |
| 4117 TestRenderer(ResourceProvider* resourceProvider) : GLRenderer(this, resource
Provider) { } | 4123 TestRenderer(ResourceProvider* resourceProvider, Proxy* proxy) : GLRenderer(
this, resourceProvider) { } |
| 4118 | 4124 |
| 4119 private: | 4125 private: |
| 4120 LayerTreeSettings m_settings; | 4126 LayerTreeSettings m_settings; |
| 4121 gfx::Size m_viewportSize; | 4127 gfx::Size m_viewportSize; |
| 4122 base::hash_set<RenderPass::Id> m_textures; | 4128 base::hash_set<RenderPass::Id> m_textures; |
| 4123 }; | 4129 }; |
| 4124 | 4130 |
| 4125 static void configureRenderPassTestData(const char* testScript, RenderPassRemova
lTestData& testData, TestRenderer* renderer) | 4131 static void configureRenderPassTestData(const char* testScript, RenderPassRemova
lTestData& testData, TestRenderer* renderer) |
| 4126 { | 4132 { |
| 4127 renderer->clearCachedTextures(); | 4133 renderer->clearCachedTextures(); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4391 dumpRenderPassTestData(testData, actualResult); | 4397 dumpRenderPassTestData(testData, actualResult); |
| 4392 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; | 4398 EXPECT_STREQ(testCase.expectedResult, actualResult) << "In test case: " << t
estCase.name; |
| 4393 } | 4399 } |
| 4394 | 4400 |
| 4395 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) | 4401 TEST_P(LayerTreeHostImplTest, testRemoveRenderPasses) |
| 4396 { | 4402 { |
| 4397 scoped_ptr<GraphicsContext> context(createContext()); | 4403 scoped_ptr<GraphicsContext> context(createContext()); |
| 4398 ASSERT_TRUE(context->context3D()); | 4404 ASSERT_TRUE(context->context3D()); |
| 4399 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); | 4405 scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(conte
xt.get())); |
| 4400 | 4406 |
| 4401 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
))); | 4407 scoped_ptr<TestRenderer> renderer(TestRenderer::create(resourceProvider.get(
), &m_proxy)); |
| 4402 | 4408 |
| 4403 int testCaseIndex = 0; | 4409 int testCaseIndex = 0; |
| 4404 while (removeRenderPassesCases[testCaseIndex].name) { | 4410 while (removeRenderPassesCases[testCaseIndex].name) { |
| 4405 RenderPassRemovalTestData testData; | 4411 RenderPassRemovalTestData testData; |
| 4406 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); | 4412 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS
cript, testData, renderer.get()); |
| 4407 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); | 4413 LayerTreeHostImpl::removeRenderPasses(LayerTreeHostImpl::CullRenderPasse
sWithCachedTextures(*renderer), testData); |
| 4408 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4414 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
| 4409 testCaseIndex++; | 4415 testCaseIndex++; |
| 4410 } | 4416 } |
| 4411 } | 4417 } |
| 4412 | 4418 |
| 4413 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4419 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4414 LayerTreeHostImplTest, | 4420 LayerTreeHostImplTest, |
| 4415 ::testing::Values(false, true)); | 4421 ::testing::Values(false, true)); |
| 4416 | 4422 |
| 4417 } // anonymous namespace | 4423 } // anonymous namespace |
| OLD | NEW |