[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 5 | #ifndef CC_TREES_LAYER_TREE_IMPL_H_ |
| 6 | #define CC_TREES_LAYER_TREE_IMPL_H_ |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 7 | |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 8 | #include <map> |
David Bokan | 092ab286 | 2020-07-09 17:40:57 | [diff] [blame] | 9 | #include <memory> |
vmpstr | d7de03c | 2014-08-27 18:11:01 | [diff] [blame] | 10 | #include <set> |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 11 | #include <string> |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 12 | #include <unordered_map> |
David Bokan | 092ab286 | 2020-07-09 17:40:57 | [diff] [blame] | 13 | #include <utility> |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
danakj | 956d1c82 | 2018-09-13 01:38:57 | [diff] [blame] | 16 | #include "base/containers/flat_set.h" |
jonross | 180dc48 | 2018-10-23 21:22:09 | [diff] [blame] | 17 | #include "base/time/time.h" |
[email protected] | 8c569022 | 2013-02-15 17:36:43 | [diff] [blame] | 18 | #include "base/values.h" |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 19 | #include "cc/base/synced_property.h" |
Sinan Sahin | 92a360bc | 2019-12-05 19:20:45 | [diff] [blame] | 20 | #include "cc/input/browser_controls_offset_manager.h" |
dtapuska | f206a40d | 2016-02-05 21:36:02 | [diff] [blame] | 21 | #include "cc/input/event_listener_properties.h" |
jamesr | 9b8fda3 | 2015-03-16 19:11:05 | [diff] [blame] | 22 | #include "cc/input/layer_selection_bound.h" |
Sandra Sun | 2288e853 | 2017-11-30 22:50:16 | [diff] [blame] | 23 | #include "cc/input/overscroll_behavior.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 24 | #include "cc/layers/layer_impl.h" |
vollick | 7ee64947 | 2016-03-03 05:55:36 | [diff] [blame] | 25 | #include "cc/layers/layer_list_iterator.h" |
Sadrul Habib Chowdhury | f37cae5 | 2020-04-02 22:20:32 | [diff] [blame] | 26 | #include "cc/metrics/event_metrics.h" |
Xida Chen | c5cb856 | 2019-08-14 22:41:56 | [diff] [blame] | 27 | #include "cc/paint/discardable_image_map.h" |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 28 | #include "cc/resources/ui_resource_client.h" |
Sinan Sahin | 92a360bc | 2019-12-05 19:20:45 | [diff] [blame] | 29 | #include "cc/trees/browser_controls_params.h" |
Sadrul Habib Chowdhury | 3d4df2e8 | 2018-06-02 05:18:00 | [diff] [blame] | 30 | #include "cc/trees/layer_tree_host.h" |
jamesr | 9b8fda3 | 2015-03-16 19:11:05 | [diff] [blame] | 31 | #include "cc/trees/layer_tree_host_impl.h" |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 32 | #include "cc/trees/property_tree.h" |
danakj | ba65a091 | 2017-09-21 16:38:42 | [diff] [blame] | 33 | #include "cc/trees/swap_promise.h" |
Fady Samuel | c296f5fb | 2017-07-21 04:02:19 | [diff] [blame] | 34 | #include "components/viz/common/frame_sinks/begin_frame_args.h" |
Xiyuan Xia | 0274c58 | 2019-12-04 20:49:03 | [diff] [blame] | 35 | #include "ui/gfx/overlay_transform.h" |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 36 | |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 37 | namespace base { |
primiano | 1596043 | 2015-02-05 14:20:26 | [diff] [blame] | 38 | namespace trace_event { |
[email protected] | d12aa93 | 2014-08-01 13:10:38 | [diff] [blame] | 39 | class TracedValue; |
| 40 | } |
| 41 | } |
| 42 | |
Xu Xing | 3254916 | 2017-07-17 22:25:43 | [diff] [blame] | 43 | namespace viz { |
danakj | 57baa77 | 2018-05-29 15:59:14 | [diff] [blame] | 44 | class ClientResourceProvider; |
Xu Xing | 3254916 | 2017-07-17 22:25:43 | [diff] [blame] | 45 | class ContextProvider; |
| 46 | } |
| 47 | |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 48 | namespace cc { |
| 49 | |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 50 | class DebugRectHistory; |
Vladimir Levin | 1b746faf | 2021-01-19 21:25:58 | [diff] [blame] | 51 | class DocumentTransitionRequest; |
Xida Chen | e5a9b4e0 | 2020-06-23 00:35:35 | [diff] [blame] | 52 | class DroppedFrameCounter; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 53 | class HeadsUpDisplayLayerImpl; |
vmpstr | 70289fb6 | 2016-12-01 02:33:05 | [diff] [blame] | 54 | class ImageDecodeCache; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 55 | class LayerTreeDebugState; |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 56 | class LayerTreeImpl; |
kylechar | df9d6f30 | 2018-03-22 20:25:54 | [diff] [blame] | 57 | class LayerTreeFrameSink; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 58 | class LayerTreeSettings; |
[email protected] | 1191d9d | 2013-02-02 06:00:33 | [diff] [blame] | 59 | class MemoryHistory; |
[email protected] | 8aa39ecb | 2014-06-12 14:19:14 | [diff] [blame] | 60 | class PictureLayerImpl; |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 61 | class TaskRunnerProvider; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 62 | class TileManager; |
[email protected] | 741fba42 | 2013-09-20 03:34:14 | [diff] [blame] | 63 | class UIResourceRequest; |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 64 | class VideoFrameControllerClient; |
bokan | fcdbc18 | 2014-11-21 21:53:33 | [diff] [blame] | 65 | struct PendingPageScaleAnimation; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 66 | |
jdduke | 5ad3681 | 2015-01-02 17:59:32 | [diff] [blame] | 67 | typedef std::vector<UIResourceRequest> UIResourceRequestQueue; |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 68 | typedef SyncedProperty<AdditionGroup<float>> SyncedBrowserControls; |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 69 | typedef SyncedProperty<AdditionGroup<gfx::Vector2dF>> SyncedElasticOverscroll; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 70 | |
pdr | 80ecb980 | 2017-05-16 03:40:09 | [diff] [blame] | 71 | class LayerTreeLifecycle { |
| 72 | public: |
| 73 | enum LifecycleState { |
| 74 | kNotSyncing, |
| 75 | |
| 76 | // The following states are the steps performed when syncing properties to |
| 77 | // this tree (see: LayerTreeHost::FinishCommitOnImplThread or |
| 78 | // LayerTreeHostImpl::ActivateSyncTree). |
| 79 | kBeginningSync, |
| 80 | kSyncedPropertyTrees, |
| 81 | kSyncedLayerProperties, |
| 82 | kLastSyncState = kSyncedLayerProperties, |
| 83 | |
| 84 | // TODO(pdr): Add states to cover more than just the synchronization steps. |
| 85 | }; |
| 86 | |
| 87 | void AdvanceTo(LifecycleState); |
| 88 | |
| 89 | bool AllowsPropertyTreeAccess() const { |
| 90 | return state_ == kNotSyncing || state_ >= kSyncedPropertyTrees; |
| 91 | } |
| 92 | bool AllowsLayerPropertyAccess() const { |
| 93 | return state_ == kNotSyncing || state_ >= kSyncedLayerProperties; |
| 94 | } |
| 95 | |
| 96 | private: |
| 97 | LifecycleState state_ = kNotSyncing; |
| 98 | }; |
| 99 | |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 100 | class CC_EXPORT LayerTreeImpl { |
| 101 | public: |
wkorman | 8c2724c | 2016-12-28 02:56:15 | [diff] [blame] | 102 | // This is the number of times a fixed point has to be hit continuously by a |
jaydasika | cb93d1c | 2015-12-09 23:52:46 | [diff] [blame] | 103 | // layer to consider it as jittering. |
vmpstr | e2ed68b | 2016-07-28 01:22:16 | [diff] [blame] | 104 | enum : int { kFixedPointHitsThreshold = 3 }; |
Sinan Sahin | b6ffa91 | 2019-10-23 21:04:46 | [diff] [blame] | 105 | LayerTreeImpl( |
| 106 | LayerTreeHostImpl* host_impl, |
| 107 | scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
| 108 | scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio, |
| 109 | scoped_refptr<SyncedBrowserControls> bottom_controls_shown_ratio, |
| 110 | scoped_refptr<SyncedElasticOverscroll> elastic_overscroll); |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 111 | LayerTreeImpl(const LayerTreeImpl&) = delete; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 112 | virtual ~LayerTreeImpl(); |
| 113 | |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 114 | LayerTreeImpl& operator=(const LayerTreeImpl&) = delete; |
| 115 | |
[email protected] | df17af5 | 2014-02-06 02:20:40 | [diff] [blame] | 116 | void Shutdown(); |
[email protected] | aeef2f0 | 2014-05-10 12:15:48 | [diff] [blame] | 117 | void ReleaseResources(); |
kylechar | 599aeeb | 2018-08-10 04:05:03 | [diff] [blame] | 118 | void OnPurgeMemory(); |
ericrk | 7cedb54 | 2016-11-02 19:03:44 | [diff] [blame] | 119 | void ReleaseTileResources(); |
| 120 | void RecreateTileResources(); |
[email protected] | df17af5 | 2014-02-06 02:20:40 | [diff] [blame] | 121 | |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 122 | // Methods called by the layer tree that pass-through or access LTHI. |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 123 | // --------------------------------------------------------------------------- |
kylechar | df9d6f30 | 2018-03-22 20:25:54 | [diff] [blame] | 124 | LayerTreeFrameSink* layer_tree_frame_sink(); |
danakj | 5b391e8 | 2018-05-17 17:53:26 | [diff] [blame] | 125 | int max_texture_size() const; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 126 | const LayerTreeSettings& settings() const; |
danakj | 875efa4 | 2015-02-10 22:18:23 | [diff] [blame] | 127 | const LayerTreeDebugState& debug_state() const; |
Xu Xing | 3254916 | 2017-07-17 22:25:43 | [diff] [blame] | 128 | viz::ContextProvider* context_provider() const; |
danakj | 57baa77 | 2018-05-29 15:59:14 | [diff] [blame] | 129 | viz::ClientResourceProvider* resource_provider() const; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 130 | TileManager* tile_manager() const; |
vmpstr | 70289fb6 | 2016-12-01 02:33:05 | [diff] [blame] | 131 | ImageDecodeCache* image_decode_cache() const; |
Khushal | fdacdc9 | 2017-09-22 22:40:52 | [diff] [blame] | 132 | ImageAnimationController* image_animation_controller() const; |
Xida Chen | e5a9b4e0 | 2020-06-23 00:35:35 | [diff] [blame] | 133 | DroppedFrameCounter* dropped_frame_counter() const; |
[email protected] | 1191d9d | 2013-02-02 06:00:33 | [diff] [blame] | 134 | MemoryHistory* memory_history() const; |
danakj | 875efa4 | 2015-02-10 22:18:23 | [diff] [blame] | 135 | DebugRectHistory* debug_rect_history() const; |
[email protected] | f117a4c | 2012-12-16 04:53:10 | [diff] [blame] | 136 | bool IsActiveTree() const; |
| 137 | bool IsPendingTree() const; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 138 | bool IsRecycleTree() const; |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 139 | bool IsSyncTree() const; |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 140 | LayerImpl* FindActiveTreeLayerById(int id); |
| 141 | LayerImpl* FindPendingTreeLayerById(int id); |
David Bokan | 318758c | 2020-09-01 22:26:36 | [diff] [blame] | 142 | // TODO(bokan): PinchGestureActive is a layering violation, it's not related |
| 143 | // to what LayerTreeImpl does. |
[email protected] | 166db5c8 | 2013-01-09 23:54:31 | [diff] [blame] | 144 | bool PinchGestureActive() const; |
Xianzhu Wang | 161f5976 | 2020-04-17 17:24:18 | [diff] [blame] | 145 | const viz::BeginFrameArgs& CurrentBeginFrameArgs() const; |
mithro | 0bdb49d | 2015-05-27 13:08:01 | [diff] [blame] | 146 | base::TimeDelta CurrentBeginFrameInterval() const; |
[email protected] | bd532459 | 2014-07-31 09:09:33 | [diff] [blame] | 147 | const gfx::Rect ViewportRectForTilePriority() const; |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 148 | std::unique_ptr<ScrollbarAnimationController> |
chrishtr | f556cef | 2017-05-13 05:31:01 | [diff] [blame] | 149 | CreateScrollbarAnimationController(ElementId scroll_element_id, |
| 150 | float initial_opacity); |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 151 | void DidAnimateScrollOffset(); |
[email protected] | 13525d6 | 2014-05-20 21:22:04 | [diff] [blame] | 152 | bool use_gpu_rasterization() const; |
hendrikw | c2bbd61 | 2014-12-03 23:49:34 | [diff] [blame] | 153 | GpuRasterizationStatus GetGpuRasterizationStatus() const; |
[email protected] | 473f1f2 | 2014-05-22 08:19:17 | [diff] [blame] | 154 | bool create_low_res_tiling() const; |
vmpstr | 61ed94a1 | 2014-10-09 04:49:30 | [diff] [blame] | 155 | bool RequiresHighResToDraw() const; |
vmpstr | 56ace23 | 2014-10-09 20:16:28 | [diff] [blame] | 156 | bool SmoothnessTakesPriority() const; |
sunnyps | 7d073dc | 2015-04-16 23:29:12 | [diff] [blame] | 157 | VideoFrameControllerClient* GetVideoFrameControllerClient() const; |
Walter Korman | aa326e4 | 2017-08-22 23:04:43 | [diff] [blame] | 158 | MutatorHost* mutator_host() const { return host_impl_->mutator_host(); } |
Vladimir Levin | 9167e1c | 2017-10-18 21:28:24 | [diff] [blame] | 159 | void UpdateImageDecodingHints( |
| 160 | base::flat_map<PaintImage::Id, PaintImage::DecodingMode> |
| 161 | decoding_mode_map); |
Khushal | ec3ba5dc | 2019-11-04 22:30:21 | [diff] [blame] | 162 | int GetMSAASampleCountForRaster( |
| 163 | const scoped_refptr<DisplayItemList>& display_list); |
Dale Curtis | 28e9765 | 2020-07-17 01:54:40 | [diff] [blame] | 164 | gfx::ColorSpace GetRasterColorSpace( |
| 165 | gfx::ContentColorUsage content_color_usage) const; |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 166 | |
| 167 | // Tree specific methods exposed to layer-impl tree. |
| 168 | // --------------------------------------------------------------------------- |
| 169 | void SetNeedsRedraw(); |
[email protected] | ff762fb | 2012-12-12 19:18:37 | [diff] [blame] | 170 | |
danakj | 875efa4 | 2015-02-10 22:18:23 | [diff] [blame] | 171 | // Tracing methods. |
| 172 | // --------------------------------------------------------------------------- |
hendrikw | c5e91585 | 2015-05-13 01:29:03 | [diff] [blame] | 173 | void GetAllPrioritizedTilesForTracing( |
| 174 | std::vector<PrioritizedTile>* prioritized_tiles) const; |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 175 | void AsValueInto(base::trace_event::TracedValue* dict) const; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 176 | |
| 177 | // Other public methods |
| 178 | // --------------------------------------------------------------------------- |
Xianzhu Wang | 66e13e0 | 2019-09-18 20:39:12 | [diff] [blame] | 179 | LayerImpl* root_layer() { |
Xianzhu Wang | f817d6c | 2019-09-17 20:08:34 | [diff] [blame] | 180 | return layer_list_.empty() ? nullptr : layer_list_[0].get(); |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 181 | } |
chrishtr | ae86b9e | 2017-05-03 22:31:01 | [diff] [blame] | 182 | const RenderSurfaceImpl* RootRenderSurface() const; |
jaydasika | e57ef9da | 2016-06-22 14:32:55 | [diff] [blame] | 183 | bool LayerListIsEmpty() const; |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 184 | void SetRootLayerForTesting(std::unique_ptr<LayerImpl>); |
jaydasika | bf1875a | 2016-06-28 03:39:59 | [diff] [blame] | 185 | void OnCanDrawStateChangedForTree(); |
jaydasika | 0c2fd47 | 2016-03-24 01:26:05 | [diff] [blame] | 186 | bool IsRootLayer(const LayerImpl* layer) const; |
Xianzhu Wang | 0340f14b | 2019-09-10 23:42:19 | [diff] [blame] | 187 | |
| 188 | OwnedLayerImplList DetachLayers(); |
| 189 | OwnedLayerImplList DetachLayersKeepingRootLayerForTesting(); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 190 | |
ajuma | e6f541b | 2016-05-31 16:50:50 | [diff] [blame] | 191 | void SetPropertyTrees(PropertyTrees* property_trees); |
pdr | 80ecb980 | 2017-05-16 03:40:09 | [diff] [blame] | 192 | PropertyTrees* property_trees() { |
| 193 | // TODO(pdr): We should enable this DCHECK because it will catch uses of |
| 194 | // stale property trees, but it currently fails too many existing tests. |
| 195 | // DCHECK(lifecycle().AllowsPropertyTreeAccess()); |
| 196 | return &property_trees_; |
| 197 | } |
Peter Mayo | b5acfb9 | 2017-09-13 20:05:10 | [diff] [blame] | 198 | const PropertyTrees* property_trees() const { return &property_trees_; } |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 199 | |
pdr | 80ecb980 | 2017-05-16 03:40:09 | [diff] [blame] | 200 | void PushPropertyTreesTo(LayerTreeImpl* tree_impl); |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 201 | void PushPropertiesTo(LayerTreeImpl* tree_impl); |
akaba | 227bfbd6 | 2018-07-11 21:46:43 | [diff] [blame] | 202 | void PushSurfaceRangesTo(LayerTreeImpl* tree_impl); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 203 | |
jaydasika | db7757b | 2016-04-28 00:17:30 | [diff] [blame] | 204 | void MoveChangeTrackingToLayers(); |
| 205 | |
enne | 8a4cb786 | 2016-10-04 20:36:45 | [diff] [blame] | 206 | void ForceRecalculateRasterScales(); |
| 207 | |
Xianzhu Wang | f817d6c | 2019-09-17 20:08:34 | [diff] [blame] | 208 | // Adapts an iterator of std::unique_ptr<LayerImpl> to an iterator of |
| 209 | // LayerImpl*. |
| 210 | template <typename Iterator> |
Xianzhu Wang | e1e018d | 2019-09-25 18:56:20 | [diff] [blame] | 211 | class IteratorAdapter |
| 212 | : public std::iterator<std::forward_iterator_tag, LayerImpl*> { |
Xianzhu Wang | f817d6c | 2019-09-17 20:08:34 | [diff] [blame] | 213 | public: |
| 214 | explicit IteratorAdapter(Iterator it) : it_(it) {} |
| 215 | bool operator==(IteratorAdapter o) const { return it_ == o.it_; } |
| 216 | bool operator!=(IteratorAdapter o) const { return !(*this == o); } |
| 217 | LayerImpl* operator*() const { return it_->get(); } |
| 218 | LayerImpl* operator->() const { return it_->get(); } |
| 219 | IteratorAdapter& operator++() { |
| 220 | ++it_; |
| 221 | return *this; |
| 222 | } |
| 223 | |
| 224 | private: |
| 225 | Iterator it_; |
| 226 | }; |
| 227 | using const_iterator = IteratorAdapter<OwnedLayerImplList::const_iterator>; |
| 228 | using const_reverse_iterator = |
| 229 | IteratorAdapter<OwnedLayerImplList::const_reverse_iterator>; |
| 230 | const_iterator begin() const { return const_iterator(layer_list_.cbegin()); } |
| 231 | const_iterator end() const { return const_iterator(layer_list_.cend()); } |
| 232 | const_reverse_iterator rbegin() const { |
| 233 | return const_reverse_iterator(layer_list_.crbegin()); |
| 234 | } |
| 235 | const_reverse_iterator rend() const { |
| 236 | return const_reverse_iterator(layer_list_.crend()); |
| 237 | } |
vollick | 7ee64947 | 2016-03-03 05:55:36 | [diff] [blame] | 238 | |
weiliangc | ea09f337 | 2017-03-29 16:43:24 | [diff] [blame] | 239 | void SetTransformMutated(ElementId element_id, |
| 240 | const gfx::Transform& transform); |
| 241 | void SetOpacityMutated(ElementId element_id, float opacity); |
| 242 | void SetFilterMutated(ElementId element_id, const FilterOperations& filters); |
Mason Freed | 384fc5b | 2019-05-30 19:49:10 | [diff] [blame] | 243 | void SetBackdropFilterMutated(ElementId element_id, |
| 244 | const FilterOperations& backdrop_filters); |
jaydasika | 2368fd5 | 2016-05-11 19:38:29 | [diff] [blame] | 245 | |
Stephen McGruer | d362daef | 2019-01-14 20:30:33 | [diff] [blame] | 246 | const std::unordered_map<ElementId, float, ElementIdHash>& |
| 247 | element_id_to_opacity_animations_for_testing() const { |
| 248 | return element_id_to_opacity_animations_; |
| 249 | } |
| 250 | const std::unordered_map<ElementId, gfx::Transform, ElementIdHash>& |
| 251 | element_id_to_transform_animations_for_testing() const { |
| 252 | return element_id_to_transform_animations_; |
| 253 | } |
| 254 | const std::unordered_map<ElementId, FilterOperations, ElementIdHash>& |
| 255 | element_id_to_filter_animations_for_testing() const { |
| 256 | return element_id_to_filter_animations_; |
| 257 | } |
Mason Freed | 384fc5b | 2019-05-30 19:49:10 | [diff] [blame] | 258 | const std::unordered_map<ElementId, FilterOperations, ElementIdHash>& |
| 259 | element_id_to_backdrop_filter_animations_for_testing() const { |
| 260 | return element_id_to_backdrop_filter_animations_; |
| 261 | } |
Stephen McGruer | d362daef | 2019-01-14 20:30:33 | [diff] [blame] | 262 | |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 263 | int source_frame_number() const { return source_frame_number_; } |
[email protected] | a3029014 | 2013-01-05 01:27:00 | [diff] [blame] | 264 | void set_source_frame_number(int frame_number) { |
| 265 | source_frame_number_ = frame_number; |
| 266 | } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 267 | |
jaydasika | cb93d1c | 2015-12-09 23:52:46 | [diff] [blame] | 268 | bool is_first_frame_after_commit() const { |
| 269 | return source_frame_number_ != is_first_frame_after_commit_tracker_; |
| 270 | } |
| 271 | |
| 272 | void set_is_first_frame_after_commit(bool is_first_frame_after_commit) { |
| 273 | is_first_frame_after_commit_tracker_ = |
| 274 | is_first_frame_after_commit ? -1 : source_frame_number_; |
| 275 | } |
| 276 | |
James Wallace-Lee | 4d3dff9 | 2017-11-02 18:12:54 | [diff] [blame] | 277 | const HeadsUpDisplayLayerImpl* hud_layer() const { return hud_layer_; } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 278 | HeadsUpDisplayLayerImpl* hud_layer() { return hud_layer_; } |
[email protected] | a3029014 | 2013-01-05 01:27:00 | [diff] [blame] | 279 | void set_hud_layer(HeadsUpDisplayLayerImpl* layer_impl) { |
| 280 | hud_layer_ = layer_impl; |
| 281 | } |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 282 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 283 | gfx::ScrollOffset TotalScrollOffset() const; |
| 284 | gfx::ScrollOffset TotalMaxScrollOffset() const; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 285 | |
Sadrul Habib Chowdhury | 3d4df2e8 | 2018-06-02 05:18:00 | [diff] [blame] | 286 | void AddPresentationCallbacks( |
| 287 | std::vector<LayerTreeHost::PresentationTimeCallback> callbacks); |
| 288 | std::vector<LayerTreeHost::PresentationTimeCallback> |
| 289 | TakePresentationCallbacks(); |
| 290 | bool has_presentation_callbacks() const { |
| 291 | return !presentation_callbacks_.empty(); |
| 292 | } |
| 293 | |
David Bokan | 4917d1d | 2019-11-22 21:52:48 | [diff] [blame] | 294 | // The following viewport related property nodes will only ever be set on the |
| 295 | // main-frame's renderer (i.e. OOPIF and UI compositors will not have these |
| 296 | // set. |
Xianzhu Wang | c9badff | 2019-10-01 23:47:22 | [diff] [blame] | 297 | using ViewportPropertyIds = LayerTreeHost::ViewportPropertyIds; |
| 298 | void SetViewportPropertyIds(const ViewportPropertyIds& ids); |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 299 | |
Xianzhu Wang | c9badff | 2019-10-01 23:47:22 | [diff] [blame] | 300 | const TransformNode* OverscrollElasticityTransformNode() const; |
| 301 | TransformNode* OverscrollElasticityTransformNode() { |
| 302 | return const_cast<TransformNode*>( |
| 303 | const_cast<const LayerTreeImpl*>(this) |
| 304 | ->OverscrollElasticityTransformNode()); |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 305 | } |
Xianzhu Wang | c9badff | 2019-10-01 23:47:22 | [diff] [blame] | 306 | const TransformNode* PageScaleTransformNode() const; |
| 307 | TransformNode* PageScaleTransformNode() { |
| 308 | return const_cast<TransformNode*>( |
| 309 | const_cast<const LayerTreeImpl*>(this)->PageScaleTransformNode()); |
pdr | 53abb45 | 2017-05-19 01:59:42 | [diff] [blame] | 310 | } |
David Bokan | c40a570 | 2018-06-12 13:01:19 | [diff] [blame] | 311 | const ScrollNode* InnerViewportScrollNode() const; |
| 312 | ScrollNode* InnerViewportScrollNode() { |
| 313 | return const_cast<ScrollNode*>( |
| 314 | const_cast<const LayerTreeImpl*>(this)->InnerViewportScrollNode()); |
| 315 | } |
Xianzhu Wang | c9badff | 2019-10-01 23:47:22 | [diff] [blame] | 316 | const ClipNode* OuterViewportClipNode() const; |
| 317 | ClipNode* OuterViewportClipNode() { |
| 318 | return const_cast<ClipNode*>( |
| 319 | const_cast<const LayerTreeImpl*>(this)->OuterViewportClipNode()); |
| 320 | } |
David Bokan | c40a570 | 2018-06-12 13:01:19 | [diff] [blame] | 321 | const ScrollNode* OuterViewportScrollNode() const; |
| 322 | ScrollNode* OuterViewportScrollNode() { |
| 323 | return const_cast<ScrollNode*>( |
| 324 | const_cast<const LayerTreeImpl*>(this)->OuterViewportScrollNode()); |
| 325 | } |
| 326 | |
Xianzhu Wang | c9badff | 2019-10-01 23:47:22 | [diff] [blame] | 327 | LayerTreeHost::ViewportPropertyIds ViewportPropertyIdsForTesting() const { |
| 328 | return viewport_property_ids_; |
Xianzhu Wang | eb746a5c8 | 2018-11-29 04:07:19 | [diff] [blame] | 329 | } |
Xianzhu Wang | c9badff | 2019-10-01 23:47:22 | [diff] [blame] | 330 | LayerImpl* InnerViewportScrollLayerForTesting() const; |
| 331 | LayerImpl* OuterViewportScrollLayerForTesting() const; |
| 332 | |
| 333 | ScrollNode* CurrentlyScrollingNode(); |
| 334 | const ScrollNode* CurrentlyScrollingNode() const; |
| 335 | int LastScrolledScrollNodeIndex() const; |
| 336 | void SetCurrentlyScrollingNode(const ScrollNode* node); |
| 337 | void ClearCurrentlyScrollingNode(); |
Xianzhu Wang | eb746a5c8 | 2018-11-29 04:07:19 | [diff] [blame] | 338 | |
[email protected] | 58241dc | 2013-08-20 01:39:25 | [diff] [blame] | 339 | void ApplySentScrollAndScaleDeltasFromAbortedCommit(); |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 340 | |
[email protected] | a3029014 | 2013-01-05 01:27:00 | [diff] [blame] | 341 | SkColor background_color() const { return background_color_; } |
| 342 | void set_background_color(SkColor color) { background_color_ = color; } |
| 343 | |
Xiyuan Xia | 0274c58 | 2019-12-04 20:49:03 | [diff] [blame] | 344 | gfx::OverlayTransform display_transform_hint() const { |
| 345 | return display_transform_hint_; |
| 346 | } |
| 347 | void set_display_transform_hint(gfx::OverlayTransform hint) { |
| 348 | display_transform_hint_ = hint; |
| 349 | } |
| 350 | |
Philip Rogers | 106da9b | 2017-07-12 04:10:18 | [diff] [blame] | 351 | void UpdatePropertyTreeAnimationFromMainThread(); |
Walter Korman | af60f63 | 2017-08-24 22:52:39 | [diff] [blame] | 352 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 353 | void SetPageScaleOnActiveTree(float active_page_scale); |
| 354 | void PushPageScaleFromMainThread(float page_scale_factor, |
| 355 | float min_page_scale_factor, |
| 356 | float max_page_scale_factor); |
| 357 | float current_page_scale_factor() const { |
| 358 | return page_scale_factor()->Current(IsActiveTree()); |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 359 | } |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 360 | float min_page_scale_factor() const { return min_page_scale_factor_; } |
| 361 | float max_page_scale_factor() const { return max_page_scale_factor_; } |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 362 | |
| 363 | float page_scale_delta() const { return page_scale_factor()->Delta(); } |
| 364 | |
| 365 | SyncedProperty<ScaleGroup>* page_scale_factor(); |
| 366 | const SyncedProperty<ScaleGroup>* page_scale_factor() const; |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 367 | |
ajuma | 1d48e01 | 2015-09-25 22:24:16 | [diff] [blame] | 368 | void SetDeviceScaleFactor(float device_scale_factor); |
| 369 | float device_scale_factor() const { return device_scale_factor_; } |
| 370 | |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 371 | void set_painted_device_scale_factor(float painted_device_scale_factor) { |
| 372 | painted_device_scale_factor_ = painted_device_scale_factor; |
| 373 | } |
| 374 | float painted_device_scale_factor() const { |
| 375 | return painted_device_scale_factor_; |
| 376 | } |
| 377 | |
Jonathan Ross | d0345bf | 2020-09-25 02:13:54 | [diff] [blame] | 378 | void SetLocalSurfaceIdFromParent( |
| 379 | const viz::LocalSurfaceId& local_surface_id_from_parent); |
| 380 | const viz::LocalSurfaceId& local_surface_id_from_parent() const { |
| 381 | return local_surface_id_from_parent_; |
jonross | 180dc48 | 2018-10-23 21:22:09 | [diff] [blame] | 382 | } |
| 383 | |
Fady Samuel | 2899c7a | 2018-05-09 16:51:21 | [diff] [blame] | 384 | void RequestNewLocalSurfaceId(); |
| 385 | bool TakeNewLocalSurfaceIdRequest(); |
| 386 | bool new_local_surface_id_request_for_testing() const { |
| 387 | return new_local_surface_id_request_; |
| 388 | } |
| 389 | |
W. James MacLean | 7df854c | 2019-08-28 16:17:53 | [diff] [blame] | 390 | void SetDeviceViewportRect(const gfx::Rect& device_viewport_rect); |
Fady Samuel | e65f318c6 | 2018-07-25 20:48:23 | [diff] [blame] | 391 | |
| 392 | // TODO(fsamuel): The reason this is not a trivial accessor is because it |
| 393 | // may return an external viewport specified in LayerTreeHostImpl. In the |
| 394 | // future, all properties should flow through the pending and active layer |
| 395 | // trees and we shouldn't need to reach out to LayerTreeHostImpl. |
| 396 | gfx::Rect GetDeviceViewport() const; |
| 397 | |
W. James MacLean | 7df854c | 2019-08-28 16:17:53 | [diff] [blame] | 398 | // This accessor is the same as above, except it only ever returns the |
| 399 | // internal (i.e. not external) device viewport. |
| 400 | gfx::Rect internal_device_viewport() { return device_viewport_rect_; } |
| 401 | |
Dale Curtis | af1074b2 | 2020-08-20 06:33:30 | [diff] [blame] | 402 | void SetDisplayColorSpaces( |
| 403 | const gfx::DisplayColorSpaces& display_color_spaces); |
| 404 | |
W. James MacLean | fee5b4f | 2019-02-07 20:20:35 | [diff] [blame] | 405 | // OOPIFs need to know the page scale factor used in the main frame, but it |
| 406 | // is distributed differently (via VisualPropertiesSync), and used only to |
| 407 | // set raster-scale (page_scale_factor has geometry implications that are |
| 408 | // inappropriate for OOPIFs). |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 409 | void SetExternalPageScaleFactor(float external_page_scale_factor); |
| 410 | float external_page_scale_factor() const { |
| 411 | return external_page_scale_factor_; |
| 412 | } |
David Bokan | f888178b | 2020-07-22 16:10:56 | [diff] [blame] | 413 | // A function to provide page scale information for scaling scroll deltas. In |
| 414 | // top-level frames we store this value in page_scale_factor_, but for |
| 415 | // cross-process subframes it's stored in external_page_scale_factor_, so |
| 416 | // that it only affects raster scale. These cases are mutually exclusive, |
| 417 | // except for a page hosted in a <portal>, so only one of the values should |
| 418 | // ever vary from 1.f. |
W. James MacLean | fee5b4f | 2019-02-07 20:20:35 | [diff] [blame] | 419 | float page_scale_factor_for_scroll() const { |
| 420 | DCHECK(external_page_scale_factor_ == 1.f || |
David Bokan | f888178b | 2020-07-22 16:10:56 | [diff] [blame] | 421 | current_page_scale_factor() == 1.f || |
| 422 | !settings().is_layer_tree_for_subframe); |
W. James MacLean | fee5b4f | 2019-02-07 20:20:35 | [diff] [blame] | 423 | return external_page_scale_factor_ * current_page_scale_factor(); |
| 424 | } |
Dale Curtis | af1074b2 | 2020-08-20 06:33:30 | [diff] [blame] | 425 | const gfx::DisplayColorSpaces& display_color_spaces() const { |
| 426 | return display_color_spaces_; |
ccameron | 99961cb | 2016-09-19 19:15:19 | [diff] [blame] | 427 | } |
| 428 | |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 429 | SyncedElasticOverscroll* elastic_overscroll() { |
| 430 | return elastic_overscroll_.get(); |
| 431 | } |
| 432 | const SyncedElasticOverscroll* elastic_overscroll() const { |
| 433 | return elastic_overscroll_.get(); |
| 434 | } |
| 435 | |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 436 | SyncedBrowserControls* top_controls_shown_ratio() { |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 437 | return top_controls_shown_ratio_.get(); |
| 438 | } |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 439 | const SyncedBrowserControls* top_controls_shown_ratio() const { |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 440 | return top_controls_shown_ratio_.get(); |
| 441 | } |
Sinan Sahin | b6ffa91 | 2019-10-23 21:04:46 | [diff] [blame] | 442 | SyncedBrowserControls* bottom_controls_shown_ratio() { |
| 443 | return bottom_controls_shown_ratio_.get(); |
| 444 | } |
| 445 | const SyncedBrowserControls* bottom_controls_shown_ratio() const { |
| 446 | return bottom_controls_shown_ratio_.get(); |
| 447 | } |
Xianzhu Wang | 66e13e0 | 2019-09-18 20:39:12 | [diff] [blame] | 448 | gfx::Vector2dF current_elastic_overscroll() const { |
| 449 | return elastic_overscroll()->Current(IsActiveTree()); |
| 450 | } |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 451 | |
vollick | ef2ae92 | 2016-06-29 17:54:27 | [diff] [blame] | 452 | void SetElementIdsForTesting(); |
| 453 | |
[email protected] | 7d19dc34 | 2013-05-02 22:02:04 | [diff] [blame] | 454 | // Updates draw properties and render surface layer list, as well as tile |
enne | af5bda3 | 2015-02-19 01:27:36 | [diff] [blame] | 455 | // priorities. Returns false if it was unable to update. Updating lcd |
| 456 | // text may cause invalidations, so should only be done after a commit. |
Xianzhu Wang | 66e13e0 | 2019-09-18 20:39:12 | [diff] [blame] | 457 | bool UpdateDrawProperties( |
| 458 | bool update_image_animation_controller = true, |
| 459 | LayerImplList* output_update_layer_list_for_testing = nullptr); |
[email protected] | 7d19dc34 | 2013-05-02 22:02:04 | [diff] [blame] | 460 | |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 461 | void set_needs_update_draw_properties() { |
| 462 | needs_update_draw_properties_ = true; |
| 463 | } |
| 464 | bool needs_update_draw_properties() const { |
| 465 | return needs_update_draw_properties_; |
| 466 | } |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 467 | |
jaydasika | 8d0064f | 2016-06-02 23:34:54 | [diff] [blame] | 468 | bool is_in_resourceless_software_draw_mode() { |
Walter Korman | aa326e4 | 2017-08-22 23:04:43 | [diff] [blame] | 469 | return (host_impl_->GetDrawMode() == DRAW_MODE_RESOURCELESS_SOFTWARE); |
jaydasika | 8d0064f | 2016-06-02 23:34:54 | [diff] [blame] | 470 | } |
| 471 | |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 472 | void set_needs_full_tree_sync(bool needs) { needs_full_tree_sync_ = needs; } |
| 473 | bool needs_full_tree_sync() const { return needs_full_tree_sync_; } |
| 474 | |
akaba | 227bfbd6 | 2018-07-11 21:46:43 | [diff] [blame] | 475 | bool needs_surface_ranges_sync() const { return needs_surface_ranges_sync_; } |
| 476 | void set_needs_surface_ranges_sync(bool needs_surface_ranges_sync) { |
| 477 | needs_surface_ranges_sync_ = needs_surface_ranges_sync; |
jaydasika | 10be211 | 2017-05-26 04:35:50 | [diff] [blame] | 478 | } |
| 479 | |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 480 | void ForceRedrawNextActivation() { next_activation_forces_redraw_ = true; } |
| 481 | |
[email protected] | 759dc9f | 2014-07-23 19:18:51 | [diff] [blame] | 482 | void set_has_ever_been_drawn(bool has_drawn) { |
| 483 | has_ever_been_drawn_ = has_drawn; |
| 484 | } |
| 485 | bool has_ever_been_drawn() const { return has_ever_been_drawn_; } |
| 486 | |
khushalsagar | 8ec0740 | 2016-09-10 03:13:19 | [diff] [blame] | 487 | void set_ui_resource_request_queue(UIResourceRequestQueue queue); |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 488 | |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 489 | const RenderSurfaceList& GetRenderSurfaceList() const; |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 490 | const Region& UnoccludedScreenSpaceRegion() const; |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 491 | |
[email protected] | 257abfa8 | 2013-01-29 23:47:24 | [diff] [blame] | 492 | // These return the size of the root scrollable area and the size of |
| 493 | // the user-visible scrolling viewport, in CSS layout coordinates. |
bokan | 574c4363 | 2015-08-14 02:22:07 | [diff] [blame] | 494 | gfx::SizeF ScrollableSize() const; |
[email protected] | 257abfa8 | 2013-01-29 23:47:24 | [diff] [blame] | 495 | gfx::SizeF ScrollableViewportSize() const; |
[email protected] | caa567d | 2012-12-20 07:56:16 | [diff] [blame] | 496 | |
[email protected] | 3744e27b | 2013-11-06 21:44:08 | [diff] [blame] | 497 | gfx::Rect RootScrollLayerDeviceViewportBounds() const; |
| 498 | |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 499 | LayerImpl* LayerById(int id) const; |
Mason Freed | 310cae4 | 2019-07-19 03:40:25 | [diff] [blame] | 500 | LayerImpl* LayerByElementId(ElementId element_id) const; |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 501 | |
Robert Flack | b7010a7 | 2019-03-30 02:59:46 | [diff] [blame] | 502 | bool IsElementInPropertyTree(ElementId element_id) const; |
Robert Flack | b7010a7 | 2019-03-30 02:59:46 | [diff] [blame] | 503 | |
David Bokan | 4a19ae0 | 2018-09-15 13:59:27 | [diff] [blame] | 504 | void AddToElementLayerList(ElementId element_id, LayerImpl* layer); |
Robert Flack | 1d7d73f | 2018-05-28 17:29:36 | [diff] [blame] | 505 | void RemoveFromElementLayerList(ElementId element_id); |
vollick | ef2ae92 | 2016-06-29 17:54:27 | [diff] [blame] | 506 | |
akaba | 227bfbd6 | 2018-07-11 21:46:43 | [diff] [blame] | 507 | void SetSurfaceRanges(const base::flat_set<viz::SurfaceRange> surface_ranges); |
| 508 | const base::flat_set<viz::SurfaceRange>& SurfaceRanges() const; |
| 509 | void ClearSurfaceRanges(); |
jaydasika | 10be211 | 2017-05-26 04:35:50 | [diff] [blame] | 510 | |
jaydasika | bb0409e5 | 2016-03-08 04:05:19 | [diff] [blame] | 511 | void AddLayerShouldPushProperties(LayerImpl* layer); |
danakj | 956d1c82 | 2018-09-13 01:38:57 | [diff] [blame] | 512 | void ClearLayersThatShouldPushProperties(); |
| 513 | const base::flat_set<LayerImpl*>& LayersThatShouldPushProperties() { |
| 514 | return layers_that_should_push_properties_; |
| 515 | } |
jaydasika | bb0409e5 | 2016-03-08 04:05:19 | [diff] [blame] | 516 | |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 517 | // These should be called by LayerImpl's ctor/dtor. |
| 518 | void RegisterLayer(LayerImpl* layer); |
| 519 | void UnregisterLayer(LayerImpl* layer); |
| 520 | |
Xianzhu Wang | 0340f14b | 2019-09-10 23:42:19 | [diff] [blame] | 521 | // Append a layer to the list. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 522 | void AddLayer(std::unique_ptr<LayerImpl> layer); |
Xianzhu Wang | 0340f14b | 2019-09-10 23:42:19 | [diff] [blame] | 523 | |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 524 | size_t NumLayers(); |
| 525 | |
[email protected] | 37386f05 | 2013-01-13 00:42:22 | [diff] [blame] | 526 | void DidBecomeActive(); |
| 527 | |
khushalsagar | b64b360d | 2015-10-21 19:25:16 | [diff] [blame] | 528 | // Used for accessing the task runner and debug assertions. |
| 529 | TaskRunnerProvider* task_runner_provider() const; |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 530 | |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 531 | // Call this function when you expect there to be a swap buffer. |
| 532 | // See swap_promise.h for how to use SwapPromise. |
tobiasjs | 2e02f73e | 2015-09-02 12:08:03 | [diff] [blame] | 533 | // |
| 534 | // A swap promise queued by QueueSwapPromise travels with the layer |
| 535 | // information currently associated with the tree. For example, when |
| 536 | // a pending tree is activated, the swap promise is passed to the |
| 537 | // active tree along with the layer information. Similarly, when a |
| 538 | // new activation overwrites layer information on the active tree, |
| 539 | // queued swap promises are broken. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 540 | void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise); |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 541 | |
tobiasjs | 2e02f73e | 2015-09-02 12:08:03 | [diff] [blame] | 542 | // Queue a swap promise, pinned to this tree. Pinned swap promises |
| 543 | // may only be queued on the active tree. |
| 544 | // |
| 545 | // An active tree pinned swap promise will see only DidSwap() or |
| 546 | // DidNotSwap(SWAP_FAILS). No DidActivate() will be seen because |
| 547 | // that has already happened prior to queueing of the swap promise. |
| 548 | // |
| 549 | // Pinned active tree swap promises will not be broken prematurely |
| 550 | // on the active tree if a new tree is activated. |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 551 | void QueuePinnedSwapPromise(std::unique_ptr<SwapPromise> swap_promise); |
tobiasjs | 2e02f73e | 2015-09-02 12:08:03 | [diff] [blame] | 552 | |
sunnyps | ad3235e | 2016-08-09 04:57:52 | [diff] [blame] | 553 | // Takes ownership of |new_swap_promises|. Existing swap promises in |
| 554 | // |swap_promise_list_| are cancelled (SWAP_FAILS). |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 555 | void PassSwapPromises( |
sunnyps | ad3235e | 2016-08-09 04:57:52 | [diff] [blame] | 556 | std::vector<std::unique_ptr<SwapPromise>> new_swap_promises); |
| 557 | void AppendSwapPromises( |
| 558 | std::vector<std::unique_ptr<SwapPromise>> new_swap_promises); |
Sadrul Habib Chowdhury | 2485621 | 2018-05-25 21:38:43 | [diff] [blame] | 559 | void FinishSwapPromises(viz::CompositorFrameMetadata* metadata); |
samans | e7345c8 | 2016-12-16 02:51:16 | [diff] [blame] | 560 | void ClearSwapPromises(); |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 561 | void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); |
| 562 | |
[email protected] | c48536a5 | 2013-09-14 00:02:08 | [diff] [blame] | 563 | void DidModifyTilePriorities(); |
[email protected] | fcb846d | 2013-05-22 01:42:36 | [diff] [blame] | 564 | |
Fady Samuel | c80a4a86 | 2017-07-28 10:23:36 | [diff] [blame] | 565 | viz::ResourceId ResourceIdForUIResource(UIResourceId uid) const; |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 566 | void ProcessUIResourceRequestQueue(); |
| 567 | |
[email protected] | 709c954 | 2013-10-26 01:43:51 | [diff] [blame] | 568 | bool IsUIResourceOpaque(UIResourceId uid) const; |
| 569 | |
danakj | 7383c55 | 2015-02-11 18:01:48 | [diff] [blame] | 570 | void RegisterPictureLayerImpl(PictureLayerImpl* layer); |
| 571 | void UnregisterPictureLayerImpl(PictureLayerImpl* layer); |
| 572 | const std::vector<PictureLayerImpl*>& picture_layers() const { |
| 573 | return picture_layers_; |
| 574 | } |
| 575 | |
Stephen McGruer | 8e2d355 | 2019-07-10 14:06:29 | [diff] [blame] | 576 | void NotifyLayerHasPaintWorkletsChanged(PictureLayerImpl* layer, |
| 577 | bool has_worklets); |
| 578 | const base::flat_set<PictureLayerImpl*>& picture_layers_with_paint_worklets() |
| 579 | const { |
| 580 | return picture_layers_with_paint_worklets_; |
| 581 | } |
| 582 | |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 583 | void RegisterScrollbar(ScrollbarLayerImplBase* scrollbar_layer); |
| 584 | void UnregisterScrollbar(ScrollbarLayerImplBase* scrollbar_layer); |
pdr | 7b8ed8a | 2017-04-19 21:24:27 | [diff] [blame] | 585 | ScrollbarSet ScrollbarsFor(ElementId scroll_element_id) const; |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 586 | |
chaopeng | d2a75ab | 2018-09-28 17:41:23 | [diff] [blame] | 587 | LayerImpl* FindFirstScrollingLayerOrScrollbarThatIsHitByPoint( |
[email protected] | 28336d5 | 2014-05-12 19:07:28 | [diff] [blame] | 588 | const gfx::PointF& screen_space_point); |
| 589 | |
| 590 | LayerImpl* FindLayerThatIsHitByPoint(const gfx::PointF& screen_space_point); |
| 591 | |
| 592 | LayerImpl* FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 593 | const gfx::PointF& screen_space_point); |
| 594 | |
sunxd | 3e3a37a7 | 2018-07-06 22:58:43 | [diff] [blame] | 595 | LayerImpl* FindLayerThatIsHitByPointInWheelEventHandlerRegion( |
| 596 | const gfx::PointF& screen_space_point); |
| 597 | |
Philip Rogers | 755286e | 2019-07-01 21:16:08 | [diff] [blame] | 598 | // Return all layers with a hit non-fast scrollable region. |
| 599 | std::vector<const LayerImpl*> FindLayersHitByPointInNonFastScrollableRegion( |
| 600 | const gfx::PointF& screen_space_point); |
David Bokan | 092ab286 | 2020-07-09 17:40:57 | [diff] [blame] | 601 | // Returns all layers up to the first scroller or scrollbar layer, inclusive. |
| 602 | // The returned vector is sorted in order of top most come first. The back of |
| 603 | // the vector will be the scrollable layer if one was hit. |
| 604 | std::vector<const LayerImpl*> FindAllLayersUpToAndIncludingFirstScrollable( |
| 605 | const gfx::PointF& screen_space_point); |
David Bokan | 1061035 | 2020-05-28 18:11:12 | [diff] [blame] | 606 | bool PointHitsNonFastScrollableRegion(const gfx::PointF& scree_space_point, |
| 607 | const LayerImpl& layer) const; |
Philip Rogers | 755286e | 2019-07-01 21:16:08 | [diff] [blame] | 608 | |
Andrew Comminos | 498b4b5 | 2020-03-12 03:43:23 | [diff] [blame] | 609 | // Returns the ElementId representing a frame's document at the given point. |
| 610 | // In cases where cc doesn't have enough information to perform accurate |
| 611 | // attribution (e.g. in the presence of a complex clip), kInvalidElementId is |
| 612 | // returned. |
| 613 | ElementId FindFrameElementIdAtPoint(const gfx::PointF& screen_space_point); |
| 614 | |
jdduke | 449b529 | 2015-04-23 19:36:44 | [diff] [blame] | 615 | void RegisterSelection(const LayerSelection& selection); |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 616 | |
James Wallace-Lee | e71cf58 | 2018-01-29 22:24:23 | [diff] [blame] | 617 | bool HandleVisibilityChanged() const { return handle_visibility_changed_; } |
| 618 | void ResetHandleVisibilityChanged(); |
amaralp | 1107a29 | 2017-01-17 20:05:52 | [diff] [blame] | 619 | |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 620 | // Compute the current selection handle location and visbility with respect to |
| 621 | // the viewport. |
danakj | 5e0a12b | 2017-09-25 17:26:49 | [diff] [blame] | 622 | void GetViewportSelection(viz::Selection<gfx::SelectionBound>* selection); |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 623 | |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 624 | bool browser_controls_shrink_blink_size() const { |
Sinan Sahin | 92a360bc | 2019-12-05 19:20:45 | [diff] [blame] | 625 | return browser_controls_params_.browser_controls_shrink_blink_size; |
bokan | 88eae01 | 2014-09-09 20:40:42 | [diff] [blame] | 626 | } |
Sinan Sahin | b6ffa91 | 2019-10-23 21:04:46 | [diff] [blame] | 627 | bool SetCurrentBrowserControlsShownRatio(float top_ratio, float bottom_ratio); |
| 628 | float CurrentTopControlsShownRatio() const { |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 629 | return top_controls_shown_ratio_->Current(IsActiveTree()); |
| 630 | } |
Sinan Sahin | b6ffa91 | 2019-10-23 21:04:46 | [diff] [blame] | 631 | float CurrentBottomControlsShownRatio() const { |
| 632 | return bottom_controls_shown_ratio_->Current(IsActiveTree()); |
| 633 | } |
Sinan Sahin | 92a360bc | 2019-12-05 19:20:45 | [diff] [blame] | 634 | void SetBrowserControlsParams(const BrowserControlsParams& params); |
| 635 | float top_controls_height() const { |
| 636 | return browser_controls_params_.top_controls_height; |
| 637 | } |
| 638 | float top_controls_min_height() const { |
| 639 | return browser_controls_params_.top_controls_min_height; |
| 640 | } |
Sinan Sahin | b6ffa91 | 2019-10-23 21:04:46 | [diff] [blame] | 641 | void PushBrowserControlsFromMainThread(float top_controls_shown_ratio, |
| 642 | float bottom_controls_shown_ratio); |
Sinan Sahin | 92a360bc | 2019-12-05 19:20:45 | [diff] [blame] | 643 | float bottom_controls_height() const { |
| 644 | return browser_controls_params_.bottom_controls_height; |
| 645 | } |
| 646 | float bottom_controls_min_height() const { |
| 647 | return browser_controls_params_.bottom_controls_min_height; |
| 648 | } |
Robbie McElrath | cbb6778 | 2020-08-18 00:10:36 | [diff] [blame] | 649 | bool only_expand_top_controls_at_page_top() const { |
| 650 | return browser_controls_params_.only_expand_top_controls_at_page_top; |
Robbie McElrath | c727f0e | 2020-07-22 20:22:55 | [diff] [blame] | 651 | } |
bokan | 88eae01 | 2014-09-09 20:40:42 | [diff] [blame] | 652 | |
Sandra Sun | 2288e853 | 2017-11-30 22:50:16 | [diff] [blame] | 653 | void set_overscroll_behavior(const OverscrollBehavior& behavior); |
| 654 | OverscrollBehavior overscroll_behavior() const { |
| 655 | return overscroll_behavior_; |
sunyunjia | bbea8a9 | 2017-08-31 11:18:54 | [diff] [blame] | 656 | } |
| 657 | |
bokan | fcdbc18 | 2014-11-21 21:53:33 | [diff] [blame] | 658 | void SetPendingPageScaleAnimation( |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 659 | std::unique_ptr<PendingPageScaleAnimation> pending_animation); |
| 660 | std::unique_ptr<PendingPageScaleAnimation> TakePendingPageScaleAnimation(); |
bokan | 915bf35 | 2014-10-02 21:57:14 | [diff] [blame] | 661 | |
Mohsen Izadi | b8878bf7 | 2020-11-06 19:16:42 | [diff] [blame] | 662 | void AppendEventsMetricsFromMainThread(EventMetrics::List events_metrics); |
| 663 | EventMetrics::List TakeEventsMetrics(); |
Sadrul Habib Chowdhury | f37cae5 | 2020-04-02 22:20:32 | [diff] [blame] | 664 | |
Eric Karl | 706ea671 | 2018-12-21 22:41:38 | [diff] [blame] | 665 | // Requests that we force send RenderFrameMetadata with the next frame. |
| 666 | void RequestForceSendMetadata() { force_send_metadata_request_ = true; } |
| 667 | bool TakeForceSendMetadataRequest(); |
| 668 | |
pdr | 54d03819 | 2017-06-08 22:44:13 | [diff] [blame] | 669 | void DidUpdateScrollOffset(ElementId id); |
Philip Rogers | 5e56378 | 2017-06-02 01:37:20 | [diff] [blame] | 670 | |
| 671 | // Mark the scrollbar geometries (e.g., thumb size and position) as needing an |
| 672 | // update. |
| 673 | void SetScrollbarGeometriesNeedUpdate() { |
pdr | 0521645 | 2017-06-08 23:18:28 | [diff] [blame] | 674 | if (IsActiveTree()) { |
Philip Rogers | 5e56378 | 2017-06-02 01:37:20 | [diff] [blame] | 675 | scrollbar_geometries_need_update_ = true; |
pdr | 0521645 | 2017-06-08 23:18:28 | [diff] [blame] | 676 | // Scrollbar geometries are updated in |UpdateDrawProperties|. |
| 677 | set_needs_update_draw_properties(); |
| 678 | } |
Philip Rogers | 5e56378 | 2017-06-02 01:37:20 | [diff] [blame] | 679 | } |
| 680 | bool ScrollbarGeometriesNeedUpdate() const { |
| 681 | return scrollbar_geometries_need_update_; |
| 682 | } |
| 683 | // Update the geometries of all scrollbars (e.g., thumb size and position). An |
| 684 | // update only occurs if a scroll-related layer has changed (see: |
| 685 | // SetScrollbarGeometriesNeedUpdate). |
| 686 | void UpdateScrollbarGeometries(); |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 687 | |
danakj | 26099d5d | 2018-09-13 17:08:56 | [diff] [blame] | 688 | // See LayerTreeHost. |
dtapuska | f024e55 | 2016-02-03 01:19:46 | [diff] [blame] | 689 | bool have_scroll_event_handlers() const { |
| 690 | return have_scroll_event_handlers_; |
| 691 | } |
| 692 | void set_have_scroll_event_handlers(bool have_event_handlers) { |
| 693 | have_scroll_event_handlers_ = have_event_handlers; |
| 694 | } |
| 695 | |
danakj | 26099d5d | 2018-09-13 17:08:56 | [diff] [blame] | 696 | // See LayerTreeHost. |
dtapuska | f206a40d | 2016-02-05 21:36:02 | [diff] [blame] | 697 | EventListenerProperties event_listener_properties( |
| 698 | EventListenerClass event_class) const { |
| 699 | return event_listener_properties_[static_cast<size_t>(event_class)]; |
| 700 | } |
| 701 | void set_event_listener_properties(EventListenerClass event_class, |
| 702 | EventListenerProperties event_properties) { |
| 703 | event_listener_properties_[static_cast<size_t>(event_class)] = |
| 704 | event_properties; |
dtapuska | ee0b698 | 2016-01-29 15:14:48 | [diff] [blame] | 705 | } |
| 706 | |
jaydasika | d6f778b | 2016-05-19 22:51:26 | [diff] [blame] | 707 | void ResetAllChangeTracking(); |
jaydasika | ef64f9e4 | 2016-03-12 01:08:18 | [diff] [blame] | 708 | |
chaopeng | f96bf98 | 2018-03-09 23:45:37 | [diff] [blame] | 709 | void HandleTickmarksVisibilityChange(); |
skobes | 697a467f | 2017-04-28 02:54:17 | [diff] [blame] | 710 | void HandleScrollbarShowRequestsFromMain(); |
jaydasika | 4b0fd751 | 2016-06-09 18:12:53 | [diff] [blame] | 711 | |
khushalsagar | d5e13bf | 2017-05-17 08:08:50 | [diff] [blame] | 712 | void InvalidateRegionForImages( |
| 713 | const PaintImageIdFlatSet& images_to_invalidate); |
khushalsagar | d3b8827d | 2017-02-18 18:42:54 | [diff] [blame] | 714 | |
Eric Karl | ec12101 | 2019-08-07 21:54:00 | [diff] [blame] | 715 | void UpdateViewportContainerSizes(); |
| 716 | |
pdr | 80ecb980 | 2017-05-16 03:40:09 | [diff] [blame] | 717 | LayerTreeLifecycle& lifecycle() { return lifecycle_; } |
| 718 | |
Philip Rogers | 40ac3e0 | 2018-12-20 17:13:18 | [diff] [blame] | 719 | std::string LayerListAsJson() const; |
Philip Rogers | 40ac3e0 | 2018-12-20 17:13:18 | [diff] [blame] | 720 | |
Xida Chen | c5cb856 | 2019-08-14 22:41:56 | [diff] [blame] | 721 | AnimatedPaintWorkletTracker& paint_worklet_tracker() { |
| 722 | return host_impl_->paint_worklet_tracker(); |
| 723 | } |
| 724 | |
Xianzhu Wang | 66e13e0 | 2019-09-18 20:39:12 | [diff] [blame] | 725 | const gfx::Transform& DrawTransform() const { |
| 726 | return host_impl_->DrawTransform(); |
| 727 | } |
| 728 | |
Vladimir Levin | 6abaaa8f | 2020-11-11 15:07:16 | [diff] [blame] | 729 | bool IsInSynchronousComposite() const { |
| 730 | return host_impl_->IsInSynchronousComposite(); |
| 731 | } |
| 732 | |
Mario Bianucci | 244acf8 | 2020-06-10 04:40:35 | [diff] [blame] | 733 | // These functions are used for plumbing DelegatedInkMetadata from blink |
| 734 | // through the compositor and into viz via a compositor frame. They should |
| 735 | // only be called after the JS API |updateInkTrailStartPoint| has been |
| 736 | // called, which populates the metadata with provided information. |
Mario Bianucci | 3077de53 | 2020-05-21 21:22:35 | [diff] [blame] | 737 | void set_delegated_ink_metadata( |
Mario Bianucci | a538c5d | 2021-03-15 20:40:23 | [diff] [blame] | 738 | std::unique_ptr<gfx::DelegatedInkMetadata> metadata) { |
Mario Bianucci | 3077de53 | 2020-05-21 21:22:35 | [diff] [blame] | 739 | delegated_ink_metadata_ = std::move(metadata); |
| 740 | } |
Mario Bianucci | a538c5d | 2021-03-15 20:40:23 | [diff] [blame] | 741 | std::unique_ptr<gfx::DelegatedInkMetadata> take_delegated_ink_metadata() { |
Mario Bianucci | 244acf8 | 2020-06-10 04:40:35 | [diff] [blame] | 742 | return std::move(delegated_ink_metadata_); |
| 743 | } |
Mario Bianucci | 3077de53 | 2020-05-21 21:22:35 | [diff] [blame] | 744 | |
Mohsen Izadi | cd2804d | 2020-07-15 03:39:05 | [diff] [blame] | 745 | size_t events_metrics_from_main_thread_count_for_testing() const { |
| 746 | return events_metrics_from_main_thread_.size(); |
| 747 | } |
| 748 | |
Xianzhu Wang | 118640fa | 2021-01-12 21:24:15 | [diff] [blame] | 749 | bool device_viewport_rect_changed() const { |
| 750 | return device_viewport_rect_changed_; |
| 751 | } |
| 752 | |
Liviu Tinta | 7b9d69b | 2021-02-26 20:03:56 | [diff] [blame] | 753 | bool viewport_mobile_optimized() const { |
| 754 | return host_impl_->viewport_mobile_optimized(); |
| 755 | } |
| 756 | |
Vladimir Levin | 1b746faf | 2021-01-19 21:25:58 | [diff] [blame] | 757 | // Add a document transition request from the embedder. |
| 758 | void AddDocumentTransitionRequest( |
| 759 | std::unique_ptr<DocumentTransitionRequest> request); |
| 760 | |
| 761 | // Returns all of the document transition requests stored so far, and empties |
| 762 | // the internal list. |
| 763 | std::vector<std::unique_ptr<DocumentTransitionRequest>> |
| 764 | TakeDocumentTransitionRequests(); |
| 765 | |
Vladimir Levin | 7b4ab44 | 2021-01-27 19:28:33 | [diff] [blame] | 766 | bool HasDocumentTransitionRequests() const; |
| 767 | |
[email protected] | 3c0a325 | 2013-03-18 04:24:36 | [diff] [blame] | 768 | protected: |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 769 | float ClampPageScaleFactorToLimits(float page_scale_factor) const; |
| 770 | void PushPageScaleFactorAndLimits(const float* page_scale_factor, |
| 771 | float min_page_scale_factor, |
| 772 | float max_page_scale_factor); |
| 773 | bool SetPageScaleFactorLimits(float min_page_scale_factor, |
| 774 | float max_page_scale_factor); |
| 775 | void DidUpdatePageScale(); |
Sinan Sahin | b6ffa91 | 2019-10-23 21:04:46 | [diff] [blame] | 776 | void PushBrowserControls(const float* top_controls_shown_ratio, |
| 777 | const float* bottom_controls_shown_ratio); |
| 778 | bool ClampTopControlsShownRatio(); |
| 779 | bool ClampBottomControlsShownRatio(); |
bokan | 0223f2f72 | 2016-06-23 12:35:01 | [diff] [blame] | 780 | |
Walter Korman | af60f63 | 2017-08-24 22:52:39 | [diff] [blame] | 781 | private: |
Robert Flack | 2a64f7b | 2018-11-22 21:59:28 | [diff] [blame] | 782 | friend class LayerTreeHost; |
| 783 | |
David Bokan | 6357cc72 | 2018-06-11 01:09:52 | [diff] [blame] | 784 | void UpdatePageScaleNode(); |
| 785 | |
Walter Korman | af60f63 | 2017-08-24 22:52:39 | [diff] [blame] | 786 | ElementListType GetElementTypeForAnimation() const; |
| 787 | void UpdateTransformAnimation(ElementId element_id, int transform_node_index); |
sunxd | 3e3a37a7 | 2018-07-06 22:58:43 | [diff] [blame] | 788 | template <typename Functor> |
| 789 | LayerImpl* FindLayerThatIsHitByPointInEventHandlerRegion( |
| 790 | const gfx::PointF& screen_space_point, |
| 791 | const Functor& func); |
Walter Korman | af60f63 | 2017-08-24 22:52:39 | [diff] [blame] | 792 | |
Walter Korman | aa326e4 | 2017-08-22 23:04:43 | [diff] [blame] | 793 | LayerTreeHostImpl* host_impl_; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 794 | int source_frame_number_; |
jaydasika | cb93d1c | 2015-12-09 23:52:46 | [diff] [blame] | 795 | int is_first_frame_after_commit_tracker_; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 796 | HeadsUpDisplayLayerImpl* hud_layer_; |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 797 | PropertyTrees property_trees_; |
[email protected] | a3029014 | 2013-01-05 01:27:00 | [diff] [blame] | 798 | SkColor background_color_; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 799 | |
pdr | b2d4d4b | 2017-03-01 19:56:45 | [diff] [blame] | 800 | int last_scrolled_scroll_node_index_; |
pdr | 9bb53af | 2017-05-18 03:25:08 | [diff] [blame] | 801 | |
Xianzhu Wang | eb746a5c8 | 2018-11-29 04:07:19 | [diff] [blame] | 802 | LayerTreeHost::ViewportPropertyIds viewport_property_ids_; |
[email protected] | 57ac948 | 2013-09-17 21:13:39 | [diff] [blame] | 803 | |
jdduke | 449b529 | 2015-04-23 19:36:44 | [diff] [blame] | 804 | LayerSelection selection_; |
[email protected] | 19aec37 | 2014-07-01 19:08:49 | [diff] [blame] | 805 | |
aelias | 58eec081 | 2014-12-04 01:04:40 | [diff] [blame] | 806 | scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor_; |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 807 | float min_page_scale_factor_; |
| 808 | float max_page_scale_factor_; |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 809 | float external_page_scale_factor_; |
[email protected] | c6027947 | 2013-01-30 12:10:51 | [diff] [blame] | 810 | |
ajuma | 1d48e01 | 2015-09-25 22:24:16 | [diff] [blame] | 811 | float device_scale_factor_; |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 812 | float painted_device_scale_factor_; |
Dale Curtis | af1074b2 | 2020-08-20 06:33:30 | [diff] [blame] | 813 | gfx::DisplayColorSpaces display_color_spaces_; |
ajuma | 1d48e01 | 2015-09-25 22:24:16 | [diff] [blame] | 814 | |
Jonathan Ross | d0345bf | 2020-09-25 02:13:54 | [diff] [blame] | 815 | viz::LocalSurfaceId local_surface_id_from_parent_; |
Fady Samuel | 2899c7a | 2018-05-09 16:51:21 | [diff] [blame] | 816 | bool new_local_surface_id_request_ = false; |
W. James MacLean | 7df854c | 2019-08-28 16:17:53 | [diff] [blame] | 817 | // Contains the physical rect of the device viewport, to be used in |
| 818 | // determining what needs to be drawn. |
Xianzhu Wang | 118640fa | 2021-01-12 21:24:15 | [diff] [blame] | 819 | bool device_viewport_rect_changed_ = false; |
W. James MacLean | 7df854c | 2019-08-28 16:17:53 | [diff] [blame] | 820 | gfx::Rect device_viewport_rect_; |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 821 | |
ccameron | b9aec450 | 2014-12-05 19:31:00 | [diff] [blame] | 822 | scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; |
| 823 | |
Xianzhu Wang | 0340f14b | 2019-09-10 23:42:19 | [diff] [blame] | 824 | // TODO(wangxianzhu): Combine layers_ and layer_list_ when we remove |
| 825 | // support of mask layers. |
| 826 | |
Xianzhu Wang | f817d6c | 2019-09-17 20:08:34 | [diff] [blame] | 827 | OwnedLayerImplList layer_list_; |
| 828 | // Maps from layer id to layer. |
vollick | 83fbfc8 | 2016-03-22 18:33:27 | [diff] [blame] | 829 | LayerImplMap layer_id_map_; |
Xianzhu Wang | 0340f14b | 2019-09-10 23:42:19 | [diff] [blame] | 830 | |
jaydasika | bb0409e5 | 2016-03-08 04:05:19 | [diff] [blame] | 831 | // Set of layers that need to push properties. |
danakj | 956d1c82 | 2018-09-13 01:38:57 | [diff] [blame] | 832 | base::flat_set<LayerImpl*> layers_that_should_push_properties_; |
vollick | cb3f6b1 | 2016-03-01 23:44:10 | [diff] [blame] | 833 | |
weiliangc | 1f4b78a | 2017-03-24 20:16:42 | [diff] [blame] | 834 | std::unordered_map<ElementId, float, ElementIdHash> |
| 835 | element_id_to_opacity_animations_; |
| 836 | std::unordered_map<ElementId, gfx::Transform, ElementIdHash> |
| 837 | element_id_to_transform_animations_; |
| 838 | std::unordered_map<ElementId, FilterOperations, ElementIdHash> |
| 839 | element_id_to_filter_animations_; |
Mason Freed | 384fc5b | 2019-05-30 19:49:10 | [diff] [blame] | 840 | std::unordered_map<ElementId, FilterOperations, ElementIdHash> |
| 841 | element_id_to_backdrop_filter_animations_; |
jaydasika | 2368fd5 | 2016-05-11 19:38:29 | [diff] [blame] | 842 | |
pdr | 8cafc0ba | 2017-05-22 18:39:17 | [diff] [blame] | 843 | struct ScrollbarLayerIds { |
| 844 | int horizontal = Layer::INVALID_ID; |
| 845 | int vertical = Layer::INVALID_ID; |
| 846 | }; |
| 847 | // Each scroll layer can have up to two scrollbar layers (vertical and |
| 848 | // horizontal). This mapping is maintained as part of scrollbar registration. |
| 849 | base::flat_map<ElementId, ScrollbarLayerIds> |
| 850 | element_id_to_scrollbar_layer_ids_; |
aelias | a57c40d12 | 2015-10-08 00:20:09 | [diff] [blame] | 851 | |
danakj | 7383c55 | 2015-02-11 18:01:48 | [diff] [blame] | 852 | std::vector<PictureLayerImpl*> picture_layers_; |
jaydasika | 10be211 | 2017-05-26 04:35:50 | [diff] [blame] | 853 | |
Stephen McGruer | 8e2d355 | 2019-07-10 14:06:29 | [diff] [blame] | 854 | // After commit (or impl-side invalidation), the LayerTreeHostImpl must walk |
| 855 | // all PictureLayerImpls that have PaintWorklets to ensure they are painted. |
| 856 | // To avoid unnecessary walking, we track that set here. |
| 857 | base::flat_set<PictureLayerImpl*> picture_layers_with_paint_worklets_; |
| 858 | |
akaba | 227bfbd6 | 2018-07-11 21:46:43 | [diff] [blame] | 859 | base::flat_set<viz::SurfaceRange> surface_layer_ranges_; |
[email protected] | 30fe19ff | 2013-07-04 00:54:45 | [diff] [blame] | 860 | |
ajuma | b784ef4 | 2017-04-28 23:01:52 | [diff] [blame] | 861 | // List of render surfaces for the most recently prepared frame. |
| 862 | RenderSurfaceList render_surface_list_; |
| 863 | // After drawing the |render_surface_list_| the areas in this region |
danakj | 4902c30 | 2015-02-13 22:12:16 | [diff] [blame] | 864 | // would not be fully covered by opaque content. |
| 865 | Region unoccluded_screen_space_region_; |
[email protected] | 76ffd9e | 2012-12-20 19:12:47 | [diff] [blame] | 866 | |
[email protected] | 615c78a | 2013-01-24 23:44:16 | [diff] [blame] | 867 | bool needs_update_draw_properties_; |
[email protected] | 6f90b9e | 2013-01-17 23:42:00 | [diff] [blame] | 868 | |
Philip Rogers | 5e56378 | 2017-06-02 01:37:20 | [diff] [blame] | 869 | // True if a scrollbar geometry value has changed. For example, if the scroll |
| 870 | // offset changes, scrollbar thumb positions need to be updated. |
| 871 | bool scrollbar_geometries_need_update_; |
| 872 | |
[email protected] | db8259f | 2013-02-01 05:25:04 | [diff] [blame] | 873 | // In impl-side painting mode, this is true when the tree may contain |
| 874 | // structural differences relative to the active tree. |
| 875 | bool needs_full_tree_sync_; |
| 876 | |
akaba | 227bfbd6 | 2018-07-11 21:46:43 | [diff] [blame] | 877 | bool needs_surface_ranges_sync_; |
jaydasika | 10be211 | 2017-05-26 04:35:50 | [diff] [blame] | 878 | |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 879 | bool next_activation_forces_redraw_; |
| 880 | |
[email protected] | 759dc9f | 2014-07-23 19:18:51 | [diff] [blame] | 881 | bool has_ever_been_drawn_; |
| 882 | |
amaralp | 1107a29 | 2017-01-17 20:05:52 | [diff] [blame] | 883 | bool handle_visibility_changed_; |
| 884 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 885 | std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; |
| 886 | std::vector<std::unique_ptr<SwapPromise>> pinned_swap_promise_list_; |
[email protected] | b69c1db | 2013-11-27 00:05:19 | [diff] [blame] | 887 | |
[email protected] | c928076 | 2013-08-01 06:28:57 | [diff] [blame] | 888 | UIResourceRequestQueue ui_resource_request_queue_; |
| 889 | |
dtapuska | f024e55 | 2016-02-03 01:19:46 | [diff] [blame] | 890 | bool have_scroll_event_handlers_; |
danakj | 729a2f7 | 2018-07-10 17:40:35 | [diff] [blame] | 891 | EventListenerProperties event_listener_properties_ |
| 892 | [static_cast<size_t>(EventListenerClass::kLast) + 1]; |
dtapuska | ee0b698 | 2016-01-29 15:14:48 | [diff] [blame] | 893 | |
Sinan Sahin | 92a360bc | 2019-12-05 19:20:45 | [diff] [blame] | 894 | BrowserControlsParams browser_controls_params_; |
bokan | 88eae01 | 2014-09-09 20:40:42 | [diff] [blame] | 895 | |
Sandra Sun | 2288e853 | 2017-11-30 22:50:16 | [diff] [blame] | 896 | OverscrollBehavior overscroll_behavior_; |
sunyunjia | bbea8a9 | 2017-08-31 11:18:54 | [diff] [blame] | 897 | |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 898 | // The amount that the browser controls are shown from 0 (hidden) to 1 (fully |
aelias | 6004fe0 | 2015-02-07 21:43:01 | [diff] [blame] | 899 | // shown). |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 900 | scoped_refptr<SyncedBrowserControls> top_controls_shown_ratio_; |
Sinan Sahin | b6ffa91 | 2019-10-23 21:04:46 | [diff] [blame] | 901 | scoped_refptr<SyncedBrowserControls> bottom_controls_shown_ratio_; |
bokan | 88eae01 | 2014-09-09 20:40:42 | [diff] [blame] | 902 | |
danakj | 60bc3bc | 2016-04-09 00:24:48 | [diff] [blame] | 903 | std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
bokan | 915bf35 | 2014-10-02 21:57:14 | [diff] [blame] | 904 | |
Eric Karl | 706ea671 | 2018-12-21 22:41:38 | [diff] [blame] | 905 | // Whether we have a request to force-send RenderFrameMetadata with the next |
| 906 | // frame. |
| 907 | bool force_send_metadata_request_ = false; |
| 908 | |
pdr | 80ecb980 | 2017-05-16 03:40:09 | [diff] [blame] | 909 | // Tracks the lifecycle which is used for enforcing dependencies between |
| 910 | // lifecycle states. See: |LayerTreeLifecycle|. |
| 911 | LayerTreeLifecycle lifecycle_; |
| 912 | |
Xiyuan Xia | 0274c58 | 2019-12-04 20:49:03 | [diff] [blame] | 913 | // Display transform hint to tag frames generated from this tree. |
| 914 | gfx::OverlayTransform display_transform_hint_ = gfx::OVERLAY_TRANSFORM_NONE; |
| 915 | |
Sadrul Habib Chowdhury | 3d4df2e8 | 2018-06-02 05:18:00 | [diff] [blame] | 916 | std::vector<LayerTreeHost::PresentationTimeCallback> presentation_callbacks_; |
Sadrul Habib Chowdhury | f37cae5 | 2020-04-02 22:20:32 | [diff] [blame] | 917 | |
| 918 | // Event metrics that are reported back from the main thread. |
Mohsen Izadi | b8878bf7 | 2020-11-06 19:16:42 | [diff] [blame] | 919 | EventMetrics::List events_metrics_from_main_thread_; |
Mario Bianucci | 3077de53 | 2020-05-21 21:22:35 | [diff] [blame] | 920 | |
Mario Bianucci | a538c5d | 2021-03-15 20:40:23 | [diff] [blame] | 921 | std::unique_ptr<gfx::DelegatedInkMetadata> delegated_ink_metadata_; |
Vladimir Levin | 1b746faf | 2021-01-19 21:25:58 | [diff] [blame] | 922 | |
| 923 | // Document transition requests to be transferred to Viz. |
| 924 | std::vector<std::unique_ptr<DocumentTransitionRequest>> |
| 925 | document_transition_requests_; |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 926 | }; |
| 927 | |
[email protected] | bf691c2 | 2013-03-26 21:15:06 | [diff] [blame] | 928 | } // namespace cc |
[email protected] | 3b31c6ac | 2012-12-06 21:27:29 | [diff] [blame] | 929 | |
[email protected] | 556fd29 | 2013-03-18 08:03:04 | [diff] [blame] | 930 | #endif // CC_TREES_LAYER_TREE_IMPL_H_ |