blob: d49101b451be4ad75c7bce3519985199f470d7c8 [file] [log] [blame]
[email protected]036e6c972012-01-03 18:48:051// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]adc93fa72011-06-21 19:47:392// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]116302fc2012-05-05 21:45:415#ifndef UI_COMPOSITOR_LAYER_H_
6#define UI_COMPOSITOR_LAYER_H_
[email protected]adc93fa72011-06-21 19:47:397
[email protected]33699e622011-11-17 18:29:308#include <string>
[email protected]adc93fa72011-06-21 19:47:399#include <vector>
10
[email protected]7fca53d42011-09-29 15:38:1211#include "base/compiler_specific.h"
[email protected]51f1b482011-06-23 16:52:1212#include "base/memory/ref_counted.h"
[email protected]7fca53d42011-09-29 15:38:1213#include "base/memory/scoped_ptr.h"
[email protected]4e2d03e22013-07-18 04:19:5414#include "base/message_loop/message_loop.h"
[email protected]95e4e1a02013-03-18 07:09:0915#include "cc/animation/animation_events.h"
16#include "cc/animation/layer_animation_event_observer.h"
[email protected]681ccff2013-03-18 06:13:5217#include "cc/base/scoped_ptr_vector.h"
[email protected]cc3cfaa2013-03-18 09:05:5218#include "cc/layers/content_layer_client.h"
[email protected]29e17b02013-08-30 02:13:3319#include "cc/layers/layer_client.h"
jbaumandbccae1ab2014-11-06 23:26:4420#include "cc/layers/surface_layer.h"
[email protected]cc3cfaa2013-03-18 09:05:5221#include "cc/layers/texture_layer_client.h"
[email protected]42f40a52013-06-08 04:38:5122#include "cc/resources/texture_mailbox.h"
[email protected]ca2c3ea2014-07-26 19:35:3023#include "cc/surfaces/surface_id.h"
[email protected]116302fc2012-05-05 21:45:4124#include "third_party/skia/include/core/SkColor.h"
25#include "third_party/skia/include/core/SkRegion.h"
26#include "ui/compositor/compositor.h"
27#include "ui/compositor/layer_animation_delegate.h"
28#include "ui/compositor/layer_delegate.h"
29#include "ui/compositor/layer_type.h"
tfarina3b0452d2014-12-31 15:20:0930#include "ui/gfx/geometry/rect.h"
[email protected]adc93fa72011-06-21 19:47:3931#include "ui/gfx/transform.h"
32
[email protected]892ad8a2011-07-27 02:47:2233class SkCanvas;
[email protected]adc93fa72011-06-21 19:47:3934
[email protected]ec05af52012-11-21 23:07:0035namespace cc {
36class ContentLayer;
[email protected]a7fcdda32013-07-04 02:23:0737class CopyOutputRequest;
[email protected]09f67382013-10-09 21:03:4538class DelegatedFrameProvider;
[email protected]b14d40d2013-03-06 03:53:2739class DelegatedRendererLayer;
[email protected]ec05af52012-11-21 23:07:0040class Layer;
[email protected]98a59132014-07-16 22:49:5241class NinePatchLayer;
[email protected]ec05af52012-11-21 23:07:0042class ResourceUpdateQueue;
43class SolidColorLayer;
[email protected]ca2c3ea2014-07-26 19:35:3044class SurfaceLayer;
[email protected]ec05af52012-11-21 23:07:0045class TextureLayer;
[email protected]e00bab022013-08-19 00:42:4546struct ReturnedResource;
47typedef std::vector<ReturnedResource> ReturnedResourceArray;
[email protected]ec05af52012-11-21 23:07:0048}
49
[email protected]adc93fa72011-06-21 19:47:3950namespace ui {
51
52class Compositor;
[email protected]fe7074c62011-10-28 15:22:5453class LayerAnimator;
[email protected]07ae973e2014-03-05 18:51:1054class LayerOwner;
[email protected]adc93fa72011-06-21 19:47:3955
56// Layer manages a texture, transform and a set of child Layers. Any View that
57// has enabled layers ends up creating a Layer to manage the texture.
[email protected]28cd2bb2011-09-19 21:04:1958// A Layer can also be created without a texture, in which case it renders
59// nothing and is simply used as a node in a hierarchy of layers.
[email protected]cd9a61c72012-05-08 19:16:5960// Coordinate system used in layers is DIP (Density Independent Pixel)
61// coordinates unless explicitly mentioned as pixel coordinates.
[email protected]adc93fa72011-06-21 19:47:3962//
[email protected]ae2202a2014-01-07 11:11:1063// NOTE: Unlike Views, each Layer does *not* own its child Layers. If you
64// delete a Layer and it has children, the parent of each child Layer is set to
[email protected]adc93fa72011-06-21 19:47:3965// NULL, but the children are not deleted.
[email protected]2700daddd2012-07-13 19:35:3766class COMPOSITOR_EXPORT Layer
67 : public LayerAnimationDelegate,
[email protected]ec05af52012-11-21 23:07:0068 NON_EXPORTED_BASE(public cc::ContentLayerClient),
[email protected]bf912272013-02-23 01:54:1669 NON_EXPORTED_BASE(public cc::TextureLayerClient),
[email protected]29e17b02013-08-30 02:13:3370 NON_EXPORTED_BASE(public cc::LayerClient),
[email protected]bf912272013-02-23 01:54:1671 NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) {
[email protected]adc93fa72011-06-21 19:47:3972 public:
[email protected]7ab3f272011-11-16 00:51:5673 Layer();
74 explicit Layer(LayerType type);
dcheng08038792014-10-21 10:53:2675 ~Layer() override;
[email protected]adc93fa72011-06-21 19:47:3976
[email protected]dafdf5052014-03-13 17:02:5777 static bool UsingPictureLayer();
78
[email protected]993d6b322011-09-27 19:14:3879 // Retrieves the Layer's compositor. The Layer will walk up its parent chain
80 // to locate it. Returns NULL if the Layer is not attached to a compositor.
sky6dd206092014-10-29 17:26:1681 Compositor* GetCompositor() {
82 return const_cast<Compositor*>(
83 const_cast<const Layer*>(this)->GetCompositor());
84 }
85 const Compositor* GetCompositor() const;
[email protected]993d6b322011-09-27 19:14:3886
87 // Called by the compositor when the Layer is set as its root Layer. This can
88 // only ever be called on the root layer.
89 void SetCompositor(Compositor* compositor);
90
[email protected]00b86982011-09-01 00:02:0991 LayerDelegate* delegate() { return delegate_; }
92 void set_delegate(LayerDelegate* delegate) { delegate_ = delegate; }
93
[email protected]07ae973e2014-03-05 18:51:1094 LayerOwner* owner() { return owner_; }
95
[email protected]adc93fa72011-06-21 19:47:3996 // Adds a new Layer to this Layer.
97 void Add(Layer* child);
98
99 // Removes a Layer from this Layer.
100 void Remove(Layer* child);
101
[email protected]5e4e61f2011-11-22 16:55:24102 // Stacks |child| above all other children.
103 void StackAtTop(Layer* child);
[email protected]18dab372011-10-03 21:21:44104
[email protected]ebc335f2011-11-23 00:43:51105 // Stacks |child| directly above |other|. Both must be children of this
106 // layer. Note that if |child| is initially stacked even higher, calling this
107 // method will result in |child| being lowered in the stacking order.
[email protected]5e4e61f2011-11-22 16:55:24108 void StackAbove(Layer* child, Layer* other);
[email protected]62dd7ea2011-11-08 15:51:47109
[email protected]44c6f8d2011-12-27 23:49:04110 // Stacks |child| below all other children.
111 void StackAtBottom(Layer* child);
112
113 // Stacks |child| directly below |other|. Both must be children of this
114 // layer.
115 void StackBelow(Layer* child, Layer* other);
116
[email protected]adc93fa72011-06-21 19:47:39117 // Returns the child Layers.
[email protected]25ae9a12011-10-12 14:55:22118 const std::vector<Layer*>& children() const { return children_; }
[email protected]adc93fa72011-06-21 19:47:39119
120 // The parent.
121 const Layer* parent() const { return parent_; }
122 Layer* parent() { return parent_; }
123
[email protected]036e6c972012-01-03 18:48:05124 LayerType type() const { return type_; }
125
[email protected]ad7258912011-08-29 20:33:53126 // Returns true if this Layer contains |other| somewhere in its children.
127 bool Contains(const Layer* other) const;
128
[email protected]fe7074c62011-10-28 15:22:54129 // The layer's animator is responsible for causing automatic animations when
130 // properties are set. It also manages a queue of pending animations and
131 // handles blending of animations. The layer takes ownership of the animator.
132 void SetAnimator(LayerAnimator* animator);
133
134 // Returns the layer's animator. Creates a default animator of one has not
135 // been set. Will not return NULL.
136 LayerAnimator* GetAnimator();
[email protected]7fca53d42011-09-29 15:38:12137
[email protected]adc93fa72011-06-21 19:47:39138 // The transform, relative to the parent.
[email protected]0f0453e2012-10-14 18:15:35139 void SetTransform(const gfx::Transform& transform);
[email protected]712f4b642013-03-14 07:09:15140 gfx::Transform transform() const;
[email protected]fe7074c62011-10-28 15:22:54141
142 // Return the target transform if animator is running, or the current
143 // transform otherwise.
[email protected]0f0453e2012-10-14 18:15:35144 gfx::Transform GetTargetTransform() const;
[email protected]adc93fa72011-06-21 19:47:39145
146 // The bounds, relative to the parent.
[email protected]c155c252011-07-29 16:17:55147 void SetBounds(const gfx::Rect& bounds);
[email protected]adc93fa72011-06-21 19:47:39148 const gfx::Rect& bounds() const { return bounds_; }
149
[email protected]ea2910152014-06-10 12:32:35150 // The offset from our parent (stored in bounds.origin()) is an integer but we
151 // may need to be at a fractional pixel offset to align properly on screen.
152 void SetSubpixelPositionOffset(const gfx::Vector2dF offset);
[email protected]e09c592ff2014-07-17 06:55:07153 const gfx::Vector2dF& subpixel_position_offset() const {
154 return subpixel_position_offset_;
155 }
[email protected]ea2910152014-06-10 12:32:35156
[email protected]5ba9d5f2011-10-20 01:58:33157 // Return the target bounds if animator is running, or the current bounds
158 // otherwise.
159 gfx::Rect GetTargetBounds() const;
160
[email protected]7adee632012-03-15 19:15:08161 // Sets/gets whether or not drawing of child layers should be clipped to the
162 // bounds of this layer.
163 void SetMasksToBounds(bool masks_to_bounds);
164 bool GetMasksToBounds() const;
165
[email protected]7fca53d42011-09-29 15:38:12166 // The opacity of the layer. The opacity is applied to each pixel of the
167 // texture (resulting alpha = opacity * alpha).
[email protected]bf912272013-02-23 01:54:16168 float opacity() const;
[email protected]7fca53d42011-09-29 15:38:12169 void SetOpacity(float opacity);
170
[email protected]fb4d9d12012-08-24 00:44:54171 // Returns the actual opacity, which the opacity of this layer multipled by
172 // the combined opacity of the parent.
173 float GetCombinedOpacity() const;
174
[email protected]2a6c5672012-04-23 19:37:09175 // Blur pixels by this amount in anything below the layer and visible through
176 // the layer.
177 int background_blur() const { return background_blur_radius_; }
178 void SetBackgroundBlur(int blur_radius);
179
[email protected]e5da6622012-05-30 19:58:16180 // Saturate all pixels of this layer by this amount.
[email protected]815d0c382012-07-21 08:13:44181 // This effect will get "combined" with the inverted,
182 // brightness and grayscale setting.
[email protected]e5da6622012-05-30 19:58:16183 float layer_saturation() const { return layer_saturation_; }
184 void SetLayerSaturation(float saturation);
185
186 // Change the brightness of all pixels from this layer by this amount.
[email protected]815d0c382012-07-21 08:13:44187 // This effect will get "combined" with the inverted, saturate
188 // and grayscale setting.
[email protected]e5da6622012-05-30 19:58:16189 float layer_brightness() const { return layer_brightness_; }
190 void SetLayerBrightness(float brightness);
191
[email protected]815d0c382012-07-21 08:13:44192 // Return the target brightness if animator is running, or the current
193 // brightness otherwise.
194 float GetTargetBrightness() const;
195
196 // Change the grayscale of all pixels from this layer by this amount.
197 // This effect will get "combined" with the inverted, saturate
198 // and brightness setting.
199 float layer_grayscale() const { return layer_grayscale_; }
200 void SetLayerGrayscale(float grayscale);
201
202 // Return the target grayscale if animator is running, or the current
203 // grayscale otherwise.
204 float GetTargetGrayscale() const;
205
[email protected]56322be2013-03-13 18:27:37206 // Zoom the background by a factor of |zoom|. The effect is blended along the
207 // edge across |inset| pixels.
208 void SetBackgroundZoom(float zoom, int inset);
[email protected]77f7c132012-11-15 06:52:54209
[email protected]fbb145c2014-04-16 19:21:28210 // Set the shape of this layer.
jackhou1d1fa232014-09-11 01:18:41211 SkRegion* alpha_shape() const { return alpha_shape_.get(); }
[email protected]fbb145c2014-04-16 19:21:28212 void SetAlphaShape(scoped_ptr<SkRegion> region);
213
[email protected]f48075d2012-05-24 11:06:51214 // Invert the layer.
[email protected]e5da6622012-05-30 19:58:16215 bool layer_inverted() const { return layer_inverted_; }
216 void SetLayerInverted(bool inverted);
[email protected]f48075d2012-05-24 11:06:51217
[email protected]3f1f5e6a2011-11-11 15:09:02218 // Return the target opacity if animator is running, or the current opacity
[email protected]fe7074c62011-10-28 15:22:54219 // otherwise.
220 float GetTargetOpacity() const;
221
[email protected]498e623c2012-07-12 21:12:42222 // Set a layer mask for a layer.
223 // Note the provided layer mask can neither have a layer mask itself nor can
[email protected]c0dc4b172014-01-07 11:24:09224 // it have any children. The ownership of |layer_mask| will not be
225 // transferred with this call.
[email protected]498e623c2012-07-12 21:12:42226 // Furthermore: A mask layer can only be set to one layer.
[email protected]c0dc4b172014-01-07 11:24:09227 void SetMaskLayer(Layer* layer_mask);
228 Layer* layer_mask_layer() { return layer_mask_; }
[email protected]498e623c2012-07-12 21:12:42229
[email protected]e4e8afef2011-10-05 13:58:33230 // Sets the visibility of the Layer. A Layer may be visible but not
231 // drawn. This happens if any ancestor of a Layer is not visible.
[email protected]993d6b322011-09-27 19:14:38232 void SetVisible(bool visible);
[email protected]f941f47a2011-10-15 18:44:51233 bool visible() const { return visible_; }
[email protected]3aa43942011-09-13 20:59:53234
[email protected]a67935f2012-02-10 14:26:24235 // Returns the target visibility if the animator is running. Otherwise, it
236 // returns the current visibility.
237 bool GetTargetVisibility() const;
238
[email protected]e4e8afef2011-10-05 13:58:33239 // Returns true if this Layer is drawn. A Layer is drawn only if all ancestors
240 // are visible.
241 bool IsDrawn() const;
242
[email protected]c1f67302011-09-27 14:18:09243 // Returns true if this layer can have a texture (has_texture_ is true)
244 // and is not completely obscured by a child.
[email protected]332749032011-10-22 00:32:46245 bool ShouldDraw() const;
[email protected]c1f67302011-09-27 14:18:09246
[email protected]ad7258912011-08-29 20:33:53247 // Converts a point from the coordinates of |source| to the coordinates of
248 // |target|. Necessarily, |source| and |target| must inhabit the same Layer
249 // tree.
250 static void ConvertPointToLayer(const Layer* source,
251 const Layer* target,
252 gfx::Point* point);
253
[email protected]bdcf3bbf2013-03-25 18:39:03254 // Converts a transform to be relative to the given |ancestor|. Returns
255 // whether success (that is, whether the given ancestor was really an
256 // ancestor of this layer).
257 bool GetTargetTransformRelativeTo(const Layer* ancestor,
258 gfx::Transform* transform) const;
259
[email protected]c155c252011-07-29 16:17:55260 // See description in View for details
261 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely);
262 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; }
263
[email protected]1d96e032014-03-25 05:59:08264 // Set to true if this layer always paints completely within its bounds. If so
265 // we can omit an unnecessary clear, even if the layer is transparent.
266 void SetFillsBoundsCompletely(bool fills_bounds_completely);
267
[email protected]33699e622011-11-17 18:29:30268 const std::string& name() const { return name_; }
269 void set_name(const std::string& name) { name_ = name; }
270
[email protected]42f40a52013-06-08 04:38:51271 // Set new TextureMailbox for this layer. Note that |mailbox| may hold a
272 // shared memory resource or an actual mailbox for a texture.
[email protected]9260757f2013-09-17 01:24:16273 void SetTextureMailbox(const cc::TextureMailbox& mailbox,
274 scoped_ptr<cc::SingleReleaseCallback> release_callback,
[email protected]4508b152014-04-09 22:14:17275 gfx::Size texture_size_in_dip);
276 void SetTextureSize(gfx::Size texture_size_in_dip);
achaulk01137b82015-01-30 01:03:05277 void SetTextureFlipped(bool flipped);
278 bool TextureFlipped() const;
[email protected]42f40a52013-06-08 04:38:51279
[email protected]09f67382013-10-09 21:03:45280 // Begins showing delegated frames from the |frame_provider|.
281 void SetShowDelegatedContent(cc::DelegatedFrameProvider* frame_provider,
282 gfx::Size frame_size_in_dip);
[email protected]b14d40d2013-03-06 03:53:27283
[email protected]ca2c3ea2014-07-26 19:35:30284 // Begins showing content from a surface with a particular id.
jbaumandbccae1ab2014-11-06 23:26:44285 void SetShowSurface(cc::SurfaceId surface_id,
286 const cc::SurfaceLayer::SatisfyCallback& satisfy_callback,
287 const cc::SurfaceLayer::RequireCallback& require_callback,
jbauman5a8f0ab2014-11-07 01:41:16288 gfx::Size surface_size,
jbaumanb71b07c22014-11-13 01:10:34289 float scale,
jbaumandbccae1ab2014-11-06 23:26:44290 gfx::Size frame_size_in_dip);
[email protected]ca2c3ea2014-07-26 19:35:30291
[email protected]a7fcdda32013-07-04 02:23:07292 bool has_external_content() {
[email protected]ca2c3ea2014-07-26 19:35:30293 return texture_layer_.get() || delegated_renderer_layer_.get() ||
294 surface_layer_.get();
[email protected]a7fcdda32013-07-04 02:23:07295 }
296
jbaumanf472c6872014-10-13 20:06:43297 // Show a solid color instead of delegated or surface contents.
298 void SetShowSolidColorContent();
[email protected]785b0af2013-10-02 18:08:41299
[email protected]da7584c2012-01-28 03:19:12300 // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR.
301 void SetColor(SkColor color);
302
hshid89c83ac2014-09-19 17:39:28303 // Updates the nine patch layer's bitmap, aperture and border. May only be
304 // called for LAYER_NINE_PATCH.
305 void UpdateNinePatchLayerBitmap(const SkBitmap& bitmap);
306 void UpdateNinePatchLayerAperture(const gfx::Rect& aperture);
[email protected]98a59132014-07-16 22:49:52307 void UpdateNinePatchLayerBorder(const gfx::Rect& border);
308
[email protected]870119a2011-09-30 18:13:22309 // Adds |invalid_rect| to the Layer's pending invalid rect and calls
[email protected]f78649ea2012-02-23 18:39:04310 // ScheduleDraw(). Returns false if the paint request is ignored.
311 bool SchedulePaint(const gfx::Rect& invalid_rect);
[email protected]00b86982011-09-01 00:02:09312
[email protected]870119a2011-09-30 18:13:22313 // Schedules a redraw of the layer tree at the compositor.
[email protected]35470cc2012-02-23 23:04:31314 // Note that this _does not_ invalidate any region of this layer; use
315 // SchedulePaint() for that.
[email protected]870119a2011-09-30 18:13:22316 void ScheduleDraw();
317
[email protected]1e5da63d2014-01-16 22:44:00318 // Uses damaged rectangles recorded in |damaged_region_| to invalidate the
319 // |cc_layer_|.
[email protected]cedc3952012-03-06 06:15:55320 void SendDamagedRects();
[email protected]f78649ea2012-02-23 18:39:04321
[email protected]88fa18e82013-12-03 16:29:37322 const SkRegion& damaged_region() const { return damaged_region_; }
323
[email protected]9034a282014-06-05 03:11:47324 void CompleteAllAnimations();
325
[email protected]1e5da63d2014-01-16 22:44:00326 // Suppresses painting the content by disconnecting |delegate_|.
[email protected]f78649ea2012-02-23 18:39:04327 void SuppressPaint();
328
[email protected]cd9a61c72012-05-08 19:16:59329 // Notifies the layer that the device scale factor has changed.
330 void OnDeviceScaleFactorChanged(float device_scale_factor);
331
enne9a3ddb32014-08-23 21:27:46332 // Notifies the layer that one of its children has received a new
333 // delegated frame.
334 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip);
335
[email protected]a7fcdda32013-07-04 02:23:07336 // Requets a copy of the layer's output as a texture or bitmap.
337 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
338
[email protected]ec05af52012-11-21 23:07:00339 // ContentLayerClient
dcheng08038792014-10-21 10:53:26340 void PaintContents(
[email protected]276172b2014-05-02 21:03:03341 SkCanvas* canvas,
342 const gfx::Rect& clip,
mostynb3b3d52b2014-10-09 10:54:27343 ContentLayerClient::GraphicsContextStatus gc_status) override;
ajuma5e77f7d42014-11-27 14:19:14344 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList(
345 const gfx::Rect& clip,
346 GraphicsContextStatus gc_status) override;
dcheng08038792014-10-21 10:53:26347 bool FillsBoundsCompletely() const override;
[email protected]332749032011-10-22 00:32:46348
[email protected]ec05af52012-11-21 23:07:00349 cc::Layer* cc_layer() { return cc_layer_; }
[email protected]332749032011-10-22 00:32:46350
[email protected]ec05af52012-11-21 23:07:00351 // TextureLayerClient
dcheng08038792014-10-21 10:53:26352 bool PrepareTextureMailbox(
[email protected]9260757f2013-09-17 01:24:16353 cc::TextureMailbox* mailbox,
354 scoped_ptr<cc::SingleReleaseCallback>* release_callback,
mostynb3b3d52b2014-10-09 10:54:27355 bool use_shared_memory) override;
[email protected]7ba5f4b62012-08-25 01:19:36356
[email protected]cd9a61c72012-05-08 19:16:59357 float device_scale_factor() const { return device_scale_factor_; }
358
[email protected]09c01c12012-05-26 00:07:19359 // Forces a render surface to be used on this layer. This has no positive
360 // impact, and is only used for benchmarking/testing purpose.
361 void SetForceRenderSurface(bool force);
362 bool force_render_surface() const { return force_render_surface_; }
363
[email protected]29e17b02013-08-30 02:13:33364 // LayerClient
dcheng08038792014-10-21 10:53:26365 scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo() override;
[email protected]9f3be432013-12-03 03:53:22366
[email protected]bf912272013-02-23 01:54:16367 // LayerAnimationEventObserver
dcheng08038792014-10-21 10:53:26368 void OnAnimationStarted(const cc::AnimationEvent& event) override;
[email protected]bf912272013-02-23 01:54:16369
[email protected]f2891462013-03-11 23:26:51370 // Whether this layer has animations waiting to get sent to its cc::Layer.
371 bool HasPendingThreadedAnimations() {
372 return pending_threaded_animations_.size() != 0;
373 }
374
[email protected]ffd1ccb2013-03-15 07:48:24375 // Triggers a call to SwitchToLayer.
376 void SwitchCCLayerForTest();
377
[email protected]adc93fa72011-06-21 19:47:39378 private:
[email protected]07ae973e2014-03-05 18:51:10379 friend class LayerOwner;
380
[email protected]9034a282014-06-05 03:11:47381 void CollectAnimators(std::vector<scoped_refptr<LayerAnimator> >* animators);
382
[email protected]44c6f8d2011-12-27 23:49:04383 // Stacks |child| above or below |other|. Helper method for StackAbove() and
384 // StackBelow().
385 void StackRelativeTo(Layer* child, Layer* other, bool above);
386
[email protected]ad7258912011-08-29 20:33:53387 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const;
388 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const;
389
[email protected]fe7074c62011-10-28 15:22:54390 // Implementation of LayerAnimatorDelegate
dcheng08038792014-10-21 10:53:26391 void SetBoundsFromAnimation(const gfx::Rect& bounds) override;
392 void SetTransformFromAnimation(const gfx::Transform& transform) override;
393 void SetOpacityFromAnimation(float opacity) override;
394 void SetVisibilityFromAnimation(bool visibility) override;
395 void SetBrightnessFromAnimation(float brightness) override;
396 void SetGrayscaleFromAnimation(float grayscale) override;
397 void SetColorFromAnimation(SkColor color) override;
398 void ScheduleDrawForAnimation() override;
399 const gfx::Rect& GetBoundsForAnimation() const override;
400 gfx::Transform GetTransformForAnimation() const override;
401 float GetOpacityForAnimation() const override;
402 bool GetVisibilityForAnimation() const override;
403 float GetBrightnessForAnimation() const override;
404 float GetGrayscaleForAnimation() const override;
405 SkColor GetColorForAnimation() const override;
406 float GetDeviceScaleFactor() const override;
407 void AddThreadedAnimation(scoped_ptr<cc::Animation> animation) override;
408 void RemoveThreadedAnimation(int animation_id) override;
409 LayerAnimatorCollection* GetLayerAnimatorCollection() override;
[email protected]7fca53d42011-09-29 15:38:12410
[email protected]1e5da63d2014-01-16 22:44:00411 // Creates a corresponding composited layer for |type_|.
jbaumanf472c6872014-10-13 20:06:43412 void CreateCcLayer();
[email protected]1e5da63d2014-01-16 22:44:00413
414 // Recomputes and sets to |cc_layer_|.
[email protected]b9616d592011-11-14 20:04:42415 void RecomputeDrawsContentAndUVRect();
[email protected]b9cff562013-04-06 00:04:42416 void RecomputePosition();
[email protected]332749032011-10-22 00:32:46417
[email protected]e5da6622012-05-30 19:58:16418 // Set all filters which got applied to the layer.
419 void SetLayerFilters();
420
[email protected]77f7c132012-11-15 06:52:54421 // Set all filters which got applied to the layer background.
422 void SetLayerBackgroundFilters();
423
[email protected]1e5da63d2014-01-16 22:44:00424 // Cleanup |cc_layer_| and replaces it with |new_layer|.
[email protected]b14d40d2013-03-06 03:53:27425 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer);
426
[email protected]f2891462013-03-11 23:26:51427 // We cannot send animations to our cc_layer_ until we have been added to a
428 // layer tree. Instead, we hold on to these animations in
429 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to
430 // be called once we have been added to a tree.
431 void SendPendingThreadedAnimations();
432
[email protected]9034a282014-06-05 03:11:47433 void AddAnimatorsInTreeToCollection(LayerAnimatorCollection* collection);
434 void RemoveAnimatorsInTreeFromCollection(LayerAnimatorCollection* collection);
435
436 // Returns whether the layer has an animating LayerAnimator.
437 bool IsAnimating() const;
438
[email protected]993d6b322011-09-27 19:14:38439 const LayerType type_;
440
[email protected]adc93fa72011-06-21 19:47:39441 Compositor* compositor_;
442
[email protected]adc93fa72011-06-21 19:47:39443 Layer* parent_;
444
[email protected]ebc335f2011-11-23 00:43:51445 // This layer's children, in bottom-to-top stacking order.
[email protected]adc93fa72011-06-21 19:47:39446 std::vector<Layer*> children_;
447
[email protected]adc93fa72011-06-21 19:47:39448 gfx::Rect bounds_;
[email protected]ea2910152014-06-10 12:32:35449 gfx::Vector2dF subpixel_position_offset_;
[email protected]adc93fa72011-06-21 19:47:39450
[email protected]e4e8afef2011-10-05 13:58:33451 // Visibility of this layer. See SetVisible/IsDrawn for more details.
[email protected]3aa43942011-09-13 20:59:53452 bool visible_;
453
[email protected]09c01c12012-05-26 00:07:19454 bool force_render_surface_;
455
[email protected]c155c252011-07-29 16:17:55456 bool fills_bounds_opaquely_;
[email protected]1d96e032014-03-25 05:59:08457 bool fills_bounds_completely_;
[email protected]c155c252011-07-29 16:17:55458
[email protected]cd9a61c72012-05-08 19:16:59459 // Union of damaged rects, in pixel coordinates, to be used when
460 // compositor is ready to paint the content.
[email protected]cedc3952012-03-06 06:15:55461 SkRegion damaged_region_;
[email protected]f78649ea2012-02-23 18:39:04462
[email protected]2a6c5672012-04-23 19:37:09463 int background_blur_radius_;
[email protected]e5da6622012-05-30 19:58:16464
465 // Several variables which will change the visible representation of
466 // the layer.
467 float layer_saturation_;
468 float layer_brightness_;
[email protected]815d0c382012-07-21 08:13:44469 float layer_grayscale_;
[email protected]e5da6622012-05-30 19:58:16470 bool layer_inverted_;
[email protected]b4bb9ca2011-09-23 20:53:14471
[email protected]c0dc4b172014-01-07 11:24:09472 // The associated mask layer with this layer.
473 Layer* layer_mask_;
474 // The back link from the mask layer to it's associated masked layer.
475 // We keep this reference for the case that if the mask layer gets deleted
476 // while attached to the main layer before the main layer is deleted.
477 Layer* layer_mask_back_link_;
[email protected]498e623c2012-07-12 21:12:42478
[email protected]77f7c132012-11-15 06:52:54479 // The zoom factor to scale the layer by. Zooming is disabled when this is
480 // set to 1.
481 float zoom_;
482
483 // Width of the border in pixels, where the scaling is blended.
484 int zoom_inset_;
485
[email protected]fbb145c2014-04-16 19:21:28486 // Shape of the window.
487 scoped_ptr<SkRegion> alpha_shape_;
488
[email protected]33699e622011-11-17 18:29:30489 std::string name_;
490
[email protected]00b86982011-09-01 00:02:09491 LayerDelegate* delegate_;
492
[email protected]07ae973e2014-03-05 18:51:10493 LayerOwner* owner_;
494
[email protected]5d86a112012-09-23 00:21:58495 scoped_refptr<LayerAnimator> animator_;
[email protected]7fca53d42011-09-29 15:38:12496
[email protected]f2891462013-03-11 23:26:51497 // Animations that are passed to AddThreadedAnimation before this layer is
498 // added to a tree.
499 cc::ScopedPtrVector<cc::Animation> pending_threaded_animations_;
500
[email protected]66efabe2012-08-18 03:06:06501 // Ownership of the layer is held through one of the strongly typed layer
502 // pointers, depending on which sort of layer this is.
[email protected]dafdf5052014-03-13 17:02:57503 scoped_refptr<cc::Layer> content_layer_;
[email protected]98a59132014-07-16 22:49:52504 scoped_refptr<cc::NinePatchLayer> nine_patch_layer_;
[email protected]ec05af52012-11-21 23:07:00505 scoped_refptr<cc::TextureLayer> texture_layer_;
506 scoped_refptr<cc::SolidColorLayer> solid_color_layer_;
[email protected]b14d40d2013-03-06 03:53:27507 scoped_refptr<cc::DelegatedRendererLayer> delegated_renderer_layer_;
[email protected]ca2c3ea2014-07-26 19:35:30508 scoped_refptr<cc::SurfaceLayer> surface_layer_;
[email protected]ec05af52012-11-21 23:07:00509 cc::Layer* cc_layer_;
[email protected]332749032011-10-22 00:32:46510
[email protected]cd9a61c72012-05-08 19:16:59511 // A cached copy of |Compositor::device_scale_factor()|.
512 float device_scale_factor_;
513
[email protected]4508b152014-04-09 22:14:17514 // The mailbox used by texture_layer_.
[email protected]42f40a52013-06-08 04:38:51515 cc::TextureMailbox mailbox_;
516
[email protected]4508b152014-04-09 22:14:17517 // The callback to release the mailbox. This is only set after
518 // SetTextureMailbox is called, before we give it to the TextureLayer.
519 scoped_ptr<cc::SingleReleaseCallback> mailbox_release_callback_;
[email protected]42f40a52013-06-08 04:38:51520
[email protected]4508b152014-04-09 22:14:17521 // The size of the frame or texture in DIP, set when SetShowDelegatedContent
522 // or SetTextureMailbox was called.
523 gfx::Size frame_size_in_dip_;
[email protected]b14d40d2013-03-06 03:53:27524
[email protected]adc93fa72011-06-21 19:47:39525 DISALLOW_COPY_AND_ASSIGN(Layer);
526};
527
528} // namespace ui
529
[email protected]116302fc2012-05-05 21:45:41530#endif // UI_COMPOSITOR_LAYER_H_