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