Home | History | Annotate | Download | only in compositor_bindings
      1 // Copyright 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
      6 #define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
      7 
      8 #include <string>
      9 
     10 #include "base/memory/ref_counted.h"
     11 #include "base/memory/scoped_ptr.h"
     12 #include "cc/layers/layer_client.h"
     13 #include "third_party/WebKit/public/platform/WebAnimation.h"
     14 #include "third_party/WebKit/public/platform/WebCString.h"
     15 #include "third_party/WebKit/public/platform/WebColor.h"
     16 #include "third_party/WebKit/public/platform/WebCompositingReasons.h"
     17 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
     18 #include "third_party/WebKit/public/platform/WebLayer.h"
     19 #include "third_party/WebKit/public/platform/WebPoint.h"
     20 #include "third_party/WebKit/public/platform/WebRect.h"
     21 #include "third_party/WebKit/public/platform/WebSize.h"
     22 #include "third_party/WebKit/public/platform/WebString.h"
     23 #include "third_party/WebKit/public/platform/WebVector.h"
     24 #include "third_party/skia/include/utils/SkMatrix44.h"
     25 #include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
     26 
     27 namespace cc { class Layer; }
     28 
     29 // TODO(senorblanco):  Remove this once WebKit changes have landed.
     30 class SkImageFilter;
     31 
     32 namespace blink {
     33 class WebFilterOperations;
     34 class WebLayerClient;
     35 struct WebFloatRect;
     36 }
     37 
     38 namespace base {
     39 namespace debug {
     40 class ConvertableToTraceFormat;
     41 }
     42 }
     43 
     44 namespace webkit {
     45 
     46 class WebToCCAnimationDelegateAdapter;
     47 
     48 class WebLayerImpl : public blink::WebLayer, public cc::LayerClient {
     49  public:
     50   WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebLayerImpl();
     51   WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebLayerImpl(
     52       scoped_refptr<cc::Layer>);
     53   virtual ~WebLayerImpl();
     54 
     55   WEBKIT_COMPOSITOR_BINDINGS_EXPORT cc::Layer* layer() const;
     56 
     57   // WebLayer implementation.
     58   virtual int id() const;
     59   virtual void invalidateRect(const blink::WebFloatRect&);
     60   virtual void invalidate();
     61   virtual void addChild(blink::WebLayer* child);
     62   virtual void insertChild(blink::WebLayer* child, size_t index);
     63   virtual void replaceChild(blink::WebLayer* reference,
     64                             blink::WebLayer* new_layer);
     65   virtual void removeFromParent();
     66   virtual void removeAllChildren();
     67   virtual void setAnchorPoint(const blink::WebFloatPoint&);
     68   virtual blink::WebFloatPoint anchorPoint() const;
     69   virtual void setAnchorPointZ(float anchor_point_z);
     70   virtual float anchorPointZ() const;
     71   virtual void setBounds(const blink::WebSize& bounds);
     72   virtual blink::WebSize bounds() const;
     73   virtual void setMasksToBounds(bool masks_to_bounds);
     74   virtual bool masksToBounds() const;
     75   virtual void setMaskLayer(blink::WebLayer* mask);
     76   virtual void setReplicaLayer(blink::WebLayer* replica);
     77   virtual void setOpacity(float opacity);
     78   virtual float opacity() const;
     79   virtual void setBlendMode(blink::WebBlendMode blend_mode);
     80   virtual blink::WebBlendMode blendMode() const;
     81   virtual void setIsRootForIsolatedGroup(bool root);
     82   virtual bool isRootForIsolatedGroup();
     83   virtual void setOpaque(bool opaque);
     84   virtual bool opaque() const;
     85   virtual void setPosition(const blink::WebFloatPoint& position);
     86   virtual blink::WebFloatPoint position() const;
     87   virtual void setSublayerTransform(const SkMatrix44&);
     88   virtual SkMatrix44 sublayerTransform() const;
     89   virtual void setTransform(const SkMatrix44& transform);
     90   virtual SkMatrix44 transform() const;
     91   virtual void setDrawsContent(bool draws_content);
     92   virtual bool drawsContent() const;
     93   virtual void setPreserves3D(bool preserves_3d);
     94   virtual void setUseParentBackfaceVisibility(bool visible);
     95   virtual void setBackgroundColor(blink::WebColor color);
     96   virtual blink::WebColor backgroundColor() const;
     97   virtual void setFilters(const blink::WebFilterOperations& filters);
     98   virtual void setBackgroundFilters(const blink::WebFilterOperations& filters);
     99   virtual void setCompositingReasons(blink::WebCompositingReasons);
    100   virtual void setAnimationDelegate(blink::WebAnimationDelegate* delegate);
    101   virtual bool addAnimation(blink::WebAnimation* animation);
    102   virtual void removeAnimation(int animation_id);
    103   virtual void removeAnimation(int animation_id,
    104                                blink::WebAnimation::TargetProperty);
    105   virtual void pauseAnimation(int animation_id, double time_offset);
    106   virtual bool hasActiveAnimation();
    107   virtual void setForceRenderSurface(bool force);
    108   virtual void setScrollPosition(blink::WebPoint position);
    109   virtual blink::WebPoint scrollPosition() const;
    110   virtual void setMaxScrollPosition(blink::WebSize max_position);
    111   virtual blink::WebSize maxScrollPosition() const;
    112   virtual void setScrollable(bool scrollable);
    113   virtual bool scrollable() const;
    114   virtual void setUserScrollable(bool horizontal, bool vertical);
    115   virtual bool userScrollableHorizontal() const;
    116   virtual bool userScrollableVertical() const;
    117   virtual void setHaveWheelEventHandlers(bool have_wheel_event_handlers);
    118   virtual bool haveWheelEventHandlers() const;
    119   virtual void setShouldScrollOnMainThread(bool scroll_on_main);
    120   virtual bool shouldScrollOnMainThread() const;
    121   virtual void setNonFastScrollableRegion(
    122       const blink::WebVector<blink::WebRect>& region);
    123   virtual blink::WebVector<blink::WebRect> nonFastScrollableRegion() const;
    124   virtual void setTouchEventHandlerRegion(
    125       const blink::WebVector<blink::WebRect>& region);
    126   virtual blink::WebVector<blink::WebRect> touchEventHandlerRegion() const;
    127   virtual void setIsContainerForFixedPositionLayers(bool is_container);
    128   virtual bool isContainerForFixedPositionLayers() const;
    129   virtual void setPositionConstraint(
    130       const blink::WebLayerPositionConstraint& constraint);
    131   virtual blink::WebLayerPositionConstraint positionConstraint() const;
    132   virtual void setScrollClient(blink::WebLayerScrollClient* client);
    133   virtual bool isOrphan() const;
    134   virtual void setWebLayerClient(blink::WebLayerClient* client);
    135 
    136   // LayerClient implementation.
    137   virtual std::string DebugName() OVERRIDE;
    138   virtual scoped_refptr<base::debug::ConvertableToTraceFormat>
    139       TakeDebugInfo() OVERRIDE;
    140 
    141   virtual void setScrollParent(blink::WebLayer* parent);
    142   virtual void setClipParent(blink::WebLayer* parent);
    143 
    144  protected:
    145   scoped_refptr<cc::Layer> layer_;
    146   blink::WebLayerClient* web_layer_client_;
    147 
    148  private:
    149   scoped_ptr<WebToCCAnimationDelegateAdapter> animation_delegate_adapter_;
    150 
    151   DISALLOW_COPY_AND_ASSIGN(WebLayerImpl);
    152 };
    153 
    154 }  // namespace webkit
    155 
    156 #endif  // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
    157