Upstream version 11.39.250.0
[platform/framework/web/crosswalk.git] / src / cc / layers / layer_impl.h
index 9d3951b..d3aa8b0 100644 (file)
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
 #include "base/values.h"
+#include "cc/animation/animation_delegate.h"
 #include "cc/animation/layer_animation_controller.h"
 #include "cc/animation/layer_animation_value_observer.h"
+#include "cc/animation/layer_animation_value_provider.h"
 #include "cc/base/cc_export.h"
 #include "cc/base/region.h"
 #include "cc/base/scoped_ptr_vector.h"
 #include "cc/input/input_handler.h"
-#include "cc/layers/compositing_reasons.h"
 #include "cc/layers/draw_properties.h"
 #include "cc/layers/layer_lists.h"
 #include "cc/layers/layer_position_constraint.h"
 #include "cc/layers/render_surface_impl.h"
 #include "cc/output/filter_operations.h"
-#include "cc/quads/render_pass.h"
 #include "cc/quads/shared_quad_state.h"
 #include "cc/resources/resource_provider.h"
 #include "skia/ext/refptr.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "third_party/skia/include/core/SkImageFilter.h"
 #include "third_party/skia/include/core/SkPicture.h"
+#include "ui/gfx/point3_f.h"
 #include "ui/gfx/rect.h"
 #include "ui/gfx/rect_f.h"
 #include "ui/gfx/transform.h"
 
 namespace base {
+namespace debug {
+class ConvertableToTraceFormat;
+class TracedValue;
+}
+
 class DictionaryValue;
 }
 
@@ -42,11 +48,17 @@ namespace cc {
 
 class LayerTreeHostImpl;
 class LayerTreeImpl;
-class QuadSink;
+class MicroBenchmarkImpl;
+class Occlusion;
+template <typename LayerType>
+class OcclusionTracker;
+class RenderPass;
+class RenderPassId;
 class Renderer;
 class ScrollbarAnimationController;
 class ScrollbarLayerImplBase;
-class Layer;
+class SimpleEnclosedRegion;
+class Tile;
 
 struct AppendQuadsData;
 
@@ -57,12 +69,25 @@ enum DrawMode {
   DRAW_MODE_RESOURCELESS_SOFTWARE
 };
 
-class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
+class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
+                            public LayerAnimationValueProvider,
+                            public AnimationDelegate {
  public:
+  // Allows for the ownership of the total scroll offset to be delegated outside
+  // of the layer.
+  class ScrollOffsetDelegate {
+   public:
+    virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_value) = 0;
+    virtual gfx::Vector2dF GetTotalScrollOffset() = 0;
+    virtual bool IsExternalFlingActive() const = 0;
+  };
+
   typedef LayerImplList RenderSurfaceListType;
   typedef LayerImplList LayerListType;
   typedef RenderSurfaceImpl RenderSurfaceType;
 
+  enum RenderingContextConstants { NO_RENDERING_CONTEXT = 0 };
+
   static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
     return make_scoped_ptr(new LayerImpl(tree_impl, id));
   }
@@ -71,12 +96,26 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
 
   int id() const { return layer_id_; }
 
+  // LayerAnimationValueProvider implementation.
+  virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE;
+
   // LayerAnimationValueObserver implementation.
   virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE;
   virtual void OnOpacityAnimated(float opacity) OVERRIDE;
   virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
+  virtual void OnScrollOffsetAnimated(
+      const gfx::Vector2dF& scroll_offset) OVERRIDE;
+  virtual void OnAnimationWaitingForDeletion() OVERRIDE;
   virtual bool IsActive() const OVERRIDE;
 
+  // AnimationDelegate implementation.
+  virtual void NotifyAnimationStarted(
+      base::TimeTicks monotonic_time,
+      Animation::TargetProperty target_property) OVERRIDE{};
+  virtual void NotifyAnimationFinished(
+      base::TimeTicks monotonic_time,
+      Animation::TargetProperty target_property) OVERRIDE;
+
   // Tree structure.
   LayerImpl* parent() { return parent_; }
   const LayerImpl* parent() const { return parent_; }
