| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_TREES_REMOTE_CHANNEL_IMPL_H_ | 5 #ifndef CC_TREES_REMOTE_CHANNEL_IMPL_H_ |
| 6 #define CC_TREES_REMOTE_CHANNEL_IMPL_H_ | 6 #define CC_TREES_REMOTE_CHANNEL_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 bool started; | 98 bool started; |
| 99 | 99 |
| 100 // This is set to true if we lost the output surface and can not push any | 100 // This is set to true if we lost the output surface and can not push any |
| 101 // commits to the impl thread. | 101 // commits to the impl thread. |
| 102 bool waiting_for_output_surface_initialization; | 102 bool waiting_for_output_surface_initialization; |
| 103 | 103 |
| 104 // The queue of messages received from the server. The messages are added to | 104 // The queue of messages received from the server. The messages are added to |
| 105 // this queue if we are waiting for a new output surface to be initialized. | 105 // this queue if we are waiting for a new output surface to be initialized. |
| 106 std::queue<proto::CompositorMessageToImpl> pending_messages; | 106 std::queue<proto::CompositorMessageToImpl> pending_messages; |
| 107 | 107 |
| 108 RendererCapabilities renderer_capabilities; |
| 109 |
| 108 base::WeakPtrFactory<RemoteChannelImpl> remote_channel_weak_factory; | 110 base::WeakPtrFactory<RemoteChannelImpl> remote_channel_weak_factory; |
| 109 | 111 |
| 110 MainThreadOnly(RemoteChannelImpl*, | 112 MainThreadOnly(RemoteChannelImpl*, |
| 111 LayerTreeHost* layer_tree_host, | 113 LayerTreeHost* layer_tree_host, |
| 112 RemoteProtoChannel* remote_proto_channel); | 114 RemoteProtoChannel* remote_proto_channel); |
| 113 ~MainThreadOnly(); | 115 ~MainThreadOnly(); |
| 114 }; | 116 }; |
| 115 | 117 |
| 116 struct CompositorThreadOnly { | 118 struct CompositorThreadOnly { |
| 117 std::unique_ptr<ProxyImpl> proxy_impl; | 119 std::unique_ptr<ProxyImpl> proxy_impl; |
| 118 std::unique_ptr<base::WeakPtrFactory<ProxyImpl>> proxy_impl_weak_factory; | 120 std::unique_ptr<base::WeakPtrFactory<ProxyImpl>> proxy_impl_weak_factory; |
| 119 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr; | 121 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr; |
| 120 | 122 |
| 121 CompositorThreadOnly( | 123 CompositorThreadOnly( |
| 122 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr); | 124 base::WeakPtr<RemoteChannelImpl> remote_channel_weak_ptr); |
| 123 ~CompositorThreadOnly(); | 125 ~CompositorThreadOnly(); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 // called on main thread. | 128 // called on main thread. |
| 127 // RemoteProtoChannel::ProtoReceiver implementation. | 129 // RemoteProtoChannel::ProtoReceiver implementation. |
| 128 void OnProtoReceived( | 130 void OnProtoReceived( |
| 129 std::unique_ptr<proto::CompositorMessage> proto) override; | 131 std::unique_ptr<proto::CompositorMessage> proto) override; |
| 130 | 132 |
| 131 // Proxy implementation | 133 // Proxy implementation |
| 132 bool IsStarted() const override; | 134 bool IsStarted() const override; |
| 133 bool CommitToActiveTree() const override; | 135 bool CommitToActiveTree() const override; |
| 134 void SetOutputSurface(OutputSurface* output_surface) override; | 136 void SetOutputSurface(OutputSurface* output_surface) override; |
| 135 void ReleaseOutputSurface() override; | 137 void ReleaseOutputSurface() override; |
| 136 void SetVisible(bool visible) override; | 138 void SetVisible(bool visible) override; |
| 139 const RendererCapabilities& GetRendererCapabilities() const override; |
| 137 void SetNeedsAnimate() override; | 140 void SetNeedsAnimate() override; |
| 138 void SetNeedsUpdateLayers() override; | 141 void SetNeedsUpdateLayers() override; |
| 139 void SetNeedsCommit() override; | 142 void SetNeedsCommit() override; |
| 140 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 143 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
| 141 void SetNextCommitWaitsForActivation() override; | 144 void SetNextCommitWaitsForActivation() override; |
| 142 void NotifyInputThrottledUntilCommit() override; | 145 void NotifyInputThrottledUntilCommit() override; |
| 143 void SetDeferCommits(bool defer_commits) override; | 146 void SetDeferCommits(bool defer_commits) override; |
| 144 void MainThreadHasStoppedFlinging() override; | 147 void MainThreadHasStoppedFlinging() override; |
| 145 bool CommitRequested() const override; | 148 bool CommitRequested() const override; |
| 146 bool BeginMainFrameRequested() const override; | 149 bool BeginMainFrameRequested() const override; |
| 147 void Start( | 150 void Start( |
| 148 std::unique_ptr<BeginFrameSource> external_begin_frame_source) override; | 151 std::unique_ptr<BeginFrameSource> external_begin_frame_source) override; |
| 149 void Stop() override; | 152 void Stop() override; |
| 150 void SetMutator(std::unique_ptr<LayerTreeMutator> mutator) override; | 153 void SetMutator(std::unique_ptr<LayerTreeMutator> mutator) override; |
| 151 bool SupportsImplScrolling() const override; | 154 bool SupportsImplScrolling() const override; |
| 152 void UpdateTopControlsState(TopControlsState constraints, | 155 void UpdateTopControlsState(TopControlsState constraints, |
| 153 TopControlsState current, | 156 TopControlsState current, |
| 154 bool animate) override; | 157 bool animate) override; |
| 155 bool MainFrameWillHappenForTesting() override; | 158 bool MainFrameWillHappenForTesting() override; |
| 156 | 159 |
| 157 // Called on impl thread. | 160 // Called on impl thread. |
| 158 // ChannelImpl implementation | 161 // ChannelImpl implementation |
| 159 void DidCompleteSwapBuffers() override; | 162 void DidCompleteSwapBuffers() override; |
| 163 void SetRendererCapabilitiesMainCopy( |
| 164 const RendererCapabilities& capabilities) override; |
| 160 void BeginMainFrameNotExpectedSoon() override; | 165 void BeginMainFrameNotExpectedSoon() override; |
| 161 void DidCommitAndDrawFrame() override; | 166 void DidCommitAndDrawFrame() override; |
| 162 void SetAnimationEvents(std::unique_ptr<AnimationEvents> queue) override; | 167 void SetAnimationEvents(std::unique_ptr<AnimationEvents> queue) override; |
| 163 void DidLoseOutputSurface() override; | 168 void DidLoseOutputSurface() override; |
| 164 void RequestNewOutputSurface() override; | 169 void RequestNewOutputSurface() override; |
| 165 void DidInitializeOutputSurface(bool success) override; | 170 void DidInitializeOutputSurface( |
| 171 bool success, |
| 172 const RendererCapabilities& capabilities) override; |
| 166 void DidCompletePageScaleAnimation() override; | 173 void DidCompletePageScaleAnimation() override; |
| 167 void BeginMainFrame(std::unique_ptr<BeginMainFrameAndCommitState> | 174 void BeginMainFrame(std::unique_ptr<BeginMainFrameAndCommitState> |
| 168 begin_main_frame_state) override; | 175 begin_main_frame_state) override; |
| 169 | 176 |
| 170 void SendMessageProto(std::unique_ptr<proto::CompositorMessage> proto); | 177 void SendMessageProto(std::unique_ptr<proto::CompositorMessage> proto); |
| 171 | 178 |
| 172 // called on main thread. | 179 // called on main thread. |
| 173 void HandleProto(const proto::CompositorMessageToImpl& proto); | 180 void HandleProto(const proto::CompositorMessageToImpl& proto); |
| 174 void DidCompleteSwapBuffersOnMain(); | 181 void DidCompleteSwapBuffersOnMain(); |
| 175 void DidCommitAndDrawFrameOnMain(); | 182 void DidCommitAndDrawFrameOnMain(); |
| 176 void DidLoseOutputSurfaceOnMain(); | 183 void DidLoseOutputSurfaceOnMain(); |
| 177 void RequestNewOutputSurfaceOnMain(); | 184 void RequestNewOutputSurfaceOnMain(); |
| 178 void DidInitializeOutputSurfaceOnMain(bool success); | 185 void DidInitializeOutputSurfaceOnMain( |
| 186 bool success, |
| 187 const RendererCapabilities& capabilities); |
| 179 void SendMessageProtoOnMain(std::unique_ptr<proto::CompositorMessage> proto); | 188 void SendMessageProtoOnMain(std::unique_ptr<proto::CompositorMessage> proto); |
| 180 void PostSetNeedsRedrawToImpl(const gfx::Rect& damaged_rect); | 189 void PostSetNeedsRedrawToImpl(const gfx::Rect& damaged_rect); |
| 181 | 190 |
| 182 void InitializeImplOnImpl(CompletionEvent* completion, | 191 void InitializeImplOnImpl(CompletionEvent* completion, |
| 183 LayerTreeHost* layer_tree_host); | 192 LayerTreeHost* layer_tree_host); |
| 184 void ShutdownImplOnImpl(CompletionEvent* completion); | 193 void ShutdownImplOnImpl(CompletionEvent* completion); |
| 185 | 194 |
| 186 MainThreadOnly& main(); | 195 MainThreadOnly& main(); |
| 187 const MainThreadOnly& main() const; | 196 const MainThreadOnly& main() const; |
| 188 CompositorThreadOnly& impl(); | 197 CompositorThreadOnly& impl(); |
| 189 const CompositorThreadOnly& impl() const; | 198 const CompositorThreadOnly& impl() const; |
| 190 | 199 |
| 191 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; | 200 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; |
| 192 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; | 201 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; |
| 193 | 202 |
| 194 TaskRunnerProvider* task_runner_provider_; | 203 TaskRunnerProvider* task_runner_provider_; |
| 195 | 204 |
| 196 // use accessors instead of these variables directly | 205 // use accessors instead of these variables directly |
| 197 MainThreadOnly main_thread_vars_unsafe_; | 206 MainThreadOnly main_thread_vars_unsafe_; |
| 198 CompositorThreadOnly compositor_thread_vars_unsafe_; | 207 CompositorThreadOnly compositor_thread_vars_unsafe_; |
| 199 | 208 |
| 200 base::WeakPtr<ProxyImpl> proxy_impl_weak_ptr_; | 209 base::WeakPtr<ProxyImpl> proxy_impl_weak_ptr_; |
| 201 | 210 |
| 202 DISALLOW_COPY_AND_ASSIGN(RemoteChannelImpl); | 211 DISALLOW_COPY_AND_ASSIGN(RemoteChannelImpl); |
| 203 }; | 212 }; |
| 204 | 213 |
| 205 } // namespace cc | 214 } // namespace cc |
| 206 | 215 |
| 207 #endif // CC_TREES_REMOTE_CHANNEL_IMPL_H_ | 216 #endif // CC_TREES_REMOTE_CHANNEL_IMPL_H_ |
| OLD | NEW |