summaryrefslogtreecommitdiffstats
path: root/include/gui
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-07-19 12:08:33 -0700
committerJamie Gennis <jgennis@google.com>2011-07-22 14:20:41 -0700
commit5ef59bc764d6bcd0ccf0a266d7d9ab792668a3e9 (patch)
treeaa5b98091b69c5f5d65618acd90b0e6ebf543ec3 /include/gui
parentb71a4beb1afb3f91201cd416e8e56733ba17913e (diff)
downloadframeworks_base-5ef59bc764d6bcd0ccf0a266d7d9ab792668a3e9.zip
frameworks_base-5ef59bc764d6bcd0ccf0a266d7d9ab792668a3e9.tar.gz
frameworks_base-5ef59bc764d6bcd0ccf0a266d7d9ab792668a3e9.tar.bz2
SurfaceTexture: add the abandon method.
This change adds the 'abandon' method to the SurfaceTexture C++ class. This method may be used to put the SurfaceTexture in an abandoned state, causing all ISurfaceTexture methods to fail. Change-Id: Ibd261f7b73f44e2bec36a8508bf92113cfb7cf95
Diffstat (limited to 'include/gui')
-rw-r--r--include/gui/ISurfaceTexture.h2
-rw-r--r--include/gui/SurfaceTexture.h20
2 files changed, 20 insertions, 2 deletions
diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h
index 405a25a..1eda646 100644
--- a/include/gui/ISurfaceTexture.h
+++ b/include/gui/ISurfaceTexture.h
@@ -51,7 +51,7 @@ protected:
// the given slot index, and the client is expected to mirror the
// slot->buffer mapping so that it's not necessary to transfer a
// GraphicBuffer for every dequeue operation.
- virtual sp<GraphicBuffer> requestBuffer(int slot) = 0;
+ virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) = 0;
// setBufferCount sets the number of buffer slots available. Calling this
// will also cause all buffer slots to be emptied. The caller should empty
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 62ea943..134c208 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -69,7 +69,7 @@ public:
// SurfaceTexture object (i.e. they are not owned by the client).
virtual status_t setBufferCount(int bufferCount);
- virtual sp<GraphicBuffer> requestBuffer(int buf);
+ virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
// dequeueBuffer gets the next buffer slot index for the client to use. If a
// buffer slot is available then that slot index is written to the location
@@ -190,6 +190,17 @@ public:
// getCurrentScalingMode returns the scaling mode of the current buffer
uint32_t getCurrentScalingMode() const;
+ // abandon frees all the buffers and puts the SurfaceTexture into the
+ // 'abandoned' state. Once put in this state the SurfaceTexture can never
+ // leave it. When in the 'abandoned' state, all methods of the
+ // ISurfaceTexture interface will fail with the NO_INIT error.
+ //
+ // Note that while calling this method causes all the buffers to be freed
+ // from the perspective of the the SurfaceTexture, if there are additional
+ // references on the buffers (e.g. if a buffer is referenced by a client or
+ // by OpenGL ES as a texture) then those buffer will remain allocated.
+ void abandon();
+
// dump our state in a String
void dump(String8& result) const;
void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const;
@@ -411,6 +422,13 @@ private:
typedef Vector<int> Fifo;
Fifo mQueue;
+ // mAbandoned indicates that the SurfaceTexture will no longer be used to
+ // consume images buffers pushed to it using the ISurfaceTexture interface.
+ // It is initialized to false, and set to true in the abandon method. A
+ // SurfaceTexture that has been abandoned will return the NO_INIT error from
+ // all ISurfaceTexture methods capable of returning an error.
+ bool mAbandoned;
+
// mMutex is the mutex used to prevent concurrent access to the member
// variables of SurfaceTexture objects. It must be locked whenever the
// member variables are accessed.