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

Unified Diff: components/exo/buffer.cc

Issue 2083853002: exo: Recreate Surface resources on context lost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make ContextFactory pure; hold on to buffer reference Created 4 years, 6 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: components/exo/buffer.cc
diff --git a/components/exo/buffer.cc b/components/exo/buffer.cc
index 5b02cc3c130e4ffff31c1659992b56af080061a7..442d6fbaed21a0724d288c9b8d9de384131f464d 100644
--- a/components/exo/buffer.cc
+++ b/components/exo/buffer.cc
@@ -371,7 +371,9 @@ Buffer::~Buffer() {}
std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
cc::TextureMailbox* texture_mailbox,
bool secure_output_only,
- bool client_usage) {
+ bool client_usage,
+ base::Closure* detach_callback) {
+ DCHECK(detach_callback->is_null());
// Non-client usage can only be allowed when the client is not allowed to
// use the buffer. If the buffer has been released to the client then it
// can no longer be used as the client might be writing to it.
@@ -411,6 +413,11 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
return nullptr;
}
+ // Add a callback to ensure this buffer isn't released while it's attached
+ // to a surface.
+ use_count_++;
+ *detach_callback = base::Bind(&Buffer::Release, AsWeakPtr());
+
// 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.

Powered by Google App Engine
This is Rietveld 408576698