@@ -85,7 +124,8 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   LayerImpl* child_at(size_t index) const { return children_[index]; }
   void AddChild(scoped_ptr<LayerImpl> child);
   scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child);
-  void set_parent(LayerImpl* parent) { parent_ = parent; }
+  void SetParent(LayerImpl* parent);
+
   // Warning: This does not preserve tree structure invariants.
   void ClearChildList();
 
@@ -97,13 +137,13 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   const LayerImpl* scroll_parent() const { return scroll_parent_; }
 
   void SetScrollChildren(std::set<LayerImpl*>* children);
-  void RemoveScrollChild(LayerImpl* child);
 
   std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); }
   const std::set<LayerImpl*>* scroll_children() const {
     return scroll_children_.get();
   }
 
+  void SetNumDescendantsThatDrawContent(int num_descendants);
   void SetClipParent(LayerImpl* ancestor);
 
   LayerImpl* clip_parent() {
@@ -114,7 +154,6 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   }
 
   void SetClipChildren(std::set<LayerImpl*>* children);
-  void RemoveClipChild(LayerImpl* child);
 
   std::set<LayerImpl*>* clip_children() { return clip_children_.get(); }
   const std::set<LayerImpl*>* clip_children() const {
@@ -122,6 +161,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   }
 
   void PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests);
+  // Can only be called when the layer has a copy request.
   void TakeCopyRequestsAndTransformToTarget(
       ScopedPtrVector<CopyOutputRequest>* request);
   bool HasCopyRequest() const { return !copy_requests_.empty(); }
@@ -144,7 +184,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
 
   LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; }
 
-  scoped_ptr<SharedQuadState> CreateSharedQuadState() const;
+  void PopulateSharedQuadState(SharedQuadState* state) const;
   // WillDraw must be called before AppendQuads. If WillDraw returns false,
   // AppendQuads and DidDraw will not be called. If WillDraw returns true,
   // DidDraw is guaranteed to be called before another WillDraw or before
@@ -153,7 +193,8 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   // returns true.
   virtual bool WillDraw(DrawMode draw_mode,
                         ResourceProvider* resource_provider);
