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

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

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_
6 #define BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_
7
8 #include <content/public/renderer/remote_proto_channel.h>
9 #include <memory>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h"
15 #include "blimp/client/core/compositor/blimp_compositor_frame_sink_proxy.h"
16 #include "blimp/client/public/compositor/compositor_dependencies.h"
17 #include "cc/blimp/compositor_state_deserializer.h"
18 #include "cc/surfaces/surface_factory_client.h"
19 #include "cc/trees/layer_tree_host.h"
20 #include "cc/trees/layer_tree_host_client.h"
21 #include "cc/trees/layer_tree_settings.h"
22 #include "ui/gfx/geometry/size.h"
23 #include "ui/gfx/native_widget_types.h"
24
25 namespace cc {
26 class AnimationHost;
27 class InputHandler;
28
29 namespace proto {
30 class CompositorMessage;
31 } // namespace proto
32
33 class ContextProvider;
34 class CopyOutputRequest;
35 class Layer;
36 class LayerTreeHostInProcess;
37 class SurfaceFactory;
38 class SurfaceIdAllocator;
39 } // namespace cc
40
41 namespace blimp {
42
43 namespace client {
44
45 class BlimpCompositorDependencies;
46
47 // The BlimpCompositorClient provides the BlimpCompositor with the necessary
48 // dependencies for cc::LayerTreeHost owned by this compositor and for
49 // communicating the compositor and input messages to the corresponding
50 // render widget of this compositor on the engine.
51 class BlimpCompositorClient {
52 public:
53 // Should send the compositor messages from the remote client LayerTreeHost of
54 // this compositor to the corresponding remote server LayerTreeHost.
55 virtual void SendCompositorMessage(
56 const cc::proto::CompositorMessage& message) = 0;
57
58 protected:
59 virtual ~BlimpCompositorClient() {}
60 };
61
62 // BlimpCompositor provides the basic framework and setup to host a
63 // LayerTreeHost. This class owns the remote client cc::LayerTreeHost, which
64 // performs the compositing work for the remote server LayerTreeHost. The server
65 // LayerTreeHost for a BlimpCompositor is owned by the
66 // content::RenderWidgetCompositor. Thus, each BlimpCompositor is tied to a
67 // RenderWidget, identified by a custom |render_widget_id| generated on the
68 // engine. The lifetime of this compositor is controlled by its corresponding
69 // RenderWidget.
70 // This class should only be accessed from the main thread.
71 class BlimpCompositor : public cc::LayerTreeHostClient,
72 public BlimpCompositorFrameSinkProxy,
73 public cc::SurfaceFactoryClient,
74 public cc::CompositorStateDeserializerClient {
75 public:
76 static std::unique_ptr<BlimpCompositor> Create(
77 BlimpCompositorDependencies* compositor_dependencies,
78 BlimpCompositorClient* client);
79
80 ~BlimpCompositor() override;
81
82 void SetVisible(bool visible);
83 bool IsVisible() const;
84
85 // Requests a copy of the compositor frame.
86 // Setting |flush_pending_update| to true ensures that if a frame update on
87 // the main thread is pending, then it is drawn before copying from the
88 // surface.
89 void RequestCopyOfOutput(std::unique_ptr<cc::CopyOutputRequest> copy_request,
90 bool flush_pending_update);
91
92 // Called to forward the compositor message from the remote server
93 // LayerTreeHost of the render widget for this compositor.
94 // virtual for testing.
95 void OnCompositorMessageReceived(
96 std::unique_ptr<cc::proto::CompositorMessage> message);
97
98 scoped_refptr<cc::Layer> layer() const { return layer_; }
99
100 // Returns a reference to the InputHandler used to respond to input events on
101 // the compositor thread.
102 const base::WeakPtr<cc::InputHandler>& GetInputHandler();
103
104 cc::CompositorStateDeserializer* compositor_state_deserializer_for_testing() {
105 return compositor_state_deserializer_.get();
106 }
107
108 bool HasPendingFrameUpdateFromEngine() const;
109
110 // LayerTreeHostClient implementation.
111 void WillBeginMainFrame() override {}
112 void DidBeginMainFrame() override {}
113 void BeginMainFrame(const cc::BeginFrameArgs& args) override {}
114 void BeginMainFrameNotExpectedSoon() override {}
115 void UpdateLayerTreeHost() override;
116 void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
117 const gfx::Vector2dF& outer_delta,
118 const gfx::Vector2dF& elastic_overscroll_delta,
119 float page_scale,
120 float top_controls_delta) override;
121 void RequestNewCompositorFrameSink() override;
122 void DidInitializeCompositorFrameSink() override;
123 // TODO(khushalsagar): Need to handle context initialization failures.
124 void DidFailToInitializeCompositorFrameSink() override {}
125 void WillCommit() override {}
126 void DidCommit() override {}
127 void DidCommitAndDrawFrame() override;
128 void DidReceiveCompositorFrameAck() override {}
129 void DidCompletePageScaleAnimation() override {}
130
131 // CompositorStateDeserializerClient implementation.
132 void DidUpdateLocalState() override;
133
134 protected:
135 BlimpCompositor(BlimpCompositorDependencies* compositor_dependencies,
136 BlimpCompositorClient* client);
137
138 void Initialize();
139 virtual std::unique_ptr<cc::LayerTreeHostInProcess> CreateLayerTreeHost();
140
141 cc::AnimationHost* animation_host() { return animation_host_.get(); }
142
143 private:
144 class FrameTrackingSwapPromise;
145
146 // BlimpCompositorFrameSinkProxy implementation.
147 void BindToProxyClient(
148 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client) override;
149 void SubmitCompositorFrame(cc::CompositorFrame frame) override;
150 void UnbindProxyClient() override;
151
152 // SurfaceFactoryClient implementation.
153 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
154 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {}
155
156 // Called when the a ContextProvider has been created by the
157 // CompositorDependencies class. If |host_| is waiting on an
158 // CompositorFrameSink this will build one for it.
159 void OnContextProvidersCreated(
160 const scoped_refptr<cc::ContextProvider>& compositor_context_provider,
161 const scoped_refptr<cc::ContextProvider>& worker_context_provider);
162
163 // Helper method to get the embedder dependencies.
164 CompositorDependencies* GetEmbedderDeps();
165
166 // TODO(khushalsagar): Move all of this to the |DocumentView| or another
167 // platform specific class. So we use the DelegatedFrameHostAndroid like the
168 // RenderWidgetHostViewAndroid.
169 void DestroyDelegatedContent();
170
171 // Helper method to destroy the internal CC LayerTreeHost instance and all its
172 // associated state.
173 void DestroyLayerTreeHost();
174
175 // Acks a submitted CompositorFrame when it has been processed and another
176 // frame should be started.
177 void SubmitCompositorFrameAck();
178
179 // Sends an update to the engine if the state on the client was modified and
180 // an ack for a previous update sent is not pending.
181 void FlushClientState();
182
183 void MakeCopyRequestOnNextSwap(
184 std::unique_ptr<cc::CopyOutputRequest> copy_request);
185
186 BlimpCompositorClient* client_;
187
188 BlimpCompositorDependencies* compositor_dependencies_;
189
190 cc::FrameSinkId frame_sink_id_;
191
192 std::unique_ptr<cc::AnimationHost> animation_host_;
193 std::unique_ptr<cc::LayerTreeHostInProcess> host_;
194
195 std::unique_ptr<cc::SurfaceFactory> surface_factory_;
196 base::WeakPtr<BlimpCompositorFrameSinkProxyClient> proxy_client_;
197 bool bound_to_proxy_;
198
199 // Whether or not |host_| has asked for a new CompositorFrameSink.
200 bool compositor_frame_sink_request_pending_;
201
202 // Data for the current frame.
203 cc::LocalFrameId local_frame_id_;
204 gfx::Size current_surface_size_;
205
206 base::ThreadChecker thread_checker_;
207
208 // Surfaces related stuff and layer which holds the delegated content from the
209 // compositor.
210 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
211 scoped_refptr<cc::Layer> layer_;
212
213 std::vector<std::unique_ptr<cc::CopyOutputRequest>>
214 copy_requests_for_next_swap_;
215
216 // Stores a frame update received from the engine, when a threaded
217 // LayerTreeHost is used. There can only be a single frame in flight at any
218 // point.
219 std::unique_ptr<cc::proto::CompositorMessage> pending_frame_update_;
220
221 // Used with a threaded LayerTreeHost to deserialize proto updates from the
222 // engine into the LayerTree.
223 std::unique_ptr<cc::CompositorStateDeserializer>
224 compositor_state_deserializer_;
225
226 // Set to true if the compositor state on the client was modified on the impl
227 // thread and an update needs to be sent to the engine.
228 bool client_state_dirty_ = false;
229
230 // Set to true if a client state update was sent to the engine and an ack for
231 // this update from the engine is pending.
232 bool client_state_update_ack_pending_ = false;
233
234 base::WeakPtrFactory<BlimpCompositor> weak_ptr_factory_;
235
236 DISALLOW_COPY_AND_ASSIGN(BlimpCompositor);
237 };
238
239 } // namespace client
240 } // namespace blimp
241
242 #endif // BLIMP_CLIENT_CORE_COMPOSITOR_BLIMP_COMPOSITOR_H_
OLDNEW
« no previous file with comments | « blimp/client/core/compositor/blimp_client_picture_cache_unittest.cc ('k') | blimp/client/core/compositor/blimp_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698