Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: webkit/compositor_bindings/web_external_texture_layer_impl.cc

Issue 12374028: Allow WebExternalTextureLayerClient to work with mailboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f7ea31a8ce31dcd38ebba7c234451e443130cbb3 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,33 @@ 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,
jamesr 2013/04/11 17:36:58 & goes with the type, not the variable name
alexst (slow to review) 2013/04/11 18:03:12 Done.
+ unsigned sync_point,
+ bool lost_resource) {
+ if (lost_resource)
jamesr 2013/04/11 17:36:58 why is the callback invoked with lost_resource=tru
alexst (slow to review) 2013/04/11 18:03:12 In this case, lost resources are already handled i
+ return;
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698