| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TEST_HOOKS_H_ | 5 #ifndef CC_TEST_TEST_HOOKS_H_ |
| 6 #define CC_TEST_TEST_HOOKS_H_ | 6 #define CC_TEST_TEST_HOOKS_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "cc/animation/animation_delegate.h" | 9 #include "cc/animation/animation_delegate.h" |
| 10 #include "cc/trees/layer_tree_host.h" | 10 #include "cc/trees/layer_tree_host.h" |
| 11 #include "cc/trees/layer_tree_host_impl.h" | 11 #include "cc/trees/layer_tree_host_impl.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 namespace proto { | 15 namespace proto { |
| 16 class CompositorMessageToImpl; | 16 class CompositorMessageToImpl; |
| 17 } | 17 } |
| 18 | 18 |
| 19 // Used by test stubs to notify the test when something interesting happens. | 19 // Used by test stubs to notify the test when something interesting happens. |
| 20 class TestHooks : public AnimationDelegate { | 20 class TestHooks : public AnimationDelegate { |
| 21 public: | 21 public: |
| 22 TestHooks(); | 22 TestHooks(); |
| 23 ~TestHooks() override; | 23 ~TestHooks() override; |
| 24 | 24 |
| 25 // Compositor thread hooks. | |
| 26 virtual void CreateResourceAndRasterBufferProvider( | 25 virtual void CreateResourceAndRasterBufferProvider( |
| 27 LayerTreeHostImpl* host_impl, | 26 LayerTreeHostImpl* host_impl, |
| 28 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, | 27 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, |
| 29 std::unique_ptr<ResourcePool>* resource_pool); | 28 std::unique_ptr<ResourcePool>* resource_pool); |
| 30 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, | 29 virtual void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, |
| 31 const BeginFrameArgs& args) {} | 30 const BeginFrameArgs& args) {} |
| 32 virtual void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) {} | 31 virtual void DidFinishImplFrameOnThread(LayerTreeHostImpl* host_impl) {} |
| 33 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, | 32 virtual void BeginMainFrameAbortedOnThread(LayerTreeHostImpl* host_impl, |
| 34 CommitEarlyOutReason reason) {} | 33 CommitEarlyOutReason reason) {} |
| 35 virtual void ReadyToCommitOnThread(LayerTreeHostImpl* host_impl) {} | 34 virtual void ReadyToCommitOnThread(LayerTreeHostImpl* host_impl) {} |
| 36 virtual void WillPrepareTilesOnThread(LayerTreeHostImpl* host_impl) {} | 35 virtual void WillPrepareTilesOnThread(LayerTreeHostImpl* host_impl) {} |
| 37 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) {} | 36 virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) {} |
| 38 virtual void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) {} | 37 virtual void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) {} |
| 39 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) {} | 38 virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) {} |
| 40 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) {} | 39 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* host_impl) {} |
| 41 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) {} | 40 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) {} |
| 42 virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, | 41 virtual void InitializedRendererOnThread(LayerTreeHostImpl* host_impl, |
| 43 bool success) {} | 42 bool success) {} |
| 44 virtual DrawResult PrepareToDrawOnThread( | 43 virtual DrawResult PrepareToDrawOnThread( |
| 45 LayerTreeHostImpl* host_impl, | 44 LayerTreeHostImpl* host_impl, |
| 46 LayerTreeHostImpl::FrameData* frame_data, | 45 LayerTreeHostImpl::FrameData* frame_data, |
| 47 DrawResult draw_result); | 46 DrawResult draw_result); |
| 48 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) {} | 47 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) {} |
| 48 // Note that this is called asynchronously from the LayerTreeHostImpl |
| 49 // performing its draw, so you should record state you want to use here |
| 50 // in DrawLayersOnThread() instead. For that reason this method does not |
| 51 // receive a LayerTreeHostImpl pointer. |
| 52 virtual void SwapBuffersCompleteOnThread() {} |
| 49 virtual void NotifyReadyToActivateOnThread(LayerTreeHostImpl* host_impl) {} | 53 virtual void NotifyReadyToActivateOnThread(LayerTreeHostImpl* host_impl) {} |
| 50 virtual void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) {} | 54 virtual void NotifyReadyToDrawOnThread(LayerTreeHostImpl* host_impl) {} |
| 51 virtual void NotifyAllTileTasksCompleted(LayerTreeHostImpl* host_impl) {} | 55 virtual void NotifyAllTileTasksCompleted(LayerTreeHostImpl* host_impl) {} |
| 52 virtual void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, | 56 virtual void NotifyTileStateChangedOnThread(LayerTreeHostImpl* host_impl, |
| 53 const Tile* tile) {} | 57 const Tile* tile) {} |
| 54 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, | |
| 55 bool visible) {} | |
| 56 virtual void AnimateLayers(LayerTreeHostImpl* host_impl, | 58 virtual void AnimateLayers(LayerTreeHostImpl* host_impl, |
| 57 base::TimeTicks monotonic_time) {} | 59 base::TimeTicks monotonic_time) {} |
| 58 virtual void UpdateAnimationState(LayerTreeHostImpl* host_impl, | 60 virtual void UpdateAnimationState(LayerTreeHostImpl* host_impl, |
| 59 bool has_unfinished_animation) {} | 61 bool has_unfinished_animation) {} |
| 60 virtual void WillAnimateLayers(LayerTreeHostImpl* host_impl, | 62 virtual void WillAnimateLayers(LayerTreeHostImpl* host_impl, |
| 61 base::TimeTicks monotonic_time) {} | 63 base::TimeTicks monotonic_time) {} |
| 62 | |
| 63 // Asynchronous compositor thread hooks. | |
| 64 // These are called asynchronously from the LayerTreeHostImpl performing its | |
| 65 // draw, so you should record state you want to use here in | |
| 66 // DrawLayersOnThread() instead. For that reason these methods do not receive | |
| 67 // a LayerTreeHostImpl pointer. | |
| 68 virtual void DisplayReceivedCompositorFrameOnThread( | |
| 69 const CompositorFrame& frame) {} | |
| 70 virtual void DisplayWillDrawAndSwapOnThread( | |
| 71 bool will_draw_and_swap, | |
| 72 const RenderPassList& render_passes) {} | |
| 73 virtual void DisplayDidDrawAndSwapOnThread() {} | |
| 74 | |
| 75 // Main thread hooks. | |
| 76 virtual void ApplyViewportDeltas( | 64 virtual void ApplyViewportDeltas( |
| 77 const gfx::Vector2dF& inner_delta, | 65 const gfx::Vector2dF& inner_delta, |
| 78 const gfx::Vector2dF& outer_delta, | 66 const gfx::Vector2dF& outer_delta, |
| 79 const gfx::Vector2dF& elastic_overscroll_delta, | 67 const gfx::Vector2dF& elastic_overscroll_delta, |
| 80 float scale, | 68 float scale, |
| 81 float top_controls_delta) {} | 69 float top_controls_delta) {} |
| 82 virtual void BeginMainFrameNotExpectedSoon() {} | 70 virtual void BeginMainFrameNotExpectedSoon() {} |
| 83 virtual void BeginMainFrame(const BeginFrameArgs& args) {} | 71 virtual void BeginMainFrame(const BeginFrameArgs& args) {} |
| 84 virtual void WillBeginMainFrame() {} | 72 virtual void WillBeginMainFrame() {} |
| 85 virtual void DidBeginMainFrame() {} | 73 virtual void DidBeginMainFrame() {} |
| 86 virtual void UpdateLayerTreeHost() {} | 74 virtual void UpdateLayerTreeHost() {} |
| 87 virtual void DidInitializeOutputSurface() {} | 75 virtual void DidInitializeOutputSurface() {} |
| 88 virtual void DidFailToInitializeOutputSurface() {} | 76 virtual void DidFailToInitializeOutputSurface() {} |
| 89 virtual void DidAddAnimation() {} | 77 virtual void DidAddAnimation() {} |
| 90 virtual void WillCommit() {} | 78 virtual void WillCommit() {} |
| 91 virtual void DidCommit() {} | 79 virtual void DidCommit() {} |
| 92 virtual void DidCommitAndDrawFrame() {} | 80 virtual void DidCommitAndDrawFrame() {} |
| 93 virtual void DidCompleteSwapBuffers() {} | 81 virtual void DidCompleteSwapBuffers() {} |
| 82 virtual void DidSetVisibleOnImplTree(LayerTreeHostImpl* host_impl, |
| 83 bool visible) {} |
| 94 virtual void ScheduleComposite() {} | 84 virtual void ScheduleComposite() {} |
| 95 virtual void DidActivateSyncTree() {} | 85 virtual void DidActivateSyncTree() {} |
| 96 | 86 |
| 97 // AnimationDelegate implementation. | 87 // AnimationDelegate implementation. |
| 98 void NotifyAnimationStarted(base::TimeTicks monotonic_time, | 88 void NotifyAnimationStarted(base::TimeTicks monotonic_time, |
| 99 TargetProperty::Type target_property, | 89 TargetProperty::Type target_property, |
| 100 int group) override {} | 90 int group) override {} |
| 101 void NotifyAnimationFinished(base::TimeTicks monotonic_time, | 91 void NotifyAnimationFinished(base::TimeTicks monotonic_time, |
| 102 TargetProperty::Type target_property, | 92 TargetProperty::Type target_property, |
| 103 int group) override {} | 93 int group) override {} |
| (...skipping 14 matching lines...) Expand all Loading... |
| 118 const proto::CompositorMessageToImpl& proto) {} | 108 const proto::CompositorMessageToImpl& proto) {} |
| 119 | 109 |
| 120 // Used to notify the test to destroy the Remote client LayerTreeHost on | 110 // Used to notify the test to destroy the Remote client LayerTreeHost on |
| 121 // receiving a CompositorMessageToImpl of type CLOSE_IMPL. | 111 // receiving a CompositorMessageToImpl of type CLOSE_IMPL. |
| 122 virtual void DestroyRemoteClientHost() {} | 112 virtual void DestroyRemoteClientHost() {} |
| 123 }; | 113 }; |
| 124 | 114 |
| 125 } // namespace cc | 115 } // namespace cc |
| 126 | 116 |
| 127 #endif // CC_TEST_TEST_HOOKS_H_ | 117 #endif // CC_TEST_TEST_HOOKS_H_ |
| OLD | NEW |