Chromium Code Reviews| 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 BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ | 5 #ifndef BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
| 6 #define BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ | 6 #define BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 | 29 |
| 30 namespace cc { | 30 namespace cc { |
| 31 class InputHandler; | 31 class InputHandler; |
| 32 | 32 |
| 33 namespace proto { | 33 namespace proto { |
| 34 class CompositorMessage; | 34 class CompositorMessage; |
| 35 } // namespace proto | 35 } // namespace proto |
| 36 | 36 |
| 37 class CompositorStateDeserializer; | 37 class CompositorStateDeserializer; |
| 38 class ContextProvider; | 38 class ContextProvider; |
| 39 class CopyOutputRequest; | |
| 39 class Layer; | 40 class Layer; |
| 40 class LayerTreeHost; | 41 class LayerTreeHost; |
| 41 class LayerTreeSettings; | 42 class LayerTreeSettings; |
| 42 class LocalFrameid; | 43 class LocalFrameid; |
| 43 class Surface; | 44 class Surface; |
| 44 class SurfaceFactory; | 45 class SurfaceFactory; |
| 45 class SurfaceIdAllocator; | 46 class SurfaceIdAllocator; |
| 46 } // namespace cc | 47 } // namespace cc |
| 47 | 48 |
| 48 namespace blimp { | 49 namespace blimp { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 public cc::CompositorStateDeserializerClient { | 84 public cc::CompositorStateDeserializerClient { |
| 84 public: | 85 public: |
| 85 BlimpCompositor(BlimpCompositorDependencies* compositor_dependencies, | 86 BlimpCompositor(BlimpCompositorDependencies* compositor_dependencies, |
| 86 BlimpCompositorClient* client, | 87 BlimpCompositorClient* client, |
| 87 bool use_threaded_layer_tree_host); | 88 bool use_threaded_layer_tree_host); |
| 88 | 89 |
| 89 ~BlimpCompositor() override; | 90 ~BlimpCompositor() override; |
| 90 | 91 |
| 91 virtual void SetVisible(bool visible); | 92 virtual void SetVisible(bool visible); |
| 92 | 93 |
| 93 // Notifies |callback| when all pending commits have been drawn to the screen. | 94 // Requests a copy of the compositor frame. |
| 94 // If this compositor is destroyed or becomes hidden |callback| will be | 95 // Setting |flush_pending_update| to true ensures that if a frame update on |
| 95 // notified. | 96 // the main thread is pending, then it is drawn before copying from the |
| 96 void NotifyWhenDonePendingCommits(base::Closure callback); | 97 // surface. |
| 98 void RequestCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> copy_request, | |
| 99 bool flush_pending_update); | |
| 97 | 100 |
| 98 // Called to forward the compositor message from the remote server | 101 // Called to forward the compositor message from the remote server |
| 99 // LayerTreeHost of the render widget for this compositor. | 102 // LayerTreeHost of the render widget for this compositor. |
| 100 // virtual for testing. | 103 // virtual for testing. |
| 101 virtual void OnCompositorMessageReceived( | 104 virtual void OnCompositorMessageReceived( |
| 102 std::unique_ptr<cc::proto::CompositorMessage> message); | 105 std::unique_ptr<cc::proto::CompositorMessage> message); |
| 103 | 106 |
| 104 scoped_refptr<cc::Layer> layer() const { return layer_; } | 107 scoped_refptr<cc::Layer> layer() const { return layer_; } |
| 105 | 108 |
| 106 // Returns a reference to the InputHandler used to respond to input events on | 109 // Returns a reference to the InputHandler used to respond to input events on |
| 107 // the compositor thread. | 110 // the compositor thread. |
| 108 const base::WeakPtr<cc::InputHandler>& GetInputHandler(); | 111 const base::WeakPtr<cc::InputHandler>& GetInputHandler(); |
| 109 | 112 |
| 110 private: | 113 private: |
| 111 friend class BlimpCompositorForTesting; | 114 friend class BlimpCompositorForTesting; |
| 115 class FrameTrackingSwapPromise; | |
|
aelias_OOO_until_Jul13
2016/11/02 07:02:10
There's no need to put this in the header. Instea
Khushal
2016/11/02 07:24:21
I'm actually calling a private method from that cl
| |
| 112 | 116 |
| 113 // LayerTreeHostClient implementation. | 117 // LayerTreeHostClient implementation. |
| 114 void WillBeginMainFrame() override {} | 118 void WillBeginMainFrame() override {} |
| 115 void DidBeginMainFrame() override {} | 119 void DidBeginMainFrame() override {} |
| 116 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} | 120 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} |
| 117 void BeginMainFrameNotExpectedSoon() override {} | 121 void BeginMainFrameNotExpectedSoon() override {} |
| 118 void UpdateLayerTreeHost() override; | 122 void UpdateLayerTreeHost() override; |
| 119 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | 123 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
| 120 const gfx::Vector2dF& outer_delta, | 124 const gfx::Vector2dF& outer_delta, |
| 121 const gfx::Vector2dF& elastic_overscroll_delta, | 125 const gfx::Vector2dF& elastic_overscroll_delta, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 void DestroyDelegatedContent(); | 173 void DestroyDelegatedContent(); |
| 170 | 174 |
| 171 // Helper method to build the internal CC LayerTreeHost instance from | 175 // Helper method to build the internal CC LayerTreeHost instance from |
| 172 // |message|. | 176 // |message|. |
| 173 void CreateLayerTreeHost(); | 177 void CreateLayerTreeHost(); |
| 174 | 178 |
| 175 // Helper method to destroy the internal CC LayerTreeHost instance and all its | 179 // Helper method to destroy the internal CC LayerTreeHost instance and all its |
| 176 // associated state. | 180 // associated state. |
| 177 void DestroyLayerTreeHost(); | 181 void DestroyLayerTreeHost(); |
| 178 | 182 |
| 179 // Updates |pending_commit_trackers_|, decrementing the count and, if 0, | |
| 180 // notifying the callback. If |flush| is true, flushes all entries regardless | |
| 181 // of the count. | |
| 182 void CheckPendingCommitCounts(bool flush); | |
| 183 | |
| 184 // Acks a submitted CompositorFrame when it has been processed and another | 183 // Acks a submitted CompositorFrame when it has been processed and another |
| 185 // frame should be started. | 184 // frame should be started. |
| 186 void SubmitCompositorFrameAck(); | 185 void SubmitCompositorFrameAck(); |
| 187 | 186 |
| 188 // Called when the local copy of the layer with |engine_layer_id| on the | 187 // Called when the local copy of the layer with |engine_layer_id| on the |
| 189 // engine was scrolled on the compositor thread. | 188 // engine was scrolled on the compositor thread. |
| 190 void LayerScrolled(int engine_layer_id); | 189 void LayerScrolled(int engine_layer_id); |
| 191 | 190 |
| 192 // Set to true if we are using a LayerTreeHostInProcess to process frame | 191 // Set to true if we are using a LayerTreeHostInProcess to process frame |
| 193 // updates from the engine. | 192 // updates from the engine. |
| 194 const bool use_threaded_layer_tree_host_; | 193 const bool use_threaded_layer_tree_host_; |
| 195 | 194 |
| 195 void MakeCopyRequestOnNextSwap( | |
| 196 std::unique_ptr<cc::CopyOutputRequest> copy_request); | |
| 197 | |
| 198 void RequestCopyOfOutputDeprecated( | |
| 199 std::unique_ptr<cc::CopyOutputRequest> copy_request); | |
| 200 | |
| 196 BlimpCompositorClient* client_; | 201 BlimpCompositorClient* client_; |
| 197 | 202 |
| 198 BlimpCompositorDependencies* compositor_dependencies_; | 203 BlimpCompositorDependencies* compositor_dependencies_; |
| 199 | 204 |
| 200 cc::FrameSinkId frame_sink_id_; | 205 cc::FrameSinkId frame_sink_id_; |
| 201 | 206 |
| 202 std::unique_ptr<cc::LayerTreeHost> host_; | 207 std::unique_ptr<cc::LayerTreeHost> host_; |
| 203 | 208 |
| 204 // The SurfaceFactory is bound to the lifetime of the |proxy_client_|. When | 209 // The SurfaceFactory is bound to the lifetime of the |proxy_client_|. When |
| 205 // detached, the surface factory will be destroyed. | 210 // detached, the surface factory will be destroyed. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 217 | 222 |
| 218 // Surfaces related stuff and layer which holds the delegated content from the | 223 // Surfaces related stuff and layer which holds the delegated content from the |
| 219 // compositor. | 224 // compositor. |
| 220 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 225 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 221 scoped_refptr<cc::Layer> layer_; | 226 scoped_refptr<cc::Layer> layer_; |
| 222 | 227 |
| 223 // To be notified of any incoming compositor protos that are specifically sent | 228 // To be notified of any incoming compositor protos that are specifically sent |
| 224 // to |render_widget_id_|. | 229 // to |render_widget_id_|. |
| 225 cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_; | 230 cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_; |
| 226 | 231 |
| 232 std::vector<std::unique_ptr<cc::CopyOutputRequest>> | |
| 233 copy_requests_for_next_swap_; | |
| 234 | |
| 227 // The number of times a START_COMMIT proto has been received but a call to | 235 // The number of times a START_COMMIT proto has been received but a call to |
| 228 // DidCommitAndDrawFrame hasn't been seen. This should track the number of | 236 // DidCommitAndDrawFrame hasn't been seen. This should track the number of |
| 229 // outstanding commits. | 237 // outstanding commits. |
| 230 size_t outstanding_commits_; | 238 size_t outstanding_commits_; |
| 231 | 239 |
| 232 // When NotifyWhenDonePendingCommitsis called |outstanding_commits_| is copied | 240 // When NotifyWhenDonePendingCommitsis called |outstanding_commits_| is copied |
|
aelias_OOO_until_Jul13
2016/11/02 07:02:10
This comment needs to be updated.
Khushal
2016/11/02 07:31:32
Done.
| |
| 233 // along with the |callback| into this vector. Each time | 241 // along with the |callback| into this vector. Each time |
| 234 // DidCommitAndDrawFrame is called these entries get decremented. If they hit | 242 // DidCommitAndDrawFrame is called these entries get decremented. If they hit |
| 235 // 0 the callback is triggered. | 243 // 0 the callback is triggered. |
| 236 std::vector<std::pair<size_t, base::Closure>> pending_commit_trackers_; | 244 std::vector<std::pair<size_t, std::unique_ptr<cc::CopyOutputRequest>>> |
| 245 pending_commit_trackers_; | |
| 237 | 246 |
| 238 // Stores a frame update received from the engine, when a threaded | 247 // Stores a frame update received from the engine, when a threaded |
| 239 // LayerTreeHost is used. There can only be a single frame in flight at any | 248 // LayerTreeHost is used. There can only be a single frame in flight at any |
| 240 // point. | 249 // point. |
| 241 std::unique_ptr<cc::proto::CompositorMessage> pending_frame_update_; | 250 std::unique_ptr<cc::proto::CompositorMessage> pending_frame_update_; |
| 242 | 251 |
| 243 // Used with a threaded LayerTreeHost to deserialize proto updates from the | 252 // Used with a threaded LayerTreeHost to deserialize proto updates from the |
| 244 // engine into the LayerTree. | 253 // engine into the LayerTree. |
| 245 std::unique_ptr<cc::CompositorStateDeserializer> | 254 std::unique_ptr<cc::CompositorStateDeserializer> |
| 246 compositor_state_deserializer_; | 255 compositor_state_deserializer_; |
| 247 | 256 |
| 248 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_; | 257 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_; |
| 249 | 258 |
| 250 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); | 259 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); |
| 251 }; | 260 }; |
| 252 | 261 |
| 253 } // namespace client | 262 } // namespace client |
| 254 } // namespace blimp | 263 } // namespace blimp |
| 255 | 264 |
| 256 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ | 265 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
| OLD | NEW |