-  virtual void AppendQuads(QuadSink* quad_sink,
+  virtual void AppendQuads(RenderPass* render_pass,
+                           const OcclusionTracker<LayerImpl>& occlusion_tracker,
                            AppendQuadsData* append_quads_data) {}
   virtual void DidDraw(ResourceProvider* resource_provider);
 
@@ -161,10 +202,12 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
 
   virtual bool HasDelegatedContent() const;
   virtual bool HasContributingDelegatedRenderPasses() const;
-  virtual RenderPass::Id FirstContributingRenderPassId() const;
-  virtual RenderPass::Id NextContributingRenderPassId(RenderPass::Id id) const;
+  virtual RenderPassId FirstContributingRenderPassId() const;
+  virtual RenderPassId NextContributingRenderPassId(RenderPassId id) const;
 
-  virtual void UpdateTilePriorities() {}
+  virtual void UpdateTiles(const Occlusion& occlusion_in_layer_space,
+                           bool resourceless_software_draw) {}
+  virtual void NotifyTileStateChanged(const Tile* tile) {}
 
   virtual ScrollbarLayerImplBase* ToScrollbarLayer();
 
@@ -172,17 +215,15 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   void SetDrawsContent(bool draws_content);
   bool DrawsContent() const { return draws_content_; }
 
+  int NumDescendantsThatDrawContent() const;
   void SetHideLayerAndSubtree(bool hide);
   bool hide_layer_and_subtree() const { return hide_layer_and_subtree_; }
 
   bool force_render_surface() const { return force_render_surface_; }
   void SetForceRenderSurface(bool force) { force_render_surface_ = force; }
 
-  void SetAnchorPoint(gfx::PointF anchor_point);
-  gfx::PointF anchor_point() const { return anchor_point_; }
-
-  void SetAnchorPointZ(float anchor_point_z);
-  float anchor_point_z() const { return anchor_point_z_; }
+  void SetTransformOrigin(const gfx::Point3F& transform_origin);
+  gfx::Point3F transform_origin() const { return transform_origin_; }
 
   void SetBackgroundColor(SkColor background_color);
   SkColor background_color() const { return background_color_; }
@@ -211,7 +252,18 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   bool OpacityIsAnimating() const;
   bool OpacityIsAnimatingOnImplOnly() const;
 
-  void SetPosition(gfx::PointF position);
+  void SetBlendMode(SkXfermode::Mode);
+  SkXfermode::Mode blend_mode() const { return blend_mode_; }
+  bool uses_default_blend_mode() const {
+    return blend_mode_ == SkXfermode::kSrcOver_Mode;
+  }
+
+  void SetIsRootForIsolatedGroup(bool root);
+  bool is_root_for_isolated_group() const {
+    return is_root_for_isolated_group_;
+  }
+
+  void SetPosition(const gfx::PointF& position);
   gfx::PointF position() const { return position_; }
 
   void SetIsContainerForFixedPositionLayers(bool container) {
@@ -222,12 +274,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
     return is_container_for_fixed_position_layers_;
   }
 
-  void SetFixedContainerSizeDelta(gfx::Vector2dF delta) {
-    fixed_container_size_delta_ = delta;
-  }
-  gfx::Vector2dF fixed_container_size_delta() const {
-    return fixed_container_size_delta_;
-  }
+  gfx::Vector2dF FixedContainerSizeDelta() const;
 
   void SetPositionConstraint(const LayerPositionConstraint& constraint) {
     position_constraint_ = constraint;
@@ -236,8 +283,10 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
     return position_constraint_;
   }
 
-  void SetPreserves3d(bool preserves_3d);
-  bool preserves_3d() const { return preserves_3d_; }
+  void SetShouldFlattenTransform(bool flatten);
+  bool should_flatten_transform() const { return should_flatten_transform_; }
+
+  bool Is3dSorted() const { return sorting_context_id_ != 0; }
 
   void SetUseParentBackfaceVisibility(bool use) {
     use_parent_backface_visibility_ = use;
@@ -246,23 +295,6 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
     return use_parent_backface_visibility_;
   }
 
-  void SetSublayerTransform(const gfx::Transform& sublayer_transform);
-  const gfx::Transform& sublayer_transform() const {
-    return sublayer_transform_;
-  }
-
-  // Debug layer name.
-  void SetDebugName(const std::string& debug_name) { debug_name_ = debug_name; }
-  std::string debug_name() const { return debug_name_; }
-
-  void SetCompositingReasons(CompositingReasons reasons) {
-      compositing_reasons_ = reasons;
-  }
-
-  CompositingReasons compositing_reasons() const {
-      return compositing_reasons_;
-  }
-
   bool ShowDebugBorders() const;
 
   // These invalidate the host's render surface layer list.  The caller
@@ -270,6 +302,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   // so that its list can be recreated.
   void CreateRenderSurface();
   void ClearRenderSurface();
+  void ClearRenderSurfaceLayerList();
 
   DrawProperties<LayerImpl>& draw_properties() {
     return draw_properties_;
@@ -329,50 +362,45 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   // contents scale to appropriate values. LayerImpl doesn't calculate any of
   // them from the other values.
 
-  void SetBounds(gfx::Size bounds);
-  gfx::Size bounds() const { return bounds_; }
+  void SetBounds(const gfx::Size& bounds);
+  gfx::Size bounds() const;
+  void SetBoundsDelta(const gfx::Vector2dF& bounds_delta);
+  gfx::Vector2dF bounds_delta() const { return bounds_delta_; }
 
-  void SetContentBounds(gfx::Size content_bounds);
+  void SetContentBounds(const gfx::Size& content_bounds);
   gfx::Size content_bounds() const { return draw_properties_.content_bounds; }
 
   float contents_scale_x() const { return draw_properties_.contents_scale_x; }
   float contents_scale_y() const { return draw_properties_.contents_scale_y; }
   void SetContentsScale(float contents_scale_x, float contents_scale_y);
 
-  virtual void CalculateContentsScale(float ideal_contents_scale,
-                                      float device_scale_factor,
-                                      float page_scale_factor,
-                                      bool animating_transform_to_screen,
-                                      float* contents_scale_x,
-                                      float* contents_scale_y,
-                                      gfx::Size* content_bounds);
-
-  void SetScrollOffsetDelegate(
-      LayerScrollOffsetDelegate* scroll_offset_delegate);
+  void SetScrollOffsetDelegate(ScrollOffsetDelegate* scroll_offset_delegate);
   bool IsExternalFlingActive() const;
 
-  void SetScrollOffset(gfx::Vector2d scroll_offset);
-  void SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset,
-                               gfx::Vector2dF scroll_delta);
+  void SetScrollOffset(const gfx::Vector2d& scroll_offset);
+  void SetScrollOffsetAndDelta(const gfx::Vector2d& scroll_offset,
+                               const gfx::Vector2dF& scroll_delta);
   gfx::Vector2d scroll_offset() const { return scroll_offset_; }
 
-  void SetMaxScrollOffset(gfx::Vector2d max_scroll_offset);
-  gfx::Vector2d max_scroll_offset() const { return max_scroll_offset_; }
-
-  void SetScrollDelta(gfx::Vector2dF scroll_delta);
+  gfx::Vector2d MaxScrollOffset() const;
+  gfx::Vector2dF ClampScrollToMaxScrollOffset();
+  void SetScrollbarPosition(ScrollbarLayerImplBase* scrollbar_layer,
+                            LayerImpl* scrollbar_clip_layer) const;
+  void SetScrollDelta(const gfx::Vector2dF& scroll_delta);
   gfx::Vector2dF ScrollDelta() const;
 
   gfx::Vector2dF TotalScrollOffset() const;
 
-  void SetSentScrollDelta(gfx::Vector2d sent_scroll_delta);
+  void SetSentScrollDelta(const gfx::Vector2d& sent_scroll_delta);
   gfx::Vector2d sent_scroll_delta() const { return sent_scroll_delta_; }
 
   // Returns the delta of the scroll that was outside of the bounds of the
   // initial scroll
-  gfx::Vector2dF ScrollBy(gfx::Vector2dF scroll);
+  gfx::Vector2dF ScrollBy(const gfx::Vector2dF& scroll);
 
-  void SetScrollable(bool scrollable) { scrollable_ = scrollable; }
-  bool scrollable() const { return scrollable_; }
+  void SetScrollClipLayer(int scroll_clip_layer_id);
+  LayerImpl* scroll_clip_layer() const { return scroll_clip_layer_; }
+  bool scrollable() const { return !!scroll_clip_layer_; }
 
   void set_user_scrollable_horizontal(bool scrollable) {
     user_scrollable_horizontal_ = scrollable;
@@ -396,6 +424,13 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   }
   bool have_wheel_event_handlers() const { return have_wheel_event_handlers_; }
 
+  void SetHaveScrollEventHandlers(bool have_scroll_event_handlers) {
+    have_scroll_event_handlers_ = have_scroll_event_handlers;
+  }
+  bool have_scroll_event_handlers() const {
+    return have_scroll_event_handlers_;
+  }
+
   void SetNonFastScrollableRegion(const Region& region) {
     non_fast_scrollable_region_ = region;
   }
@@ -413,10 +448,12 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   void SetDrawCheckerboardForMissingTiles(bool checkerboard) {
     draw_checkerboard_for_missing_tiles_ = checkerboard;
   }
-  bool DrawCheckerboardForMissingTiles() const;
+  bool draw_checkerboard_for_missing_tiles() const {
+    return draw_checkerboard_for_missing_tiles_;
+  }
 
   InputHandler::ScrollStatus TryScroll(
-      gfx::PointF screen_space_point,
+      const gfx::PointF& screen_space_point,
       InputHandler::ScrollInputType type) const;
 
   void SetDoubleSided(bool double_sided);
@@ -426,69 +463,93 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   const gfx::Transform& transform() const { return transform_; }
   bool TransformIsAnimating() const;
   bool TransformIsAnimatingOnImplOnly() const;
+  void SetTransformAndInvertibility(const gfx::Transform& transform,
+                                    bool transform_is_invertible);
+  bool transform_is_invertible() const { return transform_is_invertible_; }
 
   // Note this rect is in layer space (not content space).
-  void set_update_rect(const gfx::RectF& update_rect) {
-    update_rect_ = update_rect;
-  }
+  void SetUpdateRect(const gfx::RectF& update_rect);
+
   const gfx::RectF& update_rect() const { return update_rect_; }
 
+  void AddDamageRect(const gfx::RectF& damage_rect);
+
+  const gfx::RectF& damage_rect() const { return damage_rect_; }
+
   virtual base::DictionaryValue* LayerTreeAsJson() const;
 
   void SetStackingOrderChanged(bool stacking_order_changed);
 
-  bool LayerPropertyChanged() const {
-    return layer_property_changed_ || LayerIsAlwaysDamaged();
-  }
+  bool LayerPropertyChanged() const { return layer_property_changed_; }
 
   void ResetAllChangeTrackingForSubtree();
 
-  virtual bool LayerIsAlwaysDamaged() const;
-
   LayerAnimationController* layer_animation_controller() {
     return layer_animation_controller_.get();
   }
 
-  virtual Region VisibleContentOpaqueRegion() const;
+  const LayerAnimationController* layer_animation_controller() const {
+    return layer_animation_controller_.get();
+  }
+
+  virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const;
 
   virtual void DidBecomeActive();
 
   virtual void DidBeginTracing();
 
-  // Indicates that the surface previously used to render this layer
-  // was lost and that a new one has been created. Won't be called
-  // until the new surface has been created successfully.
-  virtual void DidLoseOutputSurface();
+  // Release resources held by this layer. Called when the output surface
+  // that rendered this layer was lost or a rendering mode switch has occured.
+  virtual void ReleaseResources();
 
   ScrollbarAnimationController* scrollbar_animation_controller() const {
     return scrollbar_animation_controller_.get();
   }
 
-  void SetHorizontalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer);
-  ScrollbarLayerImplBase* horizontal_scrollbar_layer() {
-    return horizontal_scrollbar_layer_;
-  }
-
-  void SetVerticalScrollbarLayer(ScrollbarLayerImplBase* scrollbar_layer);
-  ScrollbarLayerImplBase* vertical_scrollbar_layer() {
-    return vertical_scrollbar_layer_;
+  typedef std::set<ScrollbarLayerImplBase*> ScrollbarSet;
+  ScrollbarSet* scrollbars() { return scrollbars_.get(); }
+  void ClearScrollbars();
+  void AddScrollbar(ScrollbarLayerImplBase* layer);
+  void RemoveScrollbar(ScrollbarLayerImplBase* layer);
+  bool HasScrollbar(ScrollbarOrientation orientation) const;
+  void ScrollbarParametersDidChange();
+  int clip_height() {
+    return scroll_clip_layer_ ? scroll_clip_layer_->bounds().height() : 0;
   }
 
   gfx::Rect LayerRectToContentRect(const gfx::RectF& layer_rect) const;
 
   virtual skia::RefPtr<SkPicture> GetPicture();
 
-  virtual bool AreVisibleResourcesReady() const;
-
   virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl);
   virtual void PushPropertiesTo(LayerImpl* layer);
 
