OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CC_TREES_LAYER_TREE_HOST_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_H_ |
6 #define CC_TREES_LAYER_TREE_HOST_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_H_ |
7 | 7 |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 | |
11 #include <limits> | |
12 #include <memory> | |
13 #include <set> | |
14 #include <string> | |
15 #include <unordered_map> | |
16 #include <vector> | |
17 | |
18 #include "base/cancelable_callback.h" | |
19 #include "base/macros.h" | 8 #include "base/macros.h" |
20 #include "base/memory/ref_counted.h" | |
21 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
22 #include "base/time/time.h" | |
23 #include "cc/animation/target_property.h" | |
24 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
25 #include "cc/debug/micro_benchmark.h" | 11 #include "cc/debug/micro_benchmark.h" |
26 #include "cc/debug/micro_benchmark_controller.h" | |
27 #include "cc/input/event_listener_properties.h" | |
28 #include "cc/input/input_handler.h" | |
29 #include "cc/input/layer_selection_bound.h" | |
30 #include "cc/input/scrollbar.h" | |
31 #include "cc/input/top_controls_state.h" | 12 #include "cc/input/top_controls_state.h" |
32 #include "cc/layers/layer_collections.h" | 13 |
33 #include "cc/layers/layer_list_iterator.h" | 14 namespace base { |
34 #include "cc/output/compositor_frame_sink.h" | 15 class TimeTicks; |
35 #include "cc/output/swap_promise.h" | 16 } // namespace base |
36 #include "cc/resources/resource_format.h" | 17 |
37 #include "cc/trees/compositor_mode.h" | 18 namespace gfx { |
38 #include "cc/trees/layer_tree.h" | 19 class Rect; |
39 #include "cc/trees/layer_tree_host_client.h" | 20 } // namespace gfx |
40 #include "cc/trees/layer_tree_host_interface.h" | |
41 #include "cc/trees/layer_tree_settings.h" | |
42 #include "cc/trees/proxy.h" | |
43 #include "cc/trees/surface_sequence_generator.h" | |
44 #include "cc/trees/swap_promise_manager.h" | |
45 #include "third_party/skia/include/core/SkColor.h" | |
46 #include "ui/gfx/geometry/rect.h" | |
47 | |
48 namespace gpu { | |
49 class GpuMemoryBufferManager; | |
50 } | |
51 | 21 |
52 namespace cc { | 22 namespace cc { |
53 | 23 class InputHandler; |
54 class AnimationEvents; | 24 class LayerTree; |
55 class AnimationHost; | 25 class LayerTreeDebugState; |
56 class BeginFrameSource; | |
57 class ClientPictureCache; | |
58 class EnginePictureCache; | |
59 class HeadsUpDisplayLayer; | |
60 class ImageSerializationProcessor; | |
61 class Layer; | |
62 class LayerTreeHostImpl; | |
63 class LayerTreeHostImplClient; | |
64 class LayerTreeHostSingleThreadClient; | |
65 class LayerTreeMutator; | 26 class LayerTreeMutator; |
66 class PropertyTrees; | 27 class LayerTreeSettings; |
67 class Region; | 28 class CompositorFrameSink; |
68 class RemoteProtoChannel; | 29 class SurfaceSequenceGenerator; |
69 class RenderingStatsInstrumentation; | 30 class SwapPromise; |
70 class ResourceProvider; | 31 class SwapPromiseManager; |
71 class ResourceUpdateQueue; | 32 class TaskRunnerProvider; |
72 class SharedBitmapManager; | 33 class UIResourceManager; |
73 class TaskGraphRunner; | 34 |
74 class TopControlsManager; | 35 // This encapsulates the API for any embedder to use cc. The |
75 struct PendingPageScaleAnimation; | 36 // LayerTreeHostInProcess provides the implementation where the compositor |
76 struct RenderingStats; | 37 // thread components of this host run within the same process. Use |
77 struct ScrollAndScaleSet; | 38 // LayerTreeHostInProcess::CreateThreaded/CreateSingleThread to get either. |
78 | 39 class CC_EXPORT LayerTreeHost { |
79 namespace proto { | |
80 class LayerTreeHost; | |
81 } | |
82 | |
83 // This class is being refactored to an interface, see LayerTreeHostInterface, | |
84 // which is the API for the cc embedder. When adding new code to this class, | |
85 // consider the following: | |
86 // 1) If its state/data that gets pushed to the LayerTreeImpl during commit, add | |
87 // it to the LayerTree. | |
88 // 2) If it's a call from the embedder, add it to the LayerTreeHostInterface. | |
89 // 3) If it's a call from any of the internal cc classes, i.e., LayerTree or | |
90 // PropertyTreeBuilder, etc., add it to the LayerTreeHostInterface. | |
91 // 4) If it's a notification from the impl thread or a call from Proxy, add it | |
92 // to this class. | |
93 // This class will be renamed to LayerTreeHostInProcess and will be the | |
94 // LayerTreeHost implementation for when the impl thread for the compositor runs | |
95 // in the same process, and thus uses a Proxy. | |
96 class CC_EXPORT LayerTreeHost : public LayerTreeHostInterface { | |
97 public: | 40 public: |
98 // TODO(sad): InitParams should be a movable type so that it can be | 41 virtual ~LayerTreeHost() {} |
99 // std::move()d to the Create* functions. | 42 |
100 struct CC_EXPORT InitParams { | 43 // Returns the process global unique identifier for this LayerTreeHost. |
101 LayerTreeHostClient* client = nullptr; | 44 virtual int GetId() const = 0; |
102 SharedBitmapManager* shared_bitmap_manager = nullptr; | 45 |
103 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = nullptr; | 46 // The current source frame number. This is incremented for each main frame |
104 TaskGraphRunner* task_graph_runner = nullptr; | 47 // update(commit) pushed to the compositor thread. |
105 LayerTreeSettings const* settings = nullptr; | 48 virtual int SourceFrameNumber() const = 0; |
106 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner; | 49 |
107 std::unique_ptr<BeginFrameSource> external_begin_frame_source; | 50 // Returns the LayerTree that holds the main frame state pushed to the |
108 ImageSerializationProcessor* image_serialization_processor = nullptr; | 51 // LayerTreeImpl on commit. |
109 std::unique_ptr<AnimationHost> animation_host; | 52 virtual LayerTree* GetLayerTree() = 0; |
110 | 53 virtual const LayerTree* GetLayerTree() const = 0; |
111 InitParams(); | 54 |
112 ~InitParams(); | 55 // Returns the UIResourceManager used to create UIResources for |
113 }; | 56 // UIResourceLayers pushed to the LayerTree. |
114 | 57 virtual UIResourceManager* GetUIResourceManager() const = 0; |
115 // The SharedBitmapManager will be used on the compositor thread. | 58 |
116 static std::unique_ptr<LayerTreeHostInterface> CreateThreaded( | 59 // Returns the TaskRunnerProvider used to access the main and compositor |
117 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 60 // thread task runners. |
118 InitParams* params); | 61 virtual TaskRunnerProvider* GetTaskRunnerProvider() const = 0; |
119 | 62 |
120 static std::unique_ptr<LayerTreeHost> CreateSingleThreaded( | 63 // Returns the settings used by this host. |
121 LayerTreeHostSingleThreadClient* single_thread_client, | 64 virtual const LayerTreeSettings& GetSettings() const = 0; |
122 InitParams* params); | 65 |
123 | 66 // Sets the client id used to generate the SurfaceId that uniquely identifies |
124 static std::unique_ptr<LayerTreeHostInterface> CreateRemoteServer( | 67 // the Surfaces produced by this compositor. |
125 RemoteProtoChannel* remote_proto_channel, | 68 virtual void SetSurfaceClientId(uint32_t client_id) = 0; |
126 InitParams* params); | 69 |
127 | 70 // Sets the LayerTreeMutator interface used to directly mutate the compositor |
128 // The lifetime of this LayerTreeHost is tied to the lifetime of the remote | 71 // state on the compositor thread. (Compositor-Worker) |
129 // server LayerTreeHost. It should be created on receiving | 72 virtual void SetLayerTreeMutator( |
130 // CompositorMessageToImpl::InitializeImpl message and destroyed on receiving | 73 std::unique_ptr<LayerTreeMutator> mutator) = 0; |
131 // a CompositorMessageToImpl::CloseImpl message from the server. This ensures | 74 |
132 // that the client will not send any compositor messages once the | 75 // Call this function when you expect there to be a swap buffer. |
133 // LayerTreeHost on the server is destroyed. | 76 // See swap_promise.h for how to use SwapPromise. |
134 static std::unique_ptr<LayerTreeHostInterface> CreateRemoteClient( | 77 virtual void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) = 0; |
135 RemoteProtoChannel* remote_proto_channel, | 78 |
136 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 79 // Returns the SwapPromiseManager used to create SwapPromiseMonitors for this |
137 InitParams* params); | 80 // host. |
138 | 81 virtual SwapPromiseManager* GetSwapPromiseManager() = 0; |
139 ~LayerTreeHost() override; | 82 |
140 | 83 // Sets whether the content is suitable to use Gpu Rasterization. |
141 // LayerTreeHostInterface implementation. | 84 virtual void SetHasGpuRasterizationTrigger(bool has_trigger) = 0; |
142 int GetId() const override; | 85 |
143 int SourceFrameNumber() const override; | 86 // Visibility and CompositorFrameSink ------------------------------- |
144 LayerTree* GetLayerTree() override; | 87 |
145 const LayerTree* GetLayerTree() const override; | 88 virtual void SetVisible(bool visible) = 0; |
146 UIResourceManager* GetUIResourceManager() const override; | 89 virtual bool IsVisible() const = 0; |
147 TaskRunnerProvider* GetTaskRunnerProvider() const override; | 90 |
148 const LayerTreeSettings& GetSettings() const override; | 91 // Called in response to an CompositorFrameSink request made to the client |
149 void SetSurfaceClientId(uint32_t client_id) override; | 92 // using LayerTreeHostClient::RequestNewCompositorFrameSink. The client will |
150 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; | 93 // be informed of the CompositorFrameSink initialization status using |
151 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override; | 94 // DidInitializaCompositorFrameSink or DidFailToInitializeCompositorFrameSink. |
152 SwapPromiseManager* GetSwapPromiseManager() override; | 95 // The request is completed when the host successfully initializes an |
153 void SetHasGpuRasterizationTrigger(bool has_trigger) override; | 96 // CompositorFrameSink. |
154 void SetVisible(bool visible) override; | 97 virtual void SetCompositorFrameSink( |
155 bool IsVisible() const override; | 98 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) = 0; |
156 void SetCompositorFrameSink( | 99 |
157 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override; | 100 // Forces the host to immediately release all references to the |
158 std::unique_ptr<CompositorFrameSink> ReleaseCompositorFrameSink() override; | 101 // CompositorFrameSink, if any. Can be safely called any time. |
159 void SetNeedsAnimate() override; | 102 virtual std::unique_ptr<CompositorFrameSink> ReleaseCompositorFrameSink() = 0; |
160 void SetNeedsUpdateLayers() override; | 103 |
161 void SetNeedsCommit() override; | 104 // Frame Scheduling (main and compositor frames) requests ------- |
162 bool BeginMainFrameRequested() const override; | 105 |
163 bool CommitRequested() const override; | 106 // Requests a main frame update even if no content has changed. This is used, |
164 void SetDeferCommits(bool defer_commits) override; | 107 // for instance in the case of RequestAnimationFrame from blink to ensure the |
165 void LayoutAndUpdateLayers() override; | 108 // main frame update is run on the next tick without pre-emptively forcing a |
166 void Composite(base::TimeTicks frame_begin_time) override; | 109 // full commit synchronization or layer updates. |
167 void SetNeedsRedraw() override; | 110 virtual void SetNeedsAnimate() = 0; |
168 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override; | 111 |
169 void SetNextCommitForcesRedraw() override; | 112 // Requests a main frame update and also ensure that the host pulls layer |
170 void NotifyInputThrottledUntilCommit() override; | 113 // updates from the client, even if no content might have changed, without |
171 void UpdateTopControlsState(TopControlsState constraints, | 114 // forcing a full commit synchronization. |
172 TopControlsState current, | 115 virtual void SetNeedsUpdateLayers() = 0; |
173 bool animate) override; | 116 |
174 const base::WeakPtr<InputHandler>& GetInputHandler() const override; | 117 // Requests that the next main frame update performs a full commit |
175 void DidStopFlinging() override; | 118 // synchronization. |
176 void SetDebugState(const LayerTreeDebugState& debug_state) override; | 119 virtual void SetNeedsCommit() = 0; |
177 const LayerTreeDebugState& GetDebugState() const override; | 120 |
178 int ScheduleMicroBenchmark( | 121 // Returns true if a main frame (for any pipeline stage above) has been |
| 122 // requested. |
| 123 virtual bool BeginMainFrameRequested() const = 0; |
| 124 |
| 125 // Returns true if a main frame with commit synchronization has been |
| 126 // requested. |
| 127 virtual bool CommitRequested() const = 0; |
| 128 |
| 129 // Enables/disables the compositor from requesting main frame updates from the |
| 130 // client. |
| 131 virtual void SetDeferCommits(bool defer_commits) = 0; |
| 132 |
| 133 // Synchronously performs a main frame update and layer updates. Used only in |
| 134 // single threaded mode when the compositor's internal scheduling is disabled. |
| 135 virtual void LayoutAndUpdateLayers() = 0; |
| 136 |
| 137 // Synchronously performs a complete main frame update, commit and compositor |
| 138 // frame. Used only in single threaded mode when the compositor's internal |
| 139 // scheduling is disabled. |
| 140 virtual void Composite(base::TimeTicks frame_begin_time) = 0; |
| 141 |
| 142 // Requests a redraw (compositor frame) for the complete viewport. |
| 143 virtual void SetNeedsRedraw() = 0; |
| 144 |
| 145 // Requests a redraw (compositor frame) for the given rect. |
| 146 virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) = 0; |
| 147 |
| 148 // Requests a main frame (including layer updates) and ensures that this main |
| 149 // frame results in a redraw for the complete viewport when producing the |
| 150 // CompositorFrame. |
| 151 virtual void SetNextCommitForcesRedraw() = 0; |
| 152 |
| 153 // Input Handling --------------------------------------------- |
| 154 |
| 155 // Notifies the compositor that input from the browser is being throttled till |
| 156 // the next commit. The compositor will prioritize activation of the pending |
| 157 // tree so a commit can be performed. |
| 158 virtual void NotifyInputThrottledUntilCommit() = 0; |
| 159 |
| 160 // Sets the state of the top controls. (Used for URL bar animations on |
| 161 // android). |
| 162 virtual void UpdateTopControlsState(TopControlsState constraints, |
| 163 TopControlsState current, |
| 164 bool animate) = 0; |
| 165 |
| 166 // Returns a reference to the InputHandler used to respond to input events on |
| 167 // the compositor thread. |
| 168 virtual const base::WeakPtr<InputHandler>& GetInputHandler() const = 0; |
| 169 |
| 170 // Informs the compositor that an active fling gesture being processed on the |
| 171 // main thread has been finished. |
| 172 virtual void DidStopFlinging() = 0; |
| 173 |
| 174 // Debugging and benchmarks --------------------------------- |
| 175 virtual void SetDebugState(const LayerTreeDebugState& debug_state) = 0; |
| 176 virtual const LayerTreeDebugState& GetDebugState() const = 0; |
| 177 |
| 178 // Returns the id of the benchmark on success, 0 otherwise. |
| 179 virtual int ScheduleMicroBenchmark( |
179 const std::string& benchmark_name, | 180 const std::string& benchmark_name, |
180 std::unique_ptr<base::Value> value, | 181 std::unique_ptr<base::Value> value, |
181 const MicroBenchmark::DoneCallback& callback) override; | 182 const MicroBenchmark::DoneCallback& callback) = 0; |
182 bool SendMessageToMicroBenchmark(int id, | 183 |
183 std::unique_ptr<base::Value> value) override; | 184 // Returns true if the message was successfully delivered and handled. |
184 SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override; | 185 virtual bool SendMessageToMicroBenchmark( |
185 | 186 int id, |
186 // LayerTreeHost interface to Proxy. | 187 std::unique_ptr<base::Value> value) = 0; |
187 void WillBeginMainFrame(); | 188 |
188 void DidBeginMainFrame(); | 189 // Methods used internally in cc. These are not intended to be a part of the |
189 void BeginMainFrame(const BeginFrameArgs& args); | 190 // public API for use by the embedder ---------------------- |
190 void BeginMainFrameNotExpectedSoon(); | 191 virtual SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() = 0; |
191 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); | 192 |
192 void RequestMainFrameUpdate(); | 193 // When the main thread informs the impl thread that it is ready to commit, |
193 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); | 194 // generally it would remain blocked till the main thread state is copied to |
194 void WillCommit(); | 195 // the pending tree. Calling this would ensure that the main thread remains |
195 void CommitComplete(); | 196 // blocked till the pending tree is activated. |
196 void RequestNewCompositorFrameSink(); | 197 virtual void SetNextCommitWaitsForActivation() = 0; |
197 void DidInitializeCompositorFrameSink(); | 198 |
198 void DidFailToInitializeCompositorFrameSink(); | 199 // The LayerTreeHost tracks whether the content is suitable for Gpu raster. |
199 virtual std::unique_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 200 // Calling this will reset it back to not suitable state. |
200 LayerTreeHostImplClient* client); | 201 virtual void ResetGpuRasterizationTracking() = 0; |
201 void DidLoseCompositorFrameSink(); | |
202 void DidCommitAndDrawFrame() { client_->DidCommitAndDrawFrame(); } | |
203 void DidCompleteSwapBuffers() { client_->DidCompleteSwapBuffers(); } | |
204 bool UpdateLayers(); | |
205 // Called when the compositor completed page scale animation. | |
206 void DidCompletePageScaleAnimation(); | |
207 void ApplyScrollAndScale(ScrollAndScaleSet* info); | |
208 | |
209 LayerTreeHostClient* client() { return client_; } | |
210 | |
211 bool gpu_rasterization_histogram_recorded() const { | |
212 return gpu_rasterization_histogram_recorded_; | |
213 } | |
214 | |
215 void CollectRenderingStats(RenderingStats* stats) const; | |
216 | |
217 RenderingStatsInstrumentation* rendering_stats_instrumentation() const { | |
218 return rendering_stats_instrumentation_.get(); | |
219 } | |
220 | |
221 void SetNextCommitWaitsForActivation(); | |
222 | |
223 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); | |
224 | |
225 bool has_gpu_rasterization_trigger() const { | |
226 return has_gpu_rasterization_trigger_; | |
227 } | |
228 | |
229 Proxy* proxy() const { return proxy_.get(); } | |
230 | |
231 // Serializes the parts of this LayerTreeHost that is needed for a commit to a | |
232 // protobuf message. Not all members are serialized as they are not helpful | |
233 // for remote usage. | |
234 // The |swap_promise_list_| is transferred to the serializer in | |
235 // |swap_promises|. | |
236 void ToProtobufForCommit( | |
237 proto::LayerTreeHost* proto, | |
238 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); | |
239 | |
240 // Deserializes the protobuf into this LayerTreeHost before a commit. The | |
241 // expected input is a serialized remote LayerTreeHost. After deserializing | |
242 // the protobuf, the normal commit-flow should continue. | |
243 void FromProtobufForCommit(const proto::LayerTreeHost& proto); | |
244 | |
245 bool IsSingleThreaded() const; | |
246 bool IsThreaded() const; | |
247 bool IsRemoteServer() const; | |
248 bool IsRemoteClient() const; | |
249 | |
250 ImageSerializationProcessor* image_serialization_processor() const { | |
251 return image_serialization_processor_; | |
252 } | |
253 | |
254 EnginePictureCache* engine_picture_cache() const { | |
255 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; | |
256 } | |
257 | |
258 ClientPictureCache* client_picture_cache() const { | |
259 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; | |
260 } | |
261 | |
262 void ResetGpuRasterizationTracking(); | |
263 | |
264 protected: | |
265 // Allow tests to inject the LayerTree. | |
266 LayerTreeHost(InitParams* params, | |
267 CompositorMode mode, | |
268 std::unique_ptr<LayerTree> layer_tree); | |
269 LayerTreeHost(InitParams* params, CompositorMode mode); | |
270 | |
271 void InitializeThreaded( | |
272 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
273 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | |
274 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | |
275 void InitializeSingleThreaded( | |
276 LayerTreeHostSingleThreadClient* single_thread_client, | |
277 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
278 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | |
279 void InitializeRemoteServer( | |
280 RemoteProtoChannel* remote_proto_channel, | |
281 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | |
282 void InitializeRemoteClient( | |
283 RemoteProtoChannel* remote_proto_channel, | |
284 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | |
285 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | |
286 void InitializeForTesting( | |
287 std::unique_ptr<TaskRunnerProvider> task_runner_provider, | |
288 std::unique_ptr<Proxy> proxy_for_testing, | |
289 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | |
290 void InitializePictureCacheForTesting(); | |
291 void SetTaskRunnerProviderForTesting( | |
292 std::unique_ptr<TaskRunnerProvider> task_runner_provider); | |
293 void SetUIResourceManagerForTesting( | |
294 std::unique_ptr<UIResourceManager> ui_resource_manager); | |
295 | |
296 // shared_bitmap_manager(), gpu_memory_buffer_manager(), and | |
297 // task_graph_runner() return valid values only until the LayerTreeHostImpl is | |
298 // created in CreateLayerTreeHostImpl(). | |
299 SharedBitmapManager* shared_bitmap_manager() const { | |
300 return shared_bitmap_manager_; | |
301 } | |
302 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const { | |
303 return gpu_memory_buffer_manager_; | |
304 } | |
305 TaskGraphRunner* task_graph_runner() const { return task_graph_runner_; } | |
306 | |
307 void OnCommitForSwapPromises(); | |
308 | |
309 void RecordGpuRasterizationHistogram(); | |
310 | |
311 MicroBenchmarkController micro_benchmark_controller_; | |
312 | |
313 std::unique_ptr<LayerTree> layer_tree_; | |
314 | |
315 base::WeakPtr<InputHandler> input_handler_weak_ptr_; | |
316 | |
317 private: | |
318 friend class LayerTreeHostSerializationTest; | |
319 | |
320 // This is the number of consecutive frames in which we want the content to be | |
321 // suitable for GPU rasterization before re-enabling it. | |
322 enum { kNumFramesToConsiderBeforeGpuRasterization = 60 }; | |
323 | |
324 void ApplyViewportDeltas(ScrollAndScaleSet* info); | |
325 void ApplyPageScaleDeltaFromImplSide(float page_scale_delta); | |
326 void InitializeProxy( | |
327 std::unique_ptr<Proxy> proxy, | |
328 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | |
329 | |
330 bool DoUpdateLayers(Layer* root_layer); | |
331 void UpdateHudLayer(); | |
332 | |
333 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); | |
334 | |
335 void CalculateLCDTextMetricsCallback(Layer* layer); | |
336 | |
337 void SetPropertyTreesNeedRebuild(); | |
338 | |
339 const CompositorMode compositor_mode_; | |
340 | |
341 std::unique_ptr<UIResourceManager> ui_resource_manager_; | |
342 | |
343 LayerTreeHostClient* client_; | |
344 std::unique_ptr<Proxy> proxy_; | |
345 std::unique_ptr<TaskRunnerProvider> task_runner_provider_; | |
346 | |
347 int source_frame_number_; | |
348 std::unique_ptr<RenderingStatsInstrumentation> | |
349 rendering_stats_instrumentation_; | |
350 | |
351 SwapPromiseManager swap_promise_manager_; | |
352 | |
353 // |current_compositor_frame_sink_| can't be updated until we've successfully | |
354 // initialized a new CompositorFrameSink. |new_compositor_frame_sink_| | |
355 // contains the new CompositorFrameSink that is currently being initialized. | |
356 // If initialization is successful then |new_compositor_frame_sink_| replaces | |
357 // |current_compositor_frame_sink_|. | |
358 std::unique_ptr<CompositorFrameSink> new_compositor_frame_sink_; | |
359 std::unique_ptr<CompositorFrameSink> current_compositor_frame_sink_; | |
360 | |
361 const LayerTreeSettings settings_; | |
362 LayerTreeDebugState debug_state_; | |
363 | |
364 bool visible_; | |
365 | |
366 bool has_gpu_rasterization_trigger_; | |
367 bool content_is_suitable_for_gpu_rasterization_; | |
368 bool gpu_rasterization_histogram_recorded_; | |
369 | |
370 // If set, then page scale animation has completed, but the client hasn't been | |
371 // notified about it yet. | |
372 bool did_complete_scale_animation_; | |
373 | |
374 int id_; | |
375 bool next_commit_forces_redraw_; | |
376 | |
377 SharedBitmapManager* shared_bitmap_manager_; | |
378 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | |
379 TaskGraphRunner* task_graph_runner_; | |
380 | |
381 ImageSerializationProcessor* image_serialization_processor_; | |
382 std::unique_ptr<EnginePictureCache> engine_picture_cache_; | |
383 std::unique_ptr<ClientPictureCache> client_picture_cache_; | |
384 | |
385 SurfaceSequenceGenerator surface_sequence_generator_; | |
386 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | |
387 | |
388 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | |
389 }; | 202 }; |
390 | 203 |
391 } // namespace cc | 204 } // namespace cc |
392 | 205 |
393 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 206 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
OLD | NEW |