1dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block/*
2dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * Copyright (C) 2010 Google Inc. All rights reserved.
3dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * Copyright (C) 2009 Apple Inc. All rights reserved.
4dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block *
5dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * Redistribution and use in source and binary forms, with or without
6dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * modification, are permitted provided that the following conditions are
7dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * met:
8dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block *
9dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block *     * Redistributions of source code must retain the above copyright
10dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * notice, this list of conditions and the following disclaimer.
11dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block *     * Redistributions in binary form must reproduce the above
12dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * copyright notice, this list of conditions and the following disclaimer
13dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * in the documentation and/or other materials provided with the
14dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * distribution.
15dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block *     * Neither the name of Google Inc. nor the names of its
16dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * contributors may be used to endorse or promote products derived from
17dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * this software without specific prior written permission.
18dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block *
19dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block */
31dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
32dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
33dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block/** FIXME
34dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * This file borrows code heavily from platform/graphics/win/GraphicsLayerCACF.cpp
35dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * (and hence it includes both copyrights)
36dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * Ideally the common code (mostly the code that keeps track of the layer hierarchy)
37dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * should be kept separate and shared between platforms. It would be a well worthwhile
38dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * effort once the Windows implementation (binaries and headers) of CoreAnimation is
39dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block * checked in to the WebKit repository. Until then only Apple can make this happen.
40dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block */
41dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
42dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "config.h"
43dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
44dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#if USE(ACCELERATED_COMPOSITING)
45dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
46dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "GraphicsLayerChromium.h"
47dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
485abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick#include "Canvas2DLayerChromium.h"
49e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block#include "ContentLayerChromium.h"
505abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick#include "DrawingBuffer.h"
51dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "FloatConversion.h"
52dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "FloatRect.h"
53dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "Image.h"
5406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen#include "ImageLayerChromium.h"
55dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "LayerChromium.h"
56dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "PlatformString.h"
57dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "SystemTime.h"
58dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch
59dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include <wtf/CurrentTime.h>
60dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include <wtf/StringExtras.h>
61dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include <wtf/text/CString.h>
62dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
63dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockusing namespace std;
64dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
65dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blocknamespace WebCore {
66dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
67dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockstatic void setLayerBorderColor(LayerChromium& layer, const Color& color)
68dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
69dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    layer.setBorderColor(color);
70dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
71dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
72dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockstatic void clearBorderColor(LayerChromium& layer)
73dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
74dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    layer.setBorderColor(static_cast<RGBA32>(0));
75dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
76dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
77dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockstatic void setLayerBackgroundColor(LayerChromium& layer, const Color& color)
78dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
79dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    layer.setBackgroundColor(color);
80dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
81dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
82dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockstatic void clearLayerBackgroundColor(LayerChromium& layer)
83dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
84dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    layer.setBackgroundColor(static_cast<RGBA32>(0));
85dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
86dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
87dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockPassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerClient* client)
88dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
89dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    return new GraphicsLayerChromium(client);
90dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
91dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
92dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockGraphicsLayerChromium::GraphicsLayerChromium(GraphicsLayerClient* client)
93dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    : GraphicsLayer(client)
94dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    , m_contentsLayerPurpose(NoContentsLayer)
95dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    , m_contentsLayerHasBackgroundColor(false)
96dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
97e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block    m_layer = ContentLayerChromium::create(this);
98dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
99dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateDebugIndicators();
100dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
101dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
102dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockGraphicsLayerChromium::~GraphicsLayerChromium()
103dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
1045abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick    if (m_layer)
1055abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick        m_layer->setOwner(0);
1065abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick    if (m_contentsLayer)
1075abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick        m_contentsLayer->setOwner(0);
1085abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick    if (m_transformLayer)
1095abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick        m_transformLayer->setOwner(0);
110dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
111dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
112dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setName(const String& inName)
113dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
11481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    m_nameBase = inName;
115dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    String name = String::format("GraphicsLayerChromium(%p) GraphicsLayer(%p) ", m_layer.get(), this) + inName;
116dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setName(name);
11781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    updateNames();
11881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch}
11981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch
12081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochvoid GraphicsLayerChromium::updateNames()
12181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch{
12281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    if (m_layer)
12381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch        m_layer->setName("Layer for " + m_nameBase);
12481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    if (m_transformLayer)
12581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch        m_transformLayer->setName("TransformLayer for " + m_nameBase);
12681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    if (m_contentsLayer)
12781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch        m_contentsLayer->setName("ContentsLayer for " + m_nameBase);
128dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
129dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
130dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockbool GraphicsLayerChromium::setChildren(const Vector<GraphicsLayer*>& children)
131dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
132dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    bool childrenChanged = GraphicsLayer::setChildren(children);
133dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // FIXME: GraphicsLayer::setChildren calls addChild() for each sublayer, which
134dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // will end up calling updateSublayerList() N times.
135dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (childrenChanged)
136dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        updateSublayerList();
137dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
138dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    return childrenChanged;
139dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
140dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
141dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::addChild(GraphicsLayer* childLayer)
142dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
143dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::addChild(childLayer);
144dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateSublayerList();
145dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
146dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
147dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::addChildAtIndex(GraphicsLayer* childLayer, int index)
148dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
149dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::addChildAtIndex(childLayer, index);
150dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateSublayerList();
151dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
152dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
153dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::addChildBelow(GraphicsLayer* childLayer, GraphicsLayer* sibling)
154dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
155dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::addChildBelow(childLayer, sibling);
156dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateSublayerList();
157dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
158dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
159dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::addChildAbove(GraphicsLayer* childLayer, GraphicsLayer *sibling)
160dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
161dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::addChildAbove(childLayer, sibling);
162dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateSublayerList();
163dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
164dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
165dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockbool GraphicsLayerChromium::replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild)
166dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
167dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (GraphicsLayer::replaceChild(oldChild, newChild)) {
168dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        updateSublayerList();
169dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return true;
170dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    }
171dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    return false;
172dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
173dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
174dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::removeFromParent()
175dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
176dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::removeFromParent();
177dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    layerForSuperlayer()->removeFromSuperlayer();
178dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
179dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
180dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setPosition(const FloatPoint& point)
181dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
182dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setPosition(point);
183dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateLayerPosition();
184dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
185dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
186dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setAnchorPoint(const FloatPoint3D& point)
187dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
188dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (point == m_anchorPoint)
189dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
190dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
191dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setAnchorPoint(point);
192dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateAnchorPoint();
193dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
194dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
195dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setSize(const FloatSize& size)
196dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
197dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (size == m_size)
198dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
199dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
200dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setSize(size);
201dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateLayerSize();
202dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
203dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
204dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setTransform(const TransformationMatrix& transform)
205dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
206dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (transform == m_transform)
207dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
208dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
209dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setTransform(transform);
210dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateTransform();
211dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
212dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
213dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setChildrenTransform(const TransformationMatrix& transform)
214dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
215dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (transform == m_childrenTransform)
216dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
217dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
218dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setChildrenTransform(transform);
219dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateChildrenTransform();
220dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
221dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
222dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setPreserves3D(bool preserves3D)
223dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
224dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (preserves3D == m_preserves3D)
225dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
226dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
227dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setPreserves3D(preserves3D);
228dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateLayerPreserves3D();
229dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
230dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
231dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setMasksToBounds(bool masksToBounds)
232dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
233dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (masksToBounds == m_masksToBounds)
234dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
235dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
236dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setMasksToBounds(masksToBounds);
237dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateMasksToBounds();
238dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
239dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
240dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setDrawsContent(bool drawsContent)
241dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
242dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (drawsContent == m_drawsContent)
243dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
244dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
245dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setDrawsContent(drawsContent);
246dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateLayerDrawsContent();
247dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
248dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
249dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setBackgroundColor(const Color& color)
250dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
251dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_backgroundColorSet && m_backgroundColor == color)
252dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
253dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
254dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setBackgroundColor(color);
255dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
256dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    m_contentsLayerHasBackgroundColor = true;
257dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateLayerBackgroundColor();
258dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
259dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
260dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::clearBackgroundColor()
261dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
262dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (!m_backgroundColorSet)
263dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
264dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
265dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::clearBackgroundColor();
266dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    clearLayerBackgroundColor(*m_contentsLayer);
267dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
268dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
269dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setContentsOpaque(bool opaque)
270dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
271dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_contentsOpaque == opaque)
272dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
273dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
274dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setContentsOpaque(opaque);
275dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateContentsOpaque();
276dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
277dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
2782fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockvoid GraphicsLayerChromium::setMaskLayer(GraphicsLayer* maskLayer)
2792fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{
2802fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    if (maskLayer == m_maskLayer)
2812fc2651226baac27029e38c9d6ef883fa32084dbSteve Block        return;
2822fc2651226baac27029e38c9d6ef883fa32084dbSteve Block
2832fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    GraphicsLayer::setMaskLayer(maskLayer);
2842fc2651226baac27029e38c9d6ef883fa32084dbSteve Block
2852fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    LayerChromium* maskLayerChromium = m_maskLayer ? m_maskLayer->platformLayer() : 0;
2862daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch    if (maskLayerChromium)
2872daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch        maskLayerChromium->setIsMask(true);
2882fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    m_layer->setMaskLayer(maskLayerChromium);
2892fc2651226baac27029e38c9d6ef883fa32084dbSteve Block}
2902fc2651226baac27029e38c9d6ef883fa32084dbSteve Block
291dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setBackfaceVisibility(bool visible)
292dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
293dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_backfaceVisibility == visible)
294dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
295dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
296dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setBackfaceVisibility(visible);
297dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateBackfaceVisibility();
298dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
299dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
300dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setOpacity(float opacity)
301dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
302dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    float clampedOpacity = max(min(opacity, 1.0f), 0.0f);
303dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
304dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_opacity == clampedOpacity)
305dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
306dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
307dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setOpacity(clampedOpacity);
308dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    primaryLayer()->setOpacity(opacity);
309dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
310dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
3112fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockvoid GraphicsLayerChromium::setReplicatedByLayer(GraphicsLayer* layer)
3122fc2651226baac27029e38c9d6ef883fa32084dbSteve Block{
3132fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    GraphicsLayerChromium* layerChromium = static_cast<GraphicsLayerChromium*>(layer);
3142fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    GraphicsLayer::setReplicatedByLayer(layer);
3152fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    LayerChromium* replicaLayer = layerChromium ? layerChromium->primaryLayer() : 0;
3162fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    primaryLayer()->setReplicaLayer(replicaLayer);
3172fc2651226baac27029e38c9d6ef883fa32084dbSteve Block}
3182fc2651226baac27029e38c9d6ef883fa32084dbSteve Block
3192fc2651226baac27029e38c9d6ef883fa32084dbSteve Block
320dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdochvoid GraphicsLayerChromium::setContentsNeedsDisplay()
321dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch{
322dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch    if (m_contentsLayer)
323dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        m_contentsLayer->setNeedsDisplay();
324dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch}
3255abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick
326dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setNeedsDisplay()
327dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
328dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (drawsContent())
329dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->setNeedsDisplay();
330dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
331dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
332dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setNeedsDisplayInRect(const FloatRect& rect)
333dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
334dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (drawsContent())
335dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->setNeedsDisplay(rect);
336dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
337dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
338dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setContentsRect(const IntRect& rect)
339dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
340dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (rect == m_contentsRect)
341dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
342dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
343dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    GraphicsLayer::setContentsRect(rect);
344dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateContentsRect();
345dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
346dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
347dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setContentsToImage(Image* image)
348dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
3496c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    bool childrenChanged = false;
3506c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    if (image) {
35106ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForImage) {
35206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen            RefPtr<ImageLayerChromium> imageLayer = ImageLayerChromium::create(this);
35306ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen            setupContentsLayer(imageLayer.get());
35406ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen            m_contentsLayer = imageLayer;
35506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen            m_contentsLayerPurpose = ContentsLayerForImage;
3566c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen            childrenChanged = true;
35706ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen        }
35806ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen        ImageLayerChromium* imageLayer = static_cast<ImageLayerChromium*>(m_contentsLayer.get());
35968513a70bcd92384395513322f1b801e7bf9c729Steve Block        imageLayer->setContents(image);
36006ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen        updateContentsRect();
3616c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    } else {
36206ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen        if (m_contentsLayer) {
3636c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen            childrenChanged = true;
3646c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
36506ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen            // The old contents layer will be removed via updateSublayerList.
36606ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen            m_contentsLayer = 0;
36706ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen        }
36806ea8e899e48f1f2f396b70e63fae369f2f23232Kristian Monsen    }
3696c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
3706c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    if (childrenChanged)
3716c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen        updateSublayerList();
372dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
373dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
374dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdochvoid GraphicsLayerChromium::setContentsToCanvas(PlatformLayer* platformLayer)
375ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block{
376ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block    bool childrenChanged = false;
377ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block    if (platformLayer) {
378dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch        platformLayer->setOwner(this);
3795abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick        if (m_contentsLayer.get() != platformLayer) {
380dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch            setupContentsLayer(platformLayer);
381dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch            m_contentsLayer = platformLayer;
382dd8bb3de4f353a81954234999f1fea748aee2ea9Ben Murdoch            m_contentsLayerPurpose = ContentsLayerForCanvas;
383ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block            childrenChanged = true;
384ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block        }
3855abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick        m_contentsLayer->setNeedsDisplay();
386ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block        updateContentsRect();
387ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block    } else {
388ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block        if (m_contentsLayer) {
389ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block            childrenChanged = true;
390ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block
391ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block            // The old contents layer will be removed via updateSublayerList.
392ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block            m_contentsLayer = 0;
393ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block        }
394ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block    }
395ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block
396ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block    if (childrenChanged)
397ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block        updateSublayerList();
398ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block}
399ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24Steve Block
400967717af5423377c967781471ee106e2bb4e11c8Ben Murdochvoid GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer)
401dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
402967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    bool childrenChanged = false;
403967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    if (layer) {
404967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForVideo) {
405967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            setupContentsLayer(layer);
406967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            m_contentsLayer = layer;
407967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            m_contentsLayerPurpose = ContentsLayerForVideo;
408967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            childrenChanged = true;
409967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        }
410967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        layer->setOwner(this);
411967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        layer->setNeedsDisplay();
412967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        updateContentsRect();
413967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    } else {
414967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        if (m_contentsLayer) {
415967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            childrenChanged = true;
416967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
417967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            // The old contents layer will be removed via updateSublayerList.
418967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch            m_contentsLayer = 0;
419967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        }
420967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    }
421967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
422967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch    if (childrenChanged)
423967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch        updateSublayerList();
424dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
425dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
426dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockPlatformLayer* GraphicsLayerChromium::hostLayerForSublayers() const
427dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
428dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    return m_transformLayer ? m_transformLayer.get() : m_layer.get();
429dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
430dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
431dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockPlatformLayer* GraphicsLayerChromium::layerForSuperlayer() const
432dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
433dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    return m_transformLayer ? m_transformLayer.get() : m_layer.get();
434dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
435dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
436dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve BlockPlatformLayer* GraphicsLayerChromium::platformLayer() const
437dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
438dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    return primaryLayer();
439dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
440dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
441dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setDebugBackgroundColor(const Color& color)
442dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
443dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (color.isValid())
444dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        setLayerBackgroundColor(*m_layer, color);
445dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    else
446dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        clearLayerBackgroundColor(*m_layer);
447dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
448dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
449dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setDebugBorder(const Color& color, float borderWidth)
450dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
451dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (color.isValid()) {
452dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        setLayerBorderColor(*m_layer, color);
453dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->setBorderWidth(borderWidth);
454dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    } else {
455dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        clearBorderColor(*m_layer);
456dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->setBorderWidth(0);
457dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    }
458dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
459dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
460dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateSublayerList()
461dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
462dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    Vector<RefPtr<LayerChromium> > newSublayers;
463dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
464dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_transformLayer) {
465dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        // Add the primary layer first. Even if we have negative z-order children, the primary layer always comes behind.
466dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        newSublayers.append(m_layer.get());
467dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    } else if (m_contentsLayer) {
468dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        // FIXME: add the contents layer in the correct order with negative z-order children.
469dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        // This does not cause visible rendering issues because currently contents layers are only used
470dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        // for replaced elements that don't have children.
471dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        newSublayers.append(m_contentsLayer.get());
472dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    }
473dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
474dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    const Vector<GraphicsLayer*>& childLayers = children();
475dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    size_t numChildren = childLayers.size();
476dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    for (size_t i = 0; i < numChildren; ++i) {
477dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        GraphicsLayerChromium* curChild = static_cast<GraphicsLayerChromium*>(childLayers[i]);
478dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
479dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        LayerChromium* childLayer = curChild->layerForSuperlayer();
480dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        newSublayers.append(childLayer);
481dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    }
482dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
483dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    for (size_t i = 0; i < newSublayers.size(); ++i)
484dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        newSublayers[i]->removeFromSuperlayer();
485dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
486dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_transformLayer) {
487dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_transformLayer->setSublayers(newSublayers);
488dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
489dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        if (m_contentsLayer) {
490dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block            // If we have a transform layer, then the contents layer is parented in the
491dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block            // primary layer (which is itself a child of the transform layer).
492dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block            m_layer->removeAllSublayers();
493dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block            m_layer->addSublayer(m_contentsLayer);
494dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        }
495dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    } else
496dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->setSublayers(newSublayers);
497dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
498dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
499dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateLayerPosition()
500dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
501dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // Position is offset on the layer by the layer anchor point.
502dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    FloatPoint layerPosition(m_position.x() + m_anchorPoint.x() * m_size.width(),
503dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block                             m_position.y() + m_anchorPoint.y() * m_size.height());
504dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
505dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    primaryLayer()->setPosition(layerPosition);
506dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
507dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
508dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateLayerSize()
509dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
510dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    IntSize layerSize(m_size.width(), m_size.height());
511dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_transformLayer) {
512dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_transformLayer->setBounds(layerSize);
513dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        // The anchor of the contents layer is always at 0.5, 0.5, so the position is center-relative.
514dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        FloatPoint centerPoint(m_size.width() / 2, m_size.height() / 2);
515dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->setPosition(centerPoint);
516dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    }
517dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
518dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    m_layer->setBounds(layerSize);
519dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
520dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // Note that we don't resize m_contentsLayer. It's up the caller to do that.
521dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
522dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // If we've changed the bounds, we need to recalculate the position
523dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // of the layer, taking anchor point into account.
524dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateLayerPosition();
525dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
526dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
527dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateAnchorPoint()
528dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
529dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    primaryLayer()->setAnchorPoint(FloatPoint(m_anchorPoint.x(), m_anchorPoint.y()));
530dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    primaryLayer()->setAnchorPointZ(m_anchorPoint.z());
5312fc2651226baac27029e38c9d6ef883fa32084dbSteve Block
532dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateLayerPosition();
533dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
534dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
535dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateTransform()
536dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
537dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    primaryLayer()->setTransform(m_transform);
538dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
539dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
540dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateChildrenTransform()
541dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
542dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    primaryLayer()->setSublayerTransform(m_childrenTransform);
543dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
544dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
545dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateMasksToBounds()
546dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
547dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    m_layer->setMasksToBounds(m_masksToBounds);
548dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateDebugIndicators();
549dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
550dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
551dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateContentsOpaque()
552dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
553dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    m_layer->setOpaque(m_contentsOpaque);
554dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
555dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
556dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateBackfaceVisibility()
557dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
558dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    m_layer->setDoubleSided(m_backfaceVisibility);
559dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
560dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
561dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateLayerPreserves3D()
562dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
563545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    if (m_preserves3D && !m_transformLayer) {
564545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        // Create the transform layer.
565e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block        m_transformLayer = LayerChromium::create(this);
566545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
567545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        // Copy the position from this layer.
568545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateLayerPosition();
569545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateLayerSize();
570545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateAnchorPoint();
571545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateTransform();
572545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateChildrenTransform();
573545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
574545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_layer->setPosition(FloatPoint(m_size.width() / 2.0f, m_size.height() / 2.0f));
575545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
576545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_layer->setAnchorPoint(FloatPoint(0.5f, 0.5f));
577545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        TransformationMatrix identity;
578545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_layer->setTransform(identity);
579545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
580545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer.
581545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_layer->setOpacity(1);
582545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
583545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        // Move this layer to be a child of the transform layer.
584545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        if (m_layer->superlayer())
585545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch            m_layer->superlayer()->replaceSublayer(m_layer.get(), m_transformLayer.get());
586545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_transformLayer->addSublayer(m_layer.get());
587545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
588545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateSublayerList();
589545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    } else if (!m_preserves3D && m_transformLayer) {
590545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        // Relace the transformLayer in the parent with this layer.
591545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_layer->removeFromSuperlayer();
592545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_transformLayer->superlayer()->replaceSublayer(m_transformLayer.get(), m_layer.get());
593545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
594545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        // Release the transform layer.
595545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        m_transformLayer = 0;
596545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
597545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateLayerPosition();
598545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateLayerSize();
599545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateAnchorPoint();
600545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateTransform();
601545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateChildrenTransform();
602545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
603545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch        updateSublayerList();
604545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    }
605545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch
606545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    updateOpacityOnLayer();
60781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    updateNames();
608dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
609dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
610dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateLayerDrawsContent()
611dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
612dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_drawsContent)
613dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->setNeedsDisplay();
614dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
615dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateDebugIndicators();
616dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
617dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
618dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateLayerBackgroundColor()
619dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
620dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (!m_contentsLayer)
621dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
622dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
623dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // We never create the contents layer just for background color yet.
624dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_backgroundColorSet)
625dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        setLayerBackgroundColor(*m_contentsLayer, m_backgroundColor);
626dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    else
627dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        clearLayerBackgroundColor(*m_contentsLayer);
628dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
629dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
630dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateContentsVideo()
631dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
632dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    // FIXME: Implement
633dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
634dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
635dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateContentsRect()
636dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
637dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (!m_contentsLayer)
638dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
639dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
640545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch    m_contentsLayer->setPosition(FloatPoint(m_contentsRect.x(), m_contentsRect.y()));
641dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    m_contentsLayer->setBounds(IntSize(m_contentsRect.width(), m_contentsRect.height()));
642dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
643dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
644dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::setupContentsLayer(LayerChromium* contentsLayer)
645dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
646dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (contentsLayer == m_contentsLayer)
647dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        return;
648dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
649dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (m_contentsLayer) {
650dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_contentsLayer->removeFromSuperlayer();
651dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_contentsLayer = 0;
652dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    }
653dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
654dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    if (contentsLayer) {
655dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_contentsLayer = contentsLayer;
656dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
657dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_contentsLayer->setAnchorPoint(FloatPoint(0, 0));
658dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
659dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        // Insert the content layer first. Video elements require this, because they have
660dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        // shadow content that must display in front of the video.
661dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        m_layer->insertSublayer(m_contentsLayer.get(), 0);
662dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
663dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        updateContentsRect();
664dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
665dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        if (showDebugBorders()) {
666dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block            setLayerBorderColor(*m_contentsLayer, Color(0, 0, 128, 180));
667dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block            m_contentsLayer->setBorderWidth(1);
668dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block        }
669dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    }
670dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    updateDebugIndicators();
67181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    updateNames();
672dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
673dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
674dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block// This function simply mimics the operation of GraphicsLayerCA
675dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid GraphicsLayerChromium::updateOpacityOnLayer()
676dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{
677dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block    primaryLayer()->setOpacity(m_opacity);
678dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}
679dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
680dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} // namespace WebCore
681dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block
682dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#endif // USE(ACCELERATED_COMPOSITING)
683