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