2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef GraphicsLayerChromium_h
32 #define GraphicsLayerChromium_h
34 #if USE(ACCELERATED_COMPOSITING)
36 #include "LayerChromium.h"
37 #include "GraphicsContext.h"
38 #include "GraphicsLayer.h"
44 class GraphicsLayerChromium : public GraphicsLayer, public CCLayerDelegate {
46 GraphicsLayerChromium(GraphicsLayerClient*);
47 virtual ~GraphicsLayerChromium();
49 virtual void setName(const String&);
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);
58 virtual void removeFromParent();
60 virtual void setPosition(const FloatPoint&);
61 virtual void setAnchorPoint(const FloatPoint3D&);
62 virtual void setSize(const FloatSize&);
64 virtual void setTransform(const TransformationMatrix&);
66 virtual void setChildrenTransform(const TransformationMatrix&);
68 virtual void setPreserves3D(bool);
69 virtual void setMasksToBounds(bool);
70 virtual void setDrawsContent(bool);
71 virtual void setMaskLayer(GraphicsLayer*);
73 virtual void setBackgroundColor(const Color&);
74 virtual void clearBackgroundColor();
76 virtual void setContentsOpaque(bool);
77 virtual void setBackfaceVisibility(bool);
79 virtual void setReplicatedByLayer(GraphicsLayer*);
81 virtual void setOpacity(float);
83 virtual void setNeedsDisplay();
84 virtual void setNeedsDisplayInRect(const FloatRect&);
85 virtual void setContentsNeedsDisplay();
87 virtual void setContentsRect(const IntRect&);
89 virtual void setContentsToImage(Image*);
90 virtual void setContentsToMedia(PlatformLayer*);
91 virtual void setContentsToCanvas(PlatformLayer*);
93 virtual PlatformLayer* platformLayer() const;
95 virtual void setDebugBackgroundColor(const Color&);
96 virtual void setDebugBorder(const Color&, float borderWidth);
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();
105 void updateOpacityOnLayer();
107 LayerChromium* primaryLayer() const { return m_transformLayer.get() ? m_transformLayer.get() : m_layer.get(); }
108 LayerChromium* hostLayerForChildren() const;
109 LayerChromium* layerForParent() const;
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();
125 void updateContentsImage();
126 void updateContentsVideo();
127 void updateContentsRect();
129 void setupContentsLayer(LayerChromium*);
130 LayerChromium* contentsLayer() const { return m_contentsLayer.get(); }
134 RefPtr<LayerChromium> m_layer;
135 RefPtr<LayerChromium> m_transformLayer;
136 RefPtr<LayerChromium> m_contentsLayer;
138 enum ContentsLayerPurpose {
140 ContentsLayerForImage,
141 ContentsLayerForVideo,
142 ContentsLayerForCanvas,
145 ContentsLayerPurpose m_contentsLayerPurpose;
146 bool m_contentsLayerHasBackgroundColor : 1;
147 bool m_inSetChildren;
150 } // namespace WebCore
152 #endif // USE(ACCELERATED_COMPOSITING)