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