| 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 "WebLayerImpl.h" | |
| 9 #include "cc/texture_layer.h" | |
| 10 #include "cc/texture_update_queue.h" | |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureL
ayerClient.h" | |
| 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h" | |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | |
| 14 #include "webcore_convert.h" | |
| 15 | |
| 16 using namespace cc; | |
| 17 | |
| 18 namespace WebKit { | |
| 19 | |
| 20 WebExternalTextureLayer* WebExternalTextureLayer::create(WebExternalTextureLayer
Client* client) | |
| 21 { | |
| 22 return new WebExternalTextureLayerImpl(client); | |
| 23 } | |
| 24 | |
| 25 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(WebExternalTextureLayer
Client* client) | |
| 26 : m_client(client) | |
| 27 { | |
| 28 scoped_refptr<TextureLayerChromium> layer; | |
| 29 if (m_client) | |
| 30 layer = TextureLayerChromium::create(this); | |
| 31 else | |
| 32 layer = TextureLayerChromium::create(0); | |
| 33 layer->setIsDrawable(true); | |
| 34 m_layer.reset(new WebLayerImpl(layer)); | |
| 35 } | |
| 36 | |
| 37 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() | |
| 38 { | |
| 39 static_cast<TextureLayerChromium*>(m_layer->layer())->clearClient(); | |
| 40 } | |
| 41 | |
| 42 WebLayer* WebExternalTextureLayerImpl::layer() | |
| 43 { | |
| 44 return m_layer.get(); | |
| 45 } | |
| 46 | |
| 47 void WebExternalTextureLayerImpl::setTextureId(unsigned id) | |
| 48 { | |
| 49 static_cast<TextureLayerChromium*>(m_layer->layer())->setTextureId(id); | |
| 50 } | |
| 51 | |
| 52 void WebExternalTextureLayerImpl::setFlipped(bool flipped) | |
| 53 { | |
| 54 static_cast<TextureLayerChromium*>(m_layer->layer())->setFlipped(flipped); | |
| 55 } | |
| 56 | |
| 57 void WebExternalTextureLayerImpl::setUVRect(const WebFloatRect& rect) | |
| 58 { | |
| 59 static_cast<TextureLayerChromium*>(m_layer->layer())->setUVRect(convert(rect
)); | |
| 60 } | |
| 61 | |
| 62 void WebExternalTextureLayerImpl::setOpaque(bool opaque) | |
| 63 { | |
| 64 static_cast<TextureLayerChromium*>(m_layer->layer())->setContentsOpaque(opaq
ue); | |
| 65 } | |
| 66 | |
| 67 void WebExternalTextureLayerImpl::setPremultipliedAlpha(bool premultipliedAlpha) | |
| 68 { | |
| 69 static_cast<TextureLayerChromium*>(m_layer->layer())->setPremultipliedAlpha(
premultipliedAlpha); | |
| 70 } | |
| 71 | |
| 72 void WebExternalTextureLayerImpl::willModifyTexture() | |
| 73 { | |
| 74 static_cast<TextureLayerChromium*>(m_layer->layer())->willModifyTexture(); | |
| 75 } | |
| 76 | |
| 77 void WebExternalTextureLayerImpl::setRateLimitContext(bool rateLimit) | |
| 78 { | |
| 79 static_cast<TextureLayerChromium*>(m_layer->layer())->setRateLimitContext(ra
teLimit); | |
| 80 } | |
| 81 | |
| 82 class WebTextureUpdaterImpl : public WebTextureUpdater { | |
| 83 public: | |
| 84 explicit WebTextureUpdaterImpl(CCTextureUpdateQueue& queue) | |
| 85 : m_queue(queue) | |
| 86 { | |
| 87 } | |
| 88 | |
| 89 virtual void appendCopy(unsigned sourceTexture, unsigned destinationTexture,
WebSize size) OVERRIDE | |
| 90 { | |
| 91 TextureCopier::Parameters copy = { sourceTexture, destinationTexture, co
nvert(size) }; | |
| 92 m_queue.appendCopy(copy); | |
| 93 } | |
| 94 | |
| 95 private: | |
| 96 CCTextureUpdateQueue& m_queue; | |
| 97 }; | |
| 98 | |
| 99 unsigned WebExternalTextureLayerImpl::prepareTexture(CCTextureUpdateQueue& queue
) | |
| 100 { | |
| 101 ASSERT(m_client); | |
| 102 WebTextureUpdaterImpl updaterImpl(queue); | |
| 103 return m_client->prepareTexture(updaterImpl); | |
| 104 } | |
| 105 | |
| 106 WebGraphicsContext3D* WebExternalTextureLayerImpl::context() | |
| 107 { | |
| 108 ASSERT(m_client); | |
| 109 return m_client->context(); | |
| 110 } | |
| 111 | |
| 112 } // namespace WebKit | |
| OLD | NEW |