| 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 #ifndef CC_TEST_LAYER_TREE_TEST_H_ | 5 #ifndef CC_TEST_LAYER_TREE_TEST_H_ |
| 6 #define CC_TEST_LAYER_TREE_TEST_H_ | 6 #define CC_TEST_LAYER_TREE_TEST_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "cc/animation/animation_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
| 11 #include "cc/trees/layer_tree_host.h" | 11 #include "cc/trees/layer_tree_host.h" |
| 12 #include "cc/trees/layer_tree_host_impl.h" | 12 #include "cc/trees/layer_tree_host_impl.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 class AnimationPlayer; | 16 class AnimationPlayer; |
| 17 class FakeExternalBeginFrameSource; | 17 class FakeExternalBeginFrameSource; |
| 18 class FakeLayerTreeHostClient; | 18 class FakeLayerTreeHostClient; |
| 19 class FakeOutputSurface; | 19 class FakeOutputSurface; |
| 20 class LayerImpl; | 20 class LayerImpl; |
| 21 class LayerTreeHost; | 21 class LayerTreeHost; |
| 22 class LayerTreeHostClient; | 22 class LayerTreeHostClient; |
| 23 class LayerTreeHostImpl; | 23 class LayerTreeHostImpl; |
| 24 class ProxyMain; |
| 25 class ProxyImpl; |
| 24 class TestContextProvider; | 26 class TestContextProvider; |
| 25 class TestGpuMemoryBufferManager; | 27 class TestGpuMemoryBufferManager; |
| 26 class TestWebGraphicsContext3D; | 28 class TestWebGraphicsContext3D; |
| 27 | 29 |
| 28 // Creates the virtual viewport layer hierarchy under the given root_layer. | 30 // Creates the virtual viewport layer hierarchy under the given root_layer. |
| 29 // Convenient overload of the method below that creates a scrolling layer as | 31 // Convenient overload of the method below that creates a scrolling layer as |
| 30 // the outer viewport scroll layer. | 32 // the outer viewport scroll layer. |
| 31 void CreateVirtualViewportLayers(Layer* root_layer, | 33 void CreateVirtualViewportLayers(Layer* root_layer, |
| 32 const gfx::Size& inner_bounds, | 34 const gfx::Size& inner_bounds, |
| 33 const gfx::Size& outer_bounds, | 35 const gfx::Size& outer_bounds, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 virtual void SetInputThrottledUntilCommitOnImpl(bool is_throttled) {} | 134 virtual void SetInputThrottledUntilCommitOnImpl(bool is_throttled) {} |
| 133 virtual void SetDeferCommitsOnImpl(bool defer_commits) {} | 135 virtual void SetDeferCommitsOnImpl(bool defer_commits) {} |
| 134 virtual void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) {} | 136 virtual void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) {} |
| 135 virtual void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) {} | 137 virtual void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) {} |
| 136 virtual void SetNeedsCommitOnImpl() {} | 138 virtual void SetNeedsCommitOnImpl() {} |
| 137 virtual void FinishAllRenderingOnImpl() {} | 139 virtual void FinishAllRenderingOnImpl() {} |
| 138 virtual void SetVisibleOnImpl(bool visible) {} | 140 virtual void SetVisibleOnImpl(bool visible) {} |
| 139 virtual void ReleaseOutputSurfaceOnImpl() {} | 141 virtual void ReleaseOutputSurfaceOnImpl() {} |
| 140 virtual void FinishGLOnImpl() {} | 142 virtual void FinishGLOnImpl() {} |
| 141 virtual void StartCommitOnImpl() {} | 143 virtual void StartCommitOnImpl() {} |
| 142 virtual void InitializeImplOnImpl() {} | |
| 143 virtual void WillCloseLayerTreeHostOnImpl() {} | |
| 144 | 144 |
| 145 // Hooks for ProxyMain | 145 // Hooks for ProxyMain |
| 146 virtual void ReceivedDidCompleteSwapBuffers() {} | 146 virtual void ReceivedDidCompleteSwapBuffers() {} |
| 147 virtual void ReceivedSetRendererCapabilitiesMainCopy( | 147 virtual void ReceivedSetRendererCapabilitiesMainCopy( |
| 148 const RendererCapabilities& capabilities) {} | 148 const RendererCapabilities& capabilities) {} |
| 149 virtual void ReceivedBeginMainFrameNotExpectedSoon() {} | 149 virtual void ReceivedBeginMainFrameNotExpectedSoon() {} |
| 150 virtual void ReceivedDidCommitAndDrawFrame() {} | 150 virtual void ReceivedDidCommitAndDrawFrame() {} |
| 151 virtual void ReceivedSetAnimationEvents() {} | 151 virtual void ReceivedSetAnimationEvents() {} |
| 152 virtual void ReceivedDidLoseOutputSurface() {} | 152 virtual void ReceivedDidLoseOutputSurface() {} |
| 153 virtual void ReceivedRequestNewOutputSurface() {} | 153 virtual void ReceivedRequestNewOutputSurface() {} |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 void DispatchSetVisible(bool visible); | 242 void DispatchSetVisible(bool visible); |
| 243 void DispatchSetNextCommitForcesRedraw(); | 243 void DispatchSetNextCommitForcesRedraw(); |
| 244 void DispatchDidAddAnimation(); | 244 void DispatchDidAddAnimation(); |
| 245 void DispatchCompositeImmediately(); | 245 void DispatchCompositeImmediately(); |
| 246 | 246 |
| 247 virtual void AfterTest() = 0; | 247 virtual void AfterTest() = 0; |
| 248 virtual void WillBeginTest(); | 248 virtual void WillBeginTest(); |
| 249 virtual void BeginTest() = 0; | 249 virtual void BeginTest() = 0; |
| 250 virtual void SetupTree(); | 250 virtual void SetupTree(); |
| 251 | 251 |
| 252 // TODO(khushalsagar): Add mode for running remote channel tests. |
| 252 virtual void RunTest(bool threaded, bool delegating_renderer); | 253 virtual void RunTest(bool threaded, bool delegating_renderer); |
| 253 | 254 |
| 254 bool HasImplThread() { return !!impl_thread_; } | 255 bool HasImplThread() const { return !!impl_thread_; } |
| 255 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { | 256 base::SingleThreadTaskRunner* ImplThreadTaskRunner() { |
| 256 DCHECK(task_runner_provider()); | 257 DCHECK(task_runner_provider()); |
| 257 base::SingleThreadTaskRunner* impl_thread_task_runner = | 258 base::SingleThreadTaskRunner* impl_thread_task_runner = |
| 258 task_runner_provider()->ImplThreadTaskRunner(); | 259 task_runner_provider()->ImplThreadTaskRunner(); |
| 259 return impl_thread_task_runner ? impl_thread_task_runner | 260 return impl_thread_task_runner ? impl_thread_task_runner |
| 260 : main_task_runner_.get(); | 261 : main_task_runner_.get(); |
| 261 } | 262 } |
| 262 base::SingleThreadTaskRunner* MainThreadTaskRunner() { | 263 base::SingleThreadTaskRunner* MainThreadTaskRunner() { |
| 263 return main_task_runner_.get(); | 264 return main_task_runner_.get(); |
| 264 } | 265 } |
| 265 Proxy* proxy() const { | 266 Proxy* proxy() const { |
| 266 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; | 267 return layer_tree_host_ ? layer_tree_host_->proxy() : NULL; |
| 267 } | 268 } |
| 268 TaskRunnerProvider* task_runner_provider() const { | 269 TaskRunnerProvider* task_runner_provider() const { |
| 269 return layer_tree_host_ ? layer_tree_host_->task_runner_provider() | 270 return layer_tree_host_ ? layer_tree_host_->task_runner_provider() |
| 270 : nullptr; | 271 : nullptr; |
| 271 } | 272 } |
| 272 TaskGraphRunner* task_graph_runner() const { | 273 TaskGraphRunner* task_graph_runner() const { |
| 273 return task_graph_runner_.get(); | 274 return task_graph_runner_.get(); |
| 274 } | 275 } |
| 275 | 276 |
| 276 bool TestEnded() const { return ended_; } | 277 bool TestEnded() const { return ended_; } |
| 277 | 278 |
| 278 LayerTreeHost* layer_tree_host(); | 279 LayerTreeHost* layer_tree_host(); |
| 279 bool delegating_renderer() const { return delegating_renderer_; } | 280 bool delegating_renderer() const { return delegating_renderer_; } |
| 280 FakeOutputSurface* output_surface() { return output_surface_; } | 281 FakeOutputSurface* output_surface() { return output_surface_; } |
| 281 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const; | 282 int LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) const; |
| 282 | 283 |
| 284 // Use these only for ProxyMain tests in threaded mode. |
| 285 // TODO(khushalsagar): Update these when adding support for remote channel |
| 286 // tests. |
| 287 ProxyMain* GetProxyMain() const; |
| 288 ProxyImpl* GetProxyImpl() const; |
| 289 |
| 283 void DestroyLayerTreeHost(); | 290 void DestroyLayerTreeHost(); |
| 284 | 291 |
| 285 // By default, output surface recreation is synchronous. | 292 // By default, output surface recreation is synchronous. |
| 286 void RequestNewOutputSurface() override; | 293 void RequestNewOutputSurface() override; |
| 287 // Override this for pixel tests, where you need a real output surface. | 294 // Override this for pixel tests, where you need a real output surface. |
| 288 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); | 295 virtual scoped_ptr<OutputSurface> CreateOutputSurface(); |
| 289 // Override this for unit tests, which should not produce pixel output. | 296 // Override this for unit tests, which should not produce pixel output. |
| 290 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); | 297 virtual scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(); |
| 291 | 298 |
| 292 TestWebGraphicsContext3D* TestContext(); | 299 TestWebGraphicsContext3D* TestContext(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ | 378 #define SINGLE_AND_MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) \ |
| 372 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ | 379 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(TEST_FIXTURE_NAME); \ |
| 373 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) | 380 SINGLE_AND_MULTI_THREAD_DELEGATING_RENDERER_TEST_F(TEST_FIXTURE_NAME) |
| 374 | 381 |
| 375 // Some tests want to control when notify ready for activation occurs, | 382 // Some tests want to control when notify ready for activation occurs, |
| 376 // but this is not supported in the single-threaded case. | 383 // but this is not supported in the single-threaded case. |
| 377 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ | 384 #define MULTI_THREAD_BLOCKNOTIFY_TEST_F(TEST_FIXTURE_NAME) \ |
| 378 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) | 385 MULTI_THREAD_TEST_F(TEST_FIXTURE_NAME) |
| 379 | 386 |
| 380 #endif // CC_TEST_LAYER_TREE_TEST_H_ | 387 #endif // CC_TEST_LAYER_TREE_TEST_H_ |
| OLD | NEW |