summaryrefslogtreecommitdiffstats
path: root/include/gui
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2012-08-20 15:44:40 -0700
committerEino-Ville Talvala <etalvala@google.com>2012-08-20 15:44:40 -0700
commitf57e7540d4cf799f18fe87d3536c55f1e0064931 (patch)
treea6b8e1fe1fb257a41fdf7bc0c9ee35d7aa6d0bb1 /include/gui
parent13233e067b8f71adc3a0ade5f442265e1f27084b (diff)
downloadframeworks_native-f57e7540d4cf799f18fe87d3536c55f1e0064931.zip
frameworks_native-f57e7540d4cf799f18fe87d3536c55f1e0064931.tar.gz
frameworks_native-f57e7540d4cf799f18fe87d3536c55f1e0064931.tar.bz2
CpuConsumer: inherit from ConsumerBase
Change-Id: I55178b1d673ffa0fbc6e63ef47642c64d4d03228
Diffstat (limited to 'include/gui')
-rw-r--r--include/gui/CpuConsumer.h53
1 files changed, 6 insertions, 47 deletions
diff --git a/include/gui/CpuConsumer.h b/include/gui/CpuConsumer.h
index a50a1de..49c90db 100644
--- a/include/gui/CpuConsumer.h
+++ b/include/gui/CpuConsumer.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_GUI_CPUCONSUMER_H
#define ANDROID_GUI_CPUCONSUMER_H
-#include <gui/BufferQueue.h>
+#include <gui/ConsumerBase.h>
#include <ui/GraphicBuffer.h>
@@ -37,19 +37,10 @@ namespace android {
* This queue is synchronous by default.
*/
-class CpuConsumer: public virtual RefBase,
- protected BufferQueue::ConsumerListener
+class CpuConsumer: public ConsumerBase
{
public:
- struct FrameAvailableListener : public virtual RefBase {
- // onFrameAvailable() is called each time an additional frame becomes
- // available for consumption. A new frame queued will always trigger the
- // callback, whether the queue is empty or not.
- //
- // This is called without any lock held and can be called concurrently
- // by multiple threads.
- virtual void onFrameAvailable() = 0;
- };
+ typedef ConsumerBase::FrameAvailableListener FrameAvailableListener;
struct LockedBuffer {
uint8_t *data;
@@ -68,8 +59,6 @@ class CpuConsumer: public virtual RefBase,
// how many buffers can be locked for user access at the same time.
CpuConsumer(uint32_t maxLockedBuffers);
- virtual ~CpuConsumer();
-
// set the name of the CpuConsumer that will be used to identify it in
// log messages.
void setName(const String8& name);
@@ -91,50 +80,20 @@ class CpuConsumer: public virtual RefBase,
// lockNextBuffer.
status_t unlockBuffer(const LockedBuffer &nativeBuffer);
- // setFrameAvailableListener sets the listener object that will be notified
- // when a new frame becomes available.
- void setFrameAvailableListener(const sp<FrameAvailableListener>& listener);
-
- sp<ISurfaceTexture> getProducerInterface() const { return mBufferQueue; }
- protected:
-
- // Implementation of the BufferQueue::ConsumerListener interface. These
- // calls are used to notify the CpuConsumer of asynchronous events in the
- // BufferQueue.
- virtual void onFrameAvailable();
- virtual void onBuffersReleased();
+ sp<ISurfaceTexture> getProducerInterface() const { return getBufferQueue(); }
private:
- // Free local buffer state
- status_t freeBufferLocked(int buf);
-
// Maximum number of buffers that can be locked at a time
uint32_t mMaxLockedBuffers;
- // mName is a string used to identify the SurfaceTexture in log messages.
- // It can be set by the setName method.
- String8 mName;
-
- // mFrameAvailableListener is the listener object that will be called when a
- // new frame becomes available. If it is not NULL it will be called from
- // queueBuffer.
- sp<FrameAvailableListener> mFrameAvailableListener;
-
- // Underlying buffer queue
- sp<BufferQueue> mBufferQueue;
+ void freeBufferLocked(int slotIndex);
- // Array for caching buffers from the buffer queue
- sp<GraphicBuffer> mBufferSlot[BufferQueue::NUM_BUFFER_SLOTS];
// Array for tracking pointers passed to the consumer, matching the
- // mBufferSlot indexing
+ // mSlots indexing
void *mBufferPointers[BufferQueue::NUM_BUFFER_SLOTS];
// Count of currently locked buffers
uint32_t mCurrentLockedBuffers;
- // mMutex is the mutex used to prevent concurrent access to the member
- // variables of CpuConsumer objects. It must be locked whenever the
- // member variables are accessed.
- mutable Mutex mMutex;
};
} // namespace android