Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / cc / layers / layer_impl.h
index 66fa84b..c86c554 100644 (file)
@@ -68,6 +68,8 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
   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));
   }
@@ -134,6 +136,7 @@ class CC_EXPORT LayerImpl : public 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(); }
@@ -245,12 +248,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
     return is_container_for_fixed_position_layers_;
   }
 
-  void SetFixedContainerSizeDelta(const 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;
@@ -259,8 +257,11 @@ class CC_EXPORT LayerImpl : public 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_; }
+
+  void SetIs3dSorted(bool sorted);
+  bool is_3d_sorted() const { return is_3d_sorted_; }
 
   void SetUseParentBackfaceVisibility(bool use) {
     use_parent_backface_visibility_ = use;
@@ -269,11 +270,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
     return use_parent_backface_visibility_;
   }
 
-  void SetSublayerTransform(const gfx::Transform& sublayer_transform);
-  const gfx::Transform& sublayer_transform() const {
-    return sublayer_transform_;
-  }
-
   bool ShowDebugBorders() const;
 
   // These invalidate the host's render surface layer list.  The caller
@@ -340,10 +336,15 @@ class CC_EXPORT LayerImpl : public 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);
+  void SetTemporaryImplBounds(const gfx::SizeF& bounds);
+  gfx::Size bounds() const;
+  gfx::Vector2dF BoundsDelta() const {
+    return gfx::Vector2dF(temporary_impl_bounds_.width() - bounds_.width(),
+                          temporary_impl_bounds_.height() - bounds_.height());
+  }
 
-  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; }
@@ -362,28 +363,30 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
       LayerScrollOffsetDelegate* scroll_offset_delegate);
   bool IsExternalFlingActive() const;
 
-  void SetScrollOffset(gfx::Vector2d scroll_offset);
-  void SetScrollOffsetAndDelta(gfx::Vector2d scroll_offset,
+  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_; }
-
+  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(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;
@@ -477,14 +480,15 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
     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;
@@ -542,8 +546,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
  private:
   void NoteLayerPropertyChangedForDescendantsInternal();
 
-  void UpdateScrollbarPositions();
-
   virtual const char* LayerTypeAsString() const;
 
   // Properties internal to LayerImpl
@@ -574,8 +576,10 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
   gfx::PointF anchor_point_;
   float anchor_point_z_;
   gfx::Size bounds_;
+  gfx::SizeF temporary_impl_bounds_;
   gfx::Vector2d scroll_offset_;
   LayerScrollOffsetDelegate* scroll_offset_delegate_;
+  LayerImpl* scroll_clip_layer_;
   bool scrollable_ : 1;
   bool should_scroll_on_main_thread_ : 1;
   bool have_wheel_event_handlers_ : 1;
@@ -584,6 +588,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
   bool stacking_order_changed_ : 1;
   // Whether the "back" of this layer should draw.
   bool double_sided_ : 1;
+  bool should_flatten_transform_ : 1;
 
   // Tracks if drawing-related properties have changed since last redraw.
   bool layer_property_changed_ : 1;
@@ -591,7 +596,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
   bool masks_to_bounds_ : 1;
   bool contents_opaque_ : 1;
   bool is_root_for_isolated_group_ : 1;
-  bool preserves_3d_ : 1;
   bool use_parent_backface_visibility_ : 1;
   bool draw_checkerboard_for_missing_tiles_ : 1;
   bool draws_content_ : 1;
@@ -600,6 +604,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
 
   // Set for the layer that other layers are fixed to.
   bool is_container_for_fixed_position_layers_ : 1;
+  bool is_3d_sorted_ : 1;
   Region non_fast_scrollable_region_;
   Region touch_event_handler_region_;
   SkColor background_color_;
@@ -607,18 +612,12 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
   float opacity_;
   SkXfermode::Mode blend_mode_;
   gfx::PointF position_;
-  gfx::Transform sublayer_transform_;
   gfx::Transform transform_;
 
-  // This property is effective when
-  // is_container_for_fixed_position_layers_ == true,
-  gfx::Vector2dF fixed_container_size_delta_;
-
   LayerPositionConstraint position_constraint_;
 
   gfx::Vector2dF scroll_delta_;
   gfx::Vector2d sent_scroll_delta_;
-  gfx::Vector2d max_scroll_offset_;
   gfx::Vector2dF last_scroll_offset_;
 
   // The global depth value of the center of the layer. This value is used
@@ -654,10 +653,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver,
   // 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_;