| Index: components/exo/buffer.cc
|
| diff --git a/components/exo/buffer.cc b/components/exo/buffer.cc
|
| index 9b1778d989d6c0250efff832d6372f401e15e129..eb097705700aa4d60b4426f56a921e0bb9c4ff33 100644
|
| --- a/components/exo/buffer.cc
|
| +++ b/components/exo/buffer.cc
|
| @@ -24,6 +24,7 @@
|
| #include "cc/output/context_provider.h"
|
| #include "cc/resources/single_release_callback.h"
|
| #include "cc/resources/texture_mailbox.h"
|
| +#include "components/exo/compositor_frame_sink_holder.h"
|
| #include "gpu/command_buffer/client/context_support.h"
|
| #include "gpu/command_buffer/client/gles2_interface.h"
|
| #include "ui/aura/env.h"
|
| @@ -220,6 +221,7 @@ bool Buffer::Texture::IsLost() {
|
| void Buffer::Texture::Release(const base::Closure& callback,
|
| const gpu::SyncToken& sync_token,
|
| bool is_lost) {
|
| + printf("Buffer::Texture::Release()\n");
|
| if (context_provider_) {
|
| gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL();
|
| if (sync_token.HasData())
|
| @@ -255,6 +257,7 @@ gpu::SyncToken Buffer::Texture::BindTexImage() {
|
| void Buffer::Texture::ReleaseTexImage(const base::Closure& callback,
|
| const gpu::SyncToken& sync_token,
|
| bool is_lost) {
|
| + printf("Buffer::Texture::ReleaseTexImage()\n");
|
| if (context_provider_) {
|
| gpu::gles2::GLES2Interface* gles2 = context_provider_->ContextGL();
|
| if (sync_token.HasData())
|
| @@ -398,10 +401,12 @@ Buffer::Buffer(std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer,
|
|
|
| Buffer::~Buffer() {}
|
|
|
| -std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
|
| - cc::TextureMailbox* texture_mailbox,
|
| +bool Buffer::ProduceTransferableResource(
|
| + CompositorFrameSinkHolder* compositor_frame_sink_holder,
|
| + cc::ResourceId resource_id,
|
| bool secure_output_only,
|
| - bool client_usage) {
|
| + bool client_usage,
|
| + cc::TransferableResource* resource) {
|
| DCHECK(attach_count_);
|
| DLOG_IF(WARNING, use_count_ && client_usage)
|
| << "Producing a texture mailbox for a buffer that has not been released";
|
| @@ -433,9 +438,20 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
|
| if (!context_provider) {
|
| DLOG(WARNING) << "Failed to acquire a context provider";
|
| Release(); // Decrements the use count
|
| - return nullptr;
|
| + resource->id = 0;
|
| + resource->size = gfx::Size();
|
| + return false;
|
| }
|
|
|
| + // The reference to the CompositorFrameSinkHolder keeps it alive until a
|
| + // release callback is received.
|
| + compositor_frame_sink_holder_ = compositor_frame_sink_holder;
|
| +
|
| + resource->id = resource_id;
|
| + resource->format = cc::RGBA_8888;
|
| + resource->filter = GL_LINEAR;
|
| + resource->size = gpu_memory_buffer_->GetSize();
|
| +
|
| // Create a new image texture for |gpu_memory_buffer_| with |texture_target_|
|
| // if one doesn't already exist. The contents of this buffer are copied to
|
| // |texture| using a call to CopyTexImage.
|
| @@ -450,18 +466,20 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
|
| Texture* texture = contents_texture_.get();
|
|
|
| // This binds the latest contents of this buffer to |texture|.
|
| - gpu::SyncToken sync_token = texture->BindTexImage();
|
| + resource->mailbox_holder = gpu::MailboxHolder(
|
| + texture->mailbox(), texture->BindTexImage(), texture_target_);
|
|
|
| - *texture_mailbox =
|
| - cc::TextureMailbox(texture->mailbox(), sync_token, texture_target_,
|
| - gpu_memory_buffer_->GetSize(), is_overlay_candidate_,
|
| - secure_output_only);
|
| - // The contents texture will be released when no longer used by the
|
| - // compositor.
|
| - return cc::SingleReleaseCallback::Create(
|
| + resource->is_overlay_candidate = is_overlay_candidate_;
|
| +
|
| + cc::ReleaseCallback cb =
|
| base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture),
|
| base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(),
|
| - base::Passed(&contents_texture_))));
|
| + base::Passed(&contents_texture_)));
|
| + // The contents texture will be released when no longer used by the
|
| + // compositor.
|
| + compositor_frame_sink_holder_->SetResourceReleaseCallback(
|
| + resource_id, base::WrapUnique(&cb));
|
| + return true;
|
| }
|
|
|
| // Create a mailbox texture that we copy the buffer contents to.
|
| @@ -476,19 +494,22 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
|
| Texture* texture = texture_.get();
|
|
|
| // The contents texture will be released when copy has completed.
|
| - gpu::SyncToken sync_token = contents_texture->CopyTexImage(
|
| - texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(),
|
| - base::Passed(&contents_texture_)));
|
| - *texture_mailbox =
|
| - cc::TextureMailbox(texture->mailbox(), sync_token, GL_TEXTURE_2D,
|
| - gpu_memory_buffer_->GetSize(),
|
| - false /* is_overlay_candidate */, secure_output_only);
|
| - // The mailbox texture will be released when no longer used by the
|
| - // compositor.
|
| - return cc::SingleReleaseCallback::Create(
|
| + resource->mailbox_holder = gpu::MailboxHolder(
|
| + texture->mailbox(),
|
| + contents_texture->CopyTexImage(
|
| + texture, base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(),
|
| + base::Passed(&contents_texture_))),
|
| + GL_TEXTURE_2D);
|
| + resource->is_overlay_candidate = false;
|
| + cc::ReleaseCallback callback =
|
| base::Bind(&Buffer::Texture::Release, base::Unretained(texture),
|
| base::Bind(&Buffer::ReleaseTexture, AsWeakPtr(),
|
| - base::Passed(&texture_))));
|
| + base::Passed(&texture_)));
|
| + // The mailbox texture will be released when no longer used by the
|
| + // compositor.
|
| + compositor_frame_sink_holder_->SetResourceReleaseCallback(
|
| + resource_id, base::WrapUnique(&callback));
|
| + return true;
|
| }
|
|
|
| void Buffer::OnAttach() {
|
| @@ -534,17 +555,23 @@ void Buffer::CheckReleaseCallback() {
|
| // Run release callback to notify the client that buffer has been released.
|
| if (!release_callback_.is_null())
|
| release_callback_.Run();
|
| +
|
| + compositor_frame_sink_holder_ = nullptr;
|
| }
|
|
|
| void Buffer::ReleaseTexture(std::unique_ptr<Texture> texture) {
|
| - texture_ = std::move(texture);
|
| + printf("Buffer::ReleaseTexture()\n");
|
| + if (this)
|
| + texture_ = std::move(texture);
|
| }
|
|
|
| void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) {
|
| TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture");
|
| -
|
| - contents_texture_ = std::move(texture);
|
| - Release();
|
| + printf("Buffer::ReleaseContentsTexture()\n");
|
| + if (this) {
|
| + contents_texture_ = std::move(texture);
|
| + Release();
|
| + }
|
| }
|
|
|
| } // namespace exo
|
|
|