Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: cc/trees/layer_tree_host.h

Issue 2159513003: Setup LayerTree class, refactor 2 functions from LayerTreeHost to it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Layer GetLayerTree now directly uses LayerTree pointer. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 22 matching lines...) Expand all
33 #include "cc/input/top_controls_state.h" 33 #include "cc/input/top_controls_state.h"
34 #include "cc/layers/layer_collections.h" 34 #include "cc/layers/layer_collections.h"
35 #include "cc/layers/layer_list_iterator.h" 35 #include "cc/layers/layer_list_iterator.h"
36 #include "cc/output/output_surface.h" 36 #include "cc/output/output_surface.h"
37 #include "cc/output/renderer_capabilities.h" 37 #include "cc/output/renderer_capabilities.h"
38 #include "cc/output/swap_promise.h" 38 #include "cc/output/swap_promise.h"
39 #include "cc/resources/resource_format.h" 39 #include "cc/resources/resource_format.h"
40 #include "cc/resources/scoped_ui_resource.h" 40 #include "cc/resources/scoped_ui_resource.h"
41 #include "cc/surfaces/surface_sequence.h" 41 #include "cc/surfaces/surface_sequence.h"
42 #include "cc/trees/compositor_mode.h" 42 #include "cc/trees/compositor_mode.h"
43 #include "cc/trees/layer_tree.h"
43 #include "cc/trees/layer_tree_host_client.h" 44 #include "cc/trees/layer_tree_host_client.h"
44 #include "cc/trees/layer_tree_settings.h" 45 #include "cc/trees/layer_tree_settings.h"
45 #include "cc/trees/mutator_host_client.h" 46 #include "cc/trees/mutator_host_client.h"
46 #include "cc/trees/proxy.h" 47 #include "cc/trees/proxy.h"
47 #include "cc/trees/swap_promise_monitor.h" 48 #include "cc/trees/swap_promise_monitor.h"
48 #include "third_party/skia/include/core/SkColor.h" 49 #include "third_party/skia/include/core/SkColor.h"
49 #include "ui/gfx/geometry/rect.h" 50 #include "ui/gfx/geometry/rect.h"
50 51
51 namespace gpu { 52 namespace gpu {
52 class GpuMemoryBufferManager; 53 class GpuMemoryBufferManager;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 void UpdateTopControlsState(TopControlsState constraints, 289 void UpdateTopControlsState(TopControlsState constraints,
289 TopControlsState current, 290 TopControlsState current,
290 bool animate); 291 bool animate);
291 292
292 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } 293 HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); }
293 294
294 Proxy* proxy() const { return proxy_.get(); } 295 Proxy* proxy() const { return proxy_.get(); }
295 TaskRunnerProvider* task_runner_provider() const { 296 TaskRunnerProvider* task_runner_provider() const {
296 return task_runner_provider_.get(); 297 return task_runner_provider_.get();
297 } 298 }
298 AnimationHost* animation_host() const { return animation_host_.get(); } 299 AnimationHost* animation_host() const;
299
300 bool in_paint_layer_contents() const { return in_paint_layer_contents_; }
301 300
302 bool has_output_surface() const { return !!current_output_surface_; } 301 bool has_output_surface() const { return !!current_output_surface_; }
303 302
304 // CreateUIResource creates a resource given a bitmap. The bitmap is 303 // CreateUIResource creates a resource given a bitmap. The bitmap is
305 // generated via an interface function, which is called when initializing the 304 // generated via an interface function, which is called when initializing the
306 // resource and when the resource has been lost (due to lost context). The 305 // resource and when the resource has been lost (due to lost context). The
307 // parameter of the interface is a single boolean, which indicates whether the 306 // parameter of the interface is a single boolean, which indicates whether the
308 // resource has been lost or not. CreateUIResource returns an Id of the 307 // resource has been lost or not. CreateUIResource returns an Id of the
309 // resource, which is always positive. 308 // resource, which is always positive.
310 virtual UIResourceId CreateUIResource(UIResourceClient* client); 309 virtual UIResourceId CreateUIResource(UIResourceClient* client);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 349 }
351 350
352 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator); 351 void SetLayerTreeMutator(std::unique_ptr<LayerTreeMutator> mutator);
353 352
354 Layer* LayerById(int id) const; 353 Layer* LayerById(int id) const;
355 354
356 Layer* LayerByElementId(ElementId element_id) const; 355 Layer* LayerByElementId(ElementId element_id) const;
357 void AddToElementMap(Layer* layer); 356 void AddToElementMap(Layer* layer);
358 void RemoveFromElementMap(Layer* layer); 357 void RemoveFromElementMap(Layer* layer);
359 358
360 void AddLayerShouldPushProperties(Layer* layer);
361 void RemoveLayerShouldPushProperties(Layer* layer);
362 std::unordered_set<Layer*>& LayersThatShouldPushProperties();
363 bool LayerNeedsPushPropertiesForTesting(Layer* layer);
364
365 void RegisterLayer(Layer* layer);
366 void UnregisterLayer(Layer* layer);
367 // MutatorHostClient implementation. 359 // MutatorHostClient implementation.
368 bool IsElementInList(ElementId element_id, 360 bool IsElementInList(ElementId element_id,
369 ElementListType list_type) const override; 361 ElementListType list_type) const override;
370 void SetMutatorsNeedCommit() override; 362 void SetMutatorsNeedCommit() override;
371 void SetMutatorsNeedRebuildPropertyTrees() override; 363 void SetMutatorsNeedRebuildPropertyTrees() override;
372 void SetElementFilterMutated(ElementId element_id, 364 void SetElementFilterMutated(ElementId element_id,
373 ElementListType list_type, 365 ElementListType list_type,
374 const FilterOperations& filters) override; 366 const FilterOperations& filters) override;
375 void SetElementOpacityMutated(ElementId element_id, 367 void SetElementOpacityMutated(ElementId element_id,
376 ElementListType list_type, 368 ElementListType list_type,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 417 }
426 418
427 EnginePictureCache* engine_picture_cache() const { 419 EnginePictureCache* engine_picture_cache() const {
428 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr; 420 return engine_picture_cache_ ? engine_picture_cache_.get() : nullptr;
429 } 421 }
430 422
431 ClientPictureCache* client_picture_cache() const { 423 ClientPictureCache* client_picture_cache() const {
432 return client_picture_cache_ ? client_picture_cache_.get() : nullptr; 424 return client_picture_cache_ ? client_picture_cache_.get() : nullptr;
433 } 425 }
434 426
427 LayerTree* GetLayerTree() { return &layer_tree_; }
428 const LayerTree* GetLayerTree() const { return &layer_tree_; }
429
435 protected: 430 protected:
436 LayerTreeHost(InitParams* params, CompositorMode mode); 431 LayerTreeHost(InitParams* params, CompositorMode mode);
437 void InitializeThreaded( 432 void InitializeThreaded(
438 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 433 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
439 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 434 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
440 std::unique_ptr<BeginFrameSource> external_begin_frame_source); 435 std::unique_ptr<BeginFrameSource> external_begin_frame_source);
441 void InitializeSingleThreaded( 436 void InitializeSingleThreaded(
442 LayerTreeHostSingleThreadClient* single_thread_client, 437 LayerTreeHostSingleThreadClient* single_thread_client,
443 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 438 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
444 std::unique_ptr<BeginFrameSource> external_begin_frame_source); 439 std::unique_ptr<BeginFrameSource> external_begin_frame_source);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 bool content_is_suitable_for_gpu_rasterization_; 555 bool content_is_suitable_for_gpu_rasterization_;
561 bool gpu_rasterization_histogram_recorded_; 556 bool gpu_rasterization_histogram_recorded_;
562 557
563 SkColor background_color_; 558 SkColor background_color_;
564 bool has_transparent_background_; 559 bool has_transparent_background_;
565 560
566 bool have_scroll_event_handlers_; 561 bool have_scroll_event_handlers_;
567 EventListenerProperties event_listener_properties_[static_cast<size_t>( 562 EventListenerProperties event_listener_properties_[static_cast<size_t>(
568 EventListenerClass::kNumClasses)]; 563 EventListenerClass::kNumClasses)];
569 564
570 std::unique_ptr<AnimationHost> animation_host_;
571
572 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; 565 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_;
573 566
574 // If set, then page scale animation has completed, but the client hasn't been 567 // If set, then page scale animation has completed, but the client hasn't been
575 // notified about it yet. 568 // notified about it yet.
576 bool did_complete_scale_animation_; 569 bool did_complete_scale_animation_;
577 570
578 bool in_paint_layer_contents_;
579
580 int id_; 571 int id_;
581 bool next_commit_forces_redraw_; 572 bool next_commit_forces_redraw_;
582 573
583 scoped_refptr<Layer> overscroll_elasticity_layer_; 574 scoped_refptr<Layer> overscroll_elasticity_layer_;
584 scoped_refptr<Layer> page_scale_layer_; 575 scoped_refptr<Layer> page_scale_layer_;
585 scoped_refptr<Layer> inner_viewport_scroll_layer_; 576 scoped_refptr<Layer> inner_viewport_scroll_layer_;
586 scoped_refptr<Layer> outer_viewport_scroll_layer_; 577 scoped_refptr<Layer> outer_viewport_scroll_layer_;
587 578
588 LayerSelection selection_; 579 LayerSelection selection_;
589 580
590 SharedBitmapManager* shared_bitmap_manager_; 581 SharedBitmapManager* shared_bitmap_manager_;
591 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_; 582 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
592 TaskGraphRunner* task_graph_runner_; 583 TaskGraphRunner* task_graph_runner_;
593 584
594 ImageSerializationProcessor* image_serialization_processor_; 585 ImageSerializationProcessor* image_serialization_processor_;
595 std::unique_ptr<EnginePictureCache> engine_picture_cache_; 586 std::unique_ptr<EnginePictureCache> engine_picture_cache_;
596 std::unique_ptr<ClientPictureCache> client_picture_cache_; 587 std::unique_ptr<ClientPictureCache> client_picture_cache_;
597 588
598 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; 589 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_;
599 std::set<SwapPromiseMonitor*> swap_promise_monitor_; 590 std::set<SwapPromiseMonitor*> swap_promise_monitor_;
600 591
601 PropertyTrees property_trees_; 592 PropertyTrees property_trees_;
602 593
603 using LayerIdMap = std::unordered_map<int, Layer*>;
604 LayerIdMap layer_id_map_;
605
606 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>; 594 using ElementLayersMap = std::unordered_map<ElementId, Layer*, ElementIdHash>;
607 ElementLayersMap element_layers_map_; 595 ElementLayersMap element_layers_map_;
608 596
609 // Set of layers that need to push properties.
610 std::unordered_set<Layer*> layers_that_should_push_properties_;
611
612 uint32_t surface_client_id_; 597 uint32_t surface_client_id_;
613 uint32_t next_surface_sequence_; 598 uint32_t next_surface_sequence_;
614 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0; 599 uint32_t num_consecutive_frames_suitable_for_gpu_ = 0;
615 600
601 // Layer tree that hold layers.
602 LayerTree layer_tree_;
603
616 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost); 604 DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
617 }; 605 };
618 606
619 } // namespace cc 607 } // namespace cc
620 608
621 #endif // CC_TREES_LAYER_TREE_HOST_H_ 609 #endif // CC_TREES_LAYER_TREE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698