| Index: webkit/compositor_bindings/web_external_texture_layer_impl.cc
|
| diff --git a/webkit/compositor_bindings/web_external_texture_layer_impl.cc b/webkit/compositor_bindings/web_external_texture_layer_impl.cc
|
| index 01f6e79214b41438ed4e1453c000461fde04418b..26d109cc0a580472215438ff6dee918ea732c5e7 100644
|
| --- a/webkit/compositor_bindings/web_external_texture_layer_impl.cc
|
| +++ b/webkit/compositor_bindings/web_external_texture_layer_impl.cc
|
| @@ -7,6 +7,7 @@
|
| #include "cc/layers/texture_layer.h"
|
| #include "cc/resources/resource_update_queue.h"
|
| #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureLayerClient.h"
|
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureMailbox.h"
|
| #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatRect.h"
|
| #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
|
| #include "webkit/compositor_bindings/web_layer_impl.h"
|
| @@ -17,13 +18,16 @@ using cc::ResourceUpdateQueue;
|
| namespace webkit {
|
|
|
| WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(
|
| - WebKit::WebExternalTextureLayerClient* client)
|
| - : client_(client) {
|
| + WebKit::WebExternalTextureLayerClient* client,
|
| + bool mailbox)
|
| + : client_(client),
|
| + uses_mailbox_(mailbox) {
|
| scoped_refptr<TextureLayer> layer;
|
| - if (client_)
|
| - layer = TextureLayer::Create(this);
|
| + cc::TextureLayerClient* cc_client = client_ ? this : NULL;
|
| + if (mailbox)
|
| + layer = TextureLayer::CreateForMailbox(cc_client);
|
| else
|
| - layer = TextureLayer::Create(NULL);
|
| + layer = TextureLayer::Create(cc_client);
|
| layer->SetIsDrawable(true);
|
| layer_.reset(new WebLayerImpl(layer));
|
| }
|
| @@ -34,6 +38,15 @@ WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() {
|
|
|
| WebKit::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); }
|
|
|
| +void WebExternalTextureLayerImpl::clearTexture() {
|
| + if (uses_mailbox_) {
|
| + static_cast<TextureLayer*>(layer_->layer())->SetTextureMailbox(
|
| + cc::TextureMailbox());
|
| + } else {
|
| + static_cast<TextureLayer*>(layer_->layer())->SetTextureId(0);
|
| + }
|
| +}
|
| +
|
| void WebExternalTextureLayerImpl::setTextureId(unsigned id) {
|
| static_cast<TextureLayer*>(layer_->layer())->SetTextureId(id);
|
| }
|
| @@ -94,4 +107,29 @@ WebKit::WebGraphicsContext3D* WebExternalTextureLayerImpl::Context3d() {
|
| return client_->context();
|
| }
|
|
|
| -} // namespace webkit
|
| +bool WebExternalTextureLayerImpl::PrepareTextureMailbox(
|
| + cc::TextureMailbox* out_mailbox) {
|
| + WebKit::WebExternalTextureMailbox mailbox;
|
| + if (!client_->prepareMailbox(&mailbox)) {
|
| + return false;
|
| + }
|
| + gpu::Mailbox name;
|
| + name.SetName(mailbox.name);
|
| + cc::TextureMailbox::ReleaseCallback callback =
|
| + base::Bind(&WebExternalTextureLayerImpl::mailboxReleased,
|
| + this->AsWeakPtr(),
|
| + mailbox);
|
| + *out_mailbox = cc::TextureMailbox(name, callback, mailbox.syncPoint);
|
| + return true;
|
| +}
|
| +
|
| +void WebExternalTextureLayerImpl::mailboxReleased(
|
| + const WebKit::WebExternalTextureMailbox &mailbox,
|
| + unsigned sync_point) {
|
| + WebKit::WebExternalTextureMailbox available_mailbox;
|
| + memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name));
|
| + available_mailbox.syncPoint = sync_point;
|
| + client_->mailboxReleased(available_mailbox);
|
| +}
|
| +
|
| +} // namespace webkit
|
|
|