2 Copyright (C) 2011 Samsung Electronics
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
22 #if ENABLE(TIZEN_ACCELERATED_COMPOSITING)
23 #if USE(ACCELERATED_COMPOSITING)
25 #include "GraphicsLayerTexture.h"
28 #include "FloatRect.h"
31 #include <wtf/text/CString.h>
35 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
37 return adoptPtr(new GraphicsLayerTexture(client));
40 GraphicsLayerTexture::GraphicsLayerTexture(GraphicsLayerClient* client)
41 : GraphicsLayer(client)
43 LOG(AcceleratedCompositing, "Layer[%p/(nil)] GraphicsLayerTexture::%s() - CONSTRUCTOR\n", this, __func__);
44 m_platformLayer = EflLayer::create(this);
45 updateDebugIndicators();
48 GraphicsLayerTexture::~GraphicsLayerTexture()
50 LOG(AcceleratedCompositing, "Layer[%p/(nil)] GraphicsLayerTexture::%s() - DESTRUCTOR\n", this, __func__);
52 m_platformLayer->setOwner(0);
55 void GraphicsLayerTexture::setName(const String & name)
57 String layerName = String::format("GraphicsLayerTexture[%p]", this) + name;
58 GraphicsLayer::setName(layerName);
61 bool GraphicsLayerTexture::setChildren(const Vector<GraphicsLayer*> & children)
63 bool b = GraphicsLayer::setChildren(children);
64 m_platformLayer->notifyChange();
68 void GraphicsLayerTexture::addChild(GraphicsLayer *child)
70 LOG(AcceleratedCompositing, "Layer[%p/%p] GraphicsLayerTexture::%s()\n", this, m_platformLayer.get(), __func__);
71 LOG(AcceleratedCompositing, "---> child: %p\n", child);
72 GraphicsLayer::addChild(child);
73 m_platformLayer->notifyChange();
76 void GraphicsLayerTexture::addChildAtIndex(GraphicsLayer *child, int index)
78 GraphicsLayer::addChildAtIndex(child, index);
79 m_platformLayer->notifyChange();
82 void GraphicsLayerTexture::addChildAbove(GraphicsLayer *child, GraphicsLayer *sibling)
84 GraphicsLayer::addChildAbove(child, sibling);
85 m_platformLayer->notifyChange();
88 void GraphicsLayerTexture::addChildBelow(GraphicsLayer *child, GraphicsLayer *sibling)
90 GraphicsLayer::addChildBelow(child, sibling);
91 m_platformLayer->notifyChange();
94 bool GraphicsLayerTexture::replaceChild(GraphicsLayer *oldChild, GraphicsLayer *newChild)
96 bool b = GraphicsLayer::replaceChild(oldChild, newChild);
97 m_platformLayer->notifyChange();
101 void GraphicsLayerTexture::removeFromParent()
103 GraphicsLayer::removeFromParent();
106 void GraphicsLayerTexture::setMaskLayer(GraphicsLayer* layer)
108 if (layer == m_maskLayer)
111 GraphicsLayer::setMaskLayer(layer);
114 void GraphicsLayerTexture::setReplicatedByLayer(GraphicsLayer* layer)
116 if (layer == m_replicaLayer)
119 GraphicsLayer::setReplicatedByLayer(layer);
122 void GraphicsLayerTexture::setMasksToBounds(bool b)
124 if (b == m_masksToBounds)
127 LOG(AcceleratedCompositing, "Layer[%p/%p] GraphicsLayerTexture::%s()\n", this, m_platformLayer.get(), __func__);
128 LOG(AcceleratedCompositing, "---> Mask: %s\n", (b?"true":"false"));
129 GraphicsLayer::setMasksToBounds(b);
130 updateDebugIndicators();
133 void GraphicsLayerTexture::setPosition(const FloatPoint& position)
135 if (position == m_position)
138 GraphicsLayer::setPosition(position);
139 m_platformLayer->setPosition(position);
142 void GraphicsLayerTexture::setAnchorPoint(const FloatPoint3D& anchorPoint)
144 if (anchorPoint == m_anchorPoint)
147 GraphicsLayer::setAnchorPoint(anchorPoint);
148 m_platformLayer->setAnchorPoint(anchorPoint);
151 void GraphicsLayerTexture::setSize(const FloatSize& size)
156 GraphicsLayer::setSize(size);
157 m_platformLayer->setSize(size);
160 void GraphicsLayerTexture::setTransform(const TransformationMatrix& transform)
162 if (transform == m_transform)
165 GraphicsLayer::setTransform(transform);
166 m_platformLayer->setTransform(transform);
169 void GraphicsLayerTexture::setChildrenTransform(const TransformationMatrix& transform)
171 if (transform == m_childrenTransform)
174 GraphicsLayer::setChildrenTransform(transform);
175 m_platformLayer->setChildrenTransform(transform);
178 void GraphicsLayerTexture::setPreserves3D(bool b)
180 if (b == m_preserves3D)
183 GraphicsLayer::setPreserves3D(b);
186 void GraphicsLayerTexture::setContentsRect(const IntRect& rect)
188 if (rect == m_contentsRect)
191 GraphicsLayer::setContentsRect(rect);
192 m_platformLayer->setContentsRect(rect);
195 void GraphicsLayerTexture::setDrawsContent(bool b)
197 if (m_platformLayer->contentsType() == EflLayer::WebGLContentsType)
199 if (b == m_drawsContent)
202 GraphicsLayer::setDrawsContent(b);
203 m_platformLayer->setDrawsContent(b);
204 updateDebugIndicators();
207 void GraphicsLayerTexture::setContentsToImage(Image* image)
209 m_platformLayer->setContentsToImage(image);
211 updateDebugIndicators();
214 void GraphicsLayerTexture::setContentsToMedia(PlatformLayer* layer)
216 if (m_platformLayer == layer)
219 LOG(AcceleratedCompositing, "Layer[%p/%p] GraphicsLayerTexture::%s()\n", this, m_platformLayer.get(), __func__);
220 LOG(AcceleratedCompositing, "---> EflLayer: %p\n", layer);
223 m_platformLayer = layer;
224 m_platformLayer->setOwner(this);
225 m_platformLayer->setNeedsDisplay();
227 m_platformLayer = EflLayer::create(this);
229 updateDebugIndicators();
232 void GraphicsLayerTexture::setContentsToCanvas(PlatformLayer* layer)
234 if (m_platformLayer == layer)
237 LOG(AcceleratedCompositing, "Layer[%p/%p] GraphicsLayerTexture::%s()\n", this, m_platformLayer.get(), __func__);
238 LOG(AcceleratedCompositing, "---> EflLayer: %p\n", layer);
241 m_platformLayer = layer;
242 m_platformLayer->setOwner(this);
243 m_platformLayer->setNeedsDisplay();
245 m_platformLayer = EflLayer::create(this);
247 updateDebugIndicators();
250 void GraphicsLayerTexture::setContentsBackgroundColor(const Color& color)
252 m_platformLayer->setContentsToColor(color);
255 bool GraphicsLayerTexture::hasContentsLayer() const
257 return m_platformLayer->hasContentsLayer();
260 void GraphicsLayerTexture::setContentsOrientation(CompositingCoordinatesOrientation orientation)
262 if (orientation == m_contentsOrientation)
265 GraphicsLayer::setContentsOrientation(orientation);
268 void GraphicsLayerTexture::setBackgroundColor(const Color& color)
270 if (color == m_backgroundColor)
273 GraphicsLayer::setBackgroundColor(color);
276 void GraphicsLayerTexture::clearBackgroundColor()
278 GraphicsLayer::clearBackgroundColor();
281 void GraphicsLayerTexture::setDebugBackgroundColor(const Color& color)
284 m_platformLayer->setBackgroundColor(color);
286 m_platformLayer->setBackgroundColor(static_cast<RGBA32>(0));
289 void GraphicsLayerTexture::setDebugBorder(const Color& color, float borderWidth)
292 m_platformLayer->setBorderColor(color);
294 m_platformLayer->setBorderColor(static_cast<RGBA32>(0));
296 m_platformLayer->setBorderWidth(borderWidth);
299 void GraphicsLayerTexture::setContentsOpaque(bool b)
301 if (b == m_contentsOpaque)
304 GraphicsLayer::setContentsOpaque(b);
307 void GraphicsLayerTexture::setBackfaceVisibility(bool b)
309 if (b == m_backfaceVisibility)
312 LOG(AcceleratedCompositing, "Layer[%p/%p] GraphicsLayerTexture::%s()\n", this, m_platformLayer.get(), __func__);
313 LOG(AcceleratedCompositing, "---> Backface Visibility: %s\n", (b?"true":"false"));
314 GraphicsLayer::setBackfaceVisibility(b);
317 void GraphicsLayerTexture::setOpacity(float opacity)
319 if (opacity == m_opacity)
322 GraphicsLayer::setOpacity(opacity);
323 m_platformLayer->setOpacity(opacity);
326 void GraphicsLayerTexture::setNeedsDisplay()
329 m_platformLayer->setNeedsDisplay();
332 void GraphicsLayerTexture::setNeedsDisplayInRect(const FloatRect& r)
338 FloatRect layerBounds(FloatPoint(), m_size);
339 rect.intersect(layerBounds);
343 m_platformLayer->setNeedsDisplayInRect(rect);
346 void GraphicsLayerTexture::setContentsNeedsDisplay()
348 if (m_platformLayer->hasContentsLayer())
349 m_platformLayer->setContentsNeedsDisplay();
352 void GraphicsLayerTexture::notifySyncRequired()
355 m_client->notifySyncRequired(this);