-  scoped_ptr<base::Value> AsValue() const;
+  virtual void GetAllTilesForTracing(std::set<const Tile*>* tiles) const;
+  virtual void AsValueInto(base::debug::TracedValue* dict) const;
+
   virtual size_t GPUMemoryUsageInBytes() const;
 
-  // TODO(danakj): Be true only if needed. crbug.com/259511
-  bool needs_push_properties() const { return true; }
-  bool descendant_needs_push_properties() const { return true; }
+  void SetNeedsPushProperties();
+  void AddDependentNeedsPushProperties();
+  void RemoveDependentNeedsPushProperties();
+  bool parent_should_know_need_push_properties() const {
+    return needs_push_properties() || descendant_needs_push_properties();
+  }
+
+  bool needs_push_properties() const { return needs_push_properties_; }
+  bool descendant_needs_push_properties() const {
+    return num_dependents_need_push_properties_ > 0;
+  }
+
+  virtual void RunMicroBenchmark(MicroBenchmarkImpl* benchmark);
+
+  virtual void SetDebugInfo(
+      scoped_refptr<base::debug::ConvertableToTraceFormat> other);
+
+  bool IsDrawnRenderSurfaceLayerListMember() const;
+
+  void Set3dSortingContextId(int id);
+  int sorting_context_id() { return sorting_context_id_; }
 
  protected:
   LayerImpl(LayerTreeImpl* layer_impl, int id);
