blob: b47dff97cada781410e60ba3618cb3fa43f44a21 (
plain)
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
|
// 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"
#include "web_external_texture_layer_impl.h"
#include "cc/resource_update_queue.h"
#include "cc/texture_layer.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureLayerClient.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "web_layer_impl.h"
#include "webcore_convert.h"
using namespace cc;
namespace WebKit {
WebExternalTextureLayer* WebExternalTextureLayer::create(WebExternalTextureLayerClient* client)
{
return new WebExternalTextureLayerImpl(client);
}
WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(WebExternalTextureLayerClient* client)
: m_client(client)
{
scoped_refptr<TextureLayer> layer;
if (m_client)
layer = TextureLayer::create(this);
else
layer = TextureLayer::create(0);
layer->setIsDrawable(true);
m_layer.reset(new WebLayerImpl(layer));
}
WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl()
{
static_cast<TextureLayer*>(m_layer->layer())->clearClient();
}
WebLayer* WebExternalTextureLayerImpl::layer()
{
return m_layer.get();
}
void WebExternalTextureLayerImpl::setTextureId(unsigned id)
{
static_cast<TextureLayer*>(m_layer->layer())->setTextureId(id);
}
void WebExternalTextureLayerImpl::setFlipped(bool flipped)
{
static_cast<TextureLayer*>(m_layer->layer())->setFlipped(flipped);
}
void WebExternalTextureLayerImpl::setUVRect(const WebFloatRect& rect)
{
static_cast<TextureLayer*>(m_layer->layer())->setUVRect(convert(rect));
}
void WebExternalTextureLayerImpl::setOpaque(bool opaque)
{
static_cast<TextureLayer*>(m_layer->layer())->setContentsOpaque(opaque);
}
void WebExternalTextureLayerImpl::setPremultipliedAlpha(bool premultipliedAlpha)
{
static_cast<TextureLayer*>(m_layer->layer())->setPremultipliedAlpha(premultipliedAlpha);
}
void WebExternalTextureLayerImpl::willModifyTexture()
{
static_cast<TextureLayer*>(m_layer->layer())->willModifyTexture();
}
void WebExternalTextureLayerImpl::setRateLimitContext(bool rateLimit)
{
static_cast<TextureLayer*>(m_layer->layer())->setRateLimitContext(rateLimit);
}
class WebTextureUpdaterImpl : public WebTextureUpdater {
public:
explicit WebTextureUpdaterImpl(ResourceUpdateQueue& queue)
: m_queue(queue)
{
}
virtual void appendCopy(unsigned sourceTexture, unsigned destinationTexture, WebSize size) OVERRIDE
{
TextureCopier::Parameters copy = { sourceTexture, destinationTexture, convert(size) };
m_queue.appendCopy(copy);
}
private:
ResourceUpdateQueue& m_queue;
};
unsigned WebExternalTextureLayerImpl::prepareTexture(ResourceUpdateQueue& queue)
{
ASSERT(m_client);
WebTextureUpdaterImpl updaterImpl(queue);
return m_client->prepareTexture(updaterImpl);
}
WebGraphicsContext3D* WebExternalTextureLayerImpl::context()
{
ASSERT(m_client);
return m_client->context();
}
} // namespace WebKit
|