blob: 9224f37689a05eb1a03483b793424925d4fe7811 [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]116302fc2012-05-05 21:45:4122#include "third_party/skia/include/core/SkColor.h"
23#include "third_party/skia/include/core/SkRegion.h"
24#include "ui/compositor/compositor.h"
25#include "ui/compositor/layer_animation_delegate.h"
26#include "ui/compositor/layer_delegate.h"
27#include "ui/compositor/layer_type.h"
[email protected]adc93fa72011-06-21 19:47:3928#include "ui/gfx/rect.h"
29#include "ui/gfx/transform.h"
30
[email protected]892ad8a2011-07-27 02:47:2231class SkCanvas;
[email protected]adc93fa72011-06-21 19:47:3932
[email protected]ec05af52012-11-21 23:07:0033namespace cc {
34class ContentLayer;
[email protected]a7fcdda32013-07-04 02:23:0735class CopyOutputRequest;
[email protected]09f67382013-10-09 21:03:4536class DelegatedFrameProvider;
[email protected]b14d40d2013-03-06 03:53:2737class DelegatedRendererLayer;
[email protected]ec05af52012-11-21 23:07:0038class Layer;
39class ResourceUpdateQueue;
40class SolidColorLayer;
41class TextureLayer;
[email protected]e00bab022013-08-19 00:42:4542struct ReturnedResource;
43typedef std::vector<ReturnedResource> ReturnedResourceArray;
[email protected]ec05af52012-11-21 23:07:0044}
45
[email protected]adc93fa72011-06-21 19:47:3946namespace ui {
47
48class Compositor;
[email protected]fe7074c62011-10-28 15:22:5449class LayerAnimator;
[email protected]07ae973e2014-03-05 18:51:1050class LayerOwner;
[email protected]adc93fa72011-06-21 19:47:3951
52// Layer manages a texture, transform and a set of child Layers. Any View that
53// has enabled layers ends up creating a Layer to manage the texture.
[email protected]28cd2bb2011-09-19 21:04:1954// A Layer can also be created without a texture, in which case it renders
55// nothing and is simply used as a node in a hierarchy of layers.
[email protected]cd9a61c72012-05-08 19:16:5956// Coordinate system used in layers is DIP (Density Independent Pixel)
57// coordinates unless explicitly mentioned as pixel coordinates.
[email protected]adc93fa72011-06-21 19:47:3958//
[email protected]ae2202a2014-01-07 11:11:1059// NOTE: Unlike Views, each Layer does *not* own its child Layers. If you
60// delete a Layer and it has children, the parent of each child Layer is set to
[email protected]adc93fa72011-06-21 19:47:3961// NULL, but the children are not deleted.
[email protected]2700daddd2012-07-13 19:35:3762class COMPOSITOR_EXPORT Layer
63 : public LayerAnimationDelegate,
[email protected]ec05af52012-11-21 23:07:0064 NON_EXPORTED_BASE(public cc::ContentLayerClient),
[email protected]bf912272013-02-23 01:54:1665 NON_EXPORTED_BASE(public cc::TextureLayerClient),
[email protected]29e17b02013-08-30 02:13:3366 NON_EXPORTED_BASE(public cc::LayerClient),
[email protected]bf912272013-02-23 01:54:1667 NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) {
[email protected]adc93fa72011-06-21 19:47:3968 public:
[email protected]7ab3f272011-11-16 00:51:5669 Layer();
70 explicit Layer(LayerType type);
[email protected]8f2a15d2011-09-29 15:50:5971 virtual ~Layer();
[email protected]adc93fa72011-06-21 19:47:3972
[email protected]dafdf5052014-03-13 17:02:5773 static bool UsingPictureLayer();
74
[email protected]993d6b322011-09-27 19:14:3875 // Retrieves the Layer's compositor. The Layer will walk up its parent chain
76 // to locate it. Returns NULL if the Layer is not attached to a compositor.
77 Compositor* GetCompositor();
78
79 // Called by the compositor when the Layer is set as its root Layer. This can
80 // only ever be called on the root layer.
81 void SetCompositor(Compositor* compositor);
82
[email protected]00b86982011-09-01 00:02:0983 LayerDelegate* delegate() { return delegate_; }
84 void set_delegate(LayerDelegate* delegate) { delegate_ = delegate; }
85
[email protected]07ae973e2014-03-05 18:51:1086 LayerOwner* owner() { return owner_; }
87
[email protected]adc93fa72011-06-21 19:47:3988 // Adds a new Layer to this Layer.
89 void Add(Layer* child);
90
91 // Removes a Layer from this Layer.
92 void Remove(Layer* child);
93
[email protected]5e4e61f2011-11-22 16:55:2494 // Stacks |child| above all other children.
95 void StackAtTop(Layer* child);
[email protected]18dab372011-10-03 21:21:4496
[email protected]ebc335f2011-11-23 00:43:5197 // Stacks |child| directly above |other|. Both must be children of this
98 // layer. Note that if |child| is initially stacked even higher, calling this
99 // method will result in |child| being lowered in the stacking order.
[email protected]5e4e61f2011-11-22 16:55:24100 void StackAbove(Layer* child, Layer* other);
[email protected]62dd7ea2011-11-08 15:51:47101
[email protected]44c6f8d2011-12-27 23:49:04102 // Stacks |child| below all other children.
103 void StackAtBottom(Layer* child);
104
105 // Stacks |child| directly below |other|. Both must be children of this
106 // layer.
107 void StackBelow(Layer* child, Layer* other);
108
[email protected]adc93fa72011-06-21 19:47:39109 // Returns the child Layers.
[email protected]25ae9a12011-10-12 14:55:22110 const std::vector<Layer*>& children() const { return children_; }
[email protected]adc93fa72011-06-21 19:47:39111
112 // The parent.
113 const Layer* parent() const { return parent_; }
114 Layer* parent() { return parent_; }
115
[email protected]036e6c972012-01-03 18:48:05116 LayerType type() const { return type_; }
117
[email protected]ad7258912011-08-29 20:33:53118 // Returns true if this Layer contains |other| somewhere in its children.
119 bool Contains(const Layer* other) const;
120
[email protected]fe7074c62011-10-28 15:22:54121 // The layer's animator is responsible for causing automatic animations when
122 // properties are set. It also manages a queue of pending animations and
123 // handles blending of animations. The layer takes ownership of the animator.
124 void SetAnimator(LayerAnimator* animator);
125
126 // Returns the layer's animator. Creates a default animator of one has not
127 // been set. Will not return NULL.
128 LayerAnimator* GetAnimator();
[email protected]7fca53d42011-09-29 15:38:12129
[email protected]adc93fa72011-06-21 19:47:39130 // The transform, relative to the parent.
[email protected]0f0453e2012-10-14 18:15:35131 void SetTransform(const gfx::Transform& transform);
[email protected]712f4b642013-03-14 07:09:15132 gfx::Transform transform() const;
[email protected]fe7074c62011-10-28 15:22:54133
134 // Return the target transform if animator is running, or the current
135 // transform otherwise.
[email protected]0f0453e2012-10-14 18:15:35136 gfx::Transform GetTargetTransform() const;
[email protected]adc93fa72011-06-21 19:47:39137
138 // The bounds, relative to the parent.
[email protected]c155c252011-07-29 16:17:55139 void SetBounds(const gfx::Rect& bounds);
[email protected]adc93fa72011-06-21 19:47:39140 const gfx::Rect& bounds() const { return bounds_; }
141
[email protected]5ba9d5f2011-10-20 01:58:33142 // Return the target bounds if animator is running, or the current bounds
143 // otherwise.
144 gfx::Rect GetTargetBounds() const;
145
[email protected]7adee632012-03-15 19:15:08146 // Sets/gets whether or not drawing of child layers should be clipped to the
147 // bounds of this layer.
148 void SetMasksToBounds(bool masks_to_bounds);
149 bool GetMasksToBounds() const;
150
[email protected]7fca53d42011-09-29 15:38:12151 // The opacity of the layer. The opacity is applied to each pixel of the
152 // texture (resulting alpha = opacity * alpha).
[email protected]bf912272013-02-23 01:54:16153 float opacity() const;
[email protected]7fca53d42011-09-29 15:38:12154 void SetOpacity(float opacity);
155
[email protected]fb4d9d12012-08-24 00:44:54156 // Returns the actual opacity, which the opacity of this layer multipled by
157 // the combined opacity of the parent.
158 float GetCombinedOpacity() const;
159
[email protected]2a6c5672012-04-23 19:37:09160 // Blur pixels by this amount in anything below the layer and visible through
161 // the layer.
162 int background_blur() const { return background_blur_radius_; }
163 void SetBackgroundBlur(int blur_radius);
164
[email protected]e5da6622012-05-30 19:58:16165 // Saturate all pixels of this layer by this amount.
[email protected]815d0c382012-07-21 08:13:44166 // This effect will get "combined" with the inverted,
167 // brightness and grayscale setting.
[email protected]e5da6622012-05-30 19:58:16168 float layer_saturation() const { return layer_saturation_; }
169 void SetLayerSaturation(float saturation);
170
171 // Change the brightness of all pixels from this layer by this amount.
[email protected]815d0c382012-07-21 08:13:44172 // This effect will get "combined" with the inverted, saturate
173 // and grayscale setting.
[email protected]e5da6622012-05-30 19:58:16174 float layer_brightness() const { return layer_brightness_; }
175 void SetLayerBrightness(float brightness);
176
[email protected]815d0c382012-07-21 08:13:44177 // Return the target brightness if animator is running, or the current
178 // brightness otherwise.
179 float GetTargetBrightness() const;
180
181 // Change the grayscale of all pixels from this layer by this amount.
182 // This effect will get "combined" with the inverted, saturate
183 // and brightness setting.
184 float layer_grayscale() const { return layer_grayscale_; }
185 void SetLayerGrayscale(float grayscale);
186
187 // Return the target grayscale if animator is running, or the current
188 // grayscale otherwise.
189 float GetTargetGrayscale() const;
190
[email protected]56322be2013-03-13 18:27:37191 // Zoom the background by a factor of |zoom|. The effect is blended along the
192 // edge across |inset| pixels.
193 void SetBackgroundZoom(float zoom, int inset);
[email protected]77f7c132012-11-15 06:52:54194
[email protected]f48075d2012-05-24 11:06:51195 // Invert the layer.
[email protected]e5da6622012-05-30 19:58:16196 bool layer_inverted() const { return layer_inverted_; }
197 void SetLayerInverted(bool inverted);
[email protected]f48075d2012-05-24 11:06:51198
[email protected]3f1f5e6a2011-11-11 15:09:02199 // Return the target opacity if animator is running, or the current opacity
[email protected]fe7074c62011-10-28 15:22:54200 // otherwise.
201 float GetTargetOpacity() const;
202
[email protected]498e623c2012-07-12 21:12:42203 // Set a layer mask for a layer.
204 // Note the provided layer mask can neither have a layer mask itself nor can
[email protected]c0dc4b172014-01-07 11:24:09205 // it have any children. The ownership of |layer_mask| will not be
206 // transferred with this call.
[email protected]498e623c2012-07-12 21:12:42207 // Furthermore: A mask layer can only be set to one layer.
[email protected]c0dc4b172014-01-07 11:24:09208 void SetMaskLayer(Layer* layer_mask);
209 Layer* layer_mask_layer() { return layer_mask_; }
[email protected]498e623c2012-07-12 21:12:42210
[email protected]e4e8afef2011-10-05 13:58:33211 // Sets the visibility of the Layer. A Layer may be visible but not
212 // drawn. This happens if any ancestor of a Layer is not visible.
[email protected]993d6b322011-09-27 19:14:38213 void SetVisible(bool visible);
[email protected]f941f47a2011-10-15 18:44:51214 bool visible() const { return visible_; }
[email protected]3aa43942011-09-13 20:59:53215
[email protected]a67935f2012-02-10 14:26:24216 // Returns the target visibility if the animator is running. Otherwise, it
217 // returns the current visibility.
218 bool GetTargetVisibility() const;
219
[email protected]e4e8afef2011-10-05 13:58:33220 // Returns true if this Layer is drawn. A Layer is drawn only if all ancestors
221 // are visible.
222 bool IsDrawn() const;
223
[email protected]c1f67302011-09-27 14:18:09224 // Returns true if this layer can have a texture (has_texture_ is true)
225 // and is not completely obscured by a child.
[email protected]332749032011-10-22 00:32:46226 bool ShouldDraw() const;
[email protected]c1f67302011-09-27 14:18:09227
[email protected]ad7258912011-08-29 20:33:53228 // Converts a point from the coordinates of |source| to the coordinates of
229 // |target|. Necessarily, |source| and |target| must inhabit the same Layer
230 // tree.
231 static void ConvertPointToLayer(const Layer* source,
232 const Layer* target,
233 gfx::Point* point);
234
[email protected]bdcf3bbf2013-03-25 18:39:03235 // Converts a transform to be relative to the given |ancestor|. Returns
236 // whether success (that is, whether the given ancestor was really an
237 // ancestor of this layer).
238 bool GetTargetTransformRelativeTo(const Layer* ancestor,
239 gfx::Transform* transform) const;
240
[email protected]712f4b642013-03-14 07:09:15241 // Converts a ui::Layer's transform to the transform on the corresponding
242 // cc::Layer.
243 static gfx::Transform ConvertTransformToCCTransform(
244 const gfx::Transform& transform,
[email protected]712f4b642013-03-14 07:09:15245 float device_scale_factor);
246
[email protected]c155c252011-07-29 16:17:55247 // See description in View for details
248 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely);
249 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; }
250
[email protected]1d96e032014-03-25 05:59:08251 // Set to true if this layer always paints completely within its bounds. If so
252 // we can omit an unnecessary clear, even if the layer is transparent.
253 void SetFillsBoundsCompletely(bool fills_bounds_completely);
254
[email protected]33699e622011-11-17 18:29:30255 const std::string& name() const { return name_; }
256 void set_name(const std::string& name) { name_ = name; }
257
[email protected]42f40a52013-06-08 04:38:51258 // Set new TextureMailbox for this layer. Note that |mailbox| may hold a
259 // shared memory resource or an actual mailbox for a texture.
[email protected]9260757f2013-09-17 01:24:16260 void SetTextureMailbox(const cc::TextureMailbox& mailbox,
261 scoped_ptr<cc::SingleReleaseCallback> release_callback,
[email protected]4508b152014-04-09 22:14:17262 gfx::Size texture_size_in_dip);
263 void SetTextureSize(gfx::Size texture_size_in_dip);
[email protected]42f40a52013-06-08 04:38:51264
[email protected]09f67382013-10-09 21:03:45265 // Begins showing delegated frames from the |frame_provider|.
266 void SetShowDelegatedContent(cc::DelegatedFrameProvider* frame_provider,
267 gfx::Size frame_size_in_dip);
[email protected]b14d40d2013-03-06 03:53:27268
[email protected]a7fcdda32013-07-04 02:23:07269 bool has_external_content() {
270 return texture_layer_.get() || delegated_renderer_layer_.get();
271 }
272
[email protected]785b0af2013-10-02 18:08:41273 void SetShowPaintedContent();
274
[email protected]da7584c2012-01-28 03:19:12275 // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR.
276 void SetColor(SkColor color);
277
[email protected]870119a2011-09-30 18:13:22278 // Adds |invalid_rect| to the Layer's pending invalid rect and calls
[email protected]f78649ea2012-02-23 18:39:04279 // ScheduleDraw(). Returns false if the paint request is ignored.
280 bool SchedulePaint(const gfx::Rect& invalid_rect);
[email protected]00b86982011-09-01 00:02:09281
[email protected]870119a2011-09-30 18:13:22282 // Schedules a redraw of the layer tree at the compositor.
[email protected]35470cc2012-02-23 23:04:31283 // Note that this _does not_ invalidate any region of this layer; use
284 // SchedulePaint() for that.
[email protected]870119a2011-09-30 18:13:22285 void ScheduleDraw();
286
[email protected]1e5da63d2014-01-16 22:44:00287 // Uses damaged rectangles recorded in |damaged_region_| to invalidate the
288 // |cc_layer_|.
[email protected]cedc3952012-03-06 06:15:55289 void SendDamagedRects();
[email protected]f78649ea2012-02-23 18:39:04290
[email protected]88fa18e82013-12-03 16:29:37291 const SkRegion& damaged_region() const { return damaged_region_; }
292
[email protected]1e5da63d2014-01-16 22:44:00293 // Suppresses painting the content by disconnecting |delegate_|.
[email protected]f78649ea2012-02-23 18:39:04294 void SuppressPaint();
295
[email protected]cd9a61c72012-05-08 19:16:59296 // Notifies the layer that the device scale factor has changed.
297 void OnDeviceScaleFactorChanged(float device_scale_factor);
298
[email protected]2486dce2012-05-23 17:18:19299 // Sets whether the layer should scale its content. If true, the canvas will
300 // be scaled in software rendering mode before it is passed to
[email protected]1e5da63d2014-01-16 22:44:00301 // |LayerDelegate::OnPaintLayer|.
[email protected]f0501aa2012-10-18 23:25:53302 // Set to false if the delegate handles scaling.
303 // NOTE: if this is called during |LayerDelegate::OnPaint|, the new value will
304 // not apply to the canvas passed to the pending draw.
[email protected]2486dce2012-05-23 17:18:19305 void set_scale_content(bool scale_content) { scale_content_ = scale_content; }
[email protected]cd9a61c72012-05-08 19:16:59306
[email protected]84ff1e92012-06-13 02:58:21307 // Returns true if the layer scales its content.
308 bool scale_content() const { return scale_content_; }
309
[email protected]a7fcdda32013-07-04 02:23:07310 // Requets a copy of the layer's output as a texture or bitmap.
311 void RequestCopyOfOutput(scoped_ptr<cc::CopyOutputRequest> request);
312
[email protected]ec05af52012-11-21 23:07:00313 // ContentLayerClient
[email protected]7f4d26b2013-03-14 20:57:10314 virtual void PaintContents(
[email protected]0023fc72014-01-10 20:05:06315 SkCanvas* canvas, const gfx::Rect& clip, gfx::RectF* opaque) OVERRIDE;
[email protected]15c54d52013-03-23 18:50:16316 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
[email protected]1d96e032014-03-25 05:59:08317 virtual bool FillsBoundsCompletely() const OVERRIDE;
[email protected]332749032011-10-22 00:32:46318
[email protected]ec05af52012-11-21 23:07:00319 cc::Layer* cc_layer() { return cc_layer_; }
[email protected]332749032011-10-22 00:32:46320
[email protected]ec05af52012-11-21 23:07:00321 // TextureLayerClient
[email protected]171cbb32013-07-11 03:51:19322 virtual unsigned PrepareTexture() OVERRIDE;
[email protected]9260757f2013-09-17 01:24:16323 virtual bool PrepareTextureMailbox(
324 cc::TextureMailbox* mailbox,
325 scoped_ptr<cc::SingleReleaseCallback>* release_callback,
326 bool use_shared_memory) OVERRIDE;
[email protected]7ba5f4b62012-08-25 01:19:36327
[email protected]cd9a61c72012-05-08 19:16:59328 float device_scale_factor() const { return device_scale_factor_; }
329
[email protected]09c01c12012-05-26 00:07:19330 // Forces a render surface to be used on this layer. This has no positive
331 // impact, and is only used for benchmarking/testing purpose.
332 void SetForceRenderSurface(bool force);
333 bool force_render_surface() const { return force_render_surface_; }
334
[email protected]29e17b02013-08-30 02:13:33335 // LayerClient
[email protected]9f3be432013-12-03 03:53:22336 virtual scoped_refptr<base::debug::ConvertableToTraceFormat>
337 TakeDebugInfo() OVERRIDE;
338
[email protected]bf912272013-02-23 01:54:16339 // LayerAnimationEventObserver
340 virtual void OnAnimationStarted(const cc::AnimationEvent& event) OVERRIDE;
341
[email protected]f2891462013-03-11 23:26:51342 // Whether this layer has animations waiting to get sent to its cc::Layer.
343 bool HasPendingThreadedAnimations() {
344 return pending_threaded_animations_.size() != 0;
345 }
346
[email protected]ffd1ccb2013-03-15 07:48:24347 // Triggers a call to SwitchToLayer.
348 void SwitchCCLayerForTest();
349
[email protected]adc93fa72011-06-21 19:47:39350 private:
[email protected]07ae973e2014-03-05 18:51:10351 friend class LayerOwner;
352
[email protected]44c6f8d2011-12-27 23:49:04353 // Stacks |child| above or below |other|. Helper method for StackAbove() and
354 // StackBelow().
355 void StackRelativeTo(Layer* child, Layer* other, bool above);
356
[email protected]ad7258912011-08-29 20:33:53357 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const;
358 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const;
359
[email protected]fe7074c62011-10-28 15:22:54360 // Implementation of LayerAnimatorDelegate
361 virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE;
[email protected]0f0453e2012-10-14 18:15:35362 virtual void SetTransformFromAnimation(
363 const gfx::Transform& transform) OVERRIDE;
[email protected]fe7074c62011-10-28 15:22:54364 virtual void SetOpacityFromAnimation(float opacity) OVERRIDE;
[email protected]a67935f2012-02-10 14:26:24365 virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE;
[email protected]815d0c382012-07-21 08:13:44366 virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE;
367 virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE;
[email protected]e81480f1f2012-10-11 23:06:45368 virtual void SetColorFromAnimation(SkColor color) OVERRIDE;
[email protected]fe7074c62011-10-28 15:22:54369 virtual void ScheduleDrawForAnimation() OVERRIDE;
370 virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE;
[email protected]712f4b642013-03-14 07:09:15371 virtual gfx::Transform GetTransformForAnimation() const OVERRIDE;
[email protected]fe7074c62011-10-28 15:22:54372 virtual float GetOpacityForAnimation() const OVERRIDE;
[email protected]a67935f2012-02-10 14:26:24373 virtual bool GetVisibilityForAnimation() const OVERRIDE;
[email protected]815d0c382012-07-21 08:13:44374 virtual float GetBrightnessForAnimation() const OVERRIDE;
375 virtual float GetGrayscaleForAnimation() const OVERRIDE;
[email protected]e81480f1f2012-10-11 23:06:45376 virtual SkColor GetColorForAnimation() const OVERRIDE;
[email protected]712f4b642013-03-14 07:09:15377 virtual float GetDeviceScaleFactor() const OVERRIDE;
[email protected]bf912272013-02-23 01:54:16378 virtual void AddThreadedAnimation(
379 scoped_ptr<cc::Animation> animation) OVERRIDE;
380 virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE;
[email protected]7fca53d42011-09-29 15:38:12381
[email protected]1e5da63d2014-01-16 22:44:00382 // Creates a corresponding composited layer for |type_|.
[email protected]332749032011-10-22 00:32:46383 void CreateWebLayer();
[email protected]1e5da63d2014-01-16 22:44:00384
385 // Recomputes and sets to |cc_layer_|.
[email protected]712f4b642013-03-14 07:09:15386 void RecomputeCCTransformFromTransform(const gfx::Transform& transform);
[email protected]b9616d592011-11-14 20:04:42387 void RecomputeDrawsContentAndUVRect();
[email protected]b9cff562013-04-06 00:04:42388 void RecomputePosition();
[email protected]332749032011-10-22 00:32:46389
[email protected]e5da6622012-05-30 19:58:16390 // Set all filters which got applied to the layer.
391 void SetLayerFilters();
392
[email protected]77f7c132012-11-15 06:52:54393 // Set all filters which got applied to the layer background.
394 void SetLayerBackgroundFilters();
395
[email protected]1e5da63d2014-01-16 22:44:00396 // Cleanup |cc_layer_| and replaces it with |new_layer|.
[email protected]b14d40d2013-03-06 03:53:27397 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer);
398
[email protected]f2891462013-03-11 23:26:51399 // We cannot send animations to our cc_layer_ until we have been added to a
400 // layer tree. Instead, we hold on to these animations in
401 // pending_threaded_animations_, and expect SendPendingThreadedAnimations to
402 // be called once we have been added to a tree.
403 void SendPendingThreadedAnimations();
404
[email protected]993d6b322011-09-27 19:14:38405 const LayerType type_;
406
[email protected]adc93fa72011-06-21 19:47:39407 Compositor* compositor_;
408
[email protected]adc93fa72011-06-21 19:47:39409 Layer* parent_;
410
[email protected]ebc335f2011-11-23 00:43:51411 // This layer's children, in bottom-to-top stacking order.
[email protected]adc93fa72011-06-21 19:47:39412 std::vector<Layer*> children_;
413
[email protected]adc93fa72011-06-21 19:47:39414 gfx::Rect bounds_;
415
[email protected]e4e8afef2011-10-05 13:58:33416 // Visibility of this layer. See SetVisible/IsDrawn for more details.
[email protected]3aa43942011-09-13 20:59:53417 bool visible_;
418
[email protected]09c01c12012-05-26 00:07:19419 bool force_render_surface_;
420
[email protected]c155c252011-07-29 16:17:55421 bool fills_bounds_opaquely_;
[email protected]1d96e032014-03-25 05:59:08422 bool fills_bounds_completely_;
[email protected]c155c252011-07-29 16:17:55423
[email protected]cd9a61c72012-05-08 19:16:59424 // Union of damaged rects, in pixel coordinates, to be used when
425 // compositor is ready to paint the content.
[email protected]cedc3952012-03-06 06:15:55426 SkRegion damaged_region_;
[email protected]f78649ea2012-02-23 18:39:04427
[email protected]2a6c5672012-04-23 19:37:09428 int background_blur_radius_;
[email protected]e5da6622012-05-30 19:58:16429
430 // Several variables which will change the visible representation of
431 // the layer.
432 float layer_saturation_;
433 float layer_brightness_;
[email protected]815d0c382012-07-21 08:13:44434 float layer_grayscale_;
[email protected]e5da6622012-05-30 19:58:16435 bool layer_inverted_;
[email protected]b4bb9ca2011-09-23 20:53:14436
[email protected]c0dc4b172014-01-07 11:24:09437 // The associated mask layer with this layer.
438 Layer* layer_mask_;
439 // The back link from the mask layer to it's associated masked layer.
440 // We keep this reference for the case that if the mask layer gets deleted
441 // while attached to the main layer before the main layer is deleted.
442 Layer* layer_mask_back_link_;
[email protected]498e623c2012-07-12 21:12:42443
[email protected]77f7c132012-11-15 06:52:54444 // The zoom factor to scale the layer by. Zooming is disabled when this is
445 // set to 1.
446 float zoom_;
447
448 // Width of the border in pixels, where the scaling is blended.
449 int zoom_inset_;
450
[email protected]33699e622011-11-17 18:29:30451 std::string name_;
452
[email protected]00b86982011-09-01 00:02:09453 LayerDelegate* delegate_;
454
[email protected]07ae973e2014-03-05 18:51:10455 LayerOwner* owner_;
456
[email protected]5d86a112012-09-23 00:21:58457 scoped_refptr<LayerAnimator> animator_;
[email protected]7fca53d42011-09-29 15:38:12458
[email protected]f2891462013-03-11 23:26:51459 // Animations that are passed to AddThreadedAnimation before this layer is
460 // added to a tree.
461 cc::ScopedPtrVector<cc::Animation> pending_threaded_animations_;
462
[email protected]66efabe2012-08-18 03:06:06463 // Ownership of the layer is held through one of the strongly typed layer
464 // pointers, depending on which sort of layer this is.
[email protected]dafdf5052014-03-13 17:02:57465 scoped_refptr<cc::Layer> content_layer_;
[email protected]ec05af52012-11-21 23:07:00466 scoped_refptr<cc::TextureLayer> texture_layer_;
467 scoped_refptr<cc::SolidColorLayer> solid_color_layer_;
[email protected]b14d40d2013-03-06 03:53:27468 scoped_refptr<cc::DelegatedRendererLayer> delegated_renderer_layer_;
[email protected]ec05af52012-11-21 23:07:00469 cc::Layer* cc_layer_;
[email protected]332749032011-10-22 00:32:46470
[email protected]2486dce2012-05-23 17:18:19471 // If true, the layer scales the canvas and the texture with the device scale
[email protected]9260757f2013-09-17 01:24:16472 // factor as apporpriate. When true, the texture size is in DIP.
[email protected]2486dce2012-05-23 17:18:19473 bool scale_content_;
[email protected]cd9a61c72012-05-08 19:16:59474
475 // A cached copy of |Compositor::device_scale_factor()|.
476 float device_scale_factor_;
477
[email protected]4508b152014-04-09 22:14:17478 // The mailbox used by texture_layer_.
[email protected]42f40a52013-06-08 04:38:51479 cc::TextureMailbox mailbox_;
480
[email protected]4508b152014-04-09 22:14:17481 // The callback to release the mailbox. This is only set after
482 // SetTextureMailbox is called, before we give it to the TextureLayer.
483 scoped_ptr<cc::SingleReleaseCallback> mailbox_release_callback_;
[email protected]42f40a52013-06-08 04:38:51484
[email protected]4508b152014-04-09 22:14:17485 // The size of the frame or texture in DIP, set when SetShowDelegatedContent
486 // or SetTextureMailbox was called.
487 gfx::Size frame_size_in_dip_;
[email protected]b14d40d2013-03-06 03:53:27488
[email protected]adc93fa72011-06-21 19:47:39489 DISALLOW_COPY_AND_ASSIGN(Layer);
490};
491
492} // namespace ui
493
[email protected]116302fc2012-05-05 21:45:41494#endif // UI_COMPOSITOR_LAYER_H_