@@ -496,17 +557,17 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   // Get the color and size of the layer's debug border.
   virtual void GetDebugBorderProperties(SkColor* color, float* width) const;
 
-  void AppendDebugBorderQuad(QuadSink* quad_sink,
+  void AppendDebugBorderQuad(RenderPass* render_pass,
+                             const gfx::Size& content_bounds,
                              const SharedQuadState* shared_quad_state,
                              AppendQuadsData* append_quads_data) const;
-  void AppendDebugBorderQuad(QuadSink* quad_sink,
+  void AppendDebugBorderQuad(RenderPass* render_pass,
+                             const gfx::Size& content_bounds,
                              const SharedQuadState* shared_quad_state,
                              AppendQuadsData* append_quads_data,
                              SkColor color,
                              float width) const;
 
-  virtual void AsValueInto(base::DictionaryValue* dict) const;
-
   void NoteLayerPropertyChanged();
   void NoteLayerPropertyChangedForSubtree();
 
@@ -514,7 +575,7 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   void NoteLayerPropertyChangedForDescendants();
 
  private:
-  void UpdateScrollbarPositions();
+  void NoteLayerPropertyChangedForDescendantsInternal();
 
   virtual const char* LayerTypeAsString() const;
 
@@ -543,84 +604,99 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   LayerTreeImpl* layer_tree_impl_;
 
   // Properties synchronized from the associated Layer.
-  gfx::PointF anchor_point_;
-  float anchor_point_z_;
+  gfx::Point3F transform_origin_;
   gfx::Size bounds_;
+  gfx::Vector2dF bounds_delta_;
   gfx::Vector2d scroll_offset_;
-  LayerScrollOffsetDelegate* scroll_offset_delegate_;
-  bool scrollable_;
-  bool should_scroll_on_main_thread_;
-  bool have_wheel_event_handlers_;
-  bool user_scrollable_horizontal_;
-  bool user_scrollable_vertical_;
-  Region non_fast_scrollable_region_;
-  Region touch_event_handler_region_;
-  SkColor background_color_;
-  bool stacking_order_changed_;
-
+  ScrollOffsetDelegate* scroll_offset_delegate_;
+  LayerImpl* scroll_clip_layer_;
+  bool scrollable_ : 1;
+  bool should_scroll_on_main_thread_ : 1;
+  bool have_wheel_event_handlers_ : 1;
+  bool have_scroll_event_handlers_ : 1;
+  bool user_scrollable_horizontal_ : 1;
+  bool user_scrollable_vertical_ : 1;
+  bool stacking_order_changed_ : 1;
   // Whether the "back" of this layer should draw.
-  bool double_sided_;
+  bool double_sided_ : 1;
+  bool should_flatten_transform_ : 1;
 
   // Tracks if drawing-related properties have changed since last redraw.
-  bool layer_property_changed_;
+  bool layer_property_changed_ : 1;
 
-  bool masks_to_bounds_;
-  bool contents_opaque_;
-  float opacity_;
-  gfx::PointF position_;
-  bool preserves_3d_;
-  bool use_parent_backface_visibility_;
-  bool draw_checkerboard_for_missing_tiles_;
-  gfx::Transform sublayer_transform_;
-  gfx::Transform transform_;
+  bool masks_to_bounds_ : 1;
+  bool contents_opaque_ : 1;
+  bool is_root_for_isolated_group_ : 1;
+  bool use_parent_backface_visibility_ : 1;
+  bool draw_checkerboard_for_missing_tiles_ : 1;
+  bool draws_content_ : 1;
+  bool hide_layer_and_subtree_ : 1;
+  bool force_render_surface_ : 1;
 
-  bool draws_content_;
-  bool hide_layer_and_subtree_;
-  bool force_render_surface_;
+  // Cache transform_'s invertibility.
+  bool transform_is_invertible_ : 1;
 
   // Set for the layer that other layers are fixed to.
-  bool is_container_for_fixed_position_layers_;
-  // This property is effective when
-  // is_container_for_fixed_position_layers_ == true,
-  gfx::Vector2dF fixed_container_size_delta_;
+  bool is_container_for_fixed_position_layers_ : 1;
+  Region non_fast_scrollable_region_;
+  Region touch_event_handler_region_;
+  SkColor background_color_;
+
+  float opacity_;
+  SkXfermode::Mode blend_mode_;
+  gfx::PointF position_;
+  gfx::Transform transform_;
 
   LayerPositionConstraint position_constraint_;
 
   gfx::Vector2dF scroll_delta_;
   gfx::Vector2d sent_scroll_delta_;
-  gfx::Vector2d max_scroll_offset_;
   gfx::Vector2dF last_scroll_offset_;
 
+  int num_descendants_that_draw_content_;
+
   // The global depth value of the center of the layer. This value is used
   // to sort layers from back to front.
   float draw_depth_;
 
-  // Debug layer name.
-  std::string debug_name_;
-  CompositingReasons compositing_reasons_;
-
   FilterOperations filters_;
   FilterOperations background_filters_;
 
  protected:
+  friend class TreeSynchronizer;
+
+  // This flag is set when the layer needs to push properties to the active
+  // side.
+  bool needs_push_properties_;
+
+  // The number of direct children or dependent layers that need to be recursed
+  // to in order for them or a descendent of them to push properties to the
+  // active side.
+  int num_dependents_need_push_properties_;
+
+  // Layers that share a sorting context id will be sorted together in 3d
+  // space.  0 is a special value that means this layer will not be sorted and
+  // will be drawn in paint order.
+  int sorting_context_id_;
+
   DrawMode current_draw_mode_;
 
  private:
   // Rect indicating what was repainted/updated during update.
   // Note that plugin layers bypass this and leave it empty.
-  // Uses layer's content space.
+  // Uses layer (not content) space.
   gfx::RectF update_rect_;
 
+  // This rect is in layer space.
+  gfx::RectF damage_rect_;
+
   // Manages animations for this layer.
   scoped_refptr<LayerAnimationController> layer_animation_controller_;
 
   // Manages scrollbars for this layer
   scoped_ptr<ScrollbarAnimationController> scrollbar_animation_controller_;
 
-  // Weak pointers to this layer's scrollbars, if it has them. Updated during
-  // tree synchronization.
-  ScrollbarLayerImplBase* horizontal_scrollbar_layer_;
-  ScrollbarLayerImplBase* vertical_scrollbar_layer_;
+  scoped_ptr<ScrollbarSet> scrollbars_;
 
   ScopedPtrVector<CopyOutputRequest> copy_requests_;
 
@@ -628,6 +704,8 @@ class CC_EXPORT LayerImpl : LayerAnimationValueObserver {
   // hierarchy before layers can be drawn.
   DrawProperties<LayerImpl> draw_properties_;
 
+  scoped_refptr<base::debug::ConvertableToTraceFormat> debug_info_;
+
   DISALLOW_COPY_AND_ASSIGN(LayerImpl);
 };