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.
5 #ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
6 #define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
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"
27 namespace cc
{ class Layer
; }
29 // TODO(senorblanco): Remove this once WebKit changes have landed.
33 class WebFilterOperations
;
40 class ConvertableToTraceFormat
;
46 class WebToCCAnimationDelegateAdapter
;
48 class WebLayerImpl
: public blink::WebLayer
, public cc::LayerClient
{
50 WEBKIT_COMPOSITOR_BINDINGS_EXPORT
WebLayerImpl();
51 WEBKIT_COMPOSITOR_BINDINGS_EXPORT
explicit WebLayerImpl(
52 scoped_refptr
<cc::Layer
>);
53 virtual ~WebLayerImpl();
55 WEBKIT_COMPOSITOR_BINDINGS_EXPORT
cc::Layer
* layer() const;
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 setOpaque(bool opaque
);
80 virtual bool opaque() const;
81 virtual void setPosition(const blink::WebFloatPoint
& position
);
82 virtual blink::WebFloatPoint
position() const;
83 virtual void setSublayerTransform(const SkMatrix44
&);
84 virtual SkMatrix44
sublayerTransform() const;
85 virtual void setTransform(const SkMatrix44
& transform
);
86 virtual SkMatrix44
transform() const;
87 virtual void setDrawsContent(bool draws_content
);
88 virtual bool drawsContent() const;
89 virtual void setPreserves3D(bool preserves_3d
);
90 virtual void setUseParentBackfaceVisibility(bool visible
);
91 virtual void setBackgroundColor(blink::WebColor color
);
92 virtual blink::WebColor
backgroundColor() const;
93 virtual void setFilters(const blink::WebFilterOperations
& filters
);
94 virtual void setBackgroundFilters(const blink::WebFilterOperations
& filters
);
95 virtual void setCompositingReasons(blink::WebCompositingReasons
);
96 virtual void setAnimationDelegate(blink::WebAnimationDelegate
* delegate
);
97 virtual bool addAnimation(blink::WebAnimation
* animation
);
98 virtual void removeAnimation(int animation_id
);
99 virtual void removeAnimation(int animation_id
,
100 blink::WebAnimation::TargetProperty
);
101 virtual void pauseAnimation(int animation_id
, double time_offset
);
102 virtual bool hasActiveAnimation();
103 virtual void setForceRenderSurface(bool force
);
104 virtual void setScrollPosition(blink::WebPoint position
);
105 virtual blink::WebPoint
scrollPosition() const;
106 virtual void setMaxScrollPosition(blink::WebSize max_position
);
107 virtual blink::WebSize
maxScrollPosition() const;
108 virtual void setScrollable(bool scrollable
);
109 virtual bool scrollable() const;
110 virtual void setUserScrollable(bool horizontal
, bool vertical
);
111 virtual bool userScrollableHorizontal() const;
112 virtual bool userScrollableVertical() const;
113 virtual void setHaveWheelEventHandlers(bool have_wheel_event_handlers
);
114 virtual bool haveWheelEventHandlers() const;
115 virtual void setShouldScrollOnMainThread(bool scroll_on_main
);
116 virtual bool shouldScrollOnMainThread() const;
117 virtual void setNonFastScrollableRegion(
118 const blink::WebVector
<blink::WebRect
>& region
);
119 virtual blink::WebVector
<blink::WebRect
> nonFastScrollableRegion() const;
120 virtual void setTouchEventHandlerRegion(
121 const blink::WebVector
<blink::WebRect
>& region
);
122 virtual blink::WebVector
<blink::WebRect
> touchEventHandlerRegion() const;
123 virtual void setIsContainerForFixedPositionLayers(bool is_container
);
124 virtual bool isContainerForFixedPositionLayers() const;
125 virtual void setPositionConstraint(
126 const blink::WebLayerPositionConstraint
& constraint
);
127 virtual blink::WebLayerPositionConstraint
positionConstraint() const;
128 virtual void setScrollClient(blink::WebLayerScrollClient
* client
);
129 virtual bool isOrphan() const;
130 virtual void setWebLayerClient(blink::WebLayerClient
* client
);
132 // LayerClient implementation.
133 virtual std::string
DebugName() OVERRIDE
;
134 virtual scoped_refptr
<base::debug::ConvertableToTraceFormat
>
135 TakeDebugInfo() OVERRIDE
;
137 virtual void setScrollParent(blink::WebLayer
* parent
);
138 virtual void setClipParent(blink::WebLayer
* parent
);
141 scoped_refptr
<cc::Layer
> layer_
;
142 blink::WebLayerClient
* web_layer_client_
;
145 scoped_ptr
<WebToCCAnimationDelegateAdapter
> animation_delegate_adapter_
;
147 DISALLOW_COPY_AND_ASSIGN(WebLayerImpl
);
150 } // namespace webkit
152 #endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_