OLD | NEW |
| (Empty) |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "WebExternalTextureLayerImpl.h" | |
7 | |
8 #include "CCTextureUpdateQueue.h" | |
9 #include "TextureLayerChromium.h" | |
10 #include "WebLayerImpl.h" | |
11 #include <public/WebExternalTextureLayerClient.h> | |
12 #include <public/WebFloatRect.h> | |
13 #include <public/WebSize.h> | |
14 | |
15 using namespace WebCore; | |
16 | |
17 namespace WebKit { | |
18 | |
19 WebExternalTextureLayer* WebExternalTextureLayer::create(WebExternalTextureLayer
Client* client) | |
20 { | |
21 return new WebExternalTextureLayerImpl(client); | |
22 } | |
23 | |
24 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(WebExternalTextureLayer
Client* client) | |
25 : m_client(client) | |
26 { | |
27 RefPtr<TextureLayerChromium> layer; | |
28 if (m_client) | |
29 layer = TextureLayerChromium::create(this); | |
30 else | |
31 layer = TextureLayerChromium::create(0); | |
32 layer->setIsDrawable(true); | |
33 m_layer = adoptPtr(new WebLayerImpl(layer.release())); | |
34 } | |
35 | |
36 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() | |
37 { | |
38 static_cast<TextureLayerChromium*>(m_layer->layer())->clearClient(); | |
39 } | |
40 | |
41 WebLayer* WebExternalTextureLayerImpl::layer() | |
42 { | |
43 return m_layer.get(); | |
44 } | |
45 | |
46 void WebExternalTextureLayerImpl::setTextureId(unsigned id) | |
47 { | |
48 static_cast<TextureLayerChromium*>(m_layer->layer())->setTextureId(id); | |
49 } | |
50 | |
51 void WebExternalTextureLayerImpl::setFlipped(bool flipped) | |
52 { | |
53 static_cast<TextureLayerChromium*>(m_layer->layer())->setFlipped(flipped); | |
54 } | |
55 | |
56 void WebExternalTextureLayerImpl::setUVRect(const WebFloatRect& rect) | |
57 { | |
58 static_cast<TextureLayerChromium*>(m_layer->layer())->setUVRect(rect); | |
59 } | |
60 | |
61 void WebExternalTextureLayerImpl::setOpaque(bool opaque) | |
62 { | |
63 static_cast<TextureLayerChromium*>(m_layer->layer())->setOpaque(opaque); | |
64 } | |
65 | |
66 void WebExternalTextureLayerImpl::setPremultipliedAlpha(bool premultipliedAlpha) | |
67 { | |
68 static_cast<TextureLayerChromium*>(m_layer->layer())->setPremultipliedAlpha(
premultipliedAlpha); | |
69 } | |
70 | |
71 void WebExternalTextureLayerImpl::willModifyTexture() | |
72 { | |
73 static_cast<TextureLayerChromium*>(m_layer->layer())->willModifyTexture(); | |
74 } | |
75 | |
76 void WebExternalTextureLayerImpl::setRateLimitContext(bool rateLimit) | |
77 { | |
78 static_cast<TextureLayerChromium*>(m_layer->layer())->setRateLimitContext(ra
teLimit); | |
79 } | |
80 | |
81 class WebTextureUpdaterImpl : public WebTextureUpdater { | |
82 public: | |
83 explicit WebTextureUpdaterImpl(CCTextureUpdateQueue& queue) | |
84 : m_queue(queue) | |
85 { | |
86 } | |
87 | |
88 virtual void appendCopy(unsigned sourceTexture, unsigned destinationTexture,
WebSize size) OVERRIDE | |
89 { | |
90 TextureCopier::Parameters copy = { sourceTexture, destinationTexture, si
ze }; | |
91 m_queue.appendCopy(copy); | |
92 } | |
93 | |
94 private: | |
95 CCTextureUpdateQueue& m_queue; | |
96 }; | |
97 | |
98 unsigned WebExternalTextureLayerImpl::prepareTexture(CCTextureUpdateQueue& queue
) | |
99 { | |
100 ASSERT(m_client); | |
101 WebTextureUpdaterImpl updaterImpl(queue); | |
102 return m_client->prepareTexture(updaterImpl); | |
103 } | |
104 | |
105 WebGraphicsContext3D* WebExternalTextureLayerImpl::context() | |
106 { | |
107 ASSERT(m_client); | |
108 return m_client->context(); | |
109 } | |
110 | |
111 } // namespace WebKit | |
OLD | NEW |