| 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 17 matching lines...) Expand all Loading... |
| 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" | 37 #include "cc/resources/scoped_ui_resource.h" |
| 38 #include "cc/surfaces/surface_sequence.h" | 38 #include "cc/surfaces/surface_sequence_generator.h" |
| 39 #include "cc/trees/compositor_mode.h" | 39 #include "cc/trees/compositor_mode.h" |
| 40 #include "cc/trees/layer_tree.h" | 40 #include "cc/trees/layer_tree.h" |
| 41 #include "cc/trees/layer_tree_host_client.h" | 41 #include "cc/trees/layer_tree_host_client.h" |
| 42 #include "cc/trees/layer_tree_host_interface.h" | 42 #include "cc/trees/layer_tree_host_interface.h" |
| 43 #include "cc/trees/layer_tree_settings.h" | 43 #include "cc/trees/layer_tree_settings.h" |
| 44 #include "cc/trees/proxy.h" | 44 #include "cc/trees/proxy.h" |
| 45 #include "cc/trees/swap_promise_monitor.h" | 45 #include "cc/trees/swap_promise_monitor.h" |
| 46 #include "third_party/skia/include/core/SkColor.h" | 46 #include "third_party/skia/include/core/SkColor.h" |
| 47 #include "ui/gfx/geometry/rect.h" | 47 #include "ui/gfx/geometry/rect.h" |
| 48 | 48 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 class RenderingStatsInstrumentation; | 70 class RenderingStatsInstrumentation; |
| 71 class ResourceProvider; | 71 class ResourceProvider; |
| 72 class ResourceUpdateQueue; | 72 class ResourceUpdateQueue; |
| 73 class SharedBitmapManager; | 73 class SharedBitmapManager; |
| 74 class TaskGraphRunner; | 74 class TaskGraphRunner; |
| 75 class TopControlsManager; | 75 class TopControlsManager; |
| 76 class UIResourceRequest; | 76 class UIResourceRequest; |
| 77 struct PendingPageScaleAnimation; | 77 struct PendingPageScaleAnimation; |
| 78 struct RenderingStats; | 78 struct RenderingStats; |
| 79 struct ScrollAndScaleSet; | 79 struct ScrollAndScaleSet; |
| 80 class SwapPromiseManager; |
| 80 | 81 |
| 81 namespace proto { | 82 namespace proto { |
| 82 class LayerTreeHost; | 83 class LayerTreeHost; |
| 83 } | 84 } |
| 84 | 85 |
| 85 // This class is being refactored to an interface, see LayerTreeHostInterface, | 86 // 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, | 87 // which is the API for the cc embedder. When adding new code to this class, |
| 87 // consider the following: | 88 // consider the following: |
| 88 // 1) If its state/data that gets pushed to the LayerTreeImpl during commit, add | 89 // 1) If its state/data that gets pushed to the LayerTreeImpl during commit, add |
| 89 // it to the LayerTree. | 90 // it to the LayerTree. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 InitParams* params); | 140 InitParams* params); |
| 140 | 141 |
| 141 ~LayerTreeHost() override; | 142 ~LayerTreeHost() override; |
| 142 | 143 |
| 143 // LayerTreeHostInterface implementation. | 144 // LayerTreeHostInterface implementation. |
| 144 int GetId() const override; | 145 int GetId() const override; |
| 145 int SourceFrameNumber() const override; | 146 int SourceFrameNumber() const override; |
| 146 LayerTree* GetLayerTree() override; | 147 LayerTree* GetLayerTree() override; |
| 147 const LayerTree* GetLayerTree() const override; | 148 const LayerTree* GetLayerTree() const override; |
| 148 TaskRunnerProvider* GetTaskRunnerProvider() const override; | 149 TaskRunnerProvider* GetTaskRunnerProvider() const override; |
| 150 SwapPromiseManager* GetSwapPromiseManager() const override; |
| 149 const LayerTreeSettings& GetSettings() const override; | 151 const LayerTreeSettings& GetSettings() const override; |
| 150 void SetSurfaceClientId(uint32_t client_id) override; | 152 SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override; |
| 151 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; | 153 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator) override; |
| 152 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise) override; | |
| 153 void SetHasGpuRasterizationTrigger(bool has_trigger) override; | 154 void SetHasGpuRasterizationTrigger(bool has_trigger) override; |
| 154 void SetVisible(bool visible) override; | 155 void SetVisible(bool visible) override; |
| 155 bool IsVisible() const override; | 156 bool IsVisible() const override; |
| 156 void SetOutputSurface(std::unique_ptr<OutputSurface> output_surface) override; | 157 void SetOutputSurface(std::unique_ptr<OutputSurface> output_surface) override; |
| 157 std::unique_ptr<OutputSurface> ReleaseOutputSurface() override; | 158 std::unique_ptr<OutputSurface> ReleaseOutputSurface() override; |
| 158 void SetNeedsAnimate() override; | 159 void SetNeedsAnimate() override; |
| 159 void SetNeedsUpdateLayers() override; | 160 void SetNeedsUpdateLayers() override; |
| 160 void SetNeedsCommit() override; | 161 void SetNeedsCommit() override; |
| 161 bool BeginMainFrameRequested() const override; | 162 bool BeginMainFrameRequested() const override; |
| 162 bool CommitRequested() const override; | 163 bool CommitRequested() const override; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 173 const base::WeakPtr<InputHandler>& GetInputHandler() const override; | 174 const base::WeakPtr<InputHandler>& GetInputHandler() const override; |
| 174 void DidStopFlinging() override; | 175 void DidStopFlinging() override; |
| 175 void SetDebugState(const LayerTreeDebugState& debug_state) override; | 176 void SetDebugState(const LayerTreeDebugState& debug_state) override; |
| 176 const LayerTreeDebugState& GetDebugState() const override; | 177 const LayerTreeDebugState& GetDebugState() const override; |
| 177 int ScheduleMicroBenchmark( | 178 int ScheduleMicroBenchmark( |
| 178 const std::string& benchmark_name, | 179 const std::string& benchmark_name, |
| 179 std::unique_ptr<base::Value> value, | 180 std::unique_ptr<base::Value> value, |
| 180 const MicroBenchmark::DoneCallback& callback) override; | 181 const MicroBenchmark::DoneCallback& callback) override; |
| 181 bool SendMessageToMicroBenchmark(int id, | 182 bool SendMessageToMicroBenchmark(int id, |
| 182 std::unique_ptr<base::Value> value) override; | 183 std::unique_ptr<base::Value> value) override; |
| 183 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) override; | |
| 184 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) override; | |
| 185 | 184 |
| 186 // LayerTreeHost interface to Proxy. | 185 // LayerTreeHost interface to Proxy. |
| 187 void WillBeginMainFrame(); | 186 void WillBeginMainFrame(); |
| 188 void DidBeginMainFrame(); | 187 void DidBeginMainFrame(); |
| 189 void BeginMainFrame(const BeginFrameArgs& args); | 188 void BeginMainFrame(const BeginFrameArgs& args); |
| 190 void BeginMainFrameNotExpectedSoon(); | 189 void BeginMainFrameNotExpectedSoon(); |
| 191 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); | 190 void AnimateLayers(base::TimeTicks monotonic_frame_begin_time); |
| 192 void RequestMainFrameUpdate(); | 191 void RequestMainFrameUpdate(); |
| 193 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); | 192 void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl); |
| 194 void WillCommit(); | 193 void WillCommit(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // resource, which is always positive. | 235 // resource, which is always positive. |
| 237 virtual UIResourceId CreateUIResource(UIResourceClient* client); | 236 virtual UIResourceId CreateUIResource(UIResourceClient* client); |
| 238 // Deletes a UI resource. May safely be called more than once. | 237 // Deletes a UI resource. May safely be called more than once. |
| 239 virtual void DeleteUIResource(UIResourceId id); | 238 virtual void DeleteUIResource(UIResourceId id); |
| 240 // Put the recreation of all UI resources into the resource queue after they | 239 // Put the recreation of all UI resources into the resource queue after they |
| 241 // were evicted on the impl thread. | 240 // were evicted on the impl thread. |
| 242 void RecreateUIResources(); | 241 void RecreateUIResources(); |
| 243 | 242 |
| 244 virtual gfx::Size GetUIResourceSize(UIResourceId id) const; | 243 virtual gfx::Size GetUIResourceSize(UIResourceId id) const; |
| 245 | 244 |
| 246 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); | |
| 247 std::vector<std::unique_ptr<SwapPromise>> TakeSwapPromises(); | |
| 248 | |
| 249 size_t num_queued_swap_promises() const { return swap_promise_list_.size(); } | |
| 250 | |
| 251 SurfaceSequence CreateSurfaceSequence(); | |
| 252 | |
| 253 // Serializes the parts of this LayerTreeHost that is needed for a commit to a | 245 // 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 | 246 // protobuf message. Not all members are serialized as they are not helpful |
| 255 // for remote usage. | 247 // for remote usage. |
| 256 // The |swap_promise_list_| is transferred to the serializer in | 248 // The |swap_promise_list_| is transferred to the serializer in |
| 257 // |swap_promises|. | 249 // |swap_promises|. |
| 258 void ToProtobufForCommit( | 250 void ToProtobufForCommit( |
| 259 proto::LayerTreeHost* proto, | 251 proto::LayerTreeHost* proto, |
| 260 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); | 252 std::vector<std::unique_ptr<SwapPromise>>* swap_promises); |
| 261 | 253 |
| 262 // Deserializes the protobuf into this LayerTreeHost before a commit. The | 254 // Deserializes the protobuf into this LayerTreeHost before a commit. The |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 using UIResourceClientMap = | 353 using UIResourceClientMap = |
| 362 std::unordered_map<UIResourceId, UIResourceClientData>; | 354 std::unordered_map<UIResourceId, UIResourceClientData>; |
| 363 UIResourceClientMap ui_resource_client_map_; | 355 UIResourceClientMap ui_resource_client_map_; |
| 364 int next_ui_resource_id_; | 356 int next_ui_resource_id_; |
| 365 | 357 |
| 366 using UIResourceRequestQueue = std::vector<UIResourceRequest>; | 358 using UIResourceRequestQueue = std::vector<UIResourceRequest>; |
| 367 UIResourceRequestQueue ui_resource_request_queue_; | 359 UIResourceRequestQueue ui_resource_request_queue_; |
| 368 | 360 |
| 369 void CalculateLCDTextMetricsCallback(Layer* layer); | 361 void CalculateLCDTextMetricsCallback(Layer* layer); |
| 370 | 362 |
| 371 void NotifySwapPromiseMonitorsOfSetNeedsCommit(); | |
| 372 | |
| 373 void SetPropertyTreesNeedRebuild(); | 363 void SetPropertyTreesNeedRebuild(); |
| 374 | 364 |
| 375 const CompositorMode compositor_mode_; | 365 const CompositorMode compositor_mode_; |
| 376 | 366 |
| 377 LayerTreeHostClient* client_; | 367 LayerTreeHostClient* client_; |
| 378 std::unique_ptr<Proxy> proxy_; | 368 std::unique_ptr<Proxy> proxy_; |
| 379 std::unique_ptr<TaskRunnerProvider> task_runner_provider_; | 369 std::unique_ptr<TaskRunnerProvider> task_runner_provider_; |
| 380 | 370 |
| 381 int source_frame_number_; | 371 int source_frame_number_; |
| 382 std::unique_ptr<RenderingStatsInstrumentation> | 372 std::unique_ptr<RenderingStatsInstrumentation> |
| 383 rendering_stats_instrumentation_; | 373 rendering_stats_instrumentation_; |
| 384 | 374 |
| 375 std::unique_ptr<SwapPromiseManager> swap_promise_manager_; |
| 376 |
| 385 // |current_output_surface_| can't be updated until we've successfully | 377 // |current_output_surface_| can't be updated until we've successfully |
| 386 // initialized a new output surface. |new_output_surface_| contains the | 378 // initialized a new output surface. |new_output_surface_| contains the |
| 387 // new output surface that is currently being initialized. If initialization | 379 // new output surface that is currently being initialized. If initialization |
| 388 // is successful then |new_output_surface_| replaces | 380 // is successful then |new_output_surface_| replaces |
| 389 // |current_output_surface_|. | 381 // |current_output_surface_|. |
| 390 std::unique_ptr<OutputSurface> new_output_surface_; | 382 std::unique_ptr<OutputSurface> new_output_surface_; |
| 391 std::unique_ptr<OutputSurface> current_output_surface_; | 383 std::unique_ptr<OutputSurface> current_output_surface_; |
| 392 | 384 |
| 393 const LayerTreeSettings settings_; | 385 const LayerTreeSettings settings_; |
| 394 LayerTreeDebugState debug_state_; | 386 LayerTreeDebugState debug_state_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 407 bool next_commit_forces_redraw_; | 399 bool next_commit_forces_redraw_; |
| 408 | 400 |
| 409 SharedBitmapManager* shared_bitmap_manager_; | 401 SharedBitmapManager* shared_bitmap_manager_; |
| 410 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; | 402 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
| 411 TaskGraphRunner* task_graph_runner_; | 403 TaskGraphRunner* task_graph_runner_; |
| 412 | 404 |
| 413 ImageSerializationProcessor* image_serialization_processor_; | 405 ImageSerializationProcessor* image_serialization_processor_; |
| 414 std::unique_ptr<EnginePictureCache> engine_picture_cache_; | 406 std::unique_ptr<EnginePictureCache> engine_picture_cache_; |
| 415 std::unique_ptr<ClientPictureCache> client_picture_cache_; | 407 std::unique_ptr<ClientPictureCache> client_picture_cache_; |
| 416 | 408 |
| 417 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; | 409 SurfaceSequenceGenerator surface_sequence_generator_; |
| 418 std::set<SwapPromiseMonitor*> swap_promise_monitor_; | |
| 419 | |
| 420 uint32_t surface_client_id_; | |
| 421 uint32_t next_surface_sequence_; | |
| 422 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; | 410 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; |
| 423 | 411 |
| 424 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); | 412 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); |
| 425 }; | 413 }; |
| 426 | 414 |
| 427 } // namespace cc | 415 } // namespace cc |
| 428 | 416 |
| 429 #endif // CC_TREES_LAYER_TREE_HOST_H_ | 417 #endif // CC_TREES_LAYER_TREE_HOST_H_ |
| OLD | NEW |