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

Unified Diff: components/exo/buffer.h

Issue 1467943002: exo: Handle lost context situations properly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move SharedMainThreadContextProvider Created 5 years, 1 month 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 192513b63bc3144d3a0349bd03ec62bfb441724c..2f60f5b9f7fa3c7b0ed21e43858ca4b7cf06d0df 100644
--- a/components/exo/buffer.h
+++ b/components/exo/buffer.h
@@ -9,9 +9,6 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "gpu/command_buffer/common/mailbox.h"
-#include "gpu/command_buffer/common/sync_token.h"
-#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/size.h"
namespace base {
@@ -29,6 +26,10 @@ namespace gfx {
class GpuMemoryBuffer;
}
+namespace gpu {
+struct SyncToken;
+}
+
namespace exo {
// This class provides the content for a Surface. The mechanism by which a
@@ -50,7 +51,7 @@ class Buffer : public base::SupportsWeakPtr<Buffer> {
// This function can be used to acquire a texture mailbox that is bound to
// the buffer. Returns a release callback on success. The release callback
// must be called before a new texture mailbox can be acquired.
- scoped_ptr<cc::SingleReleaseCallback> AcquireTextureMailbox(
+ scoped_ptr<cc::SingleReleaseCallback> ProduceTextureMailbox(
cc::TextureMailbox* mailbox);
// Returns the size of the buffer.
@@ -60,18 +61,38 @@ class Buffer : public base::SupportsWeakPtr<Buffer> {
scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const;
private:
- static void Release(base::WeakPtr<Buffer> buffer,
- unsigned texture_target,
- unsigned texture_id,
- unsigned image_id,
- const gpu::SyncToken& sync_token,
- bool is_lost);
-
+ class Texture;
+
+ // Decrements the use count of buffer and notifies the client that buffer
+ // as been released if it reached 0.
+ void Release();
+
+ // 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.
+ // Note: This is a static function as it needs to run even if the buffer
+ // has been destroyed.
+ static void ReleaseTexture(base::WeakPtr<Buffer> buffer,
+ scoped_ptr<Texture> texture,
+ const gpu::SyncToken& sync_token,
+ bool is_lost);
+
+ // The GPU memory buffer that contains the contents of this buffer.
scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer_;
+
+ // Texture target that must be used when creating a texture for buffer.
const unsigned texture_target_;
- unsigned texture_id_;
- unsigned image_id_;
- gpu::Mailbox mailbox_;
+
+ // This is incremented when a texture mailbox is produced and decremented
+ // when a texture mailbox is released. It is used to determine when we should
+ // notify the client that buffer has been released.
+ unsigned use_count_;
+
+ // The last released texture instance. ProduceTextureMailbox() will use this
+ // instead of creating a new texture when possible.
+ scoped_ptr<Texture> last_texture_;
+
+ // The client release callback.
base::Closure release_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