blob: 5d7d3ec23349e872fbdfcf6a89fe0feed41e32f6 [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"
[email protected]cc3cfaa2013-03-18 09:05:5220#include "cc/layers/texture_layer_client.h"
[email protected]42f40a52013-06-08 04:38:5121#include "cc/resources/texture_mailbox.h"
[email protected]ca2c3ea2014-07-26 19:35:3022#include "cc/surfaces/surface_id.h"
[email protected]116302fc2012-05-05 21:45:4123#include "third_party/skia/include/core/SkColor.h"
24#include "third_party/skia/include/core/SkRegion.h"
25#include "ui/compositor/compositor.h"
26#include "ui/compositor/layer_animation_delegate.h"
27#include "ui/compositor/layer_delegate.h"
28#include "ui/compositor/layer_type.h"
[email protected]adc93fa72011-06-21 19:47:3929#include "ui/gfx/rect.h"
30#include "ui/gfx/transform.h"
31
[email protected]892ad8a2011-07-27 02:47:2232class SkCanvas;
[email protected]adc93fa72011-06-21 19:47:3933
[email protected]ec05af52012-11-21 23:07:0034namespace cc {
35class ContentLayer;
[email protected]a7fcdda32013-07-04 02:23:0736class CopyOutputRequest;
[email protected]09f67382013-10-09 21:03:4537class DelegatedFrameProvider;
[email protected]b14d40d2013-03-06 03:53:2738class DelegatedRendererLayer;
[email protected]ec05af52012-11-21 23:07:0039class Layer;
[email protected]98a59132014-07-16 22:49:5240class NinePatchLayer;
[email protected]ec05af52012-11-21 23:07:0041class ResourceUpdateQueue;
42class SolidColorLayer;
[email protected]ca2c3ea2014-07-26 19:35:3043class SurfaceLayer;
[email protected]ec05af52012-11-21 23:07:0044class TextureLayer;
[email protected]e00bab022013-08-19 00:42:4545struct ReturnedResource;
46typedef std::vector<ReturnedResource> ReturnedResourceArray;
[email protected]ec05af52012-11-21 23:07:0047}
48
[email protected]adc93fa72011-06-21 19:47:3949namespace ui {
50
51class Compositor;
[email protected]fe7074c62011-10-28 15:22:5452class LayerAnimator;
[email protected]07ae973e2014-03-05 18:51:1053class LayerOwner;
[email protected]adc93fa72011-06-21 19:47:3954
55// Layer manages a texture, transform and a set of child Layers. Any View that
56// has enabled layers ends up creating a Layer to manage the texture.
[email protected]28cd2bb2011-09-19 21:04:1957// A Layer can also be created without a texture, in which case it renders
58// nothing and is simply used as a node in a hierarchy of layers.
[email protected]cd9a61c72012-05-08 19:16:5959// Coordinate system used in layers is DIP (Density Independent Pixel)
60// coordinates unless explicitly mentioned as pixel coordinates.
[email protected]adc93fa72011-06-21 19:47:3961//
[email protected]ae2202a2014-01-07 11:11:1062// NOTE: Unlike Views, each Layer does *not* own its child Layers. If you
63// delete a Layer and it has children, the parent of each child Layer is set to
[email protected]adc93fa72011-06-21 19:47:3964// NULL, but the children are not deleted.
[email protected]2700daddd2012-07-13 19:35:3765class COMPOSITOR_EXPORT Layer
66 : public LayerAnimationDelegate,
[email protected]ec05af52012-11-21 23:07:0067 NON_EXPORTED_BASE(public cc::ContentLayerClient),
[email protected]bf912272013-02-23 01:54:1668 NON_EXPORTED_BASE(public cc::TextureLayerClient),
[email protected]29e17b02013-08-30 02:13:3369 NON_EXPORTED_BASE(public cc::LayerClient),
[email protected]bf912272013-02-23 01:54:1670 NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) {
[email protected]adc93fa72011-06-21 19:47:3971 public:
[email protected]7ab3f272011-11-16 00:51:5672 Layer();
73 explicit Layer(LayerType type);
dcheng08038792014-10-21 10:53:2674 ~Layer() override;
[email protected]adc93fa72011-06-21 19:47:3975
[email protected]dafdf5052014-03-13 17:02:5776 static bool UsingPictureLayer();
77
[email protected]993d6b322011-09-27 19:14:3878 // Retrieves the Layer's compositor. The Layer will walk up its parent chain
79 // to locate it. Returns NULL if the Layer is not attached to a compositor.
sky6dd206092014-10-29 17:26:1680 Compositor* GetCompositor() {
81 return const_cast<Compositor*>(
82 const_cast<const Layer*>(this)->GetCompositor());
83 }
84 const Compositor* GetCompositor() const;
[email protected]993d6b322011-09-27 19:14:3885
86 // Called by the compositor when the Layer is set as its root Layer. This can
87 // only ever be called on the root layer.
88 void SetCompositor(Compositor* compositor);
89
[email protected]00b86982011-09-01 00:02:0990 LayerDelegate* delegate() { return delegate_; }
91 void set_delegate(LayerDelegate* delegate) { delegate_ = delegate; }
92
[email protected]07ae973e2014-03-05 18:51:1093 LayerOwner* owner() { return owner_; }
94
[email protected]adc93fa72011-06-21 19:47:3995 // Adds a new Layer to this Layer.
96 void Add(Layer* child);
97
98 // Removes a Layer from this Layer.
99 void Remove(Layer* child);
100
[email protected]5e4e61f2011-11-22 16:55:24101 // Stacks |child| above all other children.
102 void StackAtTop(Layer* child);
[email protected]18dab372011-10-03 21:21:44103
[email protected]ebc335f2011-11-23 00:43:51104 // Stacks |child| directly above |other|. Both must be children of this
105 // layer. Note that if |child| is initially stacked even higher, calling this
106 // method will result in |child| being lowered in the stacking order.
[email protected]5e4e61f2011-11-22 16:55:24107 void StackAbove(Layer* child, Layer* other);
[email protected]62dd7ea2011-11-08 15:51:47108
[email protected]44c6f8d2011-12-27 23:49:04109 // Stacks |child| below all other children.
110 void StackAtBottom(Layer* child);
111
112 // Stacks |child| directly below |other|. Both must be children of this
113 // layer.
114 void StackBelow(Layer* child, Layer* other);
115
[email protected]adc93fa72011-06-21 19:47:39116 // Returns the child Layers.
[email protected]25ae9a12011-10-12 14:55:22117 const std::vector<Layer*>& children() const { return children_; }
[email protected]adc93fa72011-06-21 19:47:39118
119 // The parent.
120 const Layer* parent() const { return parent_; }
121 Layer* parent() { return parent_; }
122
[email protected]036e6c972012-01-03 18:48:05123 LayerType type() const { return type_; }
124
[email protected]ad7258912011-08-29 20:33:53125 // Returns true if this Layer contains |other| somewhere in its children.
126 bool Contains(const Layer* other) const;
127
[email protected]fe7074c62011-10-28 15:22:54128 // The layer's animator is responsible for causing automatic animations when
129 // properties are set. It also manages a queue of pending animations and
130 // handles blending of animations. The layer takes ownership of the animator.
131 void SetAnimator(LayerAnimator* animator);
132
133 // Returns the layer's animator. Creates a default animator of one has not
134 // been set. Will not return NULL.
135 LayerAnimator* GetAnimator();
[email protected]7fca53d42011-09-29 15:38:12136
[email protected]adc93fa72011-06-21 19:47:39137 // The transform, relative to the parent.
[email protected]0f0453e2012-10-14 18:15:35138 void SetTransform(const gfx::Transform& transform);
[email protected]712f4b642013-03-14 07:09:15139 gfx::Transform transform() const;
[email protected]fe7074c62011-10-28 15:22:54140
141 // Return the target transform if animator is running, or the current
142 // transform otherwise.
[email protected]0f0453e2012-10-14 18:15:35143 gfx::Transform GetTargetTransform() const;
[email protected]adc93fa72011-06-21 19:47:39144
145 // The bounds, relative to the parent.
[email protected]c155c252011-07-29 16:17:55146 void SetBounds(const gfx::Rect& bounds);
[email protected]adc93fa72011-06-21 19:47:39147 const gfx::Rect& bounds() const { return bounds_; }
148
[email protected]ea2910152014-06-10 12:32:35149 // The offset from our parent (stored in bounds.origin()) is an integer but we
150 // may need to be at a fractional pixel offset to align properly on screen.
151 void SetSubpixelPositionOffset(const gfx::Vector2dF offset);
[email protected]e09c592ff2014-07-17 06:55:07152 const gfx::Vector2dF& subpixel_position_offset() const {
153 return subpixel_position_offset_;
154 }
[email protected]ea2910152014-06-10 12:32:35155
[email protected]5ba9d5f2011-10-20 01:58:33156 // Return the target bounds if animator is running, or the current bounds
157 // otherwise.
158 gfx::Rect GetTargetBounds() const;
159
[email protected]7adee632012-03-15 19:15:08160 // Sets/gets whether or not drawing of child layers should be clipped to the
161 // bounds of this layer.
162 void SetMasksToBounds(bool masks_to_bounds);
163 bool GetMasksToBounds() const;
164
[email protected]7fca53d42011-09-29 15:38:12165 // The opacity of the layer. The opacity is applied to each pixel of the
166 // texture (resulting alpha = opacity * alpha).
[email protected]bf912272013-02-23 01:54:16167 float opacity() const;
[email protected]7fca53d42011-09-29 15:38:12168 void SetOpacity(float opacity);
169
[email protected]fb4d9d12012-08-24 00:44:54170 // Returns the actual opacity, which the opacity of this layer multipled by
171 // the combined opacity of the parent.
172 float GetCombinedOpacity() const;
173
[email protected]2a6c5672012-04-23 19:37:09174 // Blur pixels by this amount in anything below the layer and visible through
175 // the layer.
176 int background_blur() const { return background_blur_radius_; }
177 void SetBackgroundBlur(int blur_radius);
178
[email protected]e5da6622012-05-30 19:58:16179 // Saturate all pixels of this layer by this amount.
[email protected]815d0c382012-07-21 08:13:44180 // This effect will get "combined" with the inverted,
181 // brightness and grayscale setting.
[email protected]e5da6622012-05-30 19:58:16182 float layer_saturation() const { return layer_saturation_; }
183 void SetLayerSaturation(float saturation);
184
185 // Change the brightness of all pixels from this layer by this amount.
[email protected]815d0c382012-07-21 08:13:44186 // This effect will get "combined" with the inverted, saturate
187 // and grayscale setting.
[email protected]e5da6622012-05-30 19:58:16188 float layer_brightness() const { return layer_brightness_; }
189 void SetLayerBrightness(float brightness);
190
[email protected]815d0c382012-07-21 08:13:44191 // Return the target brightness if animator is running, or the current
192 // brightness otherwise.
193 float GetTargetBrightness() const;
194
195 // Change the grayscale of all pixels from this layer by this amount.
196 // This effect will get "combined" with the inverted, saturate
197 // and brightness setting.
198 float layer_grayscale() const { return layer_grayscale_; }
199 void SetLayerGrayscale(float grayscale);
200
201 // Return the target grayscale if animator is running, or the current
202 // grayscale otherwise.
203 float GetTargetGrayscale() const;
204
[email protected]56322be2013-03-13 18:27:37205 // Zoom the background by a factor of |zoom|. The effect is blended along the
206 // edge across |inset| pixels.
207 void SetBackgroundZoom(float zoom, int inset);
[email protected]77f7c132012-11-15 06:52:54208
[email protected]fbb145c2014-04-16 19:21:28209 // Set the shape of this layer.
jackhou1d1fa232014-09-11 01:18:41210 SkRegion* alpha_shape() const { return alpha_shape_.get(); }
[email protected]fbb145c2014-04-16 19:21:28211 void SetAlphaShape(scoped_ptr<SkRegion> region);
212
[email protected]f48075d2012-05-24 11:06:51213 // Invert the layer.
[email protected]e5da6622012-05-30 19:58:16214 bool layer_inverted() const { return layer_inverted_; }
215 void SetLayerInverted(bool inverted);
[email protected]f48075d2012-05-24 11:06:51216
[email protected]3f1f5e6a2011-11-11 15:09:02217 // Return the target opacity if animator is running, or the current opacity
[email protected]fe7074c62011-10-28 15:22:54218 // otherwise.
219 float GetTargetOpacity() const;
220
[email protected]498e623c2012-07-12 21:12:42221 // Set a layer mask for a layer.
222 // Note the provided layer mask can neither have a layer mask itself nor can
[email protected]c0dc4b172014-01-07 11:24:09223 // it have any children. The ownership of |layer_mask| will not be
224 // transferred with this call.
[email protected]498e623c2012-07-12 21:12:42225 // Furthermore: A mask layer can only be set to one layer.
[email protected]c0dc4b172014-01-07 11:24:09226 void SetMaskLayer(Layer* layer_mask);
227 Layer* layer_mask_layer() { return layer_mask_; }
[email protected]498e623c2012-07-12 21:12:42228
[email protected]e4e8afef2011-10-05 13:58:33229 // Sets the visibility of the Layer. A Layer may be visible but not
230 // drawn. This happens if any ancestor of a Layer is not visible.
[email protected]993d6b322011-09-27 19:14:38231 void SetVisible(bool visible);
[email protected]f941f47a2011-10-15 18:44:51232 bool visible() const { return visible_; }
[email protected]3aa43942011-09-13 20:59:53233
[email protected]a67935f2012-02-10 14:26:24234 // Returns the target visibility if the animator is running. Otherwise, it
235 // returns the current visibility.
236 bool GetTargetVisibility() const;
237
[email protected]e4e8afef2011-10-05 13:58:33238 // Returns true if this Layer is drawn. A Layer is drawn only if all ancestors
239 // are visible.
240 bool IsDrawn() const;
241
[email protected]c1f67302011-09-27 14:18:09242 // Returns true if this layer can have a texture (has_texture_ is true)
243 // and is not completely obscured by a child.
[email protected]332749032011-10-22 00:32:46244 bool ShouldDraw() const;
[email protected]c1f67302011-09-27 14:18:09245
[email protected]ad7258912011-08-29 20:33:53246 // Converts a point from the coordinates of |source| to the coordinates of
247 // |target|. Necessarily, |source| and |target| must inhabit the same Layer
248 // tree.
249 static void ConvertPointToLayer(const Layer* source,
250 const Layer* target,
251 gfx::Point* point);
252
[email protected]bdcf3bbf2013-03-25 18:39:03253 // Converts a transform to be relative to the given |ancestor|. Returns
254 // whether success (that is, whether the given ancestor was really an
255 // ancestor of this layer).
256 bool GetTargetTransformRelativeTo(const Layer* ancestor,
257 gfx::Transform* transform) const;
258
[email protected]c155c252011-07-29 16:17:55259 // See description in View for details
260 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely);
261 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; }
262
[email protected]1d96e032014-03-25 05:59:08263 // Set to true if this layer always paints completely within its bounds. If so
264 // we can omit an unnecessary clear, even if the layer is transparent.
265 void SetFillsBoundsCompletely(bool fills_bounds_completely);
266
[email protected]33699e622011-11-17 18:29:30267 const std::string& name() const { return name_; }
268 void set_name(const std::string& name) { name_ = name; }
269
[email protected]42f40a52013-06-08 04:38:51270 // Set new TextureMailbox for this layer. Note that |mailbox| may hold a
271 // shared memory resource or an actual mailbox for a texture.
[email protected]9260757f2013-09-17 01:24:16272 void SetTextureMailbox(const cc::TextureMailbox& mailbox,
273 scoped_ptr<cc::SingleReleaseCallback> release_callback,
[email protected]4508b152014-04-09 22:14:17274 gfx::Size texture_size_in_dip);
275 void SetTextureSize(gfx::Size texture_size_in_dip);
[email protected]42f40a52013-06-08 04:38:51276
[email protected]09f67382013-10-09 21:03:45277 // Begins showing delegated frames from the |frame_provider|.
278 void SetShowDelegatedContent(cc::DelegatedFrameProvider* frame_provider,
279 gfx::Size frame_size_in_dip);
[email protected]b14d40d2013-03-06 03:53:27280
[email protected]ca2c3ea2014-07-26 19:35:30281 // Begins showing content from a surface with a particular id.
282 void SetShowSurface(cc::SurfaceId id, gfx::Size frame_size_in_dip);
283
[email protected]a7fcdda32013-07-04 02:23:07284 bool has_external_content() {
[email protected]ca2c3ea2014-07-26 19:35:30285 return texture_layer_.get() || delegated_renderer_layer_.get() ||
286 surface_layer_.get();
[email protected]a7fcdda32013-07-04 02:23:07287 }
288
jbaumanf472c6872014-10-13 20:06:43289 // Show a solid color instead of delegated or surface contents.
290 void SetShowSolidColorContent();
[email protected]785b0af2013-10-02 18:08:41291
[email protected]da7584c2012-01-28 03:19:12292 // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR.
293 void SetColor(SkColor color);
294
hshid89c83ac2014-09-19 17:39:28295 // Updates the nine patch layer's bitmap, aperture and border. May only be
296 // called for LAYER_NINE_PATCH.
297 void UpdateNinePatchLayerBitmap(const SkBitmap& bitmap);
298 void UpdateNinePatchLayerAperture(const gfx::Rect& aperture);
[email protected]98a59132014-07-16 22:49:52299 void UpdateNinePatchLayerBorder(const gfx::Rect& border);
300
[email protected]870119a2011-09-30 18:13:22301 // Adds |invalid_rect| to the Layer's pending invalid rect and calls
[email protected]f78649ea2012-02-23 18:39:04302 // ScheduleDraw(). Returns false if the paint request is ignored.
303 bool SchedulePaint(const gfx::Rect& invalid_rect);
[email protected]00b86982011-09-01 00:02:09304
[email protected]870119a2011-09-30 18:13:22305 // Schedules a redraw of the layer tree at the compositor.
[email protected]35470cc2012-02-23 23:04:31306 // Note that this _does not_ invalidate any region of this layer; use
307 // SchedulePaint() for that.
[email protected]870119a2011-09-30 18:13:22308 void ScheduleDraw();
309
[email protected]1e5da63d2014-01-16 22:44:00310 // Uses damaged rectangles recorded in |damaged_region_| to invalidate the
311 // |cc_layer_|.
[email protected]cedc3952012-03-06 06:15:55312 void SendDamagedRects();
[email protected]f78649ea2012-02-23 18:39:04313
[email protected]88fa18e82013-12-03 16:29:37314 const SkRegion& damaged_region() const { return damaged_region_; }
315
[email protected]9034a282014-06-05 03:11:47316 void CompleteAllAnimations();
317
[email protected]1e5da63d2014-01-16 22:44:00318 // Suppresses painting the content by disconnecting |delegate_|.
[email protected]f78649ea2012-02-23 18:39:04319 void SuppressPaint();
320
[email protected]cd9a61c72012-05-08 19:16:59321 // Notifies the layer that the device scale factor has changed.
322 void OnDeviceScaleFactorChanged(float device_scale_factor);
323
enne9a3ddb32014-08-23 21:27:46324 // Notifies the layer that one of its children has received a new
325 // delegated frame.
326 void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip);
327
[email protected]a7fcdda32013-07-04 02:23:07328 // Requets a copy of the layer's output as a texture or bitmap.
329 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
330
[email protected]ec05af52012-11-21 23:07:00331 // ContentLayerClient
dcheng08038792014-10-21 10:53:26332 void PaintContents(
[email protected]276172b2014-05-02 21:03:03333 SkCanvas* canvas,
334 const gfx::Rect& clip,
mostynb3b3d52b2014-10-09 10:54:27335 ContentLayerClient::GraphicsContextStatus gc_status) override;
dcheng08038792014-10-21 10:53:26336 void DidChangeLayerCanUseLCDText() override {}
337 bool FillsBoundsCompletely() const override;
[email protected]332749032011-10-22 00:32:46338
[email protected]ec05af52012-11-21 23:07:00339 cc::Layer* cc_layer() { return cc_layer_; }
[email protected]332749032011-10-22 00:32:46340
[email protected]ec05af52012-11-21 23:07:00341 // TextureLayerClient
dcheng08038792014-10-21 10:53:26342 bool PrepareTextureMailbox(
[email protected]9260757f2013-09-17 01:24:16343 cc::TextureMailbox* mailbox,
344 scoped_ptr<cc::SingleReleaseCallback>* release_callback,
mostynb3b3d52b2014-10-09 10:54:27345 bool use_shared_memory) override;
[email protected]7ba5f4b62012-08-25 01:19:36346
[email protected]cd9a61c72012-05-08 19:16:59347 float device_scale_factor() const { return device_scale_factor_; }
348
[email protected]09c01c12012-05-26 00:07:19349 // Forces a render surface to be used on this layer. This has no positive
350 // impact, and is only used for benchmarking/testing purpose.
351 void SetForceRenderSurface(bool force);
352 bool force_render_surface() const { return force_render_surface_; }
353
[email protected]29e17b02013-08-30 02:13:33354 // LayerClient
dcheng08038792014-10-21 10:53:26355 scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo() override;
[email protected]9f3be432013-12-03 03:53:22356
[email protected]bf912272013-02-23 01:54:16357 // LayerAnimationEventObserver
dcheng08038792014-10-21 10:53:26358 void OnAnimationStarted(const cc::AnimationEvent& event) override;
[email protected]bf912272013-02-23 01:54:16359
[email protected]f2891462013-03-11 23:26:51360 // Whether this layer has animations waiting to get sent to its cc::Layer.
361 bool HasPendingThreadedAnimations() {
362 return pending_threaded_animations_.size() != 0;
363 }
364
[email protected]ffd1ccb2013-03-15 07:48:24365 // Triggers a call to SwitchToLayer.
366 void SwitchCCLayerForTest();
367
[email protected]adc93fa72011-06-21 19:47:39368 private:
[email protected]07ae973e2014-03-05 18:51:10369 friend class LayerOwner;
370
[email protected]9034a282014-06-05 03:11:47371 void CollectAnimators(std::vector<scoped_refptr<LayerAnimator> >* animators);
372
[email protected]44c6f8d2011-12-27 23:49:04373 // Stacks |child| above or below |other|. Helper method for StackAbove() and
374 // StackBelow().
375 void StackRelativeTo(Layer* child, Layer* other, bool above);
376
[email protected]ad7258912011-08-29 20:33:53377 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const;
378 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const;
379
[email protected]fe7074c62011-10-28 15:22:54380 // Implementation of LayerAnimatorDelegate
dcheng08038792014-10-21 10:53:26381 void SetBoundsFromAnimation(const gfx::Rect& bounds) override;
382 void SetTransformFromAnimation(const gfx::Transform& transform) override;
383 void SetOpacityFromAnimation(float opacity) override;
384 void SetVisibilityFromAnimation(bool visibility) override;
385 void SetBrightnessFromAnimation(float brightness) override;
386 void SetGrayscaleFromAnimation(float grayscale) override;
387 void SetColorFromAnimation(SkColor color) override;
388 void ScheduleDrawForAnimation() override;
389 const gfx::Rect& GetBoundsForAnimation() const override;
390 gfx::Transform GetTransformForAnimation() const override;
391 float GetOpacityForAnimation() const override;
392 bool GetVisibilityForAnimation() const override;
393 float GetBrightnessForAnimation() const override;
394 float GetGrayscaleForAnimation() const override;
395 SkColor GetColorForAnimation() const override;
396 float GetDeviceScaleFactor() const override;
397 void AddThreadedAnimation(scoped_ptr<cc::Animation> animation) override;
398 void RemoveThreadedAnimation(int animation_id) override;
399 LayerAnimatorCollection* GetLayerAnimatorCollection() override;
[email protected]7fca53d42011-09-29 15:38:12400
[email protected]1e5da63d2014-01-16 22:44:00401 // Creates a corresponding composited layer for |type_|.
jbaumanf472c6872014-10-13 20:06:43402 void CreateCcLayer();
[email protected]1e5da63d2014-01-16 22:44:00403
404 // Recomputes and sets to |cc_layer_|.
[email protected]b9616d592011-11-14 20:04:42405 void RecomputeDrawsContentAndUVRect();
[email protected]b9cff562013-04-06 00:04:42406 void RecomputePosition();
[email protected]332749032011-10-22 00:32:46407
[email protected]e5da6622012-05-30 19:58:16408 // Set all filters which got applied to the layer.
409 void SetLayerFilters();
410
[email protected]77f7c132012-11-15 06:52:54411 // Set all filters which got applied to the layer background.
412 void SetLayerBackgroundFilters();
413
[email protected]1e5da63d2014-01-16 22:44:00414 // Cleanup |cc_layer_| and replaces it with |new_layer|.
[email protected]b14d40d2013-03-06 03:53:27415 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer);
416
[email protected]f2891462013-03-11 23:26:51417 // We cannot send animations to our cc_layer_ until we have been added to a
418 // layer tree. Instead, we hold on to these animations in
419 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to
420 // be called once we have been added to a tree.
421 void SendPendingThreadedAnimations();
422
[email protected]9034a282014-06-05 03:11:47423 void AddAnimatorsInTreeToCollection(LayerAnimatorCollection* collection);
424 void RemoveAnimatorsInTreeFromCollection(LayerAnimatorCollection* collection);
425
426 // Returns whether the layer has an animating LayerAnimator.
427 bool IsAnimating() const;
428
[email protected]993d6b322011-09-27 19:14:38429 const LayerType type_;
430
[email protected]adc93fa72011-06-21 19:47:39431 Compositor* compositor_;
432
[email protected]adc93fa72011-06-21 19:47:39433 Layer* parent_;
434
[email protected]ebc335f2011-11-23 00:43:51435 // This layer's children, in bottom-to-top stacking order.
[email protected]adc93fa72011-06-21 19:47:39436 std::vector<Layer*> children_;
437
[email protected]adc93fa72011-06-21 19:47:39438 gfx::Rect bounds_;
[email protected]ea2910152014-06-10 12:32:35439 gfx::Vector2dF subpixel_position_offset_;
[email protected]adc93fa72011-06-21 19:47:39440
[email protected]e4e8afef2011-10-05 13:58:33441 // Visibility of this layer. See SetVisible/IsDrawn for more details.
[email protected]3aa43942011-09-13 20:59:53442 bool visible_;
443
[email protected]09c01c12012-05-26 00:07:19444 bool force_render_surface_;
445
[email protected]c155c252011-07-29 16:17:55446 bool fills_bounds_opaquely_;
[email protected]1d96e032014-03-25 05:59:08447 bool fills_bounds_completely_;
[email protected]c155c252011-07-29 16:17:55448
[email protected]cd9a61c72012-05-08 19:16:59449 // Union of damaged rects, in pixel coordinates, to be used when
450 // compositor is ready to paint the content.
[email protected]cedc3952012-03-06 06:15:55451 SkRegion damaged_region_;
[email protected]f78649ea2012-02-23 18:39:04452
[email protected]2a6c5672012-04-23 19:37:09453 int background_blur_radius_;
[email protected]e5da6622012-05-30 19:58:16454
455 // Several variables which will change the visible representation of
456 // the layer.
457 float layer_saturation_;
458 float layer_brightness_;
[email protected]815d0c382012-07-21 08:13:44459 float layer_grayscale_;
[email protected]e5da6622012-05-30 19:58:16460 bool layer_inverted_;
[email protected]b4bb9ca2011-09-23 20:53:14461
[email protected]c0dc4b172014-01-07 11:24:09462 // The associated mask layer with this layer.
463 Layer* layer_mask_;
464 // The back link from the mask layer to it's associated masked layer.
465 // We keep this reference for the case that if the mask layer gets deleted
466 // while attached to the main layer before the main layer is deleted.
467 Layer* layer_mask_back_link_;
[email protected]498e623c2012-07-12 21:12:42468
[email protected]77f7c132012-11-15 06:52:54469 // The zoom factor to scale the layer by. Zooming is disabled when this is
470 // set to 1.
471 float zoom_;
472
473 // Width of the border in pixels, where the scaling is blended.
474 int zoom_inset_;
475
[email protected]fbb145c2014-04-16 19:21:28476 // Shape of the window.
477 scoped_ptr<SkRegion> alpha_shape_;
478
[email protected]33699e622011-11-17 18:29:30479 std::string name_;
480
[email protected]00b86982011-09-01 00:02:09481 LayerDelegate* delegate_;
482
[email protected]07ae973e2014-03-05 18:51:10483 LayerOwner* owner_;
484
[email protected]5d86a112012-09-23 00:21:58485 scoped_refptr<LayerAnimator> animator_;
[email protected]7fca53d42011-09-29 15:38:12486
[email protected]f2891462013-03-11 23:26:51487 // Animations that are passed to AddThreadedAnimation before this layer is
488 // added to a tree.
489 cc::ScopedPtrVector<cc::Animation> pending_threaded_animations_;
490
[email protected]66efabe2012-08-18 03:06:06491 // Ownership of the layer is held through one of the strongly typed layer
492 // pointers, depending on which sort of layer this is.
[email protected]dafdf5052014-03-13 17:02:57493 scoped_refptr<cc::Layer> content_layer_;
[email protected]98a59132014-07-16 22:49:52494 scoped_refptr<cc::NinePatchLayer> nine_patch_layer_;
[email protected]ec05af52012-11-21 23:07:00495 scoped_refptr<cc::TextureLayer> texture_layer_;
496 scoped_refptr<cc::SolidColorLayer> solid_color_layer_;
[email protected]b14d40d2013-03-06 03:53:27497 scoped_refptr<cc::DelegatedRendererLayer> delegated_renderer_layer_;
[email protected]ca2c3ea2014-07-26 19:35:30498 scoped_refptr<cc::SurfaceLayer> surface_layer_;
[email protected]ec05af52012-11-21 23:07:00499 cc::Layer* cc_layer_;
[email protected]332749032011-10-22 00:32:46500
[email protected]cd9a61c72012-05-08 19:16:59501 // A cached copy of |Compositor::device_scale_factor()|.
502 float device_scale_factor_;
503
[email protected]4508b152014-04-09 22:14:17504 // The mailbox used by texture_layer_.
[email protected]42f40a52013-06-08 04:38:51505 cc::TextureMailbox mailbox_;
506
[email protected]4508b152014-04-09 22:14:17507 // The callback to release the mailbox. This is only set after
508 // SetTextureMailbox is called, before we give it to the TextureLayer.
509 scoped_ptr<cc::SingleReleaseCallback> mailbox_release_callback_;
[email protected]42f40a52013-06-08 04:38:51510
[email protected]4508b152014-04-09 22:14:17511 // The size of the frame or texture in DIP, set when SetShowDelegatedContent
512 // or SetTextureMailbox was called.
513 gfx::Size frame_size_in_dip_;
[email protected]b14d40d2013-03-06 03:53:27514
[email protected]adc93fa72011-06-21 19:47:39515 DISALLOW_COPY_AND_ASSIGN(Layer);
516};
517
518} // namespace ui
519
[email protected]116302fc2012-05-05 21:45:41520#endif // UI_COMPOSITOR_LAYER_H_