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

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

Issue 2274323002: Expose Blimp dependencies to the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@khushal_baseline_1
Patch Set: Addressed Khushal's initial comments Created 4 years, 4 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
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_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_H_ 5 #ifndef BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_H_
6 #define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_H_ 6 #define BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 11 matching lines...) Expand all
22 namespace base { 22 namespace base {
23 class SingleThreadTaskRunner; 23 class SingleThreadTaskRunner;
24 class Thread; 24 class Thread;
25 } // namespace base 25 } // namespace base
26 26
27 namespace cc { 27 namespace cc {
28 namespace proto { 28 namespace proto {
29 class CompositorMessage; 29 class CompositorMessage;
30 class InitializeImpl; 30 class InitializeImpl;
31 } // namespace proto 31 } // namespace proto
32
33 class ContextProvider;
32 class Layer; 34 class Layer;
33 class LayerTreeHost; 35 class LayerTreeHost;
36 class LayerTreeSettings;
34 class Surface; 37 class Surface;
38 class SurfaceFactory;
35 class SurfaceId; 39 class SurfaceId;
36 class SurfaceIdAllocator; 40 class SurfaceIdAllocator;
37 class SurfaceFactory;
38 class SurfaceManager;
39 } // namespace cc 41 } // namespace cc
40 42
41 namespace gpu {
42 class GpuMemoryBufferManager;
43 } // namespace gpu
44
45 namespace blimp { 43 namespace blimp {
46 class BlimpMessage; 44 class BlimpMessage;
47 45
48 namespace client { 46 namespace client {
49 47
48 class BlimpCompositorDependencies;
49 class CompositorDependencies;
50
50 // The BlimpCompositorClient provides the BlimpCompositor with the necessary 51 // The BlimpCompositorClient provides the BlimpCompositor with the necessary
51 // dependencies for cc::LayerTreeHost owned by this compositor and for 52 // dependencies for cc::LayerTreeHost owned by this compositor and for
52 // communicating the compositor and input messages to the corresponding 53 // communicating the compositor and input messages to the corresponding
53 // render widget of this compositor on the engine. 54 // render widget of this compositor on the engine.
54 class BlimpCompositorClient { 55 class BlimpCompositorClient {
55 public: 56 public:
56 // These methods should provide the dependencies for cc::LayerTreeHost for
57 // this compositor.
58 virtual cc::LayerTreeSettings* GetLayerTreeSettings() = 0;
59 virtual scoped_refptr<base::SingleThreadTaskRunner>
60 GetCompositorTaskRunner() = 0;
61 virtual cc::TaskGraphRunner* GetTaskGraphRunner() = 0;
62 virtual gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() = 0;
63 virtual cc::ImageSerializationProcessor* GetImageSerializationProcessor() = 0;
64
65 // Should send web gesture events which could not be handled locally by the 57 // Should send web gesture events which could not be handled locally by the
66 // compositor to the engine. 58 // compositor to the engine.
67 virtual void SendWebGestureEvent( 59 virtual void SendWebGestureEvent(
68 int render_widget_id, 60 int render_widget_id,
69 const blink::WebGestureEvent& gesture_event) = 0; 61 const blink::WebGestureEvent& gesture_event) = 0;
70 62
71 // Should send the compositor messages from the remote client LayerTreeHost of 63 // Should send the compositor messages from the remote client LayerTreeHost of
72 // this compositor to the corresponding remote server LayerTreeHost. 64 // this compositor to the corresponding remote server LayerTreeHost.
73 virtual void SendCompositorMessage( 65 virtual void SendCompositorMessage(
74 int render_widget_id, 66 int render_widget_id,
(...skipping 12 matching lines...) Expand all
87 // engine. The lifetime of this compositor is controlled by its corresponding 79 // engine. The lifetime of this compositor is controlled by its corresponding
88 // RenderWidget. 80 // RenderWidget.
89 // This class should only be accessed from the main thread. 81 // This class should only be accessed from the main thread.
90 class BlimpCompositor : public cc::LayerTreeHostClient, 82 class BlimpCompositor : public cc::LayerTreeHostClient,
91 public cc::RemoteProtoChannel, 83 public cc::RemoteProtoChannel,
92 public BlimpInputManagerClient, 84 public BlimpInputManagerClient,
93 public OutputSurfaceProxy, 85 public OutputSurfaceProxy,
94 public cc::SurfaceFactoryClient { 86 public cc::SurfaceFactoryClient {
95 public: 87 public:
96 BlimpCompositor(const int render_widget_id, 88 BlimpCompositor(const int render_widget_id,
97 cc::SurfaceManager* surface_manager, 89 BlimpCompositorDependencies* compositor_dependencies,
98 uint32_t surface_client_id,
99 BlimpCompositorClient* client); 90 BlimpCompositorClient* client);
100 91
101 ~BlimpCompositor() override; 92 ~BlimpCompositor() override;
102 93
103 virtual void SetVisible(bool visible); 94 virtual void SetVisible(bool visible);
104 95
105 // Forwards the touch event to the |input_manager_|. 96 // Forwards the touch event to the |input_manager_|.
106 // virtual for testing. 97 // virtual for testing.
107 virtual bool OnTouchEvent(const ui::MotionEvent& motion_event); 98 virtual bool OnTouchEvent(const ui::MotionEvent& motion_event);
108 99
109 // Called to forward the compositor message from the remote server 100 // Called to forward the compositor message from the remote server
110 // LayerTreeHost of the render widget for this compositor. 101 // LayerTreeHost of the render widget for this compositor.
111 // virtual for testing. 102 // virtual for testing.
112 virtual void OnCompositorMessageReceived( 103 virtual void OnCompositorMessageReceived(
113 std::unique_ptr<cc::proto::CompositorMessage> message); 104 std::unique_ptr<cc::proto::CompositorMessage> message);
114 105
106 // Called when the a ContextProvider has been created by the
107 // CompositorDependencies class. If |host_| is waiting on an OutputSurface
108 // this will build one for it.
109 void OnContextProviderCreated(scoped_refptr<cc::ContextProvider> provider);
110
115 scoped_refptr<cc::Layer> layer() const { return layer_; } 111 scoped_refptr<cc::Layer> layer() const { return layer_; }
116 112
117 int render_widget_id() const { return render_widget_id_; } 113 int render_widget_id() const { return render_widget_id_; }
118 114
119 private: 115 private:
120 friend class BlimpCompositorForTesting; 116 friend class BlimpCompositorForTesting;
121 117
122 // LayerTreeHostClient implementation. 118 // LayerTreeHostClient implementation.
123 void WillBeginMainFrame() override {} 119 void WillBeginMainFrame() override {}
124 void DidBeginMainFrame() override {} 120 void DidBeginMainFrame() override {}
125 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} 121 void BeginMainFrame(const cc::BeginFrameArgs& args) override {}
126 void BeginMainFrameNotExpectedSoon() override {} 122 void BeginMainFrameNotExpectedSoon() override {}
127 void UpdateLayerTreeHost() override {} 123 void UpdateLayerTreeHost() override {}
128 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, 124 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
129 const gfx::Vector2dF& outer_delta, 125 const gfx::Vector2dF& outer_delta,
130 const gfx::Vector2dF& elastic_overscroll_delta, 126 const gfx::Vector2dF& elastic_overscroll_delta,
131 float page_scale, 127 float page_scale,
132 float top_controls_delta) override {} 128 float top_controls_delta) override {}
133 void RequestNewOutputSurface() override; 129 void RequestNewOutputSurface() override;
130 void DidInitializeOutputSurface() override;
134 // TODO(khushalsagar): Need to handle context initialization failures. 131 // TODO(khushalsagar): Need to handle context initialization failures.
135 void DidInitializeOutputSurface() override {}
136 void DidFailToInitializeOutputSurface() override {} 132 void DidFailToInitializeOutputSurface() override {}
137 void WillCommit() override {} 133 void WillCommit() override {}
138 void DidCommit() override {} 134 void DidCommit() override {}
139 void DidCommitAndDrawFrame() override; 135 void DidCommitAndDrawFrame() override;
140 void DidCompleteSwapBuffers() override {} 136 void DidCompleteSwapBuffers() override {}
141 void DidCompletePageScaleAnimation() override {} 137 void DidCompletePageScaleAnimation() override {}
142 138
143 // RemoteProtoChannel implementation. 139 // RemoteProtoChannel implementation.
144 void SetProtoReceiver(ProtoReceiver* receiver) override; 140 void SetProtoReceiver(ProtoReceiver* receiver) override;
145 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override; 141 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override;
146 142
147 // BlimpInputManagerClient implementation. 143 // BlimpInputManagerClient implementation.
148 void SendWebGestureEvent( 144 void SendWebGestureEvent(
149 const blink::WebGestureEvent& gesture_event) override; 145 const blink::WebGestureEvent& gesture_event) override;
150 146
151 // OutputSurfaceProxy implementation. 147 // OutputSurfaceProxy implementation.
152 void BindToClient(base::WeakPtr<OutputSurfaceProxyClient> client) override; 148 void BindToClient(base::WeakPtr<OutputSurfaceProxyClient> client) override;
153 void SwapCompositorFrame(cc::CompositorFrame frame) override; 149 void SwapCompositorFrame(cc::CompositorFrame frame) override;
154 void DetachFromClient() override; 150 void DetachFromClient() override;
155 151
156 // SurfaceFactoryClient implementation. 152 // SurfaceFactoryClient implementation.
157 void ReturnResources(const cc::ReturnedResourceArray& resources) override; 153 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
158 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {} 154 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {}
159 155
156 // Helper method to get the embedder dependencies.
157 CompositorDependencies* GetEmbedderDeps();
158
160 // TODO(khushalsagar): Move all of this to the |DocumentView| or another 159 // TODO(khushalsagar): Move all of this to the |DocumentView| or another
161 // platform specific class. So we use the DelegatedFrameHostAndroid like the 160 // platform specific class. So we use the DelegatedFrameHostAndroid like the
162 // RenderWidgetHostViewAndroid. 161 // RenderWidgetHostViewAndroid.
163 void DestroyDelegatedContent(); 162 void DestroyDelegatedContent();
164 163
165 // Helper method to build the internal CC LayerTreeHost instance from 164 // Helper method to build the internal CC LayerTreeHost instance from
166 // |message|. 165 // |message|.
167 void CreateLayerTreeHost( 166 void CreateLayerTreeHost(
168 const cc::proto::InitializeImpl& initialize_message); 167 const cc::proto::InitializeImpl& initialize_message);
169 168
170 // Helper method to destroy the internal CC LayerTreeHost instance and all its 169 // Helper method to destroy the internal CC LayerTreeHost instance and all its
171 // associated state. 170 // associated state.
172 void DestroyLayerTreeHost(); 171 void DestroyLayerTreeHost();
173 172
174 // The unique identifier for the render widget for this compositor. 173 // The unique identifier for the render widget for this compositor.
175 const int render_widget_id_; 174 const int render_widget_id_;
176 175
177 BlimpCompositorClient* client_; 176 BlimpCompositorClient* client_;
178 177
178 BlimpCompositorDependencies* compositor_dependencies_;
179
179 std::unique_ptr<cc::LayerTreeHost> host_; 180 std::unique_ptr<cc::LayerTreeHost> host_;
180 181
181 // Whether or not |host_| should be visible. This is stored in case |host_| 182 // Whether or not |host_| should be visible. This is stored in case |host_|
182 // is null when SetVisible() is called. 183 // is null when SetVisible() is called.
183 bool host_should_be_visible_; 184 bool host_should_be_visible_;
184 185
185 // The SurfaceFactory is bound to the lifetime of the 186 // The SurfaceFactory is bound to the lifetime of the
186 // OutputSurfaceProxyClient. When detached, the surface factory will be 187 // OutputSurfaceProxyClient. When detached, the surface factory will be
187 // destroyed. 188 // destroyed.
188 std::unique_ptr<cc::SurfaceFactory> surface_factory_; 189 std::unique_ptr<cc::SurfaceFactory> surface_factory_;
189 base::WeakPtr<OutputSurfaceProxyClient> output_surface_proxy_client_; 190 base::WeakPtr<OutputSurfaceProxyClient> output_surface_proxy_client_;
190 191
192 // Whether or not |host_| has asked for an output surface.
193 bool output_surface_request_pending_;
194
191 // Data for the current frame. 195 // Data for the current frame.
192 cc::SurfaceId surface_id_; 196 cc::SurfaceId surface_id_;
193 gfx::Size current_surface_size_; 197 gfx::Size current_surface_size_;
194 198
195 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
196
197 base::ThreadChecker thread_checker_; 199 base::ThreadChecker thread_checker_;
198 200
199 // Surfaces related stuff and layer which holds the delegated content from the 201 // Surfaces related stuff and layer which holds the delegated content from the
200 // compositor. 202 // compositor.
201 cc::SurfaceManager* surface_manager_;
202 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; 203 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
203 scoped_refptr<cc::Layer> layer_; 204 scoped_refptr<cc::Layer> layer_;
204 205
205 // To be notified of any incoming compositor protos that are specifically sent 206 // To be notified of any incoming compositor protos that are specifically sent
206 // to |render_widget_id_|. 207 // to |render_widget_id_|.
207 cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_; 208 cc::RemoteProtoChannel::ProtoReceiver* remote_proto_channel_receiver_;
208 209
209 // Handles input events for the current render widget. The lifetime of the 210 // Handles input events for the current render widget. The lifetime of the
210 // input manager is tied to the lifetime of the |host_| which owns the 211 // input manager is tied to the lifetime of the |host_| which owns the
211 // cc::InputHandler. The input events are forwarded to this input handler by 212 // cc::InputHandler. The input events are forwarded to this input handler by
212 // the manager to be handled by the client compositor for the current render 213 // the manager to be handled by the client compositor for the current render
213 // widget. 214 // widget.
214 std::unique_ptr<BlimpInputManager> input_manager_; 215 std::unique_ptr<BlimpInputManager> input_manager_;
215 216
216 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_; 217 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_;
217 218
218 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); 219 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor);
219 }; 220 };
220 221
221 } // namespace client 222 } // namespace client
222 } // namespace blimp 223 } // namespace blimp
223 224
224 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_H_ 225 #endif // BLIMP_CLIENT_FEATURE_COMPOSITOR_BLIMP_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698