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 |
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 "blimp/client/core/compositor/blimp_output_surface.h" | 13 #include "blimp/client/core/compositor/blimp_compositor_frame_sink_proxy.h" |
14 #include "blimp/client/core/input/blimp_input_manager.h" | 14 #include "blimp/client/core/input/blimp_input_manager.h" |
15 #include "blimp/client/public/compositor/compositor_dependencies.h" | 15 #include "blimp/client/public/compositor/compositor_dependencies.h" |
16 #include "cc/surfaces/surface_factory_client.h" | 16 #include "cc/surfaces/surface_factory_client.h" |
17 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" |
18 #include "cc/trees/layer_tree_host_client.h" | 18 #include "cc/trees/layer_tree_host_client.h" |
19 #include "cc/trees/layer_tree_settings.h" | 19 #include "cc/trees/layer_tree_settings.h" |
20 #include "cc/trees/remote_proto_channel.h" | 20 #include "cc/trees/remote_proto_channel.h" |
21 #include "ui/gfx/geometry/size.h" | 21 #include "ui/gfx/geometry/size.h" |
22 #include "ui/gfx/native_widget_types.h" | 22 #include "ui/gfx/native_widget_types.h" |
23 | 23 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // performs the compositing work for the remote server LayerTreeHost. The server | 75 // performs the compositing work for the remote server LayerTreeHost. The server |
76 // LayerTreeHost for a BlimpCompositor is owned by the | 76 // LayerTreeHost for a BlimpCompositor is owned by the |
77 // content::RenderWidgetCompositor. Thus, each BlimpCompositor is tied to a | 77 // content::RenderWidgetCompositor. Thus, each BlimpCompositor is tied to a |
78 // RenderWidget, identified by a custom |render_widget_id| generated on the | 78 // RenderWidget, identified by a custom |render_widget_id| generated on the |
79 // engine. The lifetime of this compositor is controlled by its corresponding | 79 // engine. The lifetime of this compositor is controlled by its corresponding |
80 // RenderWidget. | 80 // RenderWidget. |
81 // This class should only be accessed from the main thread. | 81 // This class should only be accessed from the main thread. |
82 class BlimpCompositor : public cc::LayerTreeHostClient, | 82 class BlimpCompositor : public cc::LayerTreeHostClient, |
83 public cc::RemoteProtoChannel, | 83 public cc::RemoteProtoChannel, |
84 public BlimpInputManagerClient, | 84 public BlimpInputManagerClient, |
85 public BlimpOutputSurfaceClient, | 85 public BlimpCompositorFrameSinkProxy, |
86 public cc::SurfaceFactoryClient { | 86 public cc::SurfaceFactoryClient { |
87 public: | 87 public: |
88 BlimpCompositor(const int render_widget_id, | 88 BlimpCompositor(const int render_widget_id, |
89 BlimpCompositorDependencies* compositor_dependencies, | 89 BlimpCompositorDependencies* compositor_dependencies, |
90 BlimpCompositorClient* client); | 90 BlimpCompositorClient* client); |
91 | 91 |
92 ~BlimpCompositor() override; | 92 ~BlimpCompositor() override; |
93 | 93 |
94 virtual void SetVisible(bool visible); | 94 virtual void SetVisible(bool visible); |
95 | 95 |
(...skipping 23 matching lines...) Expand all Loading... |
119 void WillBeginMainFrame() override {} | 119 void WillBeginMainFrame() override {} |
120 void DidBeginMainFrame() override {} | 120 void DidBeginMainFrame() override {} |
121 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} | 121 void BeginMainFrame(const cc::BeginFrameArgs& args) override {} |
122 void BeginMainFrameNotExpectedSoon() override {} | 122 void BeginMainFrameNotExpectedSoon() override {} |
123 void UpdateLayerTreeHost() override {} | 123 void UpdateLayerTreeHost() override {} |
124 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, | 124 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta, |
125 const gfx::Vector2dF& outer_delta, | 125 const gfx::Vector2dF& outer_delta, |
126 const gfx::Vector2dF& elastic_overscroll_delta, | 126 const gfx::Vector2dF& elastic_overscroll_delta, |
127 float page_scale, | 127 float page_scale, |
128 float top_controls_delta) override {} | 128 float top_controls_delta) override {} |
129 void RequestNewOutputSurface() override; | 129 void RequestNewCompositorFrameSink() override; |
130 void DidInitializeOutputSurface() override; | 130 void DidInitializeCompositorFrameSink() override; |
131 // TODO(khushalsagar): Need to handle context initialization failures. | 131 // TODO(khushalsagar): Need to handle context initialization failures. |
132 void DidFailToInitializeOutputSurface() override {} | 132 void DidFailToInitializeCompositorFrameSink() override {} |
133 void WillCommit() override {} | 133 void WillCommit() override {} |
134 void DidCommit() override {} | 134 void DidCommit() override {} |
135 void DidCommitAndDrawFrame() override; | 135 void DidCommitAndDrawFrame() override; |
136 void DidCompleteSwapBuffers() override {} | 136 void DidCompleteSwapBuffers() override {} |
137 void DidCompletePageScaleAnimation() override {} | 137 void DidCompletePageScaleAnimation() override {} |
138 | 138 |
139 // RemoteProtoChannel implementation. | 139 // RemoteProtoChannel implementation. |
140 void SetProtoReceiver(ProtoReceiver* receiver) override; | 140 void SetProtoReceiver(ProtoReceiver* receiver) override; |
141 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override; | 141 void SendCompositorProto(const cc::proto::CompositorMessage& proto) override; |
142 | 142 |
143 // BlimpInputManagerClient implementation. | 143 // BlimpInputManagerClient implementation. |
144 void SendWebGestureEvent( | 144 void SendWebGestureEvent( |
145 const blink::WebGestureEvent& gesture_event) override; | 145 const blink::WebGestureEvent& gesture_event) override; |
146 | 146 |
147 // BlimpOutputSurfaceClient implementation. | 147 // BlimpCompositorFrameSinkProxy implementation. |
148 void BindToOutputSurface( | 148 void BindToProxyClient( |
149 base::WeakPtr<BlimpOutputSurface> output_surface) override; | 149 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) override; |
150 void SwapCompositorFrame(cc::CompositorFrame frame) override; | 150 void SwapCompositorFrame(cc::CompositorFrame frame) override; |
151 void UnbindOutputSurface() override; | 151 void UnbindProxyClient() override; |
152 | 152 |
153 // SurfaceFactoryClient implementation. | 153 // SurfaceFactoryClient implementation. |
154 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 154 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
155 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {} | 155 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {} |
156 | 156 |
157 // Called when the a ContextProvider has been created by the | 157 // Called when the a ContextProvider has been created by the |
158 // CompositorDependencies class. If |host_| is waiting on an OutputSurface | 158 // CompositorDependencies class. If |host_| is waiting on an |
159 // this will build one for it. | 159 // CompositorFrameSink this will build one for it. |
160 void OnContextProvidersCreated( | 160 void OnContextProvidersCreated( |
161 const scoped_refptr<cc::ContextProvider>& compositor_context_provider, | 161 const scoped_refptr<cc::ContextProvider>& compositor_context_provider, |
162 const scoped_refptr<cc::ContextProvider>& worker_context_provider); | 162 const scoped_refptr<cc::ContextProvider>& worker_context_provider); |
163 | 163 |
164 // Helper method to get the embedder dependencies. | 164 // Helper method to get the embedder dependencies. |
165 CompositorDependencies* GetEmbedderDeps(); | 165 CompositorDependencies* GetEmbedderDeps(); |
166 | 166 |
167 // TODO(khushalsagar): Move all of this to the |DocumentView| or another | 167 // TODO(khushalsagar): Move all of this to the |DocumentView| or another |
168 // platform specific class. So we use the DelegatedFrameHostAndroid like the | 168 // platform specific class. So we use the DelegatedFrameHostAndroid like the |
169 // RenderWidgetHostViewAndroid. | 169 // RenderWidgetHostViewAndroid. |
(...skipping 14 matching lines...) Expand all Loading... |
184 | 184 |
185 // The unique identifier for the render widget for this compositor. | 185 // The unique identifier for the render widget for this compositor. |
186 const int render_widget_id_; | 186 const int render_widget_id_; |
187 | 187 |
188 BlimpCompositorClient* client_; | 188 BlimpCompositorClient* client_; |
189 | 189 |
190 BlimpCompositorDependencies* compositor_dependencies_; | 190 BlimpCompositorDependencies* compositor_dependencies_; |
191 | 191 |
192 std::unique_ptr<cc::LayerTreeHostInterface> host_; | 192 std::unique_ptr<cc::LayerTreeHostInterface> host_; |
193 | 193 |
194 // The SurfaceFactory is bound to the lifetime of the BlimpOutputSurface. When | 194 // The SurfaceFactory is bound to the lifetime of the |proxy_client_|. When |
195 // detached, the surface factory will be destroyed. | 195 // detached, the surface factory will be destroyed. |
196 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 196 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
197 base::WeakPtr<BlimpOutputSurface> output_surface_; | 197 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client_; |
198 | 198 |
199 // Whether or not |host_| has asked for an output surface. | 199 // Whether or not |host_| has asked for a new CompositorFrameSink. |
200 bool output_surface_request_pending_; | 200 bool compositor_frame_sink_request_pending_; |
201 | 201 |
202 // Data for the current frame. | 202 // Data for the current frame. |
203 cc::SurfaceId surface_id_; | 203 cc::SurfaceId surface_id_; |
204 gfx::Size current_surface_size_; | 204 gfx::Size current_surface_size_; |
205 | 205 |
206 base::ThreadChecker thread_checker_; | 206 base::ThreadChecker thread_checker_; |
207 | 207 |
208 // Surfaces related stuff and layer which holds the delegated content from the | 208 // Surfaces related stuff and layer which holds the delegated content from the |
209 // compositor. | 209 // compositor. |
210 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 210 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
(...skipping 23 matching lines...) Expand all Loading... |
234 | 234 |
235 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_; | 235 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_; |
236 | 236 |
237 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); | 237 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor); |
238 }; | 238 }; |
239 | 239 |
240 } // namespace client | 240 } // namespace client |
241 } // namespace blimp | 241 } // namespace blimp |
242 | 242 |
243 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ | 243 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_ |
OLD | NEW |