1 // Copyright 2014 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 CC_BLINK_WEB_LAYER_IMPL_H_
6 #define CC_BLINK_WEB_LAYER_IMPL_H_
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/blink/cc_blink_export.h"
14 #include "cc/layers/layer_client.h"
15 #include "third_party/WebKit/public/platform/WebCString.h"
16 #include "third_party/WebKit/public/platform/WebColor.h"
17 #include "third_party/WebKit/public/platform/WebCompositorAnimation.h"
18 #include "third_party/WebKit/public/platform/WebDoublePoint.h"
19 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
20 #include "third_party/WebKit/public/platform/WebLayer.h"
21 #include "third_party/WebKit/public/platform/WebPoint.h"
22 #include "third_party/WebKit/public/platform/WebRect.h"
23 #include "third_party/WebKit/public/platform/WebSize.h"
24 #include "third_party/WebKit/public/platform/WebString.h"
25 #include "third_party/WebKit/public/platform/WebVector.h"
26 #include "third_party/skia/include/utils/SkMatrix44.h"
29 class WebFilterOperations
;
35 namespace trace_event
{
36 class ConvertableToTraceFormat
;
46 class WebToCCAnimationDelegateAdapter
;
48 class WebLayerImpl
: public blink::WebLayer
, public cc::LayerClient
{
50 CC_BLINK_EXPORT
WebLayerImpl();
51 CC_BLINK_EXPORT
explicit WebLayerImpl(scoped_refptr
<cc::Layer
>);
52 virtual ~WebLayerImpl();
54 static bool UsingPictureLayer();
55 CC_BLINK_EXPORT
static void SetImplSidePaintingEnabled(bool enabled
);
57 CC_BLINK_EXPORT
cc::Layer
* layer() const;
59 // WebLayer implementation.
60 virtual int id() const;
61 virtual void invalidateRect(const blink::WebRect
&);
62 virtual void invalidate();
63 virtual void addChild(blink::WebLayer
* child
);
64 virtual void insertChild(blink::WebLayer
* child
, size_t index
);
65 virtual void replaceChild(blink::WebLayer
* reference
,
66 blink::WebLayer
* new_layer
);
67 virtual void removeFromParent();
68 virtual void removeAllChildren();
69 virtual void setBounds(const blink::WebSize
& bounds
);
70 virtual blink::WebSize
bounds() const;
71 virtual void setMasksToBounds(bool masks_to_bounds
);
72 virtual bool masksToBounds() const;
73 virtual void setMaskLayer(blink::WebLayer
* mask
);
74 virtual void setReplicaLayer(blink::WebLayer
* replica
);
75 virtual void setOpacity(float opacity
);
76 virtual float opacity() const;
77 virtual void setBlendMode(blink::WebBlendMode blend_mode
);
78 virtual blink::WebBlendMode
blendMode() const;
79 virtual void setIsRootForIsolatedGroup(bool root
);
80 virtual bool isRootForIsolatedGroup();
81 virtual void setOpaque(bool opaque
);
82 virtual bool opaque() const;
83 virtual void setPosition(const blink::WebFloatPoint
& position
);
84 virtual blink::WebFloatPoint
position() const;
85 virtual void setTransform(const SkMatrix44
& transform
);
86 virtual void setTransformOrigin(const blink::WebFloatPoint3D
& point
);
87 virtual blink::WebFloatPoint3D
transformOrigin() const;
88 virtual SkMatrix44
transform() const;
89 virtual void setDrawsContent(bool draws_content
);
90 virtual bool drawsContent() const;
91 virtual void setShouldFlattenTransform(bool flatten
);
92 virtual void setRenderingContext(int context
);
93 virtual void setUseParentBackfaceVisibility(bool visible
);
94 virtual void setBackgroundColor(blink::WebColor color
);
95 virtual blink::WebColor
backgroundColor() const;
96 virtual void setFilters(const blink::WebFilterOperations
& filters
);
97 virtual void setBackgroundFilters(const blink::WebFilterOperations
& filters
);
98 virtual void setAnimationDelegate(
99 blink::WebCompositorAnimationDelegate
* delegate
);
100 virtual bool addAnimation(blink::WebCompositorAnimation
* animation
);
101 virtual void removeAnimation(int animation_id
);
102 virtual void removeAnimation(int animation_id
,
103 blink::WebCompositorAnimation::TargetProperty
);
104 virtual void pauseAnimation(int animation_id
, double time_offset
);
105 virtual bool hasActiveAnimation();
106 virtual void setForceRenderSurface(bool force
);
107 virtual void setScrollPositionDouble(blink::WebDoublePoint position
);
108 virtual blink::WebDoublePoint
scrollPositionDouble() const;
109 virtual void setScrollCompensationAdjustment(blink::WebDoublePoint position
);
110 virtual void setScrollClipLayer(blink::WebLayer
* clip_layer
);
111 virtual bool scrollable() const;
112 virtual void setUserScrollable(bool horizontal
, bool vertical
);
113 virtual bool userScrollableHorizontal() const;
114 virtual bool userScrollableVertical() const;
115 virtual void setHaveWheelEventHandlers(bool have_wheel_event_handlers
);
116 virtual bool haveWheelEventHandlers() const;
117 virtual void setHaveScrollEventHandlers(bool have_scroll_event_handlers
);
118 virtual bool haveScrollEventHandlers() 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 setScrollBlocksOn(blink::WebScrollBlocksOn
);
128 virtual blink::WebScrollBlocksOn
scrollBlocksOn() const;
129 virtual void setFrameTimingRequests(
130 const blink::WebVector
<std::pair
<int64_t, blink::WebRect
>>& requests
);
131 virtual void setIsContainerForFixedPositionLayers(bool is_container
);
132 virtual bool isContainerForFixedPositionLayers() const;
133 virtual void setPositionConstraint(
134 const blink::WebLayerPositionConstraint
& constraint
);
135 virtual blink::WebLayerPositionConstraint
positionConstraint() const;
136 virtual void setScrollClient(blink::WebLayerScrollClient
* client
);
137 virtual bool isOrphan() const;
138 virtual void setWebLayerClient(blink::WebLayerClient
* client
);
140 // LayerClient implementation.
141 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> TakeDebugInfo()
144 virtual void setScrollParent(blink::WebLayer
* parent
);
145 virtual void setClipParent(blink::WebLayer
* parent
);
148 scoped_refptr
<cc::Layer
> layer_
;
149 blink::WebLayerClient
* web_layer_client_
;
152 scoped_ptr
<WebToCCAnimationDelegateAdapter
> animation_delegate_adapter_
;
154 DISALLOW_COPY_AND_ASSIGN(WebLayerImpl
);
157 } // namespace cc_blink
159 #endif // CC_BLINK_WEB_LAYER_IMPL_H_