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

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: fix nits 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
« no previous file with comments | « components/exo/buffer.h ('k') | components/exo/buffer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/buffer.cc
diff --git a/components/exo/buffer.cc b/components/exo/buffer.cc
index 5b02cc3c130e4ffff31c1659992b56af080061a7..1000ae2765455dbf6a7c35a49e20ae696e953772 100644
--- a/components/exo/buffer.cc
+++ b/components/exo/buffer.cc
@@ -372,12 +372,7 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
cc::TextureMailbox* texture_mailbox,
bool secure_output_only,
bool client_usage) {
- // 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.
- if (!client_usage && !use_count_)
- return nullptr;
-
+ DCHECK(attach_count_);
DLOG_IF(WARNING, use_count_ && client_usage)
<< "Producing a texture mailbox for a buffer that has not been released";
@@ -464,6 +459,18 @@ std::unique_ptr<cc::SingleReleaseCallback> Buffer::ProduceTextureMailbox(
base::Passed(&texture_))));
}
+void Buffer::OnAttach() {
+ DLOG_IF(WARNING, attach_count_ > 0u)
+ << "Reattaching a buffer that is already attached to another surface.";
+ attach_count_++;
+}
+
+void Buffer::OnDetach() {
+ DCHECK_GT(attach_count_, 0u);
+ --attach_count_;
+ CheckReleaseCallback();
+}
+
gfx::Size Buffer::GetSize() const {
return gpu_memory_buffer_->GetSize();
}
@@ -484,7 +491,12 @@ std::unique_ptr<base::trace_event::TracedValue> Buffer::AsTracedValue() const {
void Buffer::Release() {
DCHECK_GT(use_count_, 0u);
- if (--use_count_)
+ --use_count_;
+ CheckReleaseCallback();
+}
+
+void Buffer::CheckReleaseCallback() {
+ if (attach_count_ || use_count_)
return;
// Run release callback to notify the client that buffer has been released.
« no previous file with comments | « components/exo/buffer.h ('k') | components/exo/buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698