Commit e228e9cb authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

MailboxToSurfaceBridge: produce texture exactly when we create mailbox

This refactors MailboxToSurfaceBridge a bit based on existing callers.
A follow-up change will merge GenMailboxCHROMIUM and
ProduceTextureDirectCHROMIUM.

DestroyMailboxTexture was dead code, so removed. We can resurrect in a
later CL if needed.

Bug: 847674
Change-Id: I8fa52a4b7288955d3571c41bdf7b23f0ca4290f0
Reviewed-on: https://chromium-review.googlesource.com/1083333Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565114}
parent 1abab4c2
...@@ -148,14 +148,10 @@ void ARImageTransport::SetupHardwareBuffers() { ...@@ -148,14 +148,10 @@ void ARImageTransport::SetupHardwareBuffers() {
std::unique_ptr<SharedFrameBuffer> buffer = std::unique_ptr<SharedFrameBuffer> buffer =
std::make_unique<SharedFrameBuffer>(); std::make_unique<SharedFrameBuffer>();
// Remote resources // Remote resources
std::unique_ptr<gpu::MailboxHolder> holder = buffer->mailbox_holder = std::make_unique<gpu::MailboxHolder>();
std::make_unique<gpu::MailboxHolder>(); buffer->mailbox_holder->texture_target = GL_TEXTURE_2D;
mailbox_bridge_->GenerateMailbox(holder->mailbox);
holder->texture_target = GL_TEXTURE_2D;
buffer->mailbox_holder = std::move(holder);
buffer->remote_texture_id = buffer->remote_texture_id =
mailbox_bridge_->CreateMailboxTexture(buffer->mailbox_holder->mailbox); mailbox_bridge_->CreateMailboxTexture(&buffer->mailbox_holder->mailbox);
// Local resources // Local resources
glGenTextures(1, &buffer->local_texture_id); glGenTextures(1, &buffer->local_texture_id);
......
...@@ -353,14 +353,7 @@ void MailboxToSurfaceBridge::CreateGpuFence( ...@@ -353,14 +353,7 @@ void MailboxToSurfaceBridge::CreateGpuFence(
gl_->DestroyGpuFenceCHROMIUM(id); gl_->DestroyGpuFenceCHROMIUM(id);
} }
void MailboxToSurfaceBridge::GenerateMailbox(gpu::Mailbox& out_mailbox) { uint32_t MailboxToSurfaceBridge::CreateMailboxTexture(gpu::Mailbox* mailbox) {
TRACE_EVENT0("gpu", __FUNCTION__);
DCHECK(IsConnected());
gl_->GenMailboxCHROMIUM(out_mailbox.name);
}
uint32_t MailboxToSurfaceBridge::CreateMailboxTexture(
const gpu::Mailbox& mailbox) {
TRACE_EVENT0("gpu", __FUNCTION__); TRACE_EVENT0("gpu", __FUNCTION__);
DCHECK(IsConnected()); DCHECK(IsConnected());
...@@ -368,23 +361,12 @@ uint32_t MailboxToSurfaceBridge::CreateMailboxTexture( ...@@ -368,23 +361,12 @@ uint32_t MailboxToSurfaceBridge::CreateMailboxTexture(
gl_->GenTextures(1, &tex); gl_->GenTextures(1, &tex);
gl_->BindTexture(GL_TEXTURE_2D, tex); gl_->BindTexture(GL_TEXTURE_2D, tex);
gl_->ProduceTextureDirectCHROMIUM(tex, mailbox.name); gl_->GenMailboxCHROMIUM(mailbox->name);
gl_->ProduceTextureDirectCHROMIUM(tex, mailbox->name);
return tex; return tex;
} }
void MailboxToSurfaceBridge::DestroyMailboxTexture(const gpu::Mailbox& mailbox,
uint32_t texture_id) {
TRACE_EVENT0("gpu", __FUNCTION__);
DCHECK(IsConnected());
// Associating with texture ID 0 unbinds the previous binding without
// creating a new one.
gl_->ProduceTextureDirectCHROMIUM(0, mailbox.name);
GLuint tex = texture_id;
gl_->DeleteTextures(1, &tex);
}
uint32_t MailboxToSurfaceBridge::BindSharedBufferImage( uint32_t MailboxToSurfaceBridge::BindSharedBufferImage(
gfx::GpuMemoryBuffer* buffer, gfx::GpuMemoryBuffer* buffer,
const gfx::Size& size, const gfx::Size& size,
......
...@@ -112,15 +112,10 @@ class MailboxToSurfaceBridge { ...@@ -112,15 +112,10 @@ class MailboxToSurfaceBridge {
const gpu::SyncToken& sync_token, const gpu::SyncToken& sync_token,
base::OnceCallback<void(std::unique_ptr<gfx::GpuFence>)> callback); base::OnceCallback<void(std::unique_ptr<gfx::GpuFence>)> callback);
void GenerateMailbox(gpu::Mailbox& out_mailbox); // Creates a texture and binds it to a newly created mailbox. Returns its
// mailbox and texture ID in the command buffer context. (Don't use that
// Creates a texture and binds it to the mailbox. Returns its
// texture ID in the command buffer context. (Don't use that
// in the local GL context, it's not valid there.) // in the local GL context, it's not valid there.)
uint32_t CreateMailboxTexture(const gpu::Mailbox& mailbox); uint32_t CreateMailboxTexture(gpu::Mailbox* mailbox);
// Unbinds the texture from the mailbox and destroys it.
void DestroyMailboxTexture(const gpu::Mailbox& mailbox, uint32_t texture_id);
// Creates a GLImage from the |buffer| and binds it to the supplied texture_id // Creates a GLImage from the |buffer| and binds it to the supplied texture_id
// in the GPU process. Returns the image ID in the command buffer context. // in the GPU process. Returns the image ID in the command buffer context.
......
...@@ -615,13 +615,10 @@ void VrShellGl::WebVrPrepareSharedBuffer(const gfx::Size& size) { ...@@ -615,13 +615,10 @@ void VrShellGl::WebVrPrepareSharedBuffer(const gfx::Size& size) {
buffer = webxr_->GetAnimatingFrame()->shared_buffer.get(); buffer = webxr_->GetAnimatingFrame()->shared_buffer.get();
// Remote resources // Remote resources
auto holder = std::make_unique<gpu::MailboxHolder>(); buffer->mailbox_holder = std::make_unique<gpu::MailboxHolder>();
DCHECK(holder); buffer->mailbox_holder->texture_target = GL_TEXTURE_2D;
mailbox_bridge_->GenerateMailbox(holder->mailbox);
holder->texture_target = GL_TEXTURE_2D;
buffer->remote_texture = buffer->remote_texture =
mailbox_bridge_->CreateMailboxTexture(holder->mailbox); mailbox_bridge_->CreateMailboxTexture(&buffer->mailbox_holder->mailbox);
buffer->mailbox_holder = std::move(holder);
// Local resources // Local resources
glGenTextures(1, &buffer->local_texture); glGenTextures(1, &buffer->local_texture);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment