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