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
;
47 class WebToCCAnimationDelegateAdapter
;
49 class WebLayerImpl
: public blink::WebLayer
, public cc::LayerClient
{
51 CC_BLINK_EXPORT
WebLayerImpl();
52 CC_BLINK_EXPORT
explicit WebLayerImpl(scoped_refptr
<cc::Layer
>);
53 virtual ~WebLayerImpl();
55 static bool UsingPictureLayer();
56 CC_BLINK_EXPORT
static void SetImplSidePaintingEnabled(bool enabled
);
58 CC_BLINK_EXPORT
static void SetLayerSettings(
59 const cc::LayerSettings
& settings
);
60 CC_BLINK_EXPORT
static const cc::LayerSettings
& LayerSettings();
62 CC_BLINK_EXPORT
cc::Layer
* layer() const;
64 // WebLayer implementation.
65 virtual int id() const;
66 virtual void invalidateRect(const blink::WebRect
&);
67 virtual void invalidate();
68 virtual void addChild(blink::WebLayer
* child
);
69 virtual void insertChild(blink::WebLayer
* child
, size_t index
);
70 virtual void replaceChild(blink::WebLayer
* reference
,
71 blink::WebLayer
* new_layer
);
72 virtual void removeFromParent();
73 virtual void removeAllChildren();
74 virtual void setBounds(const blink::WebSize
& bounds
);
75 virtual blink::WebSize
bounds() const;
76 virtual void setMasksToBounds(bool masks_to_bounds
);
77 virtual bool masksToBounds() const;
78 virtual void setMaskLayer(blink::WebLayer
* mask
);
79 virtual void setReplicaLayer(blink::WebLayer
* replica
);
80 virtual void setOpacity(float opacity
);
81 virtual float opacity() const;
82 virtual void setBlendMode(blink::WebBlendMode blend_mode
);
83 virtual blink::WebBlendMode
blendMode() const;
84 virtual void setIsRootForIsolatedGroup(bool root
);
85 virtual bool isRootForIsolatedGroup();
86 virtual void setOpaque(bool opaque
);
87 virtual bool opaque() const;
88 virtual void setPosition(const blink::WebFloatPoint
& position
);
89 virtual blink::WebFloatPoint
position() const;
90 virtual void setTransform(const SkMatrix44
& transform
);
91 virtual void setTransformOrigin(const blink::WebFloatPoint3D
& point
);
92 virtual blink::WebFloatPoint3D
transformOrigin() const;
93 virtual SkMatrix44
transform() const;
94 virtual void setDrawsContent(bool draws_content
);
95 virtual bool drawsContent() const;
96 virtual void setShouldFlattenTransform(bool flatten
);
97 virtual void setRenderingContext(int context
);
98 virtual void setUseParentBackfaceVisibility(bool visible
);
99 virtual void setBackgroundColor(blink::WebColor color
);
100 virtual blink::WebColor
backgroundColor() const;
101 virtual void setFilters(const blink::WebFilterOperations
& filters
);
102 virtual void setBackgroundFilters(const blink::WebFilterOperations
& filters
);
103 virtual void setAnimationDelegate(
104 blink::WebCompositorAnimationDelegate
* delegate
);
105 virtual bool addAnimation(blink::WebCompositorAnimation
* animation
);
106 virtual void removeAnimation(int animation_id
);
107 virtual void removeAnimation(int animation_id
,
108 blink::WebCompositorAnimation::TargetProperty
);
109 virtual void pauseAnimation(int animation_id
, double time_offset
);
110 virtual bool hasActiveAnimation();
111 virtual void setForceRenderSurface(bool force
);
112 virtual void setScrollPositionDouble(blink::WebDoublePoint position
);
113 virtual blink::WebDoublePoint
scrollPositionDouble() const;
114 virtual void setScrollCompensationAdjustment(blink::WebDoublePoint position
);
115 virtual void setScrollClipLayer(blink::WebLayer
* clip_layer
);
116 virtual bool scrollable() const;
117 virtual void setUserScrollable(bool horizontal
, bool vertical
);
118 virtual bool userScrollableHorizontal() const;
119 virtual bool userScrollableVertical() const;
120 virtual void setHaveWheelEventHandlers(bool have_wheel_event_handlers
);
121 virtual bool haveWheelEventHandlers() const;
122 virtual void setHaveScrollEventHandlers(bool have_scroll_event_handlers
);
123 virtual bool haveScrollEventHandlers() const;
124 virtual void setShouldScrollOnMainThread(bool scroll_on_main
);
125 virtual bool shouldScrollOnMainThread() const;
126 virtual void setNonFastScrollableRegion(
127 const blink::WebVector
<blink::WebRect
>& region
);
128 virtual blink::WebVector
<blink::WebRect
> nonFastScrollableRegion() const;
129 virtual void setTouchEventHandlerRegion(
130 const blink::WebVector
<blink::WebRect
>& region
);
131 virtual blink::WebVector
<blink::WebRect
> touchEventHandlerRegion() const;
132 virtual void setScrollBlocksOn(blink::WebScrollBlocksOn
);
133 virtual blink::WebScrollBlocksOn
scrollBlocksOn() const;
134 virtual void setFrameTimingRequests(
135 const blink::WebVector
<std::pair
<int64_t, blink::WebRect
>>& requests
);
136 virtual blink::WebVector
<std::pair
<int64_t, blink::WebRect
>>
137 frameTimingRequests() const;
138 virtual void setIsContainerForFixedPositionLayers(bool is_container
);
139 virtual bool isContainerForFixedPositionLayers() const;
140 virtual void setPositionConstraint(
141 const blink::WebLayerPositionConstraint
& constraint
);
142 virtual blink::WebLayerPositionConstraint
positionConstraint() const;
143 virtual void setScrollClient(blink::WebLayerScrollClient
* client
);
144 virtual bool isOrphan() const;
145 virtual void setWebLayerClient(blink::WebLayerClient
* client
);
147 // LayerClient implementation.
148 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
> TakeDebugInfo()
151 virtual void setScrollParent(blink::WebLayer
* parent
);
152 virtual void setClipParent(blink::WebLayer
* parent
);
155 scoped_refptr
<cc::Layer
> layer_
;
156 blink::WebLayerClient
* web_layer_client_
;
159 scoped_ptr
<WebToCCAnimationDelegateAdapter
> animation_delegate_adapter_
;
161 DISALLOW_COPY_AND_ASSIGN(WebLayerImpl
);
164 } // namespace cc_blink
166 #endif // CC_BLINK_WEB_LAYER_IMPL_H_