| Index: cc/trees/layer_tree_host.h
|
| diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
|
| index 7beade48d5a39f1e6d750b8210de60a7c097d780..05c060151ff14a341d6bd5d44e71b52317dc980a 100644
|
| --- a/cc/trees/layer_tree_host.h
|
| +++ b/cc/trees/layer_tree_host.h
|
| @@ -36,9 +36,9 @@
|
| #include "cc/surfaces/surface_reference_owner.h"
|
| #include "cc/surfaces/surface_sequence_generator.h"
|
| #include "cc/trees/compositor_mode.h"
|
| -#include "cc/trees/layer_tree.h"
|
| #include "cc/trees/layer_tree_host_client.h"
|
| #include "cc/trees/layer_tree_settings.h"
|
| +#include "cc/trees/mutator_host.h"
|
| #include "cc/trees/proxy.h"
|
| #include "cc/trees/swap_promise_manager.h"
|
| #include "cc/trees/target_property.h"
|
| @@ -46,22 +46,24 @@
|
| #include "ui/gfx/geometry/rect.h"
|
|
|
| namespace cc {
|
| -class MutatorEvents;
|
| +class HeadsUpDisplayLayer;
|
| class Layer;
|
| class LayerTreeHostClient;
|
| class LayerTreeHostImpl;
|
| class LayerTreeHostImplClient;
|
| class LayerTreeHostSingleThreadClient;
|
| class LayerTreeMutator;
|
| +class MutatorEvents;
|
| class MutatorHost;
|
| +struct PendingPageScaleAnimation;
|
| class RenderingStatsInstrumentation;
|
| class TaskGraphRunner;
|
| class UIResourceManager;
|
| struct RenderingStats;
|
| struct ScrollAndScaleSet;
|
|
|
| -class CC_EXPORT LayerTreeHost
|
| - : public NON_EXPORTED_BASE(SurfaceReferenceOwner) {
|
| +class CC_EXPORT LayerTreeHost : public NON_EXPORTED_BASE(SurfaceReferenceOwner),
|
| + public NON_EXPORTED_BASE(MutatorHostClient) {
|
| public:
|
| // TODO(sad): InitParams should be a movable type so that it can be
|
| // std::move()d to the Create* functions.
|
| @@ -94,11 +96,6 @@ class CC_EXPORT LayerTreeHost
|
| // update(commit) pushed to the compositor thread.
|
| int SourceFrameNumber() const;
|
|
|
| - // Returns the LayerTree that holds the main frame state pushed to the
|
| - // LayerTreeImpl on commit.
|
| - LayerTree* GetLayerTree();
|
| - const LayerTree* GetLayerTree() const;
|
| -
|
| // Returns the UIResourceManager used to create UIResources for
|
| // UIResourceLayers pushed to the LayerTree.
|
| UIResourceManager* GetUIResourceManager() const;
|
| @@ -235,8 +232,143 @@ class CC_EXPORT LayerTreeHost
|
| // Calling this will reset it back to not suitable state.
|
| void ResetGpuRasterizationTracking();
|
|
|
| - // SurfaceReferenceOwner implementation.
|
| - SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override;
|
| + void SetRootLayer(scoped_refptr<Layer> root_layer);
|
| + Layer* root_layer() { return root_layer_.get(); }
|
| + const Layer* root_layer() const { return root_layer_.get(); }
|
| +
|
| + void RegisterViewportLayers(scoped_refptr<Layer> overscroll_elasticity_layer,
|
| + scoped_refptr<Layer> page_scale_layer,
|
| + scoped_refptr<Layer> inner_viewport_scroll_layer,
|
| + scoped_refptr<Layer> outer_viewport_scroll_layer);
|
| +
|
| + Layer* overscroll_elasticity_layer() const {
|
| + return overscroll_elasticity_layer_.get();
|
| + }
|
| + Layer* page_scale_layer() const { return page_scale_layer_.get(); }
|
| + Layer* inner_viewport_scroll_layer() const {
|
| + return inner_viewport_scroll_layer_.get();
|
| + }
|
| + Layer* outer_viewport_scroll_layer() const {
|
| + return outer_viewport_scroll_layer_.get();
|
| + }
|
| +
|
| + void RegisterSelection(const LayerSelection& selection);
|
| + const LayerSelection& selection() const { return selection_; }
|
| +
|
| + void SetHaveScrollEventHandlers(bool have_event_handlers);
|
| + bool have_scroll_event_handlers() const {
|
| + return have_scroll_event_handlers_;
|
| + }
|
| +
|
| + void SetEventListenerProperties(EventListenerClass event_class,
|
| + EventListenerProperties event_properties);
|
| + EventListenerProperties event_listener_properties(
|
| + EventListenerClass event_class) const {
|
| + return event_listener_properties_[static_cast<size_t>(event_class)];
|
| + }
|
| +
|
| + void SetViewportSize(const gfx::Size& device_viewport_size);
|
| + gfx::Size device_viewport_size() const { return device_viewport_size_; }
|
| +
|
| + void SetBrowserControlsHeight(float height, bool shrink);
|
| + void SetBrowserControlsShownRatio(float ratio);
|
| + void SetBottomControlsHeight(float height);
|
| +
|
| + void SetPageScaleFactorAndLimits(float page_scale_factor,
|
| + float min_page_scale_factor,
|
| + float max_page_scale_factor);
|
| + float page_scale_factor() const { return page_scale_factor_; }
|
| + float min_page_scale_factor() const { return min_page_scale_factor_; }
|
| + float max_page_scale_factor() const { return max_page_scale_factor_; }
|
| +
|
| + void set_background_color(SkColor color) { background_color_ = color; }
|
| + SkColor background_color() const { return background_color_; }
|
| +
|
| + void set_has_transparent_background(bool transparent) {
|
| + has_transparent_background_ = transparent;
|
| + }
|
| + bool has_transparent_background() const {
|
| + return has_transparent_background_;
|
| + }
|
| +
|
| + void StartPageScaleAnimation(const gfx::Vector2d& target_offset,
|
| + bool use_anchor,
|
| + float scale,
|
| + base::TimeDelta duration);
|
| + bool HasPendingPageScaleAnimation() const;
|
| +
|
| + void SetDeviceScaleFactor(float device_scale_factor);
|
| + float device_scale_factor() const { return device_scale_factor_; }
|
| +
|
| + void SetPaintedDeviceScaleFactor(float painted_device_scale_factor);
|
| + float painted_device_scale_factor() const {
|
| + return painted_device_scale_factor_;
|
| + }
|
| +
|
| + void SetDeviceColorSpace(const gfx::ColorSpace& device_color_space);
|
| + const gfx::ColorSpace& device_color_space() const {
|
| + return device_color_space_;
|
| + }
|
| +
|
| + // Used externally by blink for setting the PropertyTrees when
|
| + // |settings_.use_layer_lists| is true. This is a SPV2 setting.
|
| + PropertyTrees* property_trees() { return &property_trees_; }
|
| +
|
| + void SetNeedsDisplayOnAllLayers();
|
| +
|
| + void RegisterLayer(Layer* layer);
|
| + void UnregisterLayer(Layer* layer);
|
| + Layer* LayerById(int id) const;
|
| +
|
| + size_t NumLayers() const;
|
| +
|
| + bool UpdateLayers(const LayerList& update_layer_list,
|
| + bool* content_is_suitable_for_gpu);
|
| + bool in_paint_layer_contents() const { return in_paint_layer_contents_; }
|
| +
|
| + void AddLayerShouldPushProperties(Layer* layer);
|
| + void RemoveLayerShouldPushProperties(Layer* layer);
|
| + std::unordered_set<Layer*>& LayersThatShouldPushProperties();
|
| + bool LayerNeedsPushPropertiesForTesting(Layer* layer) const;
|
| +
|
| + virtual void SetNeedsMetaInfoRecomputation(
|
| + bool needs_meta_info_recomputation);
|
| + bool needs_meta_info_recomputation() const {
|
| + return needs_meta_info_recomputation_;
|
| + }
|
| +
|
| + void SetPageScaleFromImplSide(float page_scale);
|
| + void SetElasticOverscrollFromImplSide(gfx::Vector2dF elastic_overscroll);
|
| + gfx::Vector2dF elastic_overscroll() const { return elastic_overscroll_; }
|
| +
|
| + void UpdateHudLayer(bool show_hud_info);
|
| + HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); }
|
| +
|
| + virtual void SetNeedsFullTreeSync();
|
| + bool needs_full_tree_sync() const { return needs_full_tree_sync_; }
|
| +
|
| + void SetPropertyTreesNeedRebuild();
|
| +
|
| + void PushPropertiesTo(LayerTreeImpl* tree_impl);
|
| +
|
| + MutatorHost* mutator_host() const { return mutator_host_; }
|
| +
|
| + Layer* LayerByElementId(ElementId element_id) const;
|
| + void RegisterElement(ElementId element_id,
|
| + ElementListType list_type,
|
| + Layer* layer);
|
| + void UnregisterElement(ElementId element_id,
|
| + ElementListType list_type,
|
| + Layer* layer);
|
| + void SetElementIdsForTesting();
|
| +
|
| + void BuildPropertyTreesForTesting();
|
| +
|
| + // Layer iterators.
|
| + LayerListIterator<Layer> begin() const;
|
| + LayerListIterator<Layer> end() const;
|
| + LayerListReverseIterator<Layer> rbegin();
|
| + LayerListReverseIterator<Layer> rend();
|
|
|
| // LayerTreeHostInProcess interface to Proxy.
|
| void WillBeginMainFrame();
|
| @@ -286,11 +418,38 @@ class CC_EXPORT LayerTreeHost
|
| bool IsSingleThreaded() const;
|
| bool IsThreaded() const;
|
|
|
| + // SurfaceReferenceOwner implementation.
|
| + SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() override;
|
| +
|
| + // MutatorHostClient implementation.
|
| + bool IsElementInList(ElementId element_id,
|
| + ElementListType list_type) const override;
|
| + void SetMutatorsNeedCommit() override;
|
| + void SetMutatorsNeedRebuildPropertyTrees() override;
|
| + void SetElementFilterMutated(ElementId element_id,
|
| + ElementListType list_type,
|
| + const FilterOperations& filters) override;
|
| + void SetElementOpacityMutated(ElementId element_id,
|
| + ElementListType list_type,
|
| + float opacity) override;
|
| + void SetElementTransformMutated(ElementId element_id,
|
| + ElementListType list_type,
|
| + const gfx::Transform& transform) override;
|
| + void SetElementScrollOffsetMutated(
|
| + ElementId element_id,
|
| + ElementListType list_type,
|
| + const gfx::ScrollOffset& scroll_offset) override;
|
| +
|
| + void ElementIsAnimatingChanged(ElementId element_id,
|
| + ElementListType list_type,
|
| + const PropertyAnimationState& mask,
|
| + const PropertyAnimationState& state) override;
|
| +
|
| + void ScrollOffsetAnimationFinished() override {}
|
| + gfx::ScrollOffset GetScrollOffsetForAnimation(
|
| + ElementId element_id) const override;
|
| +
|
| protected:
|
| - // Allow tests to inject the LayerTree.
|
| - LayerTreeHost(InitParams* params,
|
| - CompositorMode mode,
|
| - std::unique_ptr<LayerTree> layer_tree);
|
| LayerTreeHost(InitParams* params, CompositorMode mode);
|
|
|
| void InitializeThreaded(
|
| @@ -317,8 +476,6 @@ class CC_EXPORT LayerTreeHost
|
|
|
| MicroBenchmarkController micro_benchmark_controller_;
|
|
|
| - std::unique_ptr<LayerTree> layer_tree_;
|
| -
|
| base::WeakPtr<InputHandler> input_handler_weak_ptr_;
|
|
|
| private:
|
| @@ -339,8 +496,6 @@ class CC_EXPORT LayerTreeHost
|
|
|
| void CalculateLCDTextMetricsCallback(Layer* layer);
|
|
|
| - void SetPropertyTreesNeedRebuild();
|
| -
|
| const CompositorMode compositor_mode_;
|
|
|
| std::unique_ptr<UIResourceManager> ui_resource_manager_;
|
| @@ -349,7 +504,7 @@ class CC_EXPORT LayerTreeHost
|
| std::unique_ptr<Proxy> proxy_;
|
| std::unique_ptr<TaskRunnerProvider> task_runner_provider_;
|
|
|
| - int source_frame_number_;
|
| + int source_frame_number_ = 0U;
|
| std::unique_ptr<RenderingStatsInstrumentation>
|
| rendering_stats_instrumentation_;
|
|
|
| @@ -366,15 +521,15 @@ class CC_EXPORT LayerTreeHost
|
| const LayerTreeSettings settings_;
|
| LayerTreeDebugState debug_state_;
|
|
|
| - bool visible_;
|
| + bool visible_ = false;
|
|
|
| - bool has_gpu_rasterization_trigger_;
|
| - bool content_is_suitable_for_gpu_rasterization_;
|
| - bool gpu_rasterization_histogram_recorded_;
|
| + bool has_gpu_rasterization_trigger_ = false;
|
| + bool content_is_suitable_for_gpu_rasterization_ = true;
|
| + bool gpu_rasterization_histogram_recorded_ = false;
|
|
|
| // If set, then page scale animation has completed, but the client hasn't been
|
| // notified about it yet.
|
| - bool did_complete_scale_animation_;
|
| + bool did_complete_scale_animation_ = false;
|
|
|
| int id_;
|
| bool next_commit_forces_redraw_ = false;
|
| @@ -388,6 +543,60 @@ class CC_EXPORT LayerTreeHost
|
| SurfaceSequenceGenerator surface_sequence_generator_;
|
| uint32_t num_consecutive_frames_suitable_for_gpu_ = 0;
|
|
|
| + scoped_refptr<Layer> root_layer_;
|
| +
|
| + scoped_refptr<Layer> overscroll_elasticity_layer_;
|
| + scoped_refptr<Layer> page_scale_layer_;
|
| + scoped_refptr<Layer> inner_viewport_scroll_layer_;
|
| + scoped_refptr<Layer> outer_viewport_scroll_layer_;
|
| +
|
| + float top_controls_height_ = 0.f;
|
| + float top_controls_shown_ratio_ = 0.f;
|
| + bool browser_controls_shrink_blink_size_ = false;
|
| +
|
| + float bottom_controls_height_ = 0.f;
|
| +
|
| + float device_scale_factor_ = 1.f;
|
| + float painted_device_scale_factor_ = 1.f;
|
| + float page_scale_factor_ = 1.f;
|
| + float min_page_scale_factor_ = 1.f;
|
| + float max_page_scale_factor_ = 1.f;
|
| + gfx::ColorSpace device_color_space_;
|
| +
|
| + SkColor background_color_ = SK_ColorWHITE;
|
| + bool has_transparent_background_ = false;
|
| +
|
| + LayerSelection selection_;
|
| +
|
| + gfx::Size device_viewport_size_;
|
| +
|
| + bool have_scroll_event_handlers_ = false;
|
| + EventListenerProperties event_listener_properties_[static_cast<size_t>(
|
| + EventListenerClass::kNumClasses)];
|
| +
|
| + std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_;
|
| +
|
| + PropertyTrees property_trees_;
|
| +
|
| + bool needs_full_tree_sync_ = true;
|
| + bool needs_meta_info_recomputation_ = true;
|
| +
|
| + gfx::Vector2dF elastic_overscroll_;
|
| +
|
| + scoped_refptr<HeadsUpDisplayLayer> hud_layer_;
|
| +
|
| + // Set of layers that need to push properties.
|
| + std::unordered_set<Layer*> layers_that_should_push_properties_;
|
| +
|
| + // Layer id to Layer map.
|
| + std::unordered_map<int, Layer*> layer_id_map_;
|
| +
|
| + std::unordered_map<ElementId, Layer*, ElementIdHash> element_layers_map_;
|
| +
|
| + bool in_paint_layer_contents_ = false;
|
| +
|
| + MutatorHost* mutator_host_;
|
| +
|
| scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(LayerTreeHost);
|
|
|