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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698