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

Unified Diff: components/exo/buffer.cc

Issue 2584953002: exo::CompositorFrameSinkHolder's release callbacks hold ref (Closed)
Patch Set: Added ReleaseTextureAndCompositorFrameSinkHolder() and ReleaseContentsTextureAndCompositorFrameSink… Created 4 years 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: components/exo/buffer.cc
diff --git a/components/exo/buffer.cc b/components/exo/buffer.cc
index 9b1778d989d6c0250efff832d6372f401e15e129..90b6cd9dd745698a00549a2488bcdcc361fc52b8 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"
@@ -401,7 +402,8 @@ Buffer::~Buffer() {}
std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
cc::TextureMailbox* texture_mailbox,
bool secure_output_only,
- bool client_usage) {
+ bool client_usage,
+ scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder) {
DCHECK(attach_count_);
DLOG_IF(WARNING, use_count_ && client_usage)
<< "Producing a texture mailbox for a buffer that has not been released";
@@ -458,10 +460,11 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
secure_output_only);
// The contents texture will be released when no longer used by the
// compositor.
- return cc::SingleReleaseCallback::Create(
- base::Bind(&Buffer::Texture::ReleaseTexImage, base::Unretained(texture),
- base::Bind(&Buffer::ReleaseContentsTexture, AsWeakPtr(),
- base::Passed(&contents_texture_))));
+ return cc::SingleReleaseCallback::Create(base::Bind(
+ &Buffer::Texture::ReleaseTexImage, base::Unretained(texture),
+ base::Bind(&Buffer::ReleaseContentsTextureAndCompositorFrameSinkHolder,
+ AsWeakPtr(), base::Passed(&contents_texture_),
+ base::RetainedRef(compositor_frame_sink_holder))));
}
// Create a mailbox texture that we copy the buffer contents to.
@@ -477,8 +480,9 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
// 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,
+ base::Bind(&Buffer::ReleaseContentsTextureAndCompositorFrameSinkHolder,
+ AsWeakPtr(), base::Passed(&contents_texture_), nullptr));
*texture_mailbox =
cc::TextureMailbox(texture->mailbox(), sync_token, GL_TEXTURE_2D,
gpu_memory_buffer_->GetSize(),
@@ -487,8 +491,9 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
// compositor.
return cc::SingleReleaseCallback::Create(
base::Bind(&Buffer::Texture::Release, base::Unretained(texture),
- base::Bind(&Buffer::ReleaseTexture, AsWeakPtr(),
- base::Passed(&texture_))));
+ base::Bind(&Buffer::ReleaseTextureAndCompositorFrameSinkHolder,
+ AsWeakPtr(), base::Passed(&texture_),
+ base::RetainedRef(compositor_frame_sink_holder))));
}
void Buffer::OnAttach() {
@@ -536,10 +541,22 @@ void Buffer::CheckReleaseCallback() {
release_callback_.Run();
}
+void Buffer::ReleaseTextureAndCompositorFrameSinkHolder(
+ std::unique_ptr<Texture> texture,
+ CompositorFrameSinkHolder* compositor_frame_sink_holder) {
+ ReleaseTexture(std::move(texture));
+}
+
void Buffer::ReleaseTexture(std::unique_ptr<Texture> texture) {
texture_ = std::move(texture);
}
+void Buffer::ReleaseContentsTextureAndCompositorFrameSinkHolder(
+ std::unique_ptr<Texture> texture,
+ CompositorFrameSinkHolder* compositor_frame_sink_holder) {
+ ReleaseContentsTexture(std::move(texture));
+}
+
void Buffer::ReleaseContentsTexture(std::unique_ptr<Texture> texture) {
TRACE_EVENT0("exo", "Buffer::ReleaseContentsTexture");

Powered by Google App Engine
This is Rietveld 408576698