12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2010 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CC_LAYERS_LAYER_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CC_LAYERS_LAYER_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
83551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include <set>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "base/callback.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/ref_counted.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/observer_list.h"
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/animation/layer_animation_controller.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/animation/layer_animation_value_observer.h"
16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "cc/animation/layer_animation_value_provider.h"
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/base/cc_export.h"
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/base/region.h"
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "cc/base/scoped_ptr_vector.h"
204e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "cc/debug/micro_benchmark.h"
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/layers/draw_properties.h"
22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "cc/layers/layer_lists.h"
23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "cc/layers/layer_position_constraint.h"
24c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "cc/layers/paint_properties.h"
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "cc/layers/render_surface.h"
26eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "cc/output/filter_operations.h"
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "skia/ext/refptr.h"
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "third_party/skia/include/core/SkColor.h"
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "third_party/skia/include/core/SkImageFilter.h"
303551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "third_party/skia/include/core/SkPicture.h"
31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "third_party/skia/include/core/SkXfermode.h"
3246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "ui/gfx/point3_f.h"
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/rect.h"
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/rect_f.h"
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/gfx/transform.h"
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
373551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)namespace gfx {
383551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)class BoxF;
393551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)}
403551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)namespace base {
42a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)namespace debug {
43a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class ConvertableToTraceFormat;
44a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}
45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}
46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace cc {
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class Animation;
50eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass AnimationDelegate;
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct AnimationEvent;
5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class CopyOutputRequest;
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class LayerAnimationDelegate;
54c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class LayerAnimationEventObserver;
553551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)class LayerClient;
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class LayerImpl;
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class LayerTreeHost;
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class LayerTreeImpl;
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PriorityCalculator;
60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class RenderingStatsInstrumentation;
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ResourceUpdateQueue;
6258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class ScrollbarLayerInterface;
6303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class SimpleEnclosedRegion;
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct AnimationEvent;
65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)template <typename LayerType>
66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class OcclusionTracker;
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Base class for composited layers. Special layer types are derived from
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// this class.
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class CC_EXPORT Layer : public base::RefCounted<Layer>,
71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                        public LayerAnimationValueObserver,
72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                        public LayerAnimationValueProvider {
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  typedef RenderSurfaceLayerList RenderSurfaceListType;
758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  typedef LayerList LayerListType;
768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  typedef RenderSurface RenderSurfaceType;
778bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  enum LayerIdLabels {
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    INVALID_ID = -1,
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  };
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static scoped_refptr<Layer> Create();
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int id() const { return layer_id_; }
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer* RootLayer();
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer* parent() { return parent_; }
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const Layer* parent() const { return parent_; }
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void AddChild(scoped_refptr<Layer> child);
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void InsertChild(scoped_refptr<Layer> child, size_t index);
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer);
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void RemoveFromParent();
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void RemoveAllChildren();
942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetChildren(const LayerList& children);
9558e6fbe4ee35d65e14b626c557d37565bf8ad179Ben Murdoch  bool HasAncestor(const Layer* ancestor) const;
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const LayerList& children() const { return children_; }
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer* child_at(size_t index) { return children_[index].get(); }
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
10090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // This requests the layer and its subtree be rendered and given to the
10190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // callback. If the copy is unable to be produced (the layer is destroyed
10290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // first), then the callback is called with a NULL/empty result.
10390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> request);
10490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  bool HasCopyRequest() const {
10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    return !copy_requests_.empty();
106c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
107c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetBackgroundColor(SkColor background_color);
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  SkColor background_color() const { return background_color_; }
110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // If contents_opaque(), return an opaque color else return a
111868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  // non-opaque color.  Tries to return background_color(), if possible.
112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  SkColor SafeOpaqueBackgroundColor() const;
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // A layer's bounds are in logical, non-page-scaled pixels (however, the
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // root layer's bounds are in physical pixels).
1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetBounds(const gfx::Size& bounds);
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Size bounds() const { return bounds_; }
1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetMasksToBounds(bool masks_to_bounds);
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool masks_to_bounds() const { return masks_to_bounds_; }
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetMaskLayer(Layer* mask_layer);
1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer* mask_layer() { return mask_layer_.get(); }
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const Layer* mask_layer() const { return mask_layer_.get(); }
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect);
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetNeedsDisplay() { SetNeedsDisplayRect(gfx::RectF(bounds())); }
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetOpacity(float opacity);
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float opacity() const { return opacity_; }
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool OpacityIsAnimating() const;
1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool OpacityCanAnimateOnImplThread() const;
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
134f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void SetBlendMode(SkXfermode::Mode blend_mode);
135f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  SkXfermode::Mode blend_mode() const { return blend_mode_; }
136f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
137f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  bool uses_default_blend_mode() const {
138f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    return blend_mode_ == SkXfermode::kSrcOver_Mode;
139f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  }
140f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
141f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // A layer is root for an isolated group when it and all its descendants are
142f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // drawn over a black and fully transparent background, creating an isolated
143f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // group. It should be used along with SetBlendMode(), in order to restrict
144f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // layers within the group to blend with layers outside this group.
145f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  void SetIsRootForIsolatedGroup(bool root);
146f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  bool is_root_for_isolated_group() const {
147f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    return is_root_for_isolated_group_;
148f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  }
149f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
150eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void SetFilters(const FilterOperations& filters);
151eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  const FilterOperations& filters() const { return filters_; }
1524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  bool FilterIsAnimating() const;
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Background filters are filters applied to what is behind this layer, when
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // they are viewed through non-opaque regions in this layer. They are used
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // through the WebLayer interface, and are not exposed to HTML.
157eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void SetBackgroundFilters(const FilterOperations& filters);
158eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  const FilterOperations& background_filters() const {
1592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return background_filters_;
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetContentsOpaque(bool opaque);
1632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool contents_opaque() const { return contents_opaque_; }
1642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetPosition(const gfx::PointF& position);
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::PointF position() const { return position_; }
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetIsContainerForFixedPositionLayers(bool container);
169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  bool IsContainerForFixedPositionLayers() const;
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetPositionConstraint(const LayerPositionConstraint& constraint);
172c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  const LayerPositionConstraint& position_constraint() const {
173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return position_constraint_;
174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
1752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetTransform(const gfx::Transform& transform);
1772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const gfx::Transform& transform() const { return transform_; }
1782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool TransformIsAnimating() const;
1790529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  bool transform_is_invertible() const { return transform_is_invertible_; }
1802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
18146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  void SetTransformOrigin(const gfx::Point3F&);
18246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  gfx::Point3F transform_origin() { return transform_origin_; }
18346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)
1843551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  void SetScrollParent(Layer* parent);
1853551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1863551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  Layer* scroll_parent() { return scroll_parent_; }
1873551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const Layer* scroll_parent() const { return scroll_parent_; }
1883551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1893551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  void AddScrollChild(Layer* child);
1903551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  void RemoveScrollChild(Layer* child);
1913551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1923551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  std::set<Layer*>* scroll_children() { return scroll_children_.get(); }
1933551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const std::set<Layer*>* scroll_children() const {
1943551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return scroll_children_.get();
1953551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  }
1963551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1973551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  void SetClipParent(Layer* ancestor);
1983551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
1993551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  Layer* clip_parent() { return clip_parent_; }
2003551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const Layer* clip_parent() const {
2013551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return clip_parent_;
2023551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  }
2033551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
2043551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  void AddClipChild(Layer* child);
2053551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  void RemoveClipChild(Layer* child);
2063551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
2073551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  std::set<Layer*>* clip_children() { return clip_children_.get(); }
2083551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  const std::set<Layer*>* clip_children() const {
2093551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return clip_children_.get();
2103551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  }
2113551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
2128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DrawProperties<Layer>& draw_properties() { return draw_properties_; }
2138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  const DrawProperties<Layer>& draw_properties() const {
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_;
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The following are shortcut accessors to get various information from
2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // draw_properties_
2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const gfx::Transform& draw_transform() const {
2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.target_space_transform;
2212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const gfx::Transform& screen_space_transform() const {
2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.screen_space_transform;
2242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float draw_opacity() const { return draw_properties_.opacity; }
2262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool draw_opacity_is_animating() const {
2272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.opacity_is_animating;
2282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool draw_transform_is_animating() const {
2302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.target_space_transform_is_animating;
2312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool screen_space_transform_is_animating() const {
2332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.screen_space_transform_is_animating;
2342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool screen_space_opacity_is_animating() const {
2362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.screen_space_opacity_is_animating;
2372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; }
2392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool is_clipped() const { return draw_properties_.is_clipped; }
2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Rect clip_rect() const { return draw_properties_.clip_rect; }
2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Rect drawable_content_rect() const {
2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.drawable_content_rect;
2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Rect visible_content_rect() const {
2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.visible_content_rect;
2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer* render_target() {
2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    DCHECK(!draw_properties_.render_target ||
2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)           draw_properties_.render_target->render_surface());
2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.render_target;
2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const Layer* render_target() const {
2532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    DCHECK(!draw_properties_.render_target ||
2542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)           draw_properties_.render_target->render_surface());
2552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.render_target;
2562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  RenderSurface* render_surface() const {
2582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_properties_.render_surface.get();
2592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
260424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  int num_unclipped_descendants() const {
261424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return draw_properties_.num_unclipped_descendants;
262424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  }
2632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetScrollOffset(gfx::Vector2d scroll_offset);
2652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Vector2d scroll_offset() const { return scroll_offset_; }
2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetScrollOffsetFromImplSide(const gfx::Vector2d& scroll_offset);
2672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetScrollClipLayerId(int clip_layer_id);
2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool scrollable() const { return scroll_clip_layer_id_ != INVALID_ID; }
2702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  void SetUserScrollable(bool horizontal, bool vertical);
2728bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool user_scrollable_horizontal() const {
2738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    return user_scrollable_horizontal_;
2748bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  }
2758bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  bool user_scrollable_vertical() const { return user_scrollable_vertical_; }
2768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
2772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetShouldScrollOnMainThread(bool should_scroll_on_main_thread);
2782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool should_scroll_on_main_thread() const {
2792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return should_scroll_on_main_thread_;
2802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetHaveWheelEventHandlers(bool have_wheel_event_handlers);
2832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
2842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
285e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  void SetHaveScrollEventHandlers(bool have_scroll_event_handlers);
286e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  bool have_scroll_event_handlers() const {
287e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    return have_scroll_event_handlers_;
288e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  }
289e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
2902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetNonFastScrollableRegion(const Region& non_fast_scrollable_region);
2912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const Region& non_fast_scrollable_region() const {
2922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return non_fast_scrollable_region_;
2932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetTouchEventHandlerRegion(const Region& touch_event_handler_region);
2962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const Region& touch_event_handler_region() const {
2972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return touch_event_handler_region_;
2982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
2992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
300eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void set_did_scroll_callback(const base::Closure& callback) {
301eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch    did_scroll_callback_ = callback;
3022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
3032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetDrawCheckerboardForMissingTiles(bool checkerboard);
305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bool draw_checkerboard_for_missing_tiles() const {
3062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return draw_checkerboard_for_missing_tiles_;
3072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
3082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetForceRenderSurface(bool force_render_surface);
3102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool force_render_surface() const { return force_render_surface_; }
3112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
312c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  gfx::Vector2d ScrollDelta() const { return gfx::Vector2d(); }
3137dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  gfx::Vector2dF TotalScrollOffset() const {
3147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    // Floating point to match the LayerImpl version.
3157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    return scroll_offset() + ScrollDelta();
3167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  }
3172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetDoubleSided(bool double_sided);
3192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool double_sided() const { return double_sided_; }
3202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  void SetShouldFlattenTransform(bool flatten);
3225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool should_flatten_transform() const { return should_flatten_transform_; }
3235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3246d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  bool Is3dSorted() const { return sorting_context_id_ != 0; }
3252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void set_use_parent_backface_visibility(bool use) {
3272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    use_parent_backface_visibility_ = use;
3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
3292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool use_parent_backface_visibility() const {
3302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return use_parent_backface_visibility_;
3312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
3322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetLayerTreeHost(LayerTreeHost* host);
3342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3356e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual bool HasDelegatedContent() const;
3362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool HasContributingDelegatedRenderPasses() const { return false; }
3372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetIsDrawable(bool is_drawable);
3392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
340eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void SetHideLayerAndSubtree(bool hide);
341eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
342eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
3432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetReplicaLayer(Layer* layer);
3442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer* replica_layer() { return replica_layer_.get(); }
3452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const Layer* replica_layer() const { return replica_layer_.get(); }
3462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
347868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool has_mask() const { return !!mask_layer_.get(); }
348868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool has_replica() const { return !!replica_layer_.get(); }
3492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool replica_has_mask() const {
350868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    return replica_layer_.get() &&
351868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)           (mask_layer_.get() || replica_layer_->mask_layer_.get());
3522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
3532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3546e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  int NumDescendantsThatDrawContent() const;
3556e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
3566e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // This is only virtual for tests.
3576e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // TODO(awoloszyn): Remove this once we no longer need it for tests
3582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool DrawsContent() const;
3596e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
3606e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // This methods typically need to be overwritten by derived classes.
361c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void SavePaintProperties();
3627dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Returns true iff any resources were updated that need to be committed.
3637dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  virtual bool Update(ResourceUpdateQueue* queue,
364a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                      const OcclusionTracker<Layer>* occlusion);
3652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool NeedMoreUpdates();
3662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetIsMask(bool is_mask) {}
36790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  virtual void ReduceMemoryUsage() {}
3684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void OnOutputSurfaceCreated() {}
369010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)  virtual bool IsSuitableForGpuRasterization() const;
3702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
371a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual scoped_refptr<base::debug::ConvertableToTraceFormat> TakeDebugInfo();
3723551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
3733551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  void SetLayerClient(LayerClient* client) { client_ = client; }
3743551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
3752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void PushPropertiesTo(LayerImpl* layer);
3762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void CreateRenderSurface();
378c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void ClearRenderSurface();
3795c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  void ClearRenderSurfaceLayerList();
3802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The contents scale converts from logical, non-page-scaled pixels to target
3822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // pixels. The contents scale is 1 for the root layer as it is already in
3832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // physical pixels. By default contents scale is forced to be 1 except for
3842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // subclasses of ContentsScalingLayer.
3852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float contents_scale_x() const { return draw_properties_.contents_scale_x; }
3862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float contents_scale_y() const { return draw_properties_.contents_scale_y; }
3872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
3882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void CalculateContentsScale(float ideal_contents_scale,
3902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      float* contents_scale_x,
3912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      float* contents_scale_y,
3922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                      gfx::Size* content_bounds);
3932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
394424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  LayerTreeHost* layer_tree_host() { return layer_tree_host_; }
395424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; }
3962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Set the priority of all desired textures in this layer.
3982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) {}
3992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool AddAnimation(scoped_ptr<Animation> animation);
4012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void PauseAnimation(int animation_id, double time_offset);
4022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void RemoveAnimation(int animation_id);
4032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LayerAnimationController* layer_animation_controller() {
4052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return layer_animation_controller_.get();
4062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
407c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void SetLayerAnimationControllerForTest(
4082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      scoped_refptr<LayerAnimationController> controller);
4092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
410eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void set_layer_animation_delegate(AnimationDelegate* delegate) {
411c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    layer_animation_controller_->set_layer_animation_delegate(delegate);
4122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
4132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool HasActiveAnimation() const;
4152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void AddLayerAnimationEventObserver(
4172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      LayerAnimationEventObserver* animation_observer);
4182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void RemoveLayerAnimationEventObserver(
4192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      LayerAnimationEventObserver* animation_observer);
4202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
42103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
4222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
42358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  virtual ScrollbarLayerInterface* ToScrollbarLayer();
4242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4273551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  virtual skia::RefPtr<SkPicture> GetPicture() const;
4283551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
4292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Constructs a LayerImpl of the correct runtime type for this Layer type.
4302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
4312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
432a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  bool NeedsDisplayForTesting() const { return !update_rect_.IsEmpty(); }
433a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)  void ResetNeedsDisplayForTesting() { update_rect_ = gfx::RectF(); }
4342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
435c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  RenderingStatsInstrumentation* rendering_stats_instrumentation() const;
436c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
437c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  const PaintProperties& paint_properties() const {
438c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return paint_properties_;
439c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
440c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
441b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // The scale at which contents should be rastered, to match the scale at
442b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // which they will drawn to the screen. This scale is a component of the
443b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // contents scale but does not include page/device scale factors.
444b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // TODO(danakj): This goes away when TiledLayer goes away.
445b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  void set_raster_scale(float scale) { raster_scale_ = scale; }
446b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  float raster_scale() const { return raster_scale_; }
447b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  bool raster_scale_is_unknown() const { return raster_scale_ == 0.f; }
448b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
44990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  virtual bool SupportsLCDText() const;
45090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
451a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void SetNeedsPushProperties();
4527dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  bool needs_push_properties() const { return needs_push_properties_; }
4537dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  bool descendant_needs_push_properties() const {
4547dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    return num_dependents_need_push_properties_ > 0;
4557dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  }
456a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  void reset_needs_push_properties_for_testing() {
457a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    needs_push_properties_ = false;
458a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
4597dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
4604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void RunMicroBenchmark(MicroBenchmark* benchmark);
4614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
4626d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  void Set3dSortingContextId(int id);
4636d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  int sorting_context_id() const { return sorting_context_id_; }
4646d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
4652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
4662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  friend class LayerImpl;
4672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  friend class TreeSynchronizer;
4682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~Layer();
4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer();
4712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
472558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // These SetNeeds functions are in order of severity of update:
473558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  //
474558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // Called when this layer has been modified in some way, but isn't sure
475558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // that it needs a commit yet.  It needs CalcDrawProperties and UpdateLayers
476558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // before it knows whether or not a commit is required.
477558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  void SetNeedsUpdate();
478558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // Called when a property has been modified in a way that the layer
479558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // knows immediately that a commit is required.  This implies SetNeedsUpdate
480558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // as well as SetNeedsPushProperties to push that property.
4812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetNeedsCommit();
482558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // Called when there's been a change in layer structure.  Implies both
483558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // SetNeedsUpdate and SetNeedsCommit, but not SetNeedsPushProperties.
4842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetNeedsFullTreeSync();
485424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
486424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // Called when the next commit should wait until the pending tree is activated
487424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // before finishing the commit and unblocking the main thread. Used to ensure
488424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // unused resources on the impl thread are returned before commit completes.
489424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  void SetNextCommitWaitsForActivation();
4902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4916e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Will recalculate whether the layer draws content and set draws_content_
4926e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // appropriately.
4936e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void UpdateDrawsContent(bool has_drawable_content);
4946e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  virtual bool HasDrawableContent() const;
4956e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
4966e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Called when the layer's number of drawable descendants changes.
4976e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void AddDrawableDescendants(int num);
4986e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
4997dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void AddDependentNeedsPushProperties();
5007dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void RemoveDependentNeedsPushProperties();
5017dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  bool parent_should_know_need_push_properties() const {
5027dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    return needs_push_properties() || descendant_needs_push_properties();
5037dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  }
5047dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
505424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  bool IsPropertyChangeAllowed() const;
506424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
507b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  void reset_raster_scale_to_unknown() { raster_scale_ = 0.f; }
508b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
5097dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // This flag is set when the layer needs to push properties to the impl
5107dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // side.
5117dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  bool needs_push_properties_;
5127dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
5137dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // The number of direct children or dependent layers that need to be recursed
5147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // to in order for them or a descendent of them to push properties to the impl
5157dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // side.
5167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  int num_dependents_need_push_properties_;
5177dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
5182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Tracks whether this layer may have changed stacking order with its
5192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // siblings.
5202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool stacking_order_changed_;
5212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The update rect is the region of the compositor resource that was
5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // actually updated by the compositor. For layers that may do updating
5242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // outside the compositor's control (i.e. plugin layers), this information
5252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // is not available and the update rect will remain empty.
5262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Note this rect is in layer space (not content space).
5272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::RectF update_rect_;
5282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_refptr<Layer> mask_layer_;
5302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int layer_id_;
5322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // When true, the layer is about to perform an update. Any commit requests
534558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch  // will be handled implicitly after the update completes.
5352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool ignore_set_needs_commit_;
5362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5376d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  // Layers that share a sorting context id will be sorted together in 3d
5386d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  // space.  0 is a special value that means this layer will not be sorted and
5396d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  // will be drawn in paint order.
5406d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  int sorting_context_id_;
5416d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
5422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
5432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  friend class base::RefCounted<Layer>;
5442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void SetParent(Layer* layer);
5462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool DescendantIsFixedToContainerLayer() const;
5472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns the index of the child or -1 if not found.
5492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int IndexOfChild(const Layer* reference);
5502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // This should only be called from RemoveFromParent().
5522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void RemoveChildOrDependent(Layer* child);
5532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
554a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // LayerAnimationValueProvider implementation.
555a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE;
556a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
5572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // LayerAnimationValueObserver implementation.
5584e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE;
5592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnOpacityAnimated(float opacity) OVERRIDE;
5602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
5615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void OnScrollOffsetAnimated(
5625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const gfx::Vector2dF& scroll_offset) OVERRIDE;
563f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  virtual void OnAnimationWaitingForDeletion() OVERRIDE;
5642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool IsActive() const OVERRIDE;
5652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // If this layer has a scroll parent, it removes |this| from its list of
5671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // scroll children.
5681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void RemoveFromScrollTree();
5691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
5701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // If this layer has a clip parent, it removes |this| from its list of clip
5711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // children.
5721320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  void RemoveFromClipTree();
5731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
5742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LayerList children_;
5752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Layer* parent_;
5762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Layer instances have a weak pointer to their LayerTreeHost.
5782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // This pointer value is nil when a Layer is not in a tree and is
5792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // updated via SetLayerTreeHost() if a layer moves between trees.
5802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LayerTreeHost* layer_tree_host_;
5812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_refptr<LayerAnimationController> layer_animation_controller_;
5832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Layer properties.
5852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Size bounds_;
5862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Vector2d scroll_offset_;
5885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // This variable indicates which ancestor layer (if any) whose size,
5895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // transformed relative to this layer, defines the maximum scroll offset for
5905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // this layer.
5915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int scroll_clip_layer_id_;
5926e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  int num_descendants_that_draw_content_;
593a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool should_scroll_on_main_thread_ : 1;
594a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool have_wheel_event_handlers_ : 1;
595e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  bool have_scroll_event_handlers_ : 1;
596a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool user_scrollable_horizontal_ : 1;
597a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool user_scrollable_vertical_ : 1;
598a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool is_root_for_isolated_group_ : 1;
599a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool is_container_for_fixed_position_layers_ : 1;
600a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool is_drawable_ : 1;
6016e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  bool draws_content_ : 1;
602a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool hide_layer_and_subtree_ : 1;
603a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool masks_to_bounds_ : 1;
604a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool contents_opaque_ : 1;
605a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool double_sided_ : 1;
6065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool should_flatten_transform_ : 1;
607a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool use_parent_backface_visibility_ : 1;
608a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool draw_checkerboard_for_missing_tiles_ : 1;
609a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  bool force_render_surface_ : 1;
6100529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  bool transform_is_invertible_ : 1;
6112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Region non_fast_scrollable_region_;
6122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  Region touch_event_handler_region_;
6132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::PointF position_;
6142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  SkColor background_color_;
6152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float opacity_;
616f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  SkXfermode::Mode blend_mode_;
617eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  FilterOperations filters_;
618eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  FilterOperations background_filters_;
619c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  LayerPositionConstraint position_constraint_;
6203551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  Layer* scroll_parent_;
6213551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  scoped_ptr<std::set<Layer*> > scroll_children_;
6223551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
6233551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  Layer* clip_parent_;
6243551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  scoped_ptr<std::set<Layer*> > clip_children_;
6252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gfx::Transform transform_;
62746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)  gfx::Point3F transform_origin_;
6282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Replica layer used for reflections.
6302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_refptr<Layer> replica_layer_;
6312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Transient properties.
6332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  float raster_scale_;
6342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6353551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  LayerClient* client_;
6363551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
63790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  ScopedPtrVector<CopyOutputRequest> copy_requests_;
6382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
639eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::Closure did_scroll_callback_;
6402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DrawProperties<Layer> draw_properties_;
6422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
643c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  PaintProperties paint_properties_;
644c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(Layer);
6462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
6472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace cc
6492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // CC_LAYERS_LAYER_H_
651