[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 1 | // Copyright 2010 The Chromium Authors. All rights reserved. |
[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 5 | #ifndef CC_LAYERS_LAYER_H_ |
| 6 | #define CC_LAYERS_LAYER_H_ |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 7 | |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 8 | #include <set> |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 9 | #include <string> |
vmpstr | 3d1d72c | 2015-01-26 18:27:40 | [diff] [blame] | 10 | #include <vector> |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 11 | |
[email protected] | 18a7019 | 2013-04-26 16:18:25 | [diff] [blame] | 12 | #include "base/callback.h" |
[email protected] | a8461d8 | 2012-10-16 21:11:14 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
[email protected] | e10cd02 | 2012-12-18 00:32:26 | [diff] [blame] | 14 | #include "base/observer_list.h" |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 15 | #include "cc/animation/layer_animation_controller.h" |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 16 | #include "cc/animation/layer_animation_value_observer.h" |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 17 | #include "cc/animation/layer_animation_value_provider.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 18 | #include "cc/base/cc_export.h" |
| 19 | #include "cc/base/region.h" |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 20 | #include "cc/base/scoped_ptr_vector.h" |
vmpstr | 3d1d72c | 2015-01-26 18:27:40 | [diff] [blame] | 21 | #include "cc/debug/frame_timing_request.h" |
[email protected] | 666d7cf | 2013-10-12 01:30:29 | [diff] [blame] | 22 | #include "cc/debug/micro_benchmark.h" |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 23 | #include "cc/layers/layer_lists.h" |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 24 | #include "cc/layers/layer_position_constraint.h" |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 25 | #include "cc/layers/paint_properties.h" |
rbyers | 18779d82 | 2015-02-05 06:22:06 | [diff] [blame] | 26 | #include "cc/layers/scroll_blocks_on.h" |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 27 | #include "cc/output/filter_operations.h" |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 28 | #include "cc/trees/property_tree.h" |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 29 | #include "skia/ext/refptr.h" |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 30 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 31 | #include "third_party/skia/include/core/SkImageFilter.h" |
[email protected] | f7837a9 | 2013-08-21 03:00:05 | [diff] [blame] | 32 | #include "third_party/skia/include/core/SkPicture.h" |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 33 | #include "third_party/skia/include/core/SkXfermode.h" |
heejin.r.chung | d28506ba | 2014-10-23 16:36:20 | [diff] [blame] | 34 | #include "ui/gfx/geometry/point3_f.h" |
| 35 | #include "ui/gfx/geometry/rect.h" |
| 36 | #include "ui/gfx/geometry/rect_f.h" |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 37 | #include "ui/gfx/geometry/scroll_offset.h" |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 38 | #include "ui/gfx/transform.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 39 | |
[email protected] | db2586f | 2013-08-15 22:03:14 | [diff] [blame] | 40 | namespace gfx { |
| 41 | class BoxF; |
| 42 | } |
| 43 | |
[email protected] | 9f3be43 | 2013-12-03 03:53:22 | [diff] [blame] | 44 | namespace base { |
primiano | 1596043 | 2015-02-05 14:20:26 | [diff] [blame] | 45 | namespace trace_event { |
[email protected] | 9f3be43 | 2013-12-03 03:53:22 | [diff] [blame] | 46 | class ConvertableToTraceFormat; |
| 47 | } |
| 48 | } |
| 49 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 50 | namespace cc { |
| 51 | |
[email protected] | 4d0786a | 2013-01-07 16:21:20 | [diff] [blame] | 52 | class Animation; |
[email protected] | 3cae03e | 2013-06-26 22:13:52 | [diff] [blame] | 53 | class AnimationDelegate; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 54 | struct AnimationEvent; |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 55 | class CopyOutputRequest; |
[email protected] | 7f5605c | 2013-04-08 18:08:35 | [diff] [blame] | 56 | class LayerAnimationEventObserver; |
[email protected] | ae716ce | 2013-08-16 13:04:24 | [diff] [blame] | 57 | class LayerClient; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 58 | class LayerImpl; |
loyso | a6edaaff | 2015-05-25 03:26:44 | [diff] [blame] | 59 | class LayerSettings; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 60 | class LayerTreeHost; |
awoloszyn | e83f28c | 2014-12-22 15:40:00 | [diff] [blame] | 61 | class LayerTreeHostCommon; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 62 | class LayerTreeImpl; |
loyso | 5719778 | 2015-05-28 04:10:18 | [diff] [blame] | 63 | class LayerTreeSettings; |
[email protected] | d8411661 | 2013-03-29 05:32:49 | [diff] [blame] | 64 | class RenderingStatsInstrumentation; |
[email protected] | b4da203 | 2012-10-25 21:22:55 | [diff] [blame] | 65 | class ResourceUpdateQueue; |
[email protected] | 80413d7 | 2013-08-30 20:25:33 | [diff] [blame] | 66 | class ScrollbarLayerInterface; |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame] | 67 | class SimpleEnclosedRegion; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 68 | struct AnimationEvent; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 69 | |
| 70 | // Base class for composited layers. Special layer types are derived from |
| 71 | // this class. |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 72 | class CC_EXPORT Layer : public base::RefCounted<Layer>, |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 73 | public LayerAnimationValueObserver, |
| 74 | public LayerAnimationValueProvider { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 75 | public: |
[email protected] | 44d8e84c | 2013-10-19 19:13:22 | [diff] [blame] | 76 | typedef LayerList LayerListType; |
[email protected] | 44d8e84c | 2013-10-19 19:13:22 | [diff] [blame] | 77 | |
[email protected] | b7c4783f | 2013-03-15 23:11:42 | [diff] [blame] | 78 | enum LayerIdLabels { |
[email protected] | b7c4783f | 2013-03-15 23:11:42 | [diff] [blame] | 79 | INVALID_ID = -1, |
| 80 | }; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 81 | |
loyso | a6edaaff | 2015-05-25 03:26:44 | [diff] [blame] | 82 | static scoped_refptr<Layer> Create(const LayerSettings& settings); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 83 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 84 | int id() const { return layer_id_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 85 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 86 | Layer* RootLayer(); |
| 87 | Layer* parent() { return parent_; } |
| 88 | const Layer* parent() const { return parent_; } |
| 89 | void AddChild(scoped_refptr<Layer> child); |
| 90 | void InsertChild(scoped_refptr<Layer> child, size_t index); |
| 91 | void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer); |
| 92 | void RemoveFromParent(); |
| 93 | void RemoveAllChildren(); |
| 94 | void SetChildren(const LayerList& children); |
[email protected] | f659521e | 2013-07-26 00:27:06 | [diff] [blame] | 95 | bool HasAncestor(const Layer* ancestor) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 96 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 97 | const LayerList& children() const { return children_; } |
| 98 | Layer* child_at(size_t index) { return children_[index].get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 99 | |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 100 | // This requests the layer and its subtree be rendered and given to the |
| 101 | // callback. If the copy is unable to be produced (the layer is destroyed |
miu | a6ce94ca | 2015-03-31 20:21:22 | [diff] [blame] | 102 | // first), then the callback is called with a nullptr/empty result. If the |
| 103 | // request's source property is set, any prior uncommitted requests having the |
| 104 | // same source will be aborted. |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 105 | void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> request); |
| 106 | bool HasCopyRequest() const { |
| 107 | return !copy_requests_.empty(); |
[email protected] | 18a7019 | 2013-04-26 16:18:25 | [diff] [blame] | 108 | } |
| 109 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 110 | virtual void SetBackgroundColor(SkColor background_color); |
| 111 | SkColor background_color() const { return background_color_; } |
[email protected] | 2c4cbec | 2013-06-04 21:14:50 | [diff] [blame] | 112 | // If contents_opaque(), return an opaque color else return a |
| 113 | // non-opaque color. Tries to return background_color(), if possible. |
| 114 | SkColor SafeOpaqueBackgroundColor() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 115 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 116 | // A layer's bounds are in logical, non-page-scaled pixels (however, the |
| 117 | // root layer's bounds are in physical pixels). |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 118 | void SetBounds(const gfx::Size& bounds); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 119 | gfx::Size bounds() const { return bounds_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 120 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 121 | void SetMasksToBounds(bool masks_to_bounds); |
| 122 | bool masks_to_bounds() const { return masks_to_bounds_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 123 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 124 | void SetMaskLayer(Layer* mask_layer); |
| 125 | Layer* mask_layer() { return mask_layer_.get(); } |
| 126 | const Layer* mask_layer() const { return mask_layer_.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 127 | |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 128 | virtual void SetNeedsDisplayRect(const gfx::Rect& dirty_rect); |
| 129 | void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::Rect(bounds())); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 130 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 131 | void SetOpacity(float opacity); |
| 132 | float opacity() const { return opacity_; } |
| 133 | bool OpacityIsAnimating() const; |
loyso | d71ece8 | 2015-07-03 13:48:50 | [diff] [blame] | 134 | bool HasPotentiallyRunningOpacityAnimation() const; |
[email protected] | b7c4783f | 2013-03-15 23:11:42 | [diff] [blame] | 135 | virtual bool OpacityCanAnimateOnImplThread() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 136 | |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 137 | void SetBlendMode(SkXfermode::Mode blend_mode); |
| 138 | SkXfermode::Mode blend_mode() const { return blend_mode_; } |
| 139 | |
jaydasika | 92239dc | 2015-08-15 02:59:26 | [diff] [blame] | 140 | void set_draw_blend_mode(SkXfermode::Mode blend_mode) { |
| 141 | if (draw_blend_mode_ == blend_mode) |
| 142 | return; |
| 143 | draw_blend_mode_ = blend_mode; |
| 144 | SetNeedsPushProperties(); |
| 145 | } |
| 146 | SkXfermode::Mode draw_blend_mode() const { return draw_blend_mode_; } |
| 147 | |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 148 | bool uses_default_blend_mode() const { |
| 149 | return blend_mode_ == SkXfermode::kSrcOver_Mode; |
| 150 | } |
| 151 | |
| 152 | // A layer is root for an isolated group when it and all its descendants are |
| 153 | // drawn over a black and fully transparent background, creating an isolated |
| 154 | // group. It should be used along with SetBlendMode(), in order to restrict |
| 155 | // layers within the group to blend with layers outside this group. |
| 156 | void SetIsRootForIsolatedGroup(bool root); |
| 157 | bool is_root_for_isolated_group() const { |
| 158 | return is_root_for_isolated_group_; |
| 159 | } |
| 160 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 161 | void SetFilters(const FilterOperations& filters); |
| 162 | const FilterOperations& filters() const { return filters_; } |
[email protected] | b4c6d81 | 2013-10-03 15:48:56 | [diff] [blame] | 163 | bool FilterIsAnimating() const; |
ajuma | 315a478 | 2015-07-24 21:16:34 | [diff] [blame] | 164 | bool HasPotentiallyRunningFilterAnimation() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 165 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 166 | // Background filters are filters applied to what is behind this layer, when |
| 167 | // they are viewed through non-opaque regions in this layer. They are used |
| 168 | // through the WebLayer interface, and are not exposed to HTML. |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 169 | void SetBackgroundFilters(const FilterOperations& filters); |
| 170 | const FilterOperations& background_filters() const { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 171 | return background_filters_; |
| 172 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 173 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 174 | virtual void SetContentsOpaque(bool opaque); |
| 175 | bool contents_opaque() const { return contents_opaque_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 176 | |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 177 | void SetPosition(const gfx::PointF& position); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 178 | gfx::PointF position() const { return position_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 179 | |
ajuma | 4216ee12 | 2015-05-29 13:07:17 | [diff] [blame] | 180 | // A layer that is a container for fixed position layers cannot be both |
| 181 | // scrollable and have a non-identity transform. |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 182 | void SetIsContainerForFixedPositionLayers(bool container); |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 183 | bool IsContainerForFixedPositionLayers() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 184 | |
miletus | 624d342e | 2015-03-13 03:39:44 | [diff] [blame] | 185 | gfx::Vector2dF FixedContainerSizeDelta() const { |
| 186 | return gfx::Vector2dF(); |
| 187 | } |
| 188 | |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 189 | void SetPositionConstraint(const LayerPositionConstraint& constraint); |
| 190 | const LayerPositionConstraint& position_constraint() const { |
| 191 | return position_constraint_; |
| 192 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 193 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 194 | void SetTransform(const gfx::Transform& transform); |
| 195 | const gfx::Transform& transform() const { return transform_; } |
| 196 | bool TransformIsAnimating() const; |
loyso | d71ece8 | 2015-07-03 13:48:50 | [diff] [blame] | 197 | bool HasPotentiallyRunningTransformAnimation() const; |
ajuma | b4a846f2 | 2015-08-24 19:13:44 | [diff] [blame] | 198 | bool HasOnlyTranslationTransforms() const; |
awoloszyn | e83f28c | 2014-12-22 15:40:00 | [diff] [blame] | 199 | bool AnimationsPreserveAxisAlignment() const; |
[email protected] | 08bdf1b | 2014-04-16 23:23:29 | [diff] [blame] | 200 | bool transform_is_invertible() const { return transform_is_invertible_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 201 | |
ajuma | b4a846f2 | 2015-08-24 19:13:44 | [diff] [blame] | 202 | bool MaximumTargetScale(float* max_scale) const; |
| 203 | bool AnimationStartScale(float* start_scale) const; |
| 204 | |
[email protected] | a256641 | 2014-06-05 03:14:20 | [diff] [blame] | 205 | void SetTransformOrigin(const gfx::Point3F&); |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 206 | gfx::Point3F transform_origin() const { return transform_origin_; } |
[email protected] | a256641 | 2014-06-05 03:14:20 | [diff] [blame] | 207 | |
ajuma | caaa9b3 | 2015-08-04 15:55:29 | [diff] [blame] | 208 | bool HasAnyAnimationTargetingProperty( |
| 209 | Animation::TargetProperty property) const; |
| 210 | |
loyso | d71ece8 | 2015-07-03 13:48:50 | [diff] [blame] | 211 | bool ScrollOffsetAnimationWasInterrupted() const; |
| 212 | |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 213 | void SetScrollParent(Layer* parent); |
| 214 | |
| 215 | Layer* scroll_parent() { return scroll_parent_; } |
| 216 | const Layer* scroll_parent() const { return scroll_parent_; } |
| 217 | |
| 218 | void AddScrollChild(Layer* child); |
| 219 | void RemoveScrollChild(Layer* child); |
| 220 | |
| 221 | std::set<Layer*>* scroll_children() { return scroll_children_.get(); } |
| 222 | const std::set<Layer*>* scroll_children() const { |
| 223 | return scroll_children_.get(); |
| 224 | } |
| 225 | |
| 226 | void SetClipParent(Layer* ancestor); |
| 227 | |
| 228 | Layer* clip_parent() { return clip_parent_; } |
| 229 | const Layer* clip_parent() const { |
| 230 | return clip_parent_; |
| 231 | } |
| 232 | |
| 233 | void AddClipChild(Layer* child); |
| 234 | void RemoveClipChild(Layer* child); |
| 235 | |
| 236 | std::set<Layer*>* clip_children() { return clip_children_.get(); } |
| 237 | const std::set<Layer*>* clip_children() const { |
| 238 | return clip_children_.get(); |
| 239 | } |
| 240 | |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 241 | // TODO(enne): Fix style here (and everywhere) once LayerImpl does the same. |
| 242 | gfx::Transform draw_transform() const; |
| 243 | gfx::Transform screen_space_transform() const; |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 244 | |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 245 | void set_num_unclipped_descendants(size_t descendants) { |
| 246 | num_unclipped_descendants_ = descendants; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 247 | } |
vmpstr | 762e70d | 2015-06-10 02:12:57 | [diff] [blame] | 248 | size_t num_unclipped_descendants() const { |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 249 | return num_unclipped_descendants_; |
[email protected] | 420fdf6e | 2013-08-26 20:36:38 | [diff] [blame] | 250 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 251 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 252 | void SetScrollOffset(const gfx::ScrollOffset& scroll_offset); |
miletus | ff93ab7 | 2015-01-30 04:30:44 | [diff] [blame] | 253 | void SetScrollCompensationAdjustment( |
| 254 | const gfx::Vector2dF& scroll_compensation_adjustment); |
| 255 | gfx::Vector2dF ScrollCompensationAdjustment() const; |
miletus | 2c78036b | 2015-01-29 20:52:37 | [diff] [blame] | 256 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 257 | gfx::ScrollOffset scroll_offset() const { return scroll_offset_; } |
| 258 | void SetScrollOffsetFromImplSide(const gfx::ScrollOffset& scroll_offset); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 259 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 260 | void SetScrollClipLayerId(int clip_layer_id); |
| 261 | bool scrollable() const { return scroll_clip_layer_id_ != INVALID_ID; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 262 | |
[email protected] | 59a7d55 | 2013-10-22 03:36:43 | [diff] [blame] | 263 | void SetUserScrollable(bool horizontal, bool vertical); |
| 264 | bool user_scrollable_horizontal() const { |
| 265 | return user_scrollable_horizontal_; |
| 266 | } |
| 267 | bool user_scrollable_vertical() const { return user_scrollable_vertical_; } |
| 268 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 269 | void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread); |
| 270 | bool should_scroll_on_main_thread() const { |
| 271 | return should_scroll_on_main_thread_; |
| 272 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 273 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 274 | void SetHaveWheelEventHandlers(bool have_wheel_event_handlers); |
| 275 | bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 276 | |
[email protected] | f998c53 | 2014-03-31 20:02:51 | [diff] [blame] | 277 | void SetHaveScrollEventHandlers(bool have_scroll_event_handlers); |
| 278 | bool have_scroll_event_handlers() const { |
| 279 | return have_scroll_event_handlers_; |
| 280 | } |
| 281 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 282 | void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region); |
| 283 | const Region& non_fast_scrollable_region() const { |
| 284 | return non_fast_scrollable_region_; |
| 285 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 286 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 287 | void SetTouchEventHandlerRegion(const Region& touch_event_handler_region); |
| 288 | const Region& touch_event_handler_region() const { |
| 289 | return touch_event_handler_region_; |
| 290 | } |
[email protected] | 23d56be | 2012-11-08 00:33:34 | [diff] [blame] | 291 | |
rbyers | 18779d82 | 2015-02-05 06:22:06 | [diff] [blame] | 292 | void SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on); |
| 293 | ScrollBlocksOn scroll_blocks_on() const { return scroll_blocks_on_; } |
| 294 | |
[email protected] | 28096ed | 2013-07-01 07:38:58 | [diff] [blame] | 295 | void set_did_scroll_callback(const base::Closure& callback) { |
| 296 | did_scroll_callback_ = callback; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 297 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 298 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 299 | void SetForceRenderSurface(bool force_render_surface); |
| 300 | bool force_render_surface() const { return force_render_surface_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 301 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 302 | gfx::Vector2dF ScrollDelta() const { return gfx::Vector2dF(); } |
aelias | d0070ba | 2015-01-31 13:44:49 | [diff] [blame] | 303 | gfx::ScrollOffset CurrentScrollOffset() const { return scroll_offset_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 304 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 305 | void SetDoubleSided(bool double_sided); |
| 306 | bool double_sided() const { return double_sided_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 307 | |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 308 | void SetShouldFlattenTransform(bool flatten); |
| 309 | bool should_flatten_transform() const { return should_flatten_transform_; } |
| 310 | |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 311 | bool Is3dSorted() const { return sorting_context_id_ != 0; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 312 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 313 | void set_use_parent_backface_visibility(bool use) { |
| 314 | use_parent_backface_visibility_ = use; |
| 315 | } |
| 316 | bool use_parent_backface_visibility() const { |
| 317 | return use_parent_backface_visibility_; |
| 318 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 319 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 320 | virtual void SetLayerTreeHost(LayerTreeHost* host); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 321 | |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 322 | virtual bool HasDelegatedContent() const; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 323 | bool HasContributingDelegatedRenderPasses() const { return false; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 324 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 325 | void SetIsDrawable(bool is_drawable); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 326 | |
[email protected] | c0ae06c1 | 2013-06-24 18:32:19 | [diff] [blame] | 327 | void SetHideLayerAndSubtree(bool hide); |
| 328 | bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; } |
| 329 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 330 | void SetReplicaLayer(Layer* layer); |
| 331 | Layer* replica_layer() { return replica_layer_.get(); } |
| 332 | const Layer* replica_layer() const { return replica_layer_.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 333 | |
[email protected] | 22898ed | 2013-06-01 04:52:30 | [diff] [blame] | 334 | bool has_mask() const { return !!mask_layer_.get(); } |
| 335 | bool has_replica() const { return !!replica_layer_.get(); } |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 336 | bool replica_has_mask() const { |
[email protected] | 22898ed | 2013-06-01 04:52:30 | [diff] [blame] | 337 | return replica_layer_.get() && |
| 338 | (mask_layer_.get() || replica_layer_->mask_layer_.get()); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 339 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 340 | |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 341 | int NumDescendantsThatDrawContent() const; |
| 342 | |
| 343 | // This is only virtual for tests. |
| 344 | // TODO(awoloszyn): Remove this once we no longer need it for tests |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 345 | virtual bool DrawsContent() const; |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 346 | |
| 347 | // This methods typically need to be overwritten by derived classes. |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 348 | virtual void SavePaintProperties(); |
danakj | 5f46636a | 2015-06-19 00:01:40 | [diff] [blame] | 349 | // Returns true iff anything was updated that needs to be committed. |
| 350 | virtual bool Update(); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 351 | virtual void SetIsMask(bool is_mask) {} |
[email protected] | a6c1b23 | 2014-05-05 23:53:08 | [diff] [blame] | 352 | virtual bool IsSuitableForGpuRasterization() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 353 | |
ssid | 911e40e | 2015-02-09 17:55:20 | [diff] [blame] | 354 | virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 355 | TakeDebugInfo(); |
[email protected] | ae716ce | 2013-08-16 13:04:24 | [diff] [blame] | 356 | |
| 357 | void SetLayerClient(LayerClient* client) { client_ = client; } |
| 358 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 359 | virtual void PushPropertiesTo(LayerImpl* layer); |
| 360 | |
[email protected] | 3698e79 | 2013-08-24 00:21:16 | [diff] [blame] | 361 | LayerTreeHost* layer_tree_host() { return layer_tree_host_; } |
| 362 | const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 363 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 364 | bool AddAnimation(scoped_ptr<Animation> animation); |
| 365 | void PauseAnimation(int animation_id, double time_offset); |
| 366 | void RemoveAnimation(int animation_id); |
sunnyps | ea328be1 | 2015-02-26 06:03:27 | [diff] [blame] | 367 | void RemoveAnimation(int animation_id, Animation::TargetProperty property); |
loyso | d71ece8 | 2015-07-03 13:48:50 | [diff] [blame] | 368 | LayerAnimationController* layer_animation_controller() const { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 369 | return layer_animation_controller_.get(); |
| 370 | } |
[email protected] | 7f5605c | 2013-04-08 18:08:35 | [diff] [blame] | 371 | void SetLayerAnimationControllerForTest( |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 372 | scoped_refptr<LayerAnimationController> controller); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 373 | |
[email protected] | 3cae03e | 2013-06-26 22:13:52 | [diff] [blame] | 374 | void set_layer_animation_delegate(AnimationDelegate* delegate) { |
loyso | 5719778 | 2015-05-28 04:10:18 | [diff] [blame] | 375 | DCHECK(layer_animation_controller_); |
[email protected] | 7f5605c | 2013-04-08 18:08:35 | [diff] [blame] | 376 | layer_animation_controller_->set_layer_animation_delegate(delegate); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 377 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 378 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 379 | bool HasActiveAnimation() const; |
loyso | 5719778 | 2015-05-28 04:10:18 | [diff] [blame] | 380 | void RegisterForAnimations(AnimationRegistrar* registrar); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 381 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 382 | void AddLayerAnimationEventObserver( |
| 383 | LayerAnimationEventObserver* animation_observer); |
| 384 | void RemoveLayerAnimationEventObserver( |
| 385 | LayerAnimationEventObserver* animation_observer); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 386 | |
[email protected] | 80413d7 | 2013-08-30 20:25:33 | [diff] [blame] | 387 | virtual ScrollbarLayerInterface* ToScrollbarLayer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 388 | |
[email protected] | f7837a9 | 2013-08-21 03:00:05 | [diff] [blame] | 389 | virtual skia::RefPtr<SkPicture> GetPicture() const; |
| 390 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 391 | // Constructs a LayerImpl of the correct runtime type for this Layer type. |
| 392 | virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
[email protected] | aedf4e5 | 2013-01-09 23:24:44 | [diff] [blame] | 393 | |
[email protected] | 4460464 | 2013-08-01 01:14:09 | [diff] [blame] | 394 | bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 395 | void ResetNeedsDisplayForTesting() { update_rect_ = gfx::Rect(); } |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 396 | |
[email protected] | d8411661 | 2013-03-29 05:32:49 | [diff] [blame] | 397 | RenderingStatsInstrumentation* rendering_stats_instrumentation() const; |
| 398 | |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 399 | const PaintProperties& paint_properties() const { |
| 400 | return paint_properties_; |
| 401 | } |
| 402 | |
[email protected] | 7a5a932 | 2014-02-25 12:54:57 | [diff] [blame] | 403 | void SetNeedsPushProperties(); |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 404 | bool needs_push_properties() const { return needs_push_properties_; } |
| 405 | bool descendant_needs_push_properties() const { |
| 406 | return num_dependents_need_push_properties_ > 0; |
| 407 | } |
[email protected] | 7a5a932 | 2014-02-25 12:54:57 | [diff] [blame] | 408 | void reset_needs_push_properties_for_testing() { |
| 409 | needs_push_properties_ = false; |
| 410 | } |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 411 | |
[email protected] | 666d7cf | 2013-10-12 01:30:29 | [diff] [blame] | 412 | virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
| 413 | |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 414 | void Set3dSortingContextId(int id); |
| 415 | int sorting_context_id() const { return sorting_context_id_; } |
| 416 | |
vollick | 692444f | 2015-05-20 15:39:14 | [diff] [blame] | 417 | void set_property_tree_sequence_number(int sequence_number) { |
| 418 | property_tree_sequence_number_ = sequence_number; |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 419 | } |
vollick | 692444f | 2015-05-20 15:39:14 | [diff] [blame] | 420 | |
| 421 | void SetTransformTreeIndex(int index); |
| 422 | int transform_tree_index() const; |
| 423 | |
| 424 | void SetClipTreeIndex(int index); |
| 425 | int clip_tree_index() const; |
| 426 | |
weiliangc | 6a52f30 | 2015-08-18 16:29:35 | [diff] [blame] | 427 | void SetEffectTreeIndex(int index); |
| 428 | int effect_tree_index() const; |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 429 | |
| 430 | void set_offset_to_transform_parent(gfx::Vector2dF offset) { |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 431 | if (offset_to_transform_parent_ == offset) |
| 432 | return; |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 433 | offset_to_transform_parent_ = offset; |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 434 | SetNeedsPushProperties(); |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 435 | } |
| 436 | gfx::Vector2dF offset_to_transform_parent() const { |
| 437 | return offset_to_transform_parent_; |
| 438 | } |
| 439 | |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 440 | // TODO(enne): Once LayerImpl only uses property trees, remove these |
| 441 | // functions. |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 442 | const gfx::Rect& visible_rect_from_property_trees() const { |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 443 | return visible_layer_rect(); |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 444 | } |
| 445 | void set_visible_rect_from_property_trees(const gfx::Rect& rect) { |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 446 | set_visible_layer_rect(rect); |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 447 | } |
jaydasika | 5c41bb9 | 2015-08-10 21:47:55 | [diff] [blame] | 448 | const gfx::Rect& clip_rect_in_target_space_from_property_trees() const { |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 449 | return clip_rect(); |
jaydasika | 5c41bb9 | 2015-08-10 21:47:55 | [diff] [blame] | 450 | } |
| 451 | void set_clip_rect_in_target_space_from_property_trees( |
| 452 | const gfx::Rect& rect) { |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 453 | set_clip_rect(rect); |
jaydasika | 5c41bb9 | 2015-08-10 21:47:55 | [diff] [blame] | 454 | } |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 455 | // TODO(enne): This needs a different name. It is a calculated value |
| 456 | // from the property tree builder and not a synonym for "should |
| 457 | // flatten transform". |
ajuma | d0d6442 | 2015-03-14 04:20:08 | [diff] [blame] | 458 | void set_should_flatten_transform_from_property_tree(bool should_flatten) { |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 459 | if (should_flatten_transform_from_property_tree_ == should_flatten) |
| 460 | return; |
ajuma | d0d6442 | 2015-03-14 04:20:08 | [diff] [blame] | 461 | should_flatten_transform_from_property_tree_ = should_flatten; |
enne | e95b154 | 2015-04-20 20:35:50 | [diff] [blame] | 462 | SetNeedsPushProperties(); |
| 463 | } |
| 464 | bool should_flatten_transform_from_property_tree() const { |
| 465 | return should_flatten_transform_from_property_tree_; |
ajuma | d0d6442 | 2015-03-14 04:20:08 | [diff] [blame] | 466 | } |
| 467 | |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 468 | const gfx::Rect& visible_layer_rect() const { return visible_layer_rect_; } |
| 469 | void set_visible_layer_rect(const gfx::Rect& rect) { |
| 470 | visible_layer_rect_ = rect; |
| 471 | } |
| 472 | |
| 473 | const gfx::Rect& clip_rect() const { return clip_rect_; } |
| 474 | void set_clip_rect(const gfx::Rect& rect) { clip_rect_ = rect; } |
| 475 | |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 476 | bool has_render_surface() const { |
| 477 | return has_render_surface_; |
| 478 | } |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 479 | |
vmpstr | 3d1d72c | 2015-01-26 18:27:40 | [diff] [blame] | 480 | // Sets new frame timing requests for this layer. |
| 481 | void SetFrameTimingRequests(const std::vector<FrameTimingRequest>& requests); |
| 482 | |
mpb | 39c5a2ef | 2015-04-22 23:46:15 | [diff] [blame] | 483 | // Accessor for unit tests |
| 484 | const std::vector<FrameTimingRequest>& FrameTimingRequests() const { |
| 485 | return frame_timing_requests_; |
| 486 | } |
| 487 | |
caseq | 4a4b558 | 2015-03-17 18:39:35 | [diff] [blame] | 488 | void DidBeginTracing(); |
enne | 2504193 | 2015-09-25 19:42:01 | [diff] [blame] | 489 | // TODO(weiliangc): this should move to the effect tree. |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 490 | void set_num_layer_or_descendant_with_copy_request( |
jaydasika | 3d10aa6 | 2015-05-06 17:50:44 | [diff] [blame] | 491 | int num_layer_or_descendants_with_copy_request) { |
| 492 | num_layer_or_descendants_with_copy_request_ = |
| 493 | num_layer_or_descendants_with_copy_request; |
| 494 | } |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 495 | int num_layer_or_descendants_with_copy_request() { |
| 496 | return num_layer_or_descendants_with_copy_request_; |
| 497 | } |
jaydasika | 3d10aa6 | 2015-05-06 17:50:44 | [diff] [blame] | 498 | |
jaydasika | 976cd10b | 2015-05-26 15:45:24 | [diff] [blame] | 499 | void set_visited(bool visited); |
| 500 | bool visited(); |
| 501 | void set_layer_or_descendant_is_drawn(bool layer_or_descendant_is_drawn); |
| 502 | bool layer_or_descendant_is_drawn(); |
| 503 | void set_sorted_for_recursion(bool sorted_for_recursion); |
| 504 | bool sorted_for_recursion(); |
| 505 | |
skyostil | e5cd474 | 2015-10-13 12:09:53 | [diff] [blame^] | 506 | // LayerAnimationValueProvider implementation. |
| 507 | gfx::ScrollOffset ScrollOffsetForAnimation() const override; |
| 508 | |
| 509 | // LayerAnimationValueObserver implementation. |
| 510 | void OnFilterAnimated(const FilterOperations& filters) override; |
| 511 | void OnOpacityAnimated(float opacity) override; |
| 512 | void OnTransformAnimated(const gfx::Transform& transform) override; |
| 513 | void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; |
| 514 | void OnAnimationWaitingForDeletion() override; |
| 515 | void OnTransformIsPotentiallyAnimatingChanged(bool is_animating) override; |
| 516 | bool IsActive() const override; |
| 517 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 518 | protected: |
| 519 | friend class LayerImpl; |
| 520 | friend class TreeSynchronizer; |
dcheng | 716bedf | 2014-10-21 09:51:08 | [diff] [blame] | 521 | ~Layer() override; |
[email protected] | 090e1a7 | 2013-01-29 07:07:45 | [diff] [blame] | 522 | |
loyso | a6edaaff | 2015-05-25 03:26:44 | [diff] [blame] | 523 | explicit Layer(const LayerSettings& settings); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 524 | |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 525 | // These SetNeeds functions are in order of severity of update: |
| 526 | // |
| 527 | // Called when this layer has been modified in some way, but isn't sure |
| 528 | // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers |
| 529 | // before it knows whether or not a commit is required. |
| 530 | void SetNeedsUpdate(); |
| 531 | // Called when a property has been modified in a way that the layer |
| 532 | // knows immediately that a commit is required. This implies SetNeedsUpdate |
| 533 | // as well as SetNeedsPushProperties to push that property. |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 534 | void SetNeedsCommit(); |
vollick | 5057e1e | 2015-04-17 19:12:32 | [diff] [blame] | 535 | // This is identical to SetNeedsCommit, but the former requests a rebuild of |
| 536 | // the property trees. |
| 537 | void SetNeedsCommitNoRebuild(); |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 538 | // Called when there's been a change in layer structure. Implies both |
| 539 | // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties. |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 540 | void SetNeedsFullTreeSync(); |
[email protected] | 74b43cc | 2013-08-30 06:29:27 | [diff] [blame] | 541 | |
| 542 | // Called when the next commit should wait until the pending tree is activated |
| 543 | // before finishing the commit and unblocking the main thread. Used to ensure |
| 544 | // unused resources on the impl thread are returned before commit completes. |
| 545 | void SetNextCommitWaitsForActivation(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 546 | |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 547 | // Will recalculate whether the layer draws content and set draws_content_ |
| 548 | // appropriately. |
| 549 | void UpdateDrawsContent(bool has_drawable_content); |
| 550 | virtual bool HasDrawableContent() const; |
| 551 | |
| 552 | // Called when the layer's number of drawable descendants changes. |
| 553 | void AddDrawableDescendants(int num); |
| 554 | |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 555 | void AddDependentNeedsPushProperties(); |
| 556 | void RemoveDependentNeedsPushProperties(); |
| 557 | bool parent_should_know_need_push_properties() const { |
| 558 | return needs_push_properties() || descendant_needs_push_properties(); |
| 559 | } |
| 560 | |
[email protected] | 74b43cc | 2013-08-30 06:29:27 | [diff] [blame] | 561 | bool IsPropertyChangeAllowed() const; |
| 562 | |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 563 | // This flag is set when the layer needs to push properties to the impl |
| 564 | // side. |
| 565 | bool needs_push_properties_; |
| 566 | |
| 567 | // The number of direct children or dependent layers that need to be recursed |
| 568 | // to in order for them or a descendent of them to push properties to the impl |
| 569 | // side. |
| 570 | int num_dependents_need_push_properties_; |
| 571 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 572 | // Tracks whether this layer may have changed stacking order with its |
| 573 | // siblings. |
| 574 | bool stacking_order_changed_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 575 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 576 | // The update rect is the region of the compositor resource that was |
| 577 | // actually updated by the compositor. For layers that may do updating |
| 578 | // outside the compositor's control (i.e. plugin layers), this information |
| 579 | // is not available and the update rect will remain empty. |
| 580 | // Note this rect is in layer space (not content space). |
danakj | 19f0c9e | 2014-10-11 03:24:42 | [diff] [blame] | 581 | gfx::Rect update_rect_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 582 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 583 | scoped_refptr<Layer> mask_layer_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 584 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 585 | int layer_id_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 586 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 587 | // When true, the layer is about to perform an update. Any commit requests |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 588 | // will be handled implicitly after the update completes. |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 589 | bool ignore_set_needs_commit_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 590 | |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 591 | // Layers that share a sorting context id will be sorted together in 3d |
| 592 | // space. 0 is a special value that means this layer will not be sorted and |
| 593 | // will be drawn in paint order. |
| 594 | int sorting_context_id_; |
| 595 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 596 | private: |
| 597 | friend class base::RefCounted<Layer>; |
awoloszyn | e83f28c | 2014-12-22 15:40:00 | [diff] [blame] | 598 | friend class LayerTreeHostCommon; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 599 | void SetParent(Layer* layer); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 600 | bool DescendantIsFixedToContainerLayer() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 601 | |
awoloszyn | e83f28c | 2014-12-22 15:40:00 | [diff] [blame] | 602 | // This should only be called during BeginMainFrame since it does not |
| 603 | // trigger a Commit. |
| 604 | void SetHasRenderSurface(bool has_render_surface); |
| 605 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 606 | // This should only be called from RemoveFromParent(). |
| 607 | void RemoveChildOrDependent(Layer* child); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 608 | |
vollick | 66133e8 | 2014-09-13 20:36:44 | [diff] [blame] | 609 | // If this layer has a scroll parent, it removes |this| from its list of |
| 610 | // scroll children. |
| 611 | void RemoveFromScrollTree(); |
| 612 | |
| 613 | // If this layer has a clip parent, it removes |this| from its list of clip |
| 614 | // children. |
| 615 | void RemoveFromClipTree(); |
| 616 | |
weiliangc | c4d2e74d | 2015-06-09 01:21:35 | [diff] [blame] | 617 | // When we detach or attach layer to new LayerTreeHost, all property trees' |
| 618 | // indices becomes invalid. |
| 619 | void InvalidatePropertyTreesIndices(); |
| 620 | |
enne | 2504193 | 2015-09-25 19:42:01 | [diff] [blame] | 621 | void UpdateNumCopyRequestsForSubtree(int delta); |
jaydasika | 3d10aa6 | 2015-05-06 17:50:44 | [diff] [blame] | 622 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 623 | LayerList children_; |
| 624 | Layer* parent_; |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 625 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 626 | // Layer instances have a weak pointer to their LayerTreeHost. |
| 627 | // This pointer value is nil when a Layer is not in a tree and is |
| 628 | // updated via SetLayerTreeHost() if a layer moves between trees. |
| 629 | LayerTreeHost* layer_tree_host_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 630 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 631 | scoped_refptr<LayerAnimationController> layer_animation_controller_; |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 632 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 633 | // Layer properties. |
| 634 | gfx::Size bounds_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 635 | |
miletus | f57925d | 2014-10-01 19:38:13 | [diff] [blame] | 636 | gfx::ScrollOffset scroll_offset_; |
miletus | ff93ab7 | 2015-01-30 04:30:44 | [diff] [blame] | 637 | gfx::Vector2dF scroll_compensation_adjustment_; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 638 | // This variable indicates which ancestor layer (if any) whose size, |
| 639 | // transformed relative to this layer, defines the maximum scroll offset for |
| 640 | // this layer. |
| 641 | int scroll_clip_layer_id_; |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 642 | int num_descendants_that_draw_content_; |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 643 | int transform_tree_index_; |
weiliangc | 6a52f30 | 2015-08-18 16:29:35 | [diff] [blame] | 644 | int effect_tree_index_; |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 645 | int clip_tree_index_; |
vollick | 692444f | 2015-05-20 15:39:14 | [diff] [blame] | 646 | int property_tree_sequence_number_; |
jaydasika | 3d10aa6 | 2015-05-06 17:50:44 | [diff] [blame] | 647 | int num_layer_or_descendants_with_copy_request_; |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 648 | gfx::Vector2dF offset_to_transform_parent_; |
ajuma | d0d6442 | 2015-03-14 04:20:08 | [diff] [blame] | 649 | bool should_flatten_transform_from_property_tree_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 650 | bool should_scroll_on_main_thread_ : 1; |
| 651 | bool have_wheel_event_handlers_ : 1; |
[email protected] | f998c53 | 2014-03-31 20:02:51 | [diff] [blame] | 652 | bool have_scroll_event_handlers_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 653 | bool user_scrollable_horizontal_ : 1; |
| 654 | bool user_scrollable_vertical_ : 1; |
| 655 | bool is_root_for_isolated_group_ : 1; |
| 656 | bool is_container_for_fixed_position_layers_ : 1; |
| 657 | bool is_drawable_ : 1; |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 658 | bool draws_content_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 659 | bool hide_layer_and_subtree_ : 1; |
| 660 | bool masks_to_bounds_ : 1; |
| 661 | bool contents_opaque_ : 1; |
| 662 | bool double_sided_ : 1; |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 663 | bool should_flatten_transform_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 664 | bool use_parent_backface_visibility_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 665 | bool force_render_surface_ : 1; |
[email protected] | 08bdf1b | 2014-04-16 23:23:29 | [diff] [blame] | 666 | bool transform_is_invertible_ : 1; |
vollick | 51ed1a2 | 2014-12-17 02:03:00 | [diff] [blame] | 667 | bool has_render_surface_ : 1; |
rbyers | 18779d82 | 2015-02-05 06:22:06 | [diff] [blame] | 668 | ScrollBlocksOn scroll_blocks_on_ : 3; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 669 | Region non_fast_scrollable_region_; |
| 670 | Region touch_event_handler_region_; |
| 671 | gfx::PointF position_; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 672 | SkColor background_color_; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 673 | float opacity_; |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 674 | SkXfermode::Mode blend_mode_; |
jaydasika | 92239dc | 2015-08-15 02:59:26 | [diff] [blame] | 675 | // draw_blend_mode may be different than blend_mode_, |
| 676 | // when a RenderSurface re-parents the layer's blend_mode. |
| 677 | SkXfermode::Mode draw_blend_mode_; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 678 | FilterOperations filters_; |
| 679 | FilterOperations background_filters_; |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 680 | LayerPositionConstraint position_constraint_; |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 681 | Layer* scroll_parent_; |
danakj | 6496cba | 2014-10-16 01:31:08 | [diff] [blame] | 682 | scoped_ptr<std::set<Layer*>> scroll_children_; |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 683 | |
jaydasika | 976cd10b | 2015-05-26 15:45:24 | [diff] [blame] | 684 | // The following three variables are tracker variables. They are bools |
| 685 | // wrapped inside an integer variable. If true, their value equals the |
| 686 | // LayerTreeHost's meta_information_sequence_number. This wrapping of bools |
| 687 | // inside ints is done to avoid a layer tree treewalk to reset their values. |
| 688 | int layer_or_descendant_is_drawn_tracker_; |
| 689 | int sorted_for_recursion_tracker_; |
| 690 | int visited_tracker_; |
| 691 | |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 692 | Layer* clip_parent_; |
danakj | 6496cba | 2014-10-16 01:31:08 | [diff] [blame] | 693 | scoped_ptr<std::set<Layer*>> clip_children_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 694 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 695 | gfx::Transform transform_; |
[email protected] | a256641 | 2014-06-05 03:14:20 | [diff] [blame] | 696 | gfx::Point3F transform_origin_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 697 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 698 | // Replica layer used for reflections. |
| 699 | scoped_refptr<Layer> replica_layer_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 700 | |
[email protected] | ae716ce | 2013-08-16 13:04:24 | [diff] [blame] | 701 | LayerClient* client_; |
| 702 | |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 703 | ScopedPtrVector<CopyOutputRequest> copy_requests_; |
[email protected] | 18a7019 | 2013-04-26 16:18:25 | [diff] [blame] | 704 | |
[email protected] | 28096ed | 2013-07-01 07:38:58 | [diff] [blame] | 705 | base::Closure did_scroll_callback_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 706 | |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 707 | PaintProperties paint_properties_; |
| 708 | |
enne | c95e662 | 2015-08-28 23:23:19 | [diff] [blame] | 709 | // These all act like draw properties, so don't need push properties. |
| 710 | gfx::Rect visible_layer_rect_; |
| 711 | gfx::Rect clip_rect_; |
| 712 | size_t num_unclipped_descendants_; |
vmpstr | 3d1d72c | 2015-01-26 18:27:40 | [diff] [blame] | 713 | |
| 714 | std::vector<FrameTimingRequest> frame_timing_requests_; |
| 715 | bool frame_timing_requests_dirty_; |
| 716 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 717 | DISALLOW_COPY_AND_ASSIGN(Layer); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 718 | }; |
| 719 | |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 720 | } // namespace cc |
| 721 | |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 722 | #endif // CC_LAYERS_LAYER_H_ |