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

Unified Diff: components/exo/buffer.h

Issue 2666233002: exo: Cleanup and make buffer release code more robust. (Closed)
Patch Set: fix typo Created 3 years, 11 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 | « no previous file | components/exo/buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/buffer.h
diff --git a/components/exo/buffer.h b/components/exo/buffer.h
index 38be8a99b61fada8e4e22ff95150633845449cc2..b97011e99fa53913932aba54f9c013b4bc6ba512 100644
--- a/components/exo/buffer.h
+++ b/components/exo/buffer.h
@@ -8,6 +8,7 @@
#include <memory>
#include "base/callback.h"
+#include "base/cancelable_callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "cc/resources/transferable_resource.h"
@@ -76,13 +77,10 @@ class Buffer : public base::SupportsWeakPtr<Buffer> {
private:
class Texture;
- // Decrements the use count of buffer and notifies the client that buffer
- // as been released if it reached 0.
+ // This should be called when buffer is released and will notify the
+ // client that buffer has been released.
void Release();
- // Runs the release callback if the buffer isn't attached or in use.
- void CheckReleaseCallback();
-
// This is used by ProduceTextureMailbox() to produce a release callback
// that releases a texture so it can be destroyed or reused.
void ReleaseTexture(std::unique_ptr<Texture> texture);
@@ -90,7 +88,12 @@ class Buffer : public base::SupportsWeakPtr<Buffer> {
// This is used by ProduceTextureMailbox() to produce a release callback
// that releases the buffer contents referenced by a texture before the
// texture is destroyed or reused.
- void ReleaseContentsTexture(std::unique_ptr<Texture> texture);
+ void ReleaseContentsTexture(std::unique_ptr<Texture> texture,
+ const base::Closure& callback);
+
+ // Notifies the client that buffer has been released if no longer attached
+ // to a surface.
+ void ReleaseContents();
// The GPU memory buffer that contains the contents of this buffer.
std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
@@ -107,11 +110,6 @@ class Buffer : public base::SupportsWeakPtr<Buffer> {
// True if this buffer is an overlay candidate.
const bool is_overlay_candidate_;
- // This is incremented when a transferable resource is produced and
- // decremented when a transferable resource is released. It is used to
- // determine when we should notify the client that buffer has been released.
- unsigned use_count_ = 0;
-
// This keeps track of how many Surfaces the buffer is attached to.
unsigned attach_count_ = 0;
@@ -131,6 +129,10 @@ class Buffer : public base::SupportsWeakPtr<Buffer> {
// longer in use.
scoped_refptr<CompositorFrameSinkHolder> compositor_frame_sink_holder_;
+ // Cancelable release contents callback. This is set when a release callback
+ // is pending.
+ base::CancelableClosure release_contents_callback_;
+
DISALLOW_COPY_AND_ASSIGN(Buffer);
};
« no previous file with comments | « no previous file | components/exo/buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698