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

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 1912833002: Pepper takes ownership of a mailbox before passing it to the texture layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 4 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: content/renderer/pepper/pepper_plugin_instance_impl.cc
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index 17925e9d2383f1e48448b015dbaa87315196fc16..05b07bfb8adae1c39224e4f25a9be32f2e404574 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -787,14 +787,26 @@ void PepperPluginInstanceImpl::CommitBackingTexture() {
return;
}
+ PassTextureFromGraphics3DToTextureLayer();
+ texture_layer_->SetNeedsDisplay();
+}
+
+void PepperPluginInstanceImpl::PassTextureFromGraphics3DToTextureLayer() {
+ DCHECK(bound_graphics_3d_);
+
gpu::Mailbox mailbox;
gpu::SyncToken sync_token;
- bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token);
+ bound_graphics_3d_->TakeBackingMailbox(&mailbox, &sync_token);
DCHECK(!mailbox.IsZero());
DCHECK(sync_token.HasData());
- texture_layer_->SetTextureMailboxWithoutReleaseCallback(
- cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D));
- texture_layer_->SetNeedsDisplay();
+
+ cc::TextureMailbox texture_mailbox(mailbox, sync_token, GL_TEXTURE_2D);
+ std::unique_ptr<cc::SingleReleaseCallback> callback(
+ cc::SingleReleaseCallback::Create(
+ base::Bind(&PPB_Graphics3D_Impl::ReturnBackingMailbox,
+ bound_graphics_3d_, mailbox)));
+
+ texture_layer_->SetTextureMailbox(texture_mailbox, std::move(callback));
}
void PepperPluginInstanceImpl::InstanceCrashed() {
@@ -2017,12 +2029,7 @@ void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) {
if (!container_)
return;
- gpu::Mailbox mailbox;
- gpu::SyncToken sync_token;
- if (bound_graphics_3d_.get()) {
- bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_token);
- }
- bool want_3d_layer = !mailbox.IsZero() && sync_token.HasData();
+ bool want_3d_layer = !!bound_graphics_3d_.get();
bool want_2d_layer = !!bound_graphics_2d_platform_;
bool want_texture_layer = want_3d_layer || want_2d_layer;
bool want_compositor_layer = !!bound_compositor_;
@@ -2061,8 +2068,8 @@ void PepperPluginInstanceImpl::UpdateLayer(bool force_creation) {
DCHECK(bound_graphics_3d_.get());
texture_layer_ = cc::TextureLayer::CreateForMailbox(NULL);
opaque = bound_graphics_3d_->IsOpaque();
- texture_layer_->SetTextureMailboxWithoutReleaseCallback(
- cc::TextureMailbox(mailbox, sync_token, GL_TEXTURE_2D));
+
+ PassTextureFromGraphics3DToTextureLayer();
} else {
DCHECK(bound_graphics_2d_platform_);
texture_layer_ = cc::TextureLayer::CreateForMailbox(this);

Powered by Google App Engine
This is Rietveld 408576698