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
|
// Copyright 2011 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 "CCTextureLayerImpl.h"
#include "base/stringprintf.h"
#include "CCQuadSink.h"
#include "CCRenderer.h"
#include "CCTextureDrawQuad.h"
namespace cc {
CCTextureLayerImpl::CCTextureLayerImpl(int id)
: CCLayerImpl(id)
, m_textureId(0)
, m_externalTextureResource(0)
, m_premultipliedAlpha(true)
, m_flipped(true)
, m_uvRect(0, 0, 1, 1)
{
}
CCTextureLayerImpl::~CCTextureLayerImpl()
{
}
void CCTextureLayerImpl::willDraw(CCResourceProvider* resourceProvider)
{
if (!m_textureId)
return;
ASSERT(!m_externalTextureResource);
m_externalTextureResource = resourceProvider->createResourceFromExternalTexture(m_textureId);
}
void CCTextureLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuadsData)
{
if (!m_externalTextureResource)
return;
CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQuadState());
appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
IntRect quadRect(IntPoint(), contentBounds());
quadSink.append(CCTextureDrawQuad::create(sharedQuadState, quadRect, m_externalTextureResource, m_premultipliedAlpha, m_uvRect, m_flipped), appendQuadsData);
}
void CCTextureLayerImpl::didDraw(CCResourceProvider* resourceProvider)
{
if (!m_externalTextureResource)
return;
// FIXME: the following assert will not be true when sending resources to a
// parent compositor. A synchronization scheme (double-buffering or
// pipelining of updates) for the client will need to exist to solve this.
ASSERT(!resourceProvider->inUseByConsumer(m_externalTextureResource));
resourceProvider->deleteResource(m_externalTextureResource);
m_externalTextureResource = 0;
}
void CCTextureLayerImpl::dumpLayerProperties(std::string* str, int indent) const
{
str->append(indentString(indent));
base::StringAppendF(str, "texture layer texture id: %u premultiplied: %d\n", m_textureId, m_premultipliedAlpha);
CCLayerImpl::dumpLayerProperties(str, indent);
}
void CCTextureLayerImpl::didLoseContext()
{
m_textureId = 0;
m_externalTextureResource = 0;
}
}
#endif // USE(ACCELERATED_COMPOSITING)
|