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