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 26 matching lines...) Expand all Loading... |
37 // | RemoteChannelImpl | 37 // | RemoteChannelImpl |
38 // --------------------------------------------------------------------------- | 38 // --------------------------------------------------------------------------- |
39 // RemoteChannelImpl::Start()---PostTask---> RemoteChannelImpl:: | 39 // RemoteChannelImpl::Start()---PostTask---> RemoteChannelImpl:: |
40 // InitializeImplOnImpl | 40 // InitializeImplOnImpl |
41 // | | 41 // | |
42 // ProxyImpl::Create | 42 // ProxyImpl::Create |
43 // | | 43 // | |
44 // . | 44 // . |
45 // . | 45 // . |
46 // ProxyImpl::ScheduledActionBegin | 46 // ProxyImpl::ScheduledActionBegin |
47 // OutputSurfaceCreation | 47 // CompositorFrameSinkCreation |
48 // | | 48 // | |
49 // ChannelImpl::RequestNewOutputSurface | 49 // ChannelImpl::RequestNewCompositorFrameSink |
50 // | | 50 // | |
51 // RemoteChannelImpl:: | | 51 // RemoteChannelImpl:: | |
52 // RequestNewOutputSurface()<----PostTask-------------- | 52 // RequestNewCompositorFrameSink()<----PostTask-------------- |
53 // . | 53 // . |
54 // . | 54 // . |
55 // | | 55 // | |
56 // RemoteChannelImpl:: | 56 // RemoteChannelImpl:: |
57 // ~RemoteChannelImpl() ---PostTask---> RemoteChannelImpl:: | 57 // ~RemoteChannelImpl() ---PostTask---> RemoteChannelImpl:: |
58 // ShutdownImplOnImpl | 58 // ShutdownImplOnImpl |
59 // ---------------------------------------------------------------------------- | 59 // ---------------------------------------------------------------------------- |
60 // | 60 // |
61 // The class is created and destroyed on the main thread but can be safely | 61 // The class is created and destroyed on the main thread but can be safely |
62 // called from the main or impl thread. It is safe to call RemoteChannelImpl on | 62 // called from the main or impl thread. It is safe to call RemoteChannelImpl on |
(...skipping 29 matching lines...) Expand all Loading... |
92 | 92 |
93 private: | 93 private: |
94 struct MainThreadOnly { | 94 struct MainThreadOnly { |
95 LayerTreeHost* layer_tree_host; | 95 LayerTreeHost* layer_tree_host; |
96 RemoteProtoChannel* remote_proto_channel; | 96 RemoteProtoChannel* remote_proto_channel; |
97 | 97 |
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_compositor_frame_sink_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 base::WeakPtrFactory<RemoteChannelImpl> remote_channel_weak_factory; | 108 base::WeakPtrFactory<RemoteChannelImpl> remote_channel_weak_factory; |
109 | 109 |
110 MainThreadOnly(RemoteChannelImpl*, | 110 MainThreadOnly(RemoteChannelImpl*, |
111 LayerTreeHost* layer_tree_host, | 111 LayerTreeHost* layer_tree_host, |
112 RemoteProtoChannel* remote_proto_channel); | 112 RemoteProtoChannel* remote_proto_channel); |
(...skipping 11 matching lines...) Expand all Loading... |
124 }; | 124 }; |
125 | 125 |
126 // called on main thread. | 126 // called on main thread. |
127 // RemoteProtoChannel::ProtoReceiver implementation. | 127 // RemoteProtoChannel::ProtoReceiver implementation. |
128 void OnProtoReceived( | 128 void OnProtoReceived( |
129 std::unique_ptr<proto::CompositorMessage> proto) override; | 129 std::unique_ptr<proto::CompositorMessage> proto) override; |
130 | 130 |
131 // Proxy implementation | 131 // Proxy implementation |
132 bool IsStarted() const override; | 132 bool IsStarted() const override; |
133 bool CommitToActiveTree() const override; | 133 bool CommitToActiveTree() const override; |
134 void SetOutputSurface(OutputSurface* output_surface) override; | 134 void SetCompositorFrameSink( |
135 void ReleaseOutputSurface() override; | 135 CompositorFrameSink* compositor_frame_sink) override; |
| 136 void ReleaseCompositorFrameSink() override; |
136 void SetVisible(bool visible) override; | 137 void SetVisible(bool visible) override; |
137 void SetNeedsAnimate() override; | 138 void SetNeedsAnimate() override; |
138 void SetNeedsUpdateLayers() override; | 139 void SetNeedsUpdateLayers() override; |
139 void SetNeedsCommit() override; | 140 void SetNeedsCommit() override; |
140 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 141 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
141 void SetNextCommitWaitsForActivation() override; | 142 void SetNextCommitWaitsForActivation() override; |
142 void NotifyInputThrottledUntilCommit() override; | 143 void NotifyInputThrottledUntilCommit() override; |
143 void SetDeferCommits(bool defer_commits) override; | 144 void SetDeferCommits(bool defer_commits) override; |
144 void MainThreadHasStoppedFlinging() override; | 145 void MainThreadHasStoppedFlinging() override; |
145 bool CommitRequested() const override; | 146 bool CommitRequested() const override; |
146 bool BeginMainFrameRequested() const override; | 147 bool BeginMainFrameRequested() const override; |
147 void Start( | 148 void Start( |
148 std::unique_ptr<BeginFrameSource> external_begin_frame_source) override; | 149 std::unique_ptr<BeginFrameSource> external_begin_frame_source) override; |
149 void Stop() override; | 150 void Stop() override; |
150 void SetMutator(std::unique_ptr<LayerTreeMutator> mutator) override; | 151 void SetMutator(std::unique_ptr<LayerTreeMutator> mutator) override; |
151 bool SupportsImplScrolling() const override; | 152 bool SupportsImplScrolling() const override; |
152 void UpdateTopControlsState(TopControlsState constraints, | 153 void UpdateTopControlsState(TopControlsState constraints, |
153 TopControlsState current, | 154 TopControlsState current, |
154 bool animate) override; | 155 bool animate) override; |
155 bool MainFrameWillHappenForTesting() override; | 156 bool MainFrameWillHappenForTesting() override; |
156 | 157 |
157 // Called on impl thread. | 158 // Called on impl thread. |
158 // ChannelImpl implementation | 159 // ChannelImpl implementation |
159 void DidCompleteSwapBuffers() override; | 160 void DidCompleteSwapBuffers() override; |
160 void BeginMainFrameNotExpectedSoon() override; | 161 void BeginMainFrameNotExpectedSoon() override; |
161 void DidCommitAndDrawFrame() override; | 162 void DidCommitAndDrawFrame() override; |
162 void SetAnimationEvents(std::unique_ptr<AnimationEvents> queue) override; | 163 void SetAnimationEvents(std::unique_ptr<AnimationEvents> queue) override; |
163 void DidLoseOutputSurface() override; | 164 void DidLoseCompositorFrameSink() override; |
164 void RequestNewOutputSurface() override; | 165 void RequestNewCompositorFrameSink() override; |
165 void DidInitializeOutputSurface(bool success) override; | 166 void DidInitializeCompositorFrameSink(bool success) override; |
166 void DidCompletePageScaleAnimation() override; | 167 void DidCompletePageScaleAnimation() override; |
167 void BeginMainFrame(std::unique_ptr<BeginMainFrameAndCommitState> | 168 void BeginMainFrame(std::unique_ptr<BeginMainFrameAndCommitState> |
168 begin_main_frame_state) override; | 169 begin_main_frame_state) override; |
169 | 170 |
170 void SendMessageProto(std::unique_ptr<proto::CompositorMessage> proto); | 171 void SendMessageProto(std::unique_ptr<proto::CompositorMessage> proto); |
171 | 172 |
172 // called on main thread. | 173 // called on main thread. |
173 void HandleProto(const proto::CompositorMessageToImpl& proto); | 174 void HandleProto(const proto::CompositorMessageToImpl& proto); |
174 void DidCompleteSwapBuffersOnMain(); | 175 void DidCompleteSwapBuffersOnMain(); |
175 void DidCommitAndDrawFrameOnMain(); | 176 void DidCommitAndDrawFrameOnMain(); |
176 void DidLoseOutputSurfaceOnMain(); | 177 void DidLoseCompositorFrameSinkOnMain(); |
177 void RequestNewOutputSurfaceOnMain(); | 178 void RequestNewCompositorFrameSinkOnMain(); |
178 void DidInitializeOutputSurfaceOnMain(bool success); | 179 void DidInitializeCompositorFrameSinkOnMain(bool success); |
179 void SendMessageProtoOnMain(std::unique_ptr<proto::CompositorMessage> proto); | 180 void SendMessageProtoOnMain(std::unique_ptr<proto::CompositorMessage> proto); |
180 void PostSetNeedsRedrawToImpl(const gfx::Rect& damaged_rect); | 181 void PostSetNeedsRedrawToImpl(const gfx::Rect& damaged_rect); |
181 | 182 |
182 void InitializeImplOnImpl(CompletionEvent* completion, | 183 void InitializeImplOnImpl(CompletionEvent* completion, |
183 LayerTreeHost* layer_tree_host); | 184 LayerTreeHost* layer_tree_host); |
184 void ShutdownImplOnImpl(CompletionEvent* completion); | 185 void ShutdownImplOnImpl(CompletionEvent* completion); |
185 | 186 |
186 MainThreadOnly& main(); | 187 MainThreadOnly& main(); |
187 const MainThreadOnly& main() const; | 188 const MainThreadOnly& main() const; |
188 CompositorThreadOnly& impl(); | 189 CompositorThreadOnly& impl(); |
189 const CompositorThreadOnly& impl() const; | 190 const CompositorThreadOnly& impl() const; |
190 | 191 |
191 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; | 192 base::SingleThreadTaskRunner* MainThreadTaskRunner() const; |
192 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; | 193 base::SingleThreadTaskRunner* ImplThreadTaskRunner() const; |
193 | 194 |
194 TaskRunnerProvider* task_runner_provider_; | 195 TaskRunnerProvider* task_runner_provider_; |
195 | 196 |
196 // use accessors instead of these variables directly | 197 // use accessors instead of these variables directly |
197 MainThreadOnly main_thread_vars_unsafe_; | 198 MainThreadOnly main_thread_vars_unsafe_; |
198 CompositorThreadOnly compositor_thread_vars_unsafe_; | 199 CompositorThreadOnly compositor_thread_vars_unsafe_; |
199 | 200 |
200 base::WeakPtr<ProxyImpl> proxy_impl_weak_ptr_; | 201 base::WeakPtr<ProxyImpl> proxy_impl_weak_ptr_; |
201 | 202 |
202 DISALLOW_COPY_AND_ASSIGN(RemoteChannelImpl); | 203 DISALLOW_COPY_AND_ASSIGN(RemoteChannelImpl); |
203 }; | 204 }; |
204 | 205 |
205 } // namespace cc | 206 } // namespace cc |
206 | 207 |
207 #endif // CC_TREES_REMOTE_CHANNEL_IMPL_H_ | 208 #endif // CC_TREES_REMOTE_CHANNEL_IMPL_H_ |
OLD | NEW |