initial import
[vuplus_webkit] / Source / WebCore / platform / graphics / chromium / GraphicsLayerChromium.h
1 /*
2  * Copyright (C) 2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef GraphicsLayerChromium_h
32 #define GraphicsLayerChromium_h
33
34 #if USE(ACCELERATED_COMPOSITING)
35
36 #include "LayerChromium.h"
37 #include "GraphicsContext.h"
38 #include "GraphicsLayer.h"
39
40 namespace WebCore {
41
42 class LayerChromium;
43
44 class GraphicsLayerChromium : public GraphicsLayer, public CCLayerDelegate {
45 public:
46     GraphicsLayerChromium(GraphicsLayerClient*);
47     virtual ~GraphicsLayerChromium();
48
49     virtual void setName(const String&);
50
51     virtual bool setChildren(const Vector<GraphicsLayer*>&);
52     virtual void addChild(GraphicsLayer*);
53     virtual void addChildAtIndex(GraphicsLayer*, int index);
54     virtual void addChildAbove(GraphicsLayer*, GraphicsLayer* sibling);
55     virtual void addChildBelow(GraphicsLayer*, GraphicsLayer* sibling);
56     virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
57
58     virtual void removeFromParent();
59
60     virtual void setPosition(const FloatPoint&);
61     virtual void setAnchorPoint(const FloatPoint3D&);
62     virtual void setSize(const FloatSize&);
63
64     virtual void setTransform(const TransformationMatrix&);
65
66     virtual void setChildrenTransform(const TransformationMatrix&);
67
68     virtual void setPreserves3D(bool);
69     virtual void setMasksToBounds(bool);
70     virtual void setDrawsContent(bool);
71     virtual void setMaskLayer(GraphicsLayer*);
72
73     virtual void setBackgroundColor(const Color&);
74     virtual void clearBackgroundColor();
75
76     virtual void setContentsOpaque(bool);
77     virtual void setBackfaceVisibility(bool);
78
79     virtual void setReplicatedByLayer(GraphicsLayer*);
80
81     virtual void setOpacity(float);
82
83     virtual void setNeedsDisplay();
84     virtual void setNeedsDisplayInRect(const FloatRect&);
85     virtual void setContentsNeedsDisplay();
86
87     virtual void setContentsRect(const IntRect&);
88
89     virtual void setContentsToImage(Image*);
90     virtual void setContentsToMedia(PlatformLayer*);
91     virtual void setContentsToCanvas(PlatformLayer*);
92
93     virtual PlatformLayer* platformLayer() const;
94
95     virtual void setDebugBackgroundColor(const Color&);
96     virtual void setDebugBorder(const Color&, float borderWidth);
97
98     // The following functions implement the CCLayerDelegate interface.
99     virtual bool drawsContent() const;
100     virtual bool preserves3D() const;
101     virtual void paintContents(GraphicsContext&, const IntRect& clip);
102     virtual void notifySyncRequired();
103
104 private:
105     void updateOpacityOnLayer();
106
107     LayerChromium* primaryLayer() const  { return m_transformLayer.get() ? m_transformLayer.get() : m_layer.get(); }
108     LayerChromium* hostLayerForChildren() const;
109     LayerChromium* layerForParent() const;
110
111     void updateNames();
112     void updateChildList();
113     void updateLayerPosition();
114     void updateLayerSize();
115     void updateAnchorPoint();
116     void updateTransform();
117     void updateChildrenTransform();
118     void updateMasksToBounds();
119     void updateContentsOpaque();
120     void updateBackfaceVisibility();
121     void updateLayerPreserves3D();
122     void updateLayerDrawsContent();
123     void updateLayerBackgroundColor();
124
125     void updateContentsImage();
126     void updateContentsVideo();
127     void updateContentsRect();
128
129     void setupContentsLayer(LayerChromium*);
130     LayerChromium* contentsLayer() const { return m_contentsLayer.get(); }
131
132     String m_nameBase;
133
134     RefPtr<LayerChromium> m_layer;
135     RefPtr<LayerChromium> m_transformLayer;
136     RefPtr<LayerChromium> m_contentsLayer;
137
138     enum ContentsLayerPurpose {
139         NoContentsLayer = 0,
140         ContentsLayerForImage,
141         ContentsLayerForVideo,
142         ContentsLayerForCanvas,
143     };
144
145     ContentsLayerPurpose m_contentsLayerPurpose;
146     bool m_contentsLayerHasBackgroundColor : 1;
147     bool m_inSetChildren;
148 };
149
150 } // namespace WebCore
151
152 #endif // USE(ACCELERATED_COMPOSITING)
153
154 #endif