Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: blimp/client/core/compositor/blimp_compositor.h

Issue 2415633003: blimp: Add mode to use the updated compositing path on the client. (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | blimp/client/core/compositor/blimp_compositor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "blimp/client/core/compositor/blimp_compositor_frame_sink_proxy.h" 14 #include "blimp/client/core/compositor/blimp_compositor_frame_sink_proxy.h"
15 #include "blimp/client/public/compositor/compositor_dependencies.h" 15 #include "blimp/client/public/compositor/compositor_dependencies.h"
16 #include "cc/blimp/compositor_state_deserializer_client.h"
16 #include "cc/surfaces/surface_factory_client.h" 17 #include "cc/surfaces/surface_factory_client.h"
17 #include "cc/trees/layer_tree_host.h" 18 #include "cc/trees/layer_tree_host.h"
18 #include "cc/trees/layer_tree_host_client.h" 19 #include "cc/trees/layer_tree_host_client.h"
19 #include "cc/trees/layer_tree_settings.h" 20 #include "cc/trees/layer_tree_settings.h"
20 #include "cc/trees/remote_proto_channel.h" 21 #include "cc/trees/remote_proto_channel.h"
21 #include "ui/gfx/geometry/size.h" 22 #include "ui/gfx/geometry/size.h"
22 #include "ui/gfx/native_widget_types.h" 23 #include "ui/gfx/native_widget_types.h"
23 24
24 namespace base { 25 namespace base {
25 class SingleThreadTaskRunner; 26 class SingleThreadTaskRunner;
26 class Thread; 27 class Thread;
27 } // namespace base 28 } // namespace base
28 29
29 namespace cc { 30 namespace cc {
30 class InputHandler; 31 class InputHandler;
31 32
32 namespace proto { 33 namespace proto {
33 class CompositorMessage; 34 class CompositorMessage;
34 } // namespace proto 35 } // namespace proto
35 36
37 class CompositorStateDeserializer;
36 class ContextProvider; 38 class ContextProvider;
37 class Layer; 39 class Layer;
38 class LayerTreeHost; 40 class LayerTreeHost;
39 class LayerTreeSettings; 41 class LayerTreeSettings;
40 class LocalFrameid; 42 class LocalFrameid;
41 class Surface; 43 class Surface;
42 class SurfaceFactory; 44 class SurfaceFactory;
43 class SurfaceIdAllocator; 45 class SurfaceIdAllocator;
44 } // namespace cc 46 } // namespace cc
45 47
(...skipping 24 matching lines...) Expand all
70 // performs the compositing work for the remote server LayerTreeHost. The server 72 // performs the compositing work for the remote server LayerTreeHost. The server
71 // LayerTreeHost for a BlimpCompositor is owned by the 73 // LayerTreeHost for a BlimpCompositor is owned by the
72 // content::RenderWidgetCompositor. Thus, each BlimpCompositor is tied to a 74 // content::RenderWidgetCompositor. Thus, each BlimpCompositor is tied to a
73 // RenderWidget, identified by a custom |render_widget_id| generated on the 75 // RenderWidget, identified by a custom |render_widget_id| generated on the
74 // engine. The lifetime of this compositor is controlled by its corresponding 76 // engine. The lifetime of this compositor is controlled by its corresponding
75 // RenderWidget. 77 // RenderWidget.
76 // This class should only be accessed from the main thread. 78 // This class should only be accessed from the main thread.
77 class BlimpCompositor : public cc::LayerTreeHostClient, 79 class BlimpCompositor : public cc::LayerTreeHostClient,
78 public cc::RemoteProtoChannel, 80 public cc::RemoteProtoChannel,
79 public BlimpCompositorFrameSinkProxy, 81 public BlimpCompositorFrameSinkProxy,
80 public cc::SurfaceFactoryClient { 82 public cc::SurfaceFactoryClient,
83 public cc::CompositorStateDeserializerClient {
81 public: 84 public:
82 BlimpCompositor(BlimpCompositorDependencies* compositor_dependencies, 85 BlimpCompositor(BlimpCompositorDependencies* compositor_dependencies,
83 BlimpCompositorClient* client); 86 BlimpCompositorClient* client,
87 bool use_threaded_layer_tree_host);
84 88
85 ~BlimpCompositor() override; 89 ~BlimpCompositor() override;
86 90
87 virtual void SetVisible(bool visible); 91 virtual void SetVisible(bool visible);
88 92
89 // Notifies |callback| when all pending commits have been drawn to the screen. 93 // Notifies |callback| when all pending commits have been drawn to the screen.
90 // If this compositor is destroyed or becomes hidden |callback| will be 94 // If this compositor is destroyed or becomes hidden |callback| will be
91 // notified. 95 // notified.
92 void NotifyWhenDonePendingCommits(base::Closure callback); 96 void NotifyWhenDonePendingCommits(base::Closure callback);
93 97
(...skipping 10 matching lines...) Expand all
104 const base::WeakPtr<cc::InputHandler>& GetInputHandler(); 108 const base::WeakPtr<cc::InputHandler>& GetInputHandler();
105 109
106 private: 110 private:
107 friend class BlimpCompositorForTesting; 111 friend class BlimpCompositorForTesting;
108 112
109 // LayerTreeHostClient implementation. 113 // LayerTreeHostClient implementation.
110 void WillBeginMainFrame() override {} 114 void WillBeginMainFrame() override {}
111 void DidBeginMainFrame() override {} 115 void DidBeginMainFrame() override {}
112 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} 116 void BeginMainFrame(const cc::BeginFrameArgs& args) override {}
113 void BeginMainFrameNotExpectedSoon() override {} 117 void BeginMainFrameNotExpectedSoon() override {}
114 void UpdateLayerTreeHost() override {} 118 void UpdateLayerTreeHost() override;
115 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, 119 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
116 const gfx::Vector2dF& outer_delta, 120 const gfx::Vector2dF& outer_delta,
117 const gfx::Vector2dF& elastic_overscroll_delta, 121 const gfx::Vector2dF& elastic_overscroll_delta,
118 float page_scale, 122 float page_scale,
119 float top_controls_delta) override {} 123 float top_controls_delta) override {}
120 void RequestNewCompositorFrameSink() override; 124 void RequestNewCompositorFrameSink() override;
121 void DidInitializeCompositorFrameSink() override; 125 void DidInitializeCompositorFrameSink() override;
122 // TODO(khushalsagar): Need to handle context initialization failures. 126 // TODO(khushalsagar): Need to handle context initialization failures.
123 void DidFailToInitializeCompositorFrameSink() override {} 127 void DidFailToInitializeCompositorFrameSink() override {}
124 void WillCommit() override {} 128 void WillCommit() override {}
125 void DidCommit() override {} 129 void DidCommit() override {}
126 void DidCommitAndDrawFrame() override; 130 void DidCommitAndDrawFrame() override;
127 void DidReceiveCompositorFrameAck() override {} 131 void DidReceiveCompositorFrameAck() override {}
128 void DidCompletePageScaleAnimation() override {} 132 void DidCompletePageScaleAnimation() override {}
129 133
130 // RemoteProtoChannel implementation. 134 // RemoteProtoChannel implementation.
131 void SetProtoReceiver(ProtoReceiver* receiver) override; 135 void SetProtoReceiver(ProtoReceiver* receiver) override;
132 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override; 136 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override;
133 137
134 // BlimpCompositorFrameSinkProxy implementation. 138 // BlimpCompositorFrameSinkProxy implementation.
135 void BindToProxyClient( 139 void BindToProxyClient(
136 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) override; 140 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) override;
137 void SubmitCompositorFrame(cc::CompositorFrame frame) override; 141 void SubmitCompositorFrame(cc::CompositorFrame frame) override;
138 void UnbindProxyClient() override; 142 void UnbindProxyClient() override;
139 143
140 // SurfaceFactoryClient implementation. 144 // SurfaceFactoryClient implementation.
141 void ReturnResources(const cc::ReturnedResourceArray& resources) override; 145 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
142 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {} 146 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {}
143 147
148 // CompositorStateDeserializerClient implementation.
149 bool ShouldRetainClientScroll(int engine_layer_id,
150 const gfx::ScrollOffset& new_offset) override;
151 bool ShouldRetainClientPageScale(float new_page_scale) override;
152
153 void HandleCompositorMessageToImpl(
154 std::unique_ptr<cc::proto::CompositorMessage> message);
155
144 // Called when the a ContextProvider has been created by the 156 // Called when the a ContextProvider has been created by the
145 // CompositorDependencies class. If |host_| is waiting on an 157 // CompositorDependencies class. If |host_| is waiting on an
146 // CompositorFrameSink this will build one for it. 158 // CompositorFrameSink this will build one for it.
147 void OnContextProvidersCreated( 159 void OnContextProvidersCreated(
148 const scoped_refptr<cc::ContextProvider>& compositor_context_provider, 160 const scoped_refptr<cc::ContextProvider>& compositor_context_provider,
149 const scoped_refptr<cc::ContextProvider>& worker_context_provider); 161 const scoped_refptr<cc::ContextProvider>& worker_context_provider);
150 162
151 // Helper method to get the embedder dependencies. 163 // Helper method to get the embedder dependencies.
152 CompositorDependencies* GetEmbedderDeps(); 164 CompositorDependencies* GetEmbedderDeps();
153 165
(...skipping 12 matching lines...) Expand all
166 178
167 // Updates |pending_commit_trackers_|, decrementing the count and, if 0, 179 // Updates |pending_commit_trackers_|, decrementing the count and, if 0,
168 // notifying the callback. If |flush| is true, flushes all entries regardless 180 // notifying the callback. If |flush| is true, flushes all entries regardless
169 // of the count. 181 // of the count.
170 void CheckPendingCommitCounts(bool flush); 182 void CheckPendingCommitCounts(bool flush);
171 183
172 // Acks a submitted CompositorFrame when it has been processed and another 184 // Acks a submitted CompositorFrame when it has been processed and another
173 // frame should be started. 185 // frame should be started.
174 void SubmitCompositorFrameAck(); 186 void SubmitCompositorFrameAck();
175 187
188 // Called when the local copy of the layer with |engine_layer_id| on the
189 // engine was scrolled on the compositor thread.
190 void LayerScrolled(int engine_layer_id);
191
192 // Set to true if we are using a LayerTreeHostInProcess to process frame
193 // updates from the engine.
194 const bool use_threaded_layer_tree_host_;
195
176 BlimpCompositorClient* client_; 196 BlimpCompositorClient* client_;
177 197
178 BlimpCompositorDependencies* compositor_dependencies_; 198 BlimpCompositorDependencies* compositor_dependencies_;
179 199
180 cc::FrameSinkId frame_sink_id_; 200 cc::FrameSinkId frame_sink_id_;
181 201
182 std::unique_ptr<cc::LayerTreeHost> host_; 202 std::unique_ptr<cc::LayerTreeHost> host_;
183 203
184 // The SurfaceFactory is bound to the lifetime of the |proxy_client_|. When 204 // The SurfaceFactory is bound to the lifetime of the |proxy_client_|. When
185 // detached, the surface factory will be destroyed. 205 // detached, the surface factory will be destroyed.
(...skipping 22 matching lines...) Expand all
208 // DidCommitAndDrawFrame hasn't been seen. This should track the number of 228 // DidCommitAndDrawFrame hasn't been seen. This should track the number of
209 // outstanding commits. 229 // outstanding commits.
210 size_t outstanding_commits_; 230 size_t outstanding_commits_;
211 231
212 // When NotifyWhenDonePendingCommitsis called |outstanding_commits_| is copied 232 // When NotifyWhenDonePendingCommitsis called |outstanding_commits_| is copied
213 // along with the |callback| into this vector. Each time 233 // along with the |callback| into this vector. Each time
214 // DidCommitAndDrawFrame is called these entries get decremented. If they hit 234 // DidCommitAndDrawFrame is called these entries get decremented. If they hit
215 // 0 the callback is triggered. 235 // 0 the callback is triggered.
216 std::vector<std::pair<size_t, base::Closure>> pending_commit_trackers_; 236 std::vector<std::pair<size_t, base::Closure>> pending_commit_trackers_;
217 237
238 // 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
240 // point.
241 std::unique_ptr<cc::proto::CompositorMessage> pending_frame_update_;
242
243 // Used with a threaded LayerTreeHost to deserialize proto updates from the
244 // engine into the LayerTree.
245 std::unique_ptr<cc::CompositorStateDeserializer>
246 compositor_state_deserializer_;
247
218 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_; 248 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_;
219 249
220 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); 250 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor);
221 }; 251 };
222 252
223 } // namespace client 253 } // namespace client
224 } // namespace blimp 254 } // namespace blimp
225 255
226 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ 256 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « no previous file | blimp/client/core/compositor/blimp_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698