[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> |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 10 | |
[email protected] | 18a7019 | 2013-04-26 16:18:25 | [diff] [blame] | 11 | #include "base/callback.h" |
[email protected] | a8461d8 | 2012-10-16 21:11:14 | [diff] [blame] | 12 | #include "base/memory/ref_counted.h" |
[email protected] | e10cd02 | 2012-12-18 00:32:26 | [diff] [blame] | 13 | #include "base/observer_list.h" |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 14 | #include "cc/animation/layer_animation_controller.h" |
[email protected] | 95e4e1a0 | 2013-03-18 07:09:09 | [diff] [blame] | 15 | #include "cc/animation/layer_animation_value_observer.h" |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 16 | #include "cc/animation/layer_animation_value_provider.h" |
[email protected] | 681ccff | 2013-03-18 06:13:52 | [diff] [blame] | 17 | #include "cc/base/cc_export.h" |
| 18 | #include "cc/base/region.h" |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 19 | #include "cc/base/scoped_ptr_vector.h" |
[email protected] | 666d7cf | 2013-10-12 01:30:29 | [diff] [blame] | 20 | #include "cc/debug/micro_benchmark.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 21 | #include "cc/layers/draw_properties.h" |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 22 | #include "cc/layers/layer_lists.h" |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 23 | #include "cc/layers/layer_position_constraint.h" |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 24 | #include "cc/layers/paint_properties.h" |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 25 | #include "cc/layers/render_surface.h" |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 26 | #include "cc/output/filter_operations.h" |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 27 | #include "skia/ext/refptr.h" |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 28 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 29 | #include "third_party/skia/include/core/SkImageFilter.h" |
[email protected] | f7837a9 | 2013-08-21 03:00:05 | [diff] [blame] | 30 | #include "third_party/skia/include/core/SkPicture.h" |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 31 | #include "third_party/skia/include/core/SkXfermode.h" |
[email protected] | a256641 | 2014-06-05 03:14:20 | [diff] [blame] | 32 | #include "ui/gfx/point3_f.h" |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 33 | #include "ui/gfx/rect.h" |
| 34 | #include "ui/gfx/rect_f.h" |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 35 | #include "ui/gfx/transform.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 36 | |
[email protected] | db2586f | 2013-08-15 22:03:14 | [diff] [blame] | 37 | namespace gfx { |
| 38 | class BoxF; |
| 39 | } |
| 40 | |
[email protected] | 9f3be43 | 2013-12-03 03:53:22 | [diff] [blame] | 41 | namespace base { |
| 42 | namespace debug { |
| 43 | class ConvertableToTraceFormat; |
| 44 | } |
| 45 | } |
| 46 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 47 | namespace cc { |
| 48 | |
[email protected] | 4d0786a | 2013-01-07 16:21:20 | [diff] [blame] | 49 | class Animation; |
[email protected] | 3cae03e | 2013-06-26 22:13:52 | [diff] [blame] | 50 | class AnimationDelegate; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 51 | struct AnimationEvent; |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 52 | class CopyOutputRequest; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 53 | class LayerAnimationDelegate; |
[email protected] | 7f5605c | 2013-04-08 18:08:35 | [diff] [blame] | 54 | class LayerAnimationEventObserver; |
[email protected] | ae716ce | 2013-08-16 13:04:24 | [diff] [blame] | 55 | class LayerClient; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 56 | class LayerImpl; |
| 57 | class LayerTreeHost; |
[email protected] | 8bef4057 | 2012-12-11 21:38:08 | [diff] [blame] | 58 | class LayerTreeImpl; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 59 | class PriorityCalculator; |
[email protected] | d8411661 | 2013-03-29 05:32:49 | [diff] [blame] | 60 | class RenderingStatsInstrumentation; |
[email protected] | b4da203 | 2012-10-25 21:22:55 | [diff] [blame] | 61 | class ResourceUpdateQueue; |
[email protected] | 80413d7 | 2013-08-30 20:25:33 | [diff] [blame] | 62 | class ScrollbarLayerInterface; |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 63 | class SimpleEnclosedRegion; |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 64 | struct AnimationEvent; |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 65 | template <typename LayerType> |
| 66 | class OcclusionTracker; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 67 | |
| 68 | // Base class for composited layers. Special layer types are derived from |
| 69 | // this class. |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 70 | class CC_EXPORT Layer : public base::RefCounted<Layer>, |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 71 | public LayerAnimationValueObserver, |
| 72 | public LayerAnimationValueProvider { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 73 | public: |
[email protected] | 44d8e84c | 2013-10-19 19:13:22 | [diff] [blame] | 74 | typedef RenderSurfaceLayerList RenderSurfaceListType; |
| 75 | typedef LayerList LayerListType; |
| 76 | typedef RenderSurface RenderSurfaceType; |
| 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 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 82 | static scoped_refptr<Layer> Create(); |
[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 |
| 102 | // first), then the callback is called with a NULL/empty result. |
| 103 | void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> request); |
| 104 | bool HasCopyRequest() const { |
| 105 | return !copy_requests_.empty(); |
[email protected] | 18a7019 | 2013-04-26 16:18:25 | [diff] [blame] | 106 | } |
| 107 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 108 | virtual void SetBackgroundColor(SkColor background_color); |
| 109 | SkColor background_color() const { return background_color_; } |
[email protected] | 2c4cbec | 2013-06-04 21:14:50 | [diff] [blame] | 110 | // If contents_opaque(), return an opaque color else return a |
| 111 | // non-opaque color. Tries to return background_color(), if possible. |
| 112 | SkColor SafeOpaqueBackgroundColor() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 113 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 114 | // A layer's bounds are in logical, non-page-scaled pixels (however, the |
| 115 | // root layer's bounds are in physical pixels). |
[email protected] | 64348ea | 2014-01-29 22:58:26 | [diff] [blame] | 116 | void SetBounds(const gfx::Size& bounds); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 117 | gfx::Size bounds() const { return bounds_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 118 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 119 | void SetMasksToBounds(bool masks_to_bounds); |
| 120 | bool masks_to_bounds() const { return masks_to_bounds_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 121 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 122 | void SetMaskLayer(Layer* mask_layer); |
| 123 | Layer* mask_layer() { return mask_layer_.get(); } |
| 124 | const Layer* mask_layer() const { return mask_layer_.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 125 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 126 | virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect); |
| 127 | void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::RectF(bounds())); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 128 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 129 | void SetOpacity(float opacity); |
| 130 | float opacity() const { return opacity_; } |
| 131 | bool OpacityIsAnimating() const; |
[email protected] | b7c4783f | 2013-03-15 23:11:42 | [diff] [blame] | 132 | virtual bool OpacityCanAnimateOnImplThread() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 133 | |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 134 | void SetBlendMode(SkXfermode::Mode blend_mode); |
| 135 | SkXfermode::Mode blend_mode() const { return blend_mode_; } |
| 136 | |
| 137 | bool uses_default_blend_mode() const { |
| 138 | return blend_mode_ == SkXfermode::kSrcOver_Mode; |
| 139 | } |
| 140 | |
| 141 | // A layer is root for an isolated group when it and all its descendants are |
| 142 | // drawn over a black and fully transparent background, creating an isolated |
| 143 | // group. It should be used along with SetBlendMode(), in order to restrict |
| 144 | // layers within the group to blend with layers outside this group. |
| 145 | void SetIsRootForIsolatedGroup(bool root); |
| 146 | bool is_root_for_isolated_group() const { |
| 147 | return is_root_for_isolated_group_; |
| 148 | } |
| 149 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 150 | void SetFilters(const FilterOperations& filters); |
| 151 | const FilterOperations& filters() const { return filters_; } |
[email protected] | b4c6d81 | 2013-10-03 15:48:56 | [diff] [blame] | 152 | bool FilterIsAnimating() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 153 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 154 | // Background filters are filters applied to what is behind this layer, when |
| 155 | // they are viewed through non-opaque regions in this layer. They are used |
| 156 | // through the WebLayer interface, and are not exposed to HTML. |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 157 | void SetBackgroundFilters(const FilterOperations& filters); |
| 158 | const FilterOperations& background_filters() const { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 159 | return background_filters_; |
| 160 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 161 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 162 | virtual void SetContentsOpaque(bool opaque); |
| 163 | bool contents_opaque() const { return contents_opaque_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 164 | |
[email protected] | 14bc5d68 | 2014-01-17 07:26:47 | [diff] [blame] | 165 | void SetPosition(const gfx::PointF& position); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 166 | gfx::PointF position() const { return position_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 167 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 168 | void SetIsContainerForFixedPositionLayers(bool container); |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 169 | bool IsContainerForFixedPositionLayers() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 170 | |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 171 | void SetPositionConstraint(const LayerPositionConstraint& constraint); |
| 172 | const LayerPositionConstraint& position_constraint() const { |
| 173 | return position_constraint_; |
| 174 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 175 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 176 | void SetTransform(const gfx::Transform& transform); |
| 177 | const gfx::Transform& transform() const { return transform_; } |
| 178 | bool TransformIsAnimating() const; |
[email protected] | 08bdf1b | 2014-04-16 23:23:29 | [diff] [blame] | 179 | bool transform_is_invertible() const { return transform_is_invertible_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 180 | |
[email protected] | a256641 | 2014-06-05 03:14:20 | [diff] [blame] | 181 | void SetTransformOrigin(const gfx::Point3F&); |
| 182 | gfx::Point3F transform_origin() { return transform_origin_; } |
| 183 | |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 184 | void SetScrollParent(Layer* parent); |
| 185 | |
| 186 | Layer* scroll_parent() { return scroll_parent_; } |
| 187 | const Layer* scroll_parent() const { return scroll_parent_; } |
| 188 | |
| 189 | void AddScrollChild(Layer* child); |
| 190 | void RemoveScrollChild(Layer* child); |
| 191 | |
| 192 | std::set<Layer*>* scroll_children() { return scroll_children_.get(); } |
| 193 | const std::set<Layer*>* scroll_children() const { |
| 194 | return scroll_children_.get(); |
| 195 | } |
| 196 | |
| 197 | void SetClipParent(Layer* ancestor); |
| 198 | |
| 199 | Layer* clip_parent() { return clip_parent_; } |
| 200 | const Layer* clip_parent() const { |
| 201 | return clip_parent_; |
| 202 | } |
| 203 | |
| 204 | void AddClipChild(Layer* child); |
| 205 | void RemoveClipChild(Layer* child); |
| 206 | |
| 207 | std::set<Layer*>* clip_children() { return clip_children_.get(); } |
| 208 | const std::set<Layer*>* clip_children() const { |
| 209 | return clip_children_.get(); |
| 210 | } |
| 211 | |
[email protected] | 44d8e84c | 2013-10-19 19:13:22 | [diff] [blame] | 212 | DrawProperties<Layer>& draw_properties() { return draw_properties_; } |
| 213 | const DrawProperties<Layer>& draw_properties() const { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 214 | return draw_properties_; |
| 215 | } |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 216 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 217 | // The following are shortcut accessors to get various information from |
| 218 | // draw_properties_ |
| 219 | const gfx::Transform& draw_transform() const { |
| 220 | return draw_properties_.target_space_transform; |
| 221 | } |
| 222 | const gfx::Transform& screen_space_transform() const { |
| 223 | return draw_properties_.screen_space_transform; |
| 224 | } |
| 225 | float draw_opacity() const { return draw_properties_.opacity; } |
| 226 | bool draw_opacity_is_animating() const { |
| 227 | return draw_properties_.opacity_is_animating; |
| 228 | } |
| 229 | bool draw_transform_is_animating() const { |
| 230 | return draw_properties_.target_space_transform_is_animating; |
| 231 | } |
| 232 | bool screen_space_transform_is_animating() const { |
| 233 | return draw_properties_.screen_space_transform_is_animating; |
| 234 | } |
| 235 | bool screen_space_opacity_is_animating() const { |
| 236 | return draw_properties_.screen_space_opacity_is_animating; |
| 237 | } |
| 238 | bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; } |
| 239 | bool is_clipped() const { return draw_properties_.is_clipped; } |
| 240 | gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } |
| 241 | gfx::Rect drawable_content_rect() const { |
| 242 | return draw_properties_.drawable_content_rect; |
| 243 | } |
| 244 | gfx::Rect visible_content_rect() const { |
| 245 | return draw_properties_.visible_content_rect; |
| 246 | } |
| 247 | Layer* render_target() { |
| 248 | DCHECK(!draw_properties_.render_target || |
| 249 | draw_properties_.render_target->render_surface()); |
| 250 | return draw_properties_.render_target; |
| 251 | } |
| 252 | const Layer* render_target() const { |
| 253 | DCHECK(!draw_properties_.render_target || |
| 254 | draw_properties_.render_target->render_surface()); |
| 255 | return draw_properties_.render_target; |
| 256 | } |
| 257 | RenderSurface* render_surface() const { |
| 258 | return draw_properties_.render_surface.get(); |
| 259 | } |
[email protected] | 420fdf6e | 2013-08-26 20:36:38 | [diff] [blame] | 260 | int num_unclipped_descendants() const { |
| 261 | return draw_properties_.num_unclipped_descendants; |
| 262 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 263 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 264 | void SetScrollOffset(gfx::Vector2d scroll_offset); |
| 265 | gfx::Vector2d scroll_offset() const { return scroll_offset_; } |
[email protected] | 243e4f1 | 2014-02-05 09:18:42 | [diff] [blame] | 266 | void SetScrollOffsetFromImplSide(const gfx::Vector2d& scroll_offset); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 267 | |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 268 | void SetScrollClipLayerId(int clip_layer_id); |
| 269 | bool scrollable() const { return scroll_clip_layer_id_ != INVALID_ID; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 270 | |
[email protected] | 59a7d55 | 2013-10-22 03:36:43 | [diff] [blame] | 271 | void SetUserScrollable(bool horizontal, bool vertical); |
| 272 | bool user_scrollable_horizontal() const { |
| 273 | return user_scrollable_horizontal_; |
| 274 | } |
| 275 | bool user_scrollable_vertical() const { return user_scrollable_vertical_; } |
| 276 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 277 | void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread); |
| 278 | bool should_scroll_on_main_thread() const { |
| 279 | return should_scroll_on_main_thread_; |
| 280 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 281 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 282 | void SetHaveWheelEventHandlers(bool have_wheel_event_handlers); |
| 283 | bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 284 | |
[email protected] | f998c53 | 2014-03-31 20:02:51 | [diff] [blame] | 285 | void SetHaveScrollEventHandlers(bool have_scroll_event_handlers); |
| 286 | bool have_scroll_event_handlers() const { |
| 287 | return have_scroll_event_handlers_; |
| 288 | } |
| 289 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 290 | void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region); |
| 291 | const Region& non_fast_scrollable_region() const { |
| 292 | return non_fast_scrollable_region_; |
| 293 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 294 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 295 | void SetTouchEventHandlerRegion(const Region& touch_event_handler_region); |
| 296 | const Region& touch_event_handler_region() const { |
| 297 | return touch_event_handler_region_; |
| 298 | } |
[email protected] | 23d56be | 2012-11-08 00:33:34 | [diff] [blame] | 299 | |
[email protected] | 28096ed | 2013-07-01 07:38:58 | [diff] [blame] | 300 | void set_did_scroll_callback(const base::Closure& callback) { |
| 301 | did_scroll_callback_ = callback; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 302 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 303 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 304 | void SetDrawCheckerboardForMissingTiles(bool checkerboard); |
[email protected] | b74241eb | 2014-03-08 11:35:02 | [diff] [blame] | 305 | bool draw_checkerboard_for_missing_tiles() const { |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 306 | return draw_checkerboard_for_missing_tiles_; |
| 307 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 308 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 309 | void SetForceRenderSurface(bool force_render_surface); |
| 310 | bool force_render_surface() const { return force_render_surface_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 311 | |
[email protected] | 1960a71 | 2013-04-30 17:06:47 | [diff] [blame] | 312 | gfx::Vector2d ScrollDelta() const { return gfx::Vector2d(); } |
[email protected] | 4ec78f8 | 2013-07-11 18:45:47 | [diff] [blame] | 313 | gfx::Vector2dF TotalScrollOffset() const { |
| 314 | // Floating point to match the LayerImpl version. |
| 315 | return scroll_offset() + ScrollDelta(); |
| 316 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 317 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 318 | void SetDoubleSided(bool double_sided); |
| 319 | bool double_sided() const { return double_sided_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 320 | |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 321 | void SetShouldFlattenTransform(bool flatten); |
| 322 | bool should_flatten_transform() const { return should_flatten_transform_; } |
| 323 | |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 324 | bool Is3dSorted() const { return sorting_context_id_ != 0; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 325 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 326 | void set_use_parent_backface_visibility(bool use) { |
| 327 | use_parent_backface_visibility_ = use; |
| 328 | } |
| 329 | bool use_parent_backface_visibility() const { |
| 330 | return use_parent_backface_visibility_; |
| 331 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 332 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 333 | virtual void SetLayerTreeHost(LayerTreeHost* host); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 334 | |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 335 | virtual bool HasDelegatedContent() const; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 336 | bool HasContributingDelegatedRenderPasses() const { return false; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 337 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 338 | void SetIsDrawable(bool is_drawable); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 339 | |
[email protected] | c0ae06c1 | 2013-06-24 18:32:19 | [diff] [blame] | 340 | void SetHideLayerAndSubtree(bool hide); |
| 341 | bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; } |
| 342 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 343 | void SetReplicaLayer(Layer* layer); |
| 344 | Layer* replica_layer() { return replica_layer_.get(); } |
| 345 | const Layer* replica_layer() const { return replica_layer_.get(); } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 346 | |
[email protected] | 22898ed | 2013-06-01 04:52:30 | [diff] [blame] | 347 | bool has_mask() const { return !!mask_layer_.get(); } |
| 348 | bool has_replica() const { return !!replica_layer_.get(); } |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 349 | bool replica_has_mask() const { |
[email protected] | 22898ed | 2013-06-01 04:52:30 | [diff] [blame] | 350 | return replica_layer_.get() && |
| 351 | (mask_layer_.get() || replica_layer_->mask_layer_.get()); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 352 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 353 | |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 354 | int NumDescendantsThatDrawContent() const; |
| 355 | |
| 356 | // This is only virtual for tests. |
| 357 | // TODO(awoloszyn): Remove this once we no longer need it for tests |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 358 | virtual bool DrawsContent() const; |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 359 | |
| 360 | // This methods typically need to be overwritten by derived classes. |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 361 | virtual void SavePaintProperties(); |
[email protected] | 49304bde | 2013-07-08 21:31:22 | [diff] [blame] | 362 | // Returns true iff any resources were updated that need to be committed. |
| 363 | virtual bool Update(ResourceUpdateQueue* queue, |
[email protected] | 34ba1ffb | 2014-03-05 06:55:03 | [diff] [blame] | 364 | const OcclusionTracker<Layer>* occlusion); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 365 | virtual bool NeedMoreUpdates(); |
| 366 | virtual void SetIsMask(bool is_mask) {} |
[email protected] | 4830141f | 2013-05-18 01:36:05 | [diff] [blame] | 367 | virtual void ReduceMemoryUsage() {} |
[email protected] | 039fa8c | 2013-10-09 22:37:28 | [diff] [blame] | 368 | virtual void OnOutputSurfaceCreated() {} |
[email protected] | a6c1b23 | 2014-05-05 23:53:08 | [diff] [blame] | 369 | virtual bool IsSuitableForGpuRasterization() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 370 | |
[email protected] | 9f3be43 | 2013-12-03 03:53:22 | [diff] [blame] | 371 | virtual scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo(); |
[email protected] | ae716ce | 2013-08-16 13:04:24 | [diff] [blame] | 372 | |
| 373 | void SetLayerClient(LayerClient* client) { client_ = client; } |
| 374 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 375 | virtual void PushPropertiesTo(LayerImpl* layer); |
| 376 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 377 | void CreateRenderSurface(); |
[email protected] | 50761e9 | 2013-03-29 20:51:28 | [diff] [blame] | 378 | void ClearRenderSurface(); |
[email protected] | 7644fa2 | 2014-04-28 12:20:33 | [diff] [blame] | 379 | void ClearRenderSurfaceLayerList(); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 380 | |
[email protected] | ed511b8d | 2013-03-25 03:29:29 | [diff] [blame] | 381 | // The contents scale converts from logical, non-page-scaled pixels to target |
| 382 | // pixels. The contents scale is 1 for the root layer as it is already in |
| 383 | // physical pixels. By default contents scale is forced to be 1 except for |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 384 | // subclasses of ContentsScalingLayer. |
| 385 | float contents_scale_x() const { return draw_properties_.contents_scale_x; } |
| 386 | float contents_scale_y() const { return draw_properties_.contents_scale_y; } |
| 387 | gfx::Size content_bounds() const { return draw_properties_.content_bounds; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 388 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 389 | virtual void CalculateContentsScale(float ideal_contents_scale, |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 390 | float* contents_scale_x, |
| 391 | float* contents_scale_y, |
| 392 | gfx::Size* content_bounds); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 393 | |
[email protected] | 3698e79 | 2013-08-24 00:21:16 | [diff] [blame] | 394 | LayerTreeHost* layer_tree_host() { return layer_tree_host_; } |
| 395 | const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 396 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 397 | // Set the priority of all desired textures in this layer. |
| 398 | virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {} |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 399 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 400 | bool AddAnimation(scoped_ptr<Animation> animation); |
| 401 | void PauseAnimation(int animation_id, double time_offset); |
| 402 | void RemoveAnimation(int animation_id); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 403 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 404 | LayerAnimationController* layer_animation_controller() { |
| 405 | return layer_animation_controller_.get(); |
| 406 | } |
[email protected] | 7f5605c | 2013-04-08 18:08:35 | [diff] [blame] | 407 | void SetLayerAnimationControllerForTest( |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 408 | scoped_refptr<LayerAnimationController> controller); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 409 | |
[email protected] | 3cae03e | 2013-06-26 22:13:52 | [diff] [blame] | 410 | void set_layer_animation_delegate(AnimationDelegate* delegate) { |
[email protected] | 7f5605c | 2013-04-08 18:08:35 | [diff] [blame] | 411 | layer_animation_controller_->set_layer_animation_delegate(delegate); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 412 | } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 413 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 414 | bool HasActiveAnimation() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 415 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 416 | void AddLayerAnimationEventObserver( |
| 417 | LayerAnimationEventObserver* animation_observer); |
| 418 | void RemoveLayerAnimationEventObserver( |
| 419 | LayerAnimationEventObserver* animation_observer); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 420 | |
[email protected] | d5467eb7 | 2014-08-22 01:16:43 | [diff] [blame^] | 421 | virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const; |
[email protected] | e10cd02 | 2012-12-18 00:32:26 | [diff] [blame] | 422 | |
[email protected] | 80413d7 | 2013-08-30 20:25:33 | [diff] [blame] | 423 | virtual ScrollbarLayerInterface* ToScrollbarLayer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 424 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 425 | gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 426 | |
[email protected] | f7837a9 | 2013-08-21 03:00:05 | [diff] [blame] | 427 | virtual skia::RefPtr<SkPicture> GetPicture() const; |
| 428 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 429 | // Constructs a LayerImpl of the correct runtime type for this Layer type. |
| 430 | virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); |
[email protected] | aedf4e5 | 2013-01-09 23:24:44 | [diff] [blame] | 431 | |
[email protected] | 4460464 | 2013-08-01 01:14:09 | [diff] [blame] | 432 | bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); } |
| 433 | void ResetNeedsDisplayForTesting() { update_rect_ = gfx::RectF(); } |
[email protected] | 48871fc | 2013-01-23 07:36:51 | [diff] [blame] | 434 | |
[email protected] | d8411661 | 2013-03-29 05:32:49 | [diff] [blame] | 435 | RenderingStatsInstrumentation* rendering_stats_instrumentation() const; |
| 436 | |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 437 | const PaintProperties& paint_properties() const { |
| 438 | return paint_properties_; |
| 439 | } |
| 440 | |
[email protected] | 35a99a1 | 2013-05-09 23:52:29 | [diff] [blame] | 441 | // The scale at which contents should be rastered, to match the scale at |
| 442 | // which they will drawn to the screen. This scale is a component of the |
| 443 | // contents scale but does not include page/device scale factors. |
| 444 | // TODO(danakj): This goes away when TiledLayer goes away. |
| 445 | void set_raster_scale(float scale) { raster_scale_ = scale; } |
| 446 | float raster_scale() const { return raster_scale_; } |
| 447 | bool raster_scale_is_unknown() const { return raster_scale_ == 0.f; } |
| 448 | |
[email protected] | 7924c185 | 2013-05-24 16:18:43 | [diff] [blame] | 449 | virtual bool SupportsLCDText() const; |
| 450 | |
[email protected] | 7a5a932 | 2014-02-25 12:54:57 | [diff] [blame] | 451 | void SetNeedsPushProperties(); |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 452 | bool needs_push_properties() const { return needs_push_properties_; } |
| 453 | bool descendant_needs_push_properties() const { |
| 454 | return num_dependents_need_push_properties_ > 0; |
| 455 | } |
[email protected] | 7a5a932 | 2014-02-25 12:54:57 | [diff] [blame] | 456 | void reset_needs_push_properties_for_testing() { |
| 457 | needs_push_properties_ = false; |
| 458 | } |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 459 | |
[email protected] | 666d7cf | 2013-10-12 01:30:29 | [diff] [blame] | 460 | virtual void RunMicroBenchmark(MicroBenchmark* benchmark); |
| 461 | |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 462 | void Set3dSortingContextId(int id); |
| 463 | int sorting_context_id() const { return sorting_context_id_; } |
| 464 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 465 | protected: |
| 466 | friend class LayerImpl; |
| 467 | friend class TreeSynchronizer; |
| 468 | virtual ~Layer(); |
[email protected] | 090e1a7 | 2013-01-29 07:07:45 | [diff] [blame] | 469 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 470 | Layer(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 471 | |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 472 | // These SetNeeds functions are in order of severity of update: |
| 473 | // |
| 474 | // Called when this layer has been modified in some way, but isn't sure |
| 475 | // that it needs a commit yet. It needs CalcDrawProperties and UpdateLayers |
| 476 | // before it knows whether or not a commit is required. |
| 477 | void SetNeedsUpdate(); |
| 478 | // Called when a property has been modified in a way that the layer |
| 479 | // knows immediately that a commit is required. This implies SetNeedsUpdate |
| 480 | // as well as SetNeedsPushProperties to push that property. |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 481 | void SetNeedsCommit(); |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 482 | // Called when there's been a change in layer structure. Implies both |
| 483 | // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties. |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 484 | void SetNeedsFullTreeSync(); |
[email protected] | 74b43cc | 2013-08-30 06:29:27 | [diff] [blame] | 485 | |
| 486 | // Called when the next commit should wait until the pending tree is activated |
| 487 | // before finishing the commit and unblocking the main thread. Used to ensure |
| 488 | // unused resources on the impl thread are returned before commit completes. |
| 489 | void SetNextCommitWaitsForActivation(); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 490 | |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 491 | // Will recalculate whether the layer draws content and set draws_content_ |
| 492 | // appropriately. |
| 493 | void UpdateDrawsContent(bool has_drawable_content); |
| 494 | virtual bool HasDrawableContent() const; |
| 495 | |
| 496 | // Called when the layer's number of drawable descendants changes. |
| 497 | void AddDrawableDescendants(int num); |
| 498 | |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 499 | void AddDependentNeedsPushProperties(); |
| 500 | void RemoveDependentNeedsPushProperties(); |
| 501 | bool parent_should_know_need_push_properties() const { |
| 502 | return needs_push_properties() || descendant_needs_push_properties(); |
| 503 | } |
| 504 | |
[email protected] | 74b43cc | 2013-08-30 06:29:27 | [diff] [blame] | 505 | bool IsPropertyChangeAllowed() const; |
| 506 | |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 507 | // If this layer has a scroll parent, it removes |this| from its list of |
| 508 | // scroll children. |
| 509 | void RemoveFromScrollTree(); |
| 510 | |
| 511 | // If this layer has a clip parent, it removes |this| from its list of clip |
| 512 | // children. |
| 513 | void RemoveFromClipTree(); |
| 514 | |
[email protected] | 35a99a1 | 2013-05-09 23:52:29 | [diff] [blame] | 515 | void reset_raster_scale_to_unknown() { raster_scale_ = 0.f; } |
| 516 | |
[email protected] | f4e25f9 | 2013-07-13 20:54:53 | [diff] [blame] | 517 | // This flag is set when the layer needs to push properties to the impl |
| 518 | // side. |
| 519 | bool needs_push_properties_; |
| 520 | |
| 521 | // The number of direct children or dependent layers that need to be recursed |
| 522 | // to in order for them or a descendent of them to push properties to the impl |
| 523 | // side. |
| 524 | int num_dependents_need_push_properties_; |
| 525 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 526 | // Tracks whether this layer may have changed stacking order with its |
| 527 | // siblings. |
| 528 | bool stacking_order_changed_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 529 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 530 | // The update rect is the region of the compositor resource that was |
| 531 | // actually updated by the compositor. For layers that may do updating |
| 532 | // outside the compositor's control (i.e. plugin layers), this information |
| 533 | // is not available and the update rect will remain empty. |
| 534 | // Note this rect is in layer space (not content space). |
| 535 | gfx::RectF update_rect_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 536 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 537 | scoped_refptr<Layer> mask_layer_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 538 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 539 | int layer_id_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 540 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 541 | // When true, the layer is about to perform an update. Any commit requests |
[email protected] | 3519b87 | 2013-07-30 07:17:50 | [diff] [blame] | 542 | // will be handled implicitly after the update completes. |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 543 | bool ignore_set_needs_commit_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 544 | |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 545 | // Layers that share a sorting context id will be sorted together in 3d |
| 546 | // space. 0 is a special value that means this layer will not be sorted and |
| 547 | // will be drawn in paint order. |
| 548 | int sorting_context_id_; |
| 549 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 550 | private: |
| 551 | friend class base::RefCounted<Layer>; |
[email protected] | 29493a1 | 2012-12-20 01:42:42 | [diff] [blame] | 552 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 553 | void SetParent(Layer* layer); |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 554 | bool DescendantIsFixedToContainerLayer() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 555 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 556 | // Returns the index of the child or -1 if not found. |
| 557 | int IndexOfChild(const Layer* reference); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 558 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 559 | // This should only be called from RemoveFromParent(). |
| 560 | void RemoveChildOrDependent(Layer* child); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 561 | |
[email protected] | b8384e2 | 2013-12-03 02:20:48 | [diff] [blame] | 562 | // LayerAnimationValueProvider implementation. |
| 563 | virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE; |
| 564 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 565 | // LayerAnimationValueObserver implementation. |
[email protected] | b4c6d81 | 2013-10-03 15:48:56 | [diff] [blame] | 566 | virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 567 | virtual void OnOpacityAnimated(float opacity) OVERRIDE; |
| 568 | virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE; |
[email protected] | 3244c913 | 2014-01-23 10:39:12 | [diff] [blame] | 569 | virtual void OnScrollOffsetAnimated( |
| 570 | const gfx::Vector2dF& scroll_offset) OVERRIDE; |
[email protected] | 1c24cf296 | 2013-11-18 23:34:51 | [diff] [blame] | 571 | virtual void OnAnimationWaitingForDeletion() OVERRIDE; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 572 | virtual bool IsActive() const OVERRIDE; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 573 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 574 | LayerList children_; |
| 575 | Layer* parent_; |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 576 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 577 | // Layer instances have a weak pointer to their LayerTreeHost. |
| 578 | // This pointer value is nil when a Layer is not in a tree and is |
| 579 | // updated via SetLayerTreeHost() if a layer moves between trees. |
| 580 | LayerTreeHost* layer_tree_host_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 581 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 582 | scoped_refptr<LayerAnimationController> layer_animation_controller_; |
[email protected] | de4afb5e | 2012-12-20 00:11:34 | [diff] [blame] | 583 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 584 | // Layer properties. |
| 585 | gfx::Size bounds_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 586 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 587 | gfx::Vector2d scroll_offset_; |
[email protected] | adeda57 | 2014-01-31 00:49:47 | [diff] [blame] | 588 | // This variable indicates which ancestor layer (if any) whose size, |
| 589 | // transformed relative to this layer, defines the maximum scroll offset for |
| 590 | // this layer. |
| 591 | int scroll_clip_layer_id_; |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 592 | int num_descendants_that_draw_content_; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 593 | bool should_scroll_on_main_thread_ : 1; |
| 594 | bool have_wheel_event_handlers_ : 1; |
[email protected] | f998c53 | 2014-03-31 20:02:51 | [diff] [blame] | 595 | bool have_scroll_event_handlers_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 596 | bool user_scrollable_horizontal_ : 1; |
| 597 | bool user_scrollable_vertical_ : 1; |
| 598 | bool is_root_for_isolated_group_ : 1; |
| 599 | bool is_container_for_fixed_position_layers_ : 1; |
| 600 | bool is_drawable_ : 1; |
[email protected] | ad63b2f | 2014-08-11 17:39:54 | [diff] [blame] | 601 | bool draws_content_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 602 | bool hide_layer_and_subtree_ : 1; |
| 603 | bool masks_to_bounds_ : 1; |
| 604 | bool contents_opaque_ : 1; |
| 605 | bool double_sided_ : 1; |
[email protected] | 56fffdd | 2014-02-11 19:50:57 | [diff] [blame] | 606 | bool should_flatten_transform_ : 1; |
[email protected] | c55f3fc | 2013-12-10 05:48:48 | [diff] [blame] | 607 | bool use_parent_backface_visibility_ : 1; |
| 608 | bool draw_checkerboard_for_missing_tiles_ : 1; |
| 609 | bool force_render_surface_ : 1; |
[email protected] | 08bdf1b | 2014-04-16 23:23:29 | [diff] [blame] | 610 | bool transform_is_invertible_ : 1; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 611 | Region non_fast_scrollable_region_; |
| 612 | Region touch_event_handler_region_; |
| 613 | gfx::PointF position_; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 614 | SkColor background_color_; |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 615 | float opacity_; |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 616 | SkXfermode::Mode blend_mode_; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 617 | FilterOperations filters_; |
| 618 | FilterOperations background_filters_; |
[email protected] | fe956c9c4 | 2013-04-09 04:26:33 | [diff] [blame] | 619 | LayerPositionConstraint position_constraint_; |
[email protected] | 0e98cdd | 2013-08-23 00:44:30 | [diff] [blame] | 620 | Layer* scroll_parent_; |
| 621 | scoped_ptr<std::set<Layer*> > scroll_children_; |
| 622 | |
| 623 | Layer* clip_parent_; |
| 624 | scoped_ptr<std::set<Layer*> > clip_children_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 625 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 626 | gfx::Transform transform_; |
[email protected] | a256641 | 2014-06-05 03:14:20 | [diff] [blame] | 627 | gfx::Point3F transform_origin_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 628 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 629 | // Replica layer used for reflections. |
| 630 | scoped_refptr<Layer> replica_layer_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 631 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 632 | // Transient properties. |
| 633 | float raster_scale_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 634 | |
[email protected] | ae716ce | 2013-08-16 13:04:24 | [diff] [blame] | 635 | LayerClient* client_; |
| 636 | |
[email protected] | 0e5f714 | 2013-05-24 06:45:36 | [diff] [blame] | 637 | ScopedPtrVector<CopyOutputRequest> copy_requests_; |
[email protected] | 18a7019 | 2013-04-26 16:18:25 | [diff] [blame] | 638 | |
[email protected] | 28096ed | 2013-07-01 07:38:58 | [diff] [blame] | 639 | base::Closure did_scroll_callback_; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 640 | |
[email protected] | 44d8e84c | 2013-10-19 19:13:22 | [diff] [blame] | 641 | DrawProperties<Layer> draw_properties_; |
[email protected] | d76806f8 | 2012-12-05 21:41:50 | [diff] [blame] | 642 | |
[email protected] | 445881f | 2013-04-16 01:11:59 | [diff] [blame] | 643 | PaintProperties paint_properties_; |
| 644 | |
[email protected] | 7aba666 | 2013-03-12 10:17:34 | [diff] [blame] | 645 | DISALLOW_COPY_AND_ASSIGN(Layer); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 646 | }; |
| 647 | |
[email protected] | ddf9df8 | 2012-10-16 06:52:46 | [diff] [blame] | 648 | } // namespace cc |
| 649 | |
[email protected] | cc3cfaa | 2013-03-18 09:05:52 | [diff] [blame] | 650 | #endif // CC_LAYERS_LAYER_H_ |