layer.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef UI_COMPOSITOR_LAYER_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define UI_COMPOSITOR_LAYER_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector> 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/ref_counted.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/message_loop.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/animation/animation_events.h" 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/animation/layer_animation_event_observer.h" 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/base/scoped_ptr_vector.h" 182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/layers/content_layer_client.h" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/layers/texture_layer_client.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkColor.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/skia/include/core/SkRegion.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/compositor/compositor.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/compositor/layer_animation_delegate.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/compositor/layer_delegate.h" 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/compositor/layer_type.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/transform.h" 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class SkCanvas; 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace cc { 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ContentLayer; 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class DelegatedFrameData; 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class DelegatedRendererLayer; 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Layer; 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ResourceUpdateQueue; 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class SolidColorLayer; 382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class TextureLayer; 392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct TransferableResource; 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)typedef std::vector<TransferableResource> TransferableResourceArray; 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui { 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Compositor; 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class LayerAnimator; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Texture; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Layer manages a texture, transform and a set of child Layers. Any View that 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// has enabled layers ends up creating a Layer to manage the texture. 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A Layer can also be created without a texture, in which case it renders 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// nothing and is simply used as a node in a hierarchy of layers. 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Coordinate system used in layers is DIP (Density Independent Pixel) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// coordinates unless explicitly mentioned as pixel coordinates. 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// NOTE: unlike Views, each Layer does *not* own its children views. If you 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// delete a Layer and it has children, the parent of each child layer is set to 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// NULL, but the children are not deleted. 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class COMPOSITOR_EXPORT Layer 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : public LayerAnimationDelegate, 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NON_EXPORTED_BASE(public cc::ContentLayerClient), 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NON_EXPORTED_BASE(public cc::TextureLayerClient), 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) NON_EXPORTED_BASE(public cc::LayerAnimationEventObserver) { 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Layer(); 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit Layer(LayerType type); 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~Layer(); 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Retrieves the Layer's compositor. The Layer will walk up its parent chain 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // to locate it. Returns NULL if the Layer is not attached to a compositor. 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Compositor* GetCompositor(); 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Called by the compositor when the Layer is set as its root Layer. This can 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // only ever be called on the root layer. 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetCompositor(Compositor* compositor); 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LayerDelegate* delegate() { return delegate_; } 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_delegate(LayerDelegate* delegate) { delegate_ = delegate; } 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Adds a new Layer to this Layer. 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Add(Layer* child); 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Removes a Layer from this Layer. 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void Remove(Layer* child); 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stacks |child| above all other children. 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StackAtTop(Layer* child); 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stacks |child| directly above |other|. Both must be children of this 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // layer. Note that if |child| is initially stacked even higher, calling this 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // method will result in |child| being lowered in the stacking order. 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StackAbove(Layer* child, Layer* other); 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stacks |child| below all other children. 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StackAtBottom(Layer* child); 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stacks |child| directly below |other|. Both must be children of this 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // layer. 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StackBelow(Layer* child, Layer* other); 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the child Layers. 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::vector<Layer*>& children() const { return children_; } 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The parent. 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const Layer* parent() const { return parent_; } 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Layer* parent() { return parent_; } 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LayerType type() const { return type_; } 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if this Layer contains |other| somewhere in its children. 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool Contains(const Layer* other) const; 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The layer's animator is responsible for causing automatic animations when 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // properties are set. It also manages a queue of pending animations and 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // handles blending of animations. The layer takes ownership of the animator. 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetAnimator(LayerAnimator* animator); 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the layer's animator. Creates a default animator of one has not 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // been set. Will not return NULL. 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LayerAnimator* GetAnimator(); 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The transform, relative to the parent. 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetTransform(const gfx::Transform& transform); 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Transform transform() const; 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return the target transform if animator is running, or the current 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // transform otherwise. 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Transform GetTargetTransform() const; 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The bounds, relative to the parent. 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBounds(const gfx::Rect& bounds); 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& bounds() const { return bounds_; } 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return the target bounds if animator is running, or the current bounds 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // otherwise. 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect GetTargetBounds() const; 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets/gets whether or not drawing of child layers should be clipped to the 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // bounds of this layer. 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetMasksToBounds(bool masks_to_bounds); 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetMasksToBounds() const; 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The opacity of the layer. The opacity is applied to each pixel of the 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // texture (resulting alpha = opacity * alpha). 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) float opacity() const; 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetOpacity(float opacity); 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the actual opacity, which the opacity of this layer multipled by 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the combined opacity of the parent. 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float GetCombinedOpacity() const; 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Blur pixels by this amount in anything below the layer and visible through 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the layer. 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int background_blur() const { return background_blur_radius_; } 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBackgroundBlur(int blur_radius); 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Saturate all pixels of this layer by this amount. 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This effect will get "combined" with the inverted, 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // brightness and grayscale setting. 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float layer_saturation() const { return layer_saturation_; } 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetLayerSaturation(float saturation); 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Change the brightness of all pixels from this layer by this amount. 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This effect will get "combined" with the inverted, saturate 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and grayscale setting. 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float layer_brightness() const { return layer_brightness_; } 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetLayerBrightness(float brightness); 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return the target brightness if animator is running, or the current 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // brightness otherwise. 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float GetTargetBrightness() const; 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Change the grayscale of all pixels from this layer by this amount. 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This effect will get "combined" with the inverted, saturate 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and brightness setting. 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float layer_grayscale() const { return layer_grayscale_; } 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetLayerGrayscale(float grayscale); 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return the target grayscale if animator is running, or the current 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // grayscale otherwise. 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float GetTargetGrayscale() const; 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Zoom the background by a factor of |zoom|. The effect is blended along the 1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // edge across |inset| pixels. 1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SetBackgroundZoom(float zoom, int inset); 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Invert the layer. 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool layer_inverted() const { return layer_inverted_; } 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetLayerInverted(bool inverted); 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Return the target opacity if animator is running, or the current opacity 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // otherwise. 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float GetTargetOpacity() const; 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set a layer mask for a layer. 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note the provided layer mask can neither have a layer mask itself nor can 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // it have any children. The ownership of |layer_mask| will not be 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // transferred with this call. 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Furthermore: A mask layer can only be set to one layer. 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetMaskLayer(Layer* layer_mask); 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Layer* layer_mask_layer() { return layer_mask_; } 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the visibility of the Layer. A Layer may be visible but not 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // drawn. This happens if any ancestor of a Layer is not visible. 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetVisible(bool visible); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool visible() const { return visible_; } 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the target visibility if the animator is running. Otherwise, it 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // returns the current visibility. 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool GetTargetVisibility() const; 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if this Layer is drawn. A Layer is drawn only if all ancestors 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // are visible. 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool IsDrawn() const; 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if this layer can have a texture (has_texture_ is true) 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and is not completely obscured by a child. 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ShouldDraw() const; 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Converts a point from the coordinates of |source| to the coordinates of 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |target|. Necessarily, |source| and |target| must inhabit the same Layer 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tree. 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void ConvertPointToLayer(const Layer* source, 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const Layer* target, 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point* point); 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Converts a transform to be relative to the given |ancestor|. Returns 2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // whether success (that is, whether the given ancestor was really an 2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // ancestor of this layer). 2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool GetTargetTransformRelativeTo(const Layer* ancestor, 2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Transform* transform) const; 2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Converts a ui::Layer's transform to the transform on the corresponding 2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // cc::Layer. 2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) static gfx::Transform ConvertTransformToCCTransform( 2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Transform& transform, 2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const gfx::Rect& bounds, 2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) float device_scale_factor); 2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // See description in View for details 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& name() const { return name_; } 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_name(const std::string& name) { name_ = name; } 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const ui::Texture* texture() const { return texture_.get(); } 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Assigns a new external texture. |texture| can be NULL to disable external 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // updates. 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetExternalTexture(ui::Texture* texture); 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui::Texture* external_texture() { return texture_.get(); } 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Sets a delegated frame, coming from a child compositor. 2552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SetDelegatedFrame(scoped_ptr<cc::DelegatedFrameData> frame, 2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Size frame_size_in_dip); 2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Gets unused resources to recycle to the child compositor. 2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void TakeUnusedResourcesForChildCompositor( 2602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) cc::TransferableResourceArray* array); 2612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR. 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetColor(SkColor color); 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Adds |invalid_rect| to the Layer's pending invalid rect and calls 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ScheduleDraw(). Returns false if the paint request is ignored. 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool SchedulePaint(const gfx::Rect& invalid_rect); 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Schedules a redraw of the layer tree at the compositor. 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note that this _does not_ invalidate any region of this layer; use 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // SchedulePaint() for that. 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void ScheduleDraw(); 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sends damaged rectangles recorded in |damaged_region_| to 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |compostior_| to repaint the content. 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SendDamagedRects(); 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Suppresses painting the content by disgarding damaged region and ignoring 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // new paint requests. 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SuppressPaint(); 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notifies the layer that the device scale factor has changed. 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void OnDeviceScaleFactorChanged(float device_scale_factor); 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sets whether the layer should scale its content. If true, the canvas will 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // be scaled in software rendering mode before it is passed to 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |LayerDelegate::OnPaint|. 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set to false if the delegate handles scaling. 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: if this is called during |LayerDelegate::OnPaint|, the new value will 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // not apply to the canvas passed to the pending draw. 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void set_scale_content(bool scale_content) { scale_content_ = scale_content; } 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns true if the layer scales its content. 2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool scale_content() const { return scale_content_; } 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Sometimes the Layer is being updated by something other than SetCanvas 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool layer_updated_externally() const { return layer_updated_externally_; } 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // ContentLayerClient 3012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void PaintContents( 3022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SkCanvas* canvas, gfx::Rect clip, gfx::RectF* opaque) OVERRIDE; 3032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) cc::Layer* cc_layer() { return cc_layer_; } 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // TextureLayerClient 3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual unsigned PrepareTexture(cc::ResourceUpdateQueue* queue) OVERRIDE; 3092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float device_scale_factor() const { return device_scale_factor_; } 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Forces a render surface to be used on this layer. This has no positive 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // impact, and is only used for benchmarking/testing purpose. 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetForceRenderSurface(bool force); 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool force_render_surface() const { return force_render_surface_; } 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // LayerAnimationEventObserver 3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void OnAnimationStarted(const cc::AnimationEvent& event) OVERRIDE; 3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Whether this layer has animations waiting to get sent to its cc::Layer. 3222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool HasPendingThreadedAnimations() { 3232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return pending_threaded_animations_.size() != 0; 3242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 3252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Triggers a call to SwitchToLayer. 3272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SwitchCCLayerForTest(); 3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Stacks |child| above or below |other|. Helper method for StackAbove() and 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // StackBelow(). 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StackRelativeTo(Layer* child, Layer* other, bool above); 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Following are invoked from the animation or if no animation exists to 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // update the values immediately. 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBoundsImmediately(const gfx::Rect& bounds); 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetTransformImmediately(const gfx::Transform& transform); 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetOpacityImmediately(float opacity); 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetVisibilityImmediately(bool visibility); 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetBrightnessImmediately(float brightness); 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetGrayscaleImmediately(float grayscale); 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetColorImmediately(SkColor color); 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Implementation of LayerAnimatorDelegate 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetBoundsFromAnimation(const gfx::Rect& bounds) OVERRIDE; 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetTransformFromAnimation( 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Transform& transform) OVERRIDE; 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetOpacityFromAnimation(float opacity) OVERRIDE; 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetVisibilityFromAnimation(bool visibility) OVERRIDE; 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetBrightnessFromAnimation(float brightness) OVERRIDE; 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetGrayscaleFromAnimation(float grayscale) OVERRIDE; 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetColorFromAnimation(SkColor color) OVERRIDE; 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ScheduleDrawForAnimation() OVERRIDE; 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual const gfx::Rect& GetBoundsForAnimation() const OVERRIDE; 3582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual gfx::Transform GetTransformForAnimation() const OVERRIDE; 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual float GetOpacityForAnimation() const OVERRIDE; 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool GetVisibilityForAnimation() const OVERRIDE; 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual float GetBrightnessForAnimation() const OVERRIDE; 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual float GetGrayscaleForAnimation() const OVERRIDE; 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual SkColor GetColorForAnimation() const OVERRIDE; 3642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual float GetDeviceScaleFactor() const OVERRIDE; 3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void AddThreadedAnimation( 3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_ptr<cc::Animation> animation) OVERRIDE; 3672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void RemoveThreadedAnimation(int animation_id) OVERRIDE; 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void CreateWebLayer(); 3702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void RecomputeCCTransformFromTransform(const gfx::Transform& transform); 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void RecomputeDrawsContentAndUVRect(); 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Set all filters which got applied to the layer. 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void SetLayerFilters(); 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Set all filters which got applied to the layer background. 3772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SetLayerBackgroundFilters(); 3782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void UpdateIsDrawn(); 3802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); 3822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // We cannot send animations to our cc_layer_ until we have been added to a 3842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // layer tree. Instead, we hold on to these animations in 3852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // pending_threaded_animations_, and expect SendPendingThreadedAnimations to 3862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // be called once we have been added to a tree. 3872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void SendPendingThreadedAnimations(); 3882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const LayerType type_; 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Compositor* compositor_; 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_refptr<ui::Texture> texture_; 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Layer* parent_; 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This layer's children, in bottom-to-top stacking order. 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<Layer*> children_; 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect bounds_; 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Visibility of this layer. See SetVisible/IsDrawn for more details. 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool visible_; 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Computed based on the visibility of this layer and its ancestors. 4062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) bool is_drawn_; 4072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool force_render_surface_; 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool fills_bounds_opaquely_; 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If true the layer is always up to date. 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool layer_updated_externally_; 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Union of damaged rects, in pixel coordinates, to be used when 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // compositor is ready to paint the content. 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SkRegion damaged_region_; 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int background_blur_radius_; 4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Several variables which will change the visible representation of 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the layer. 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float layer_saturation_; 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float layer_brightness_; 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float layer_grayscale_; 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool layer_inverted_; 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The associated mask layer with this layer. 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Layer* layer_mask_; 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The back link from the mask layer to it's associated masked layer. 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We keep this reference for the case that if the mask layer gets deleted 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // while attached to the main layer before the main layer is deleted. 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Layer* layer_mask_back_link_; 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The zoom factor to scale the layer by. Zooming is disabled when this is 4362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // set to 1. 4372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) float zoom_; 4382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Width of the border in pixels, where the scaling is blended. 4402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int zoom_inset_; 4412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string name_; 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LayerDelegate* delegate_; 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_refptr<LayerAnimator> animator_; 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Animations that are passed to AddThreadedAnimation before this layer is 4492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // added to a tree. 4502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) cc::ScopedPtrVector<cc::Animation> pending_threaded_animations_; 4512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Ownership of the layer is held through one of the strongly typed layer 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // pointers, depending on which sort of layer this is. 4542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_refptr<cc::ContentLayer> content_layer_; 4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_refptr<cc::TextureLayer> texture_layer_; 4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_refptr<cc::SolidColorLayer> solid_color_layer_; 4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) scoped_refptr<cc::DelegatedRendererLayer> delegated_renderer_layer_; 4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) cc::Layer* cc_layer_; 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If true, the layer scales the canvas and the texture with the device scale 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // factor as appropriate. When true, the texture size is in DIP. 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool scale_content_; 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A cached copy of |Compositor::device_scale_factor()|. 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) float device_scale_factor_; 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // The size of the delegated frame in DIP, set when SetDelegatedFrame was 4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // called. 4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) gfx::Size delegated_frame_size_in_dip_; 4702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(Layer); 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace ui 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // UI_COMPOSITOR_LAYER_H_ 477