1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
// Copyright 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#if USE(ACCELERATED_COMPOSITING)
#include "TextureLayerChromium.h"
#include "CCLayerTreeHost.h"
#include "CCTextureLayerImpl.h"
#include <public/WebGraphicsContext3D.h>
namespace WebCore {
PassRefPtr<TextureLayerChromium> TextureLayerChromium::create(TextureLayerChromiumClient* client)
{
return adoptRef(new TextureLayerChromium(client));
}
TextureLayerChromium::TextureLayerChromium(TextureLayerChromiumClient* client)
: LayerChromium()
, m_client(client)
, m_flipped(true)
, m_uvRect(0, 0, 1, 1)
, m_premultipliedAlpha(true)
, m_rateLimitContext(false)
, m_contextLost(false)
, m_textureId(0)
{
}
TextureLayerChromium::~TextureLayerChromium()
{
if (layerTreeHost()) {
if (m_textureId)
layerTreeHost()->acquireLayerTextures();
if (m_rateLimitContext && m_client)
layerTreeHost()->stopRateLimiter(m_client->context());
}
}
PassOwnPtr<CCLayerImpl> TextureLayerChromium::createCCLayerImpl()
{
return CCTextureLayerImpl::create(m_layerId);
}
void TextureLayerChromium::setFlipped(bool flipped)
{
m_flipped = flipped;
setNeedsCommit();
}
void TextureLayerChromium::setUVRect(const FloatRect& rect)
{
m_uvRect = rect;
setNeedsCommit();
}
void TextureLayerChromium::setPremultipliedAlpha(bool premultipliedAlpha)
{
m_premultipliedAlpha = premultipliedAlpha;
setNeedsCommit();
}
void TextureLayerChromium::setRateLimitContext(bool rateLimit)
{
if (!rateLimit && m_rateLimitContext && m_client && layerTreeHost())
layerTreeHost()->stopRateLimiter(m_client->context());
m_rateLimitContext = rateLimit;
}
void TextureLayerChromium::setTextureId(unsigned id)
{
if (m_textureId == id)
return;
if (m_textureId && layerTreeHost())
layerTreeHost()->acquireLayerTextures();
m_textureId = id;
setNeedsCommit();
}
void TextureLayerChromium::willModifyTexture()
{
if (layerTreeHost())
layerTreeHost()->acquireLayerTextures();
}
void TextureLayerChromium::setNeedsDisplayRect(const FloatRect& dirtyRect)
{
LayerChromium::setNeedsDisplayRect(dirtyRect);
if (m_rateLimitContext && m_client && layerTreeHost())
layerTreeHost()->startRateLimiter(m_client->context());
}
void TextureLayerChromium::setLayerTreeHost(CCLayerTreeHost* host)
{
if (m_textureId && layerTreeHost() && host != layerTreeHost())
layerTreeHost()->acquireLayerTextures();
LayerChromium::setLayerTreeHost(host);
}
bool TextureLayerChromium::drawsContent() const
{
return (m_client || m_textureId) && !m_contextLost && LayerChromium::drawsContent();
}
void TextureLayerChromium::update(CCTextureUpdateQueue& queue, const CCOcclusionTracker*, CCRenderingStats&)
{
if (m_client) {
m_textureId = m_client->prepareTexture(queue);
m_contextLost = m_client->context()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR;
}
m_needsDisplay = false;
}
void TextureLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
{
LayerChromium::pushPropertiesTo(layer);
CCTextureLayerImpl* textureLayer = static_cast<CCTextureLayerImpl*>(layer);
textureLayer->setFlipped(m_flipped);
textureLayer->setUVRect(m_uvRect);
textureLayer->setPremultipliedAlpha(m_premultipliedAlpha);
textureLayer->setTextureId(m_textureId);
}
}
#endif // USE(ACCELERATED_COMPOSITING)
|