| OLD | NEW |
| 1 // Copyright 2011 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> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "cc/input/event_listener_properties.h" | 27 #include "cc/input/event_listener_properties.h" |
| 28 #include "cc/input/input_handler.h" | 28 #include "cc/input/input_handler.h" |
| 29 #include "cc/input/layer_selection_bound.h" | 29 #include "cc/input/layer_selection_bound.h" |
| 30 #include "cc/input/scrollbar.h" | 30 #include "cc/input/scrollbar.h" |
| 31 #include "cc/input/top_controls_state.h" | 31 #include "cc/input/top_controls_state.h" |
| 32 #include "cc/layers/layer_collections.h" | 32 #include "cc/layers/layer_collections.h" |
| 33 #include "cc/layers/layer_list_iterator.h" | 33 #include "cc/layers/layer_list_iterator.h" |
| 34 #include "cc/output/output_surface.h" | 34 #include "cc/output/output_surface.h" |
| 35 #include "cc/output/swap_promise.h" | 35 #include "cc/output/swap_promise.h" |
| 36 #include "cc/resources/resource_format.h" | 36 #include "cc/resources/resource_format.h" |
| 37 #include "cc/resources/scoped_ui_resource.h" | |
| 38 #include "cc/surfaces/surface_sequence.h" | 37 #include "cc/surfaces/surface_sequence.h" |
| 39 #include "cc/trees/compositor_mode.h" | 38 #include "cc/trees/compositor_mode.h" |
| 40 #include "cc/trees/layer_tree.h" | 39 #include "cc/trees/layer_tree.h" |
| 41 #include "cc/trees/layer_tree_host_client.h" | 40 #include "cc/trees/layer_tree_host_client.h" |
| 42 #include "cc/trees/layer_tree_host_interface.h" | 41 #include "cc/trees/layer_tree_host_interface.h" |
| 43 #include "cc/trees/layer_tree_settings.h" | 42 #include "cc/trees/layer_tree_settings.h" |
| 44 #include "cc/trees/proxy.h" | 43 #include "cc/trees/proxy.h" |
| 45 #include "cc/trees/swap_promise_monitor.h" | 44 #include "cc/trees/swap_promise_monitor.h" |
| 46 #include "third_party/skia/include/core/SkColor.h" | 45 #include "third_party/skia/include/core/SkColor.h" |
| 47 #include "ui/gfx/geometry/rect.h" | 46 #include "ui/gfx/geometry/rect.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 66 class LayerTreeMutator; | 65 class LayerTreeMutator; |
| 67 class PropertyTrees; | 66 class PropertyTrees; |
| 68 class Region; | 67 class Region; |
| 69 class RemoteProtoChannel; | 68 class RemoteProtoChannel; |
| 70 class RenderingStatsInstrumentation; | 69 class RenderingStatsInstrumentation; |
| 71 class ResourceProvider; | 70 class ResourceProvider; |
| 72 class ResourceUpdateQueue; | 71 class ResourceUpdateQueue; |
| 73 class SharedBitmapManager; | 72 class SharedBitmapManager; |
| 74 class TaskGraphRunner; | 73 class TaskGraphRunner; |
| 75 class TopControlsManager; | 74 class TopControlsManager; |
| 76 class UIResourceRequest; | |
| 77 struct PendingPageScaleAnimation; | 75 struct PendingPageScaleAnimation; |
| 78 struct RenderingStats; | 76 struct RenderingStats; |
| 79 struct ScrollAndScaleSet; | 77 struct ScrollAndScaleSet; |
| 80 | 78 |
| 81 namespace proto { | 79 namespace proto { |
| 82 class LayerTreeHost; | 80 class LayerTreeHost; |
| 83 } | 81 } |
| 84 | 82 |
| 85 // This class is being refactored to an interface, see LayerTreeHostInterface, | 83 // This class is being refactored to an interface, see LayerTreeHostInterface, |
| 86 // which is the API for the cc embedder. When adding new code to this class, | 84 // which is the API for the cc embedder. When adding new code to this class, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 136 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 139 InitParams* params); | 137 InitParams* params); |
| 140 | 138 |
| 141 ~LayerTreeHost() override; | 139 ~LayerTreeHost() override; |
| 142 | 140 |
| 143 // LayerTreeHostInterface implementation. | 141 // LayerTreeHostInterface implementation. |
| 144 int GetId() const override; | 142 int GetId() const override; |
| 145 int SourceFrameNumber() const override; | 143 int SourceFrameNumber() const override; |
| 146 LayerTree* GetLayerTree() override; | 144 LayerTree* GetLayerTree() override; |
| 147 const LayerTree* GetLayerTree() const override; | 145 const LayerTree* GetLayerTree() const override; |
| 146 UIResourceManager* GetUIResourceManager() const override; |
| 148 TaskRunnerProvider* GetTaskRunnerProvider() const override; | 147 TaskRunnerProvider* GetTaskRunnerProvider() const override; |
| 149 const LayerTreeSettings& GetSettings() const override; | 148 const LayerTreeSettings& GetSettings() const override; |
| 150 void SetSurfaceClientId(uint32_t client_id) override; | 149 void SetSurfaceClientId(uint32_t client_id) override; |
| 151 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; | 150 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; |
| 152 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override; | 151 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override; |
| 153 void SetHasGpuRasterizationTrigger(bool has_trigger) override; | 152 void SetHasGpuRasterizationTrigger(bool has_trigger) override; |
| 154 void SetVisible(bool visible) override; | 153 void SetVisible(bool visible) override; |
| 155 bool IsVisible() const override; | 154 bool IsVisible() const override; |
| 156 void SetOutputSurface(std::unique_ptr<OutputSurface> output_surface) override; | 155 void SetOutputSurface(std::unique_ptr<OutputSurface> output_surface) override; |
| 157 std::unique_ptr<OutputSurface> ReleaseOutputSurface() override; | 156 std::unique_ptr<OutputSurface> ReleaseOutputSurface() override; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 void SetNextCommitWaitsForActivation(); | 220 void SetNextCommitWaitsForActivation(); |
| 222 | 221 |
| 223 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); | 222 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); |
| 224 | 223 |
| 225 bool has_gpu_rasterization_trigger() const { | 224 bool has_gpu_rasterization_trigger() const { |
| 226 return has_gpu_rasterization_trigger_; | 225 return has_gpu_rasterization_trigger_; |
| 227 } | 226 } |
| 228 | 227 |
| 229 Proxy* proxy() const { return proxy_.get(); } | 228 Proxy* proxy() const { return proxy_.get(); } |
| 230 | 229 |
| 231 // CreateUIResource creates a resource given a bitmap. The bitmap is | |
| 232 // generated via an interface function, which is called when initializing the | |
| 233 // resource and when the resource has been lost (due to lost context). The | |
| 234 // parameter of the interface is a single boolean, which indicates whether the | |
| 235 // resource has been lost or not. CreateUIResource returns an Id of the | |
| 236 // resource, which is always positive. | |
| 237 virtual UIResourceId CreateUIResource(UIResourceClient* client); | |
| 238 // Deletes a UI resource. May safely be called more than once. | |
| 239 virtual void DeleteUIResource(UIResourceId id); | |
| 240 // Put the recreation of all UI resources into the resource queue after they | |
| 241 // were evicted on the impl thread. | |
| 242 void RecreateUIResources(); | |
| 243 | |
| 244 virtual gfx::Size GetUIResourceSize(UIResourceId id) const; | |
| 245 | |
| 246 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); | 230 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); |
| 247 std::vector<std::unique_ptr<SwapPromise>> TakeSwapPromises(); | 231 std::vector<std::unique_ptr<SwapPromise>> TakeSwapPromises(); |
| 248 | 232 |
| 249 size_t num_queued_swap_promises() const { return swap_promise_list_.size(); } | 233 size_t num_queued_swap_promises() const { return swap_promise_list_.size(); } |
| 250 | 234 |
| 251 SurfaceSequence CreateSurfaceSequence(); | 235 SurfaceSequence CreateSurfaceSequence(); |
| 252 | 236 |
| 253 // Serializes the parts of this LayerTreeHost that is needed for a commit to a | 237 // Serializes the parts of this LayerTreeHost that is needed for a commit to a |
| 254 // protobuf message. Not all members are serialized as they are not helpful | 238 // protobuf message. Not all members are serialized as they are not helpful |
| 255 // for remote usage. | 239 // for remote usage. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 RemoteProtoChannel* remote_proto_channel, | 290 RemoteProtoChannel* remote_proto_channel, |
| 307 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 291 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 308 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 292 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 309 void InitializeForTesting( | 293 void InitializeForTesting( |
| 310 std::unique_ptr<TaskRunnerProvider> task_runner_provider, | 294 std::unique_ptr<TaskRunnerProvider> task_runner_provider, |
| 311 std::unique_ptr<Proxy> proxy_for_testing, | 295 std::unique_ptr<Proxy> proxy_for_testing, |
| 312 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 296 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
| 313 void InitializePictureCacheForTesting(); | 297 void InitializePictureCacheForTesting(); |
| 314 void SetTaskRunnerProviderForTesting( | 298 void SetTaskRunnerProviderForTesting( |
| 315 std::unique_ptr<TaskRunnerProvider> task_runner_provider); | 299 std::unique_ptr<TaskRunnerProvider> task_runner_provider); |
| 300 void SetUIResourceManagerForTesting( |
| 301 std::unique_ptr<UIResourceManager> ui_resource_manager); |
| 316 | 302 |
| 317 // shared_bitmap_manager(), gpu_memory_buffer_manager(), and | 303 // shared_bitmap_manager(), gpu_memory_buffer_manager(), and |
| 318 // task_graph_runner() return valid values only until the LayerTreeHostImpl is | 304 // task_graph_runner() return valid values only until the LayerTreeHostImpl is |
| 319 // created in CreateLayerTreeHostImpl(). | 305 // created in CreateLayerTreeHostImpl(). |
| 320 SharedBitmapManager* shared_bitmap_manager() const { | 306 SharedBitmapManager* shared_bitmap_manager() const { |
| 321 return shared_bitmap_manager_; | 307 return shared_bitmap_manager_; |
| 322 } | 308 } |
| 323 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const { | 309 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const { |
| 324 return gpu_memory_buffer_manager_; | 310 return gpu_memory_buffer_manager_; |
| 325 } | 311 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 346 void ApplyPageScaleDeltaFromImplSide(float page_scale_delta); | 332 void ApplyPageScaleDeltaFromImplSide(float page_scale_delta); |
| 347 void InitializeProxy( | 333 void InitializeProxy( |
| 348 std::unique_ptr<Proxy> proxy, | 334 std::unique_ptr<Proxy> proxy, |
| 349 std::unique_ptr<BeginFrameSource> external_begin_frame_source); | 335 std::unique_ptr<BeginFrameSource> external_begin_frame_source); |
| 350 | 336 |
| 351 bool DoUpdateLayers(Layer* root_layer); | 337 bool DoUpdateLayers(Layer* root_layer); |
| 352 void UpdateHudLayer(); | 338 void UpdateHudLayer(); |
| 353 | 339 |
| 354 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); | 340 bool AnimateLayersRecursive(Layer* current, base::TimeTicks time); |
| 355 | 341 |
| 356 struct UIResourceClientData { | |
| 357 UIResourceClient* client; | |
| 358 gfx::Size size; | |
| 359 }; | |
| 360 | |
| 361 using UIResourceClientMap = | |
| 362 std::unordered_map<UIResourceId, UIResourceClientData>; | |
| 363 UIResourceClientMap ui_resource_client_map_; | |
| 364 int next_ui_resource_id_; | |
| 365 | |
| 366 using UIResourceRequestQueue = std::vector<UIResourceRequest>; | |
| 367 UIResourceRequestQueue ui_resource_request_queue_; | |
| 368 | |
| 369 void CalculateLCDTextMetricsCallback(Layer* layer); | 342 void CalculateLCDTextMetricsCallback(Layer* layer); |
| 370 | 343 |
| 371 void NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 344 void NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
| 372 | 345 |
| 373 void SetPropertyTreesNeedRebuild(); | 346 void SetPropertyTreesNeedRebuild(); |
| 374 | 347 |
| 375 const CompositorMode compositor_mode_; | 348 const CompositorMode compositor_mode_; |
| 376 | 349 |
| 350 std::unique_ptr<UIResourceManager> ui_resource_manager_; |
| 351 |
| 377 LayerTreeHostClient* client_; | 352 LayerTreeHostClient* client_; |
| 378 std::unique_ptr<Proxy> proxy_; | 353 std::unique_ptr<Proxy> proxy_; |
| 379 std::unique_ptr<TaskRunnerProvider> task_runner_provider_; | 354 std::unique_ptr<TaskRunnerProvider> task_runner_provider_; |
| 380 | 355 |
| 381 int source_frame_number_; | 356 int source_frame_number_; |
| 382 std::unique_ptr<RenderingStatsInstrumentation> | 357 std::unique_ptr<RenderingStatsInstrumentation> |
| 383 rendering_stats_instrumentation_; | 358 rendering_stats_instrumentation_; |
| 384 | 359 |
| 385 // |current_output_surface_| can't be updated until we've successfully | 360 // |current_output_surface_| can't be updated until we've successfully |
| 386 // initialized a new output surface. |new_output_surface_| contains the | 361 // initialized a new output surface. |new_output_surface_| contains the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 uint32_t surface_client_id_; | 395 uint32_t surface_client_id_; |
| 421 uint32_t next_surface_sequence_; | 396 uint32_t next_surface_sequence_; |
| 422 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | 397 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; |
| 423 | 398 |
| 424 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 399 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
| 425 }; | 400 }; |
| 426 | 401 |
| 427 } // namespace cc | 402 } // namespace cc |
| 428 | 403 |
| 429 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 404 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
| OLD | NEW |