From b856052c00dfef70d0957482c72c2979ffc4733a Mon Sep 17 00:00:00 2001 From: Daniel Lam Date: Mon, 30 Jan 2012 15:51:27 -0800 Subject: [PATCH] Refactored query function from SurfaceTexture into BufferQueue Change-Id: Id1cb6cc38d01edb4fcfcad867c5a7693bdcc3ab1 --- include/gui/BufferQueue.h | 2 ++ include/gui/SurfaceTexture.h | 2 +- libs/gui/BufferQueue.cpp | 31 +++++++++++++++++++++++++++++++ libs/gui/SurfaceTexture.cpp | 29 ----------------------------- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 991a1817a..ae9916018 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -60,6 +60,8 @@ public: BufferQueue(bool allowSynchronousMode = true); virtual ~BufferQueue(); + virtual int query(int what, int* value); + // setBufferCount updates the number of available buffer slots. After // calling this all buffer slots are both unallocated and owned by the // BufferQueue object (i.e. they are not owned by the client). diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h index 4318f0fa4..dcab049ef 100644 --- a/include/gui/SurfaceTexture.h +++ b/include/gui/SurfaceTexture.h @@ -55,7 +55,7 @@ public: virtual ~SurfaceTexture(); - virtual int query(int what, int* value); + // updateTexImage sets the image contents of the target texture to that of // the most recently queued buffer. diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index c7e2c0f21..0791de226 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -166,6 +166,37 @@ status_t BufferQueue::setBufferCount(int bufferCount) { return OK; } +int BufferQueue::query(int what, int* outValue) +{ + Mutex::Autolock lock(mMutex); + + if (mAbandoned) { + ST_LOGE("query: SurfaceTexture has been abandoned!"); + return NO_INIT; + } + + int value; + switch (what) { + case NATIVE_WINDOW_WIDTH: + value = mDefaultWidth; + break; + case NATIVE_WINDOW_HEIGHT: + value = mDefaultHeight; + break; + case NATIVE_WINDOW_FORMAT: + value = mPixelFormat; + break; + case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS: + value = mSynchronousMode ? + (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS; + break; + default: + return BAD_VALUE; + } + outValue[0] = value; + return NO_ERROR; +} + status_t BufferQueue::requestBuffer(int slot, sp* buf) { ST_LOGV("requestBuffer: slot=%d", slot); Mutex::Autolock lock(mMutex); diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp index be1bcd1a8..a7bfc613a 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/SurfaceTexture.cpp @@ -416,36 +416,7 @@ bool SurfaceTexture::isSynchronousMode() const { return mSynchronousMode; } -int SurfaceTexture::query(int what, int* outValue) -{ - Mutex::Autolock lock(mMutex); - if (mAbandoned) { - ST_LOGE("query: SurfaceTexture has been abandoned!"); - return NO_INIT; - } - - int value; - switch (what) { - case NATIVE_WINDOW_WIDTH: - value = mDefaultWidth; - break; - case NATIVE_WINDOW_HEIGHT: - value = mDefaultHeight; - break; - case NATIVE_WINDOW_FORMAT: - value = mPixelFormat; - break; - case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS: - value = mSynchronousMode ? - (MIN_UNDEQUEUED_BUFFERS-1) : MIN_UNDEQUEUED_BUFFERS; - break; - default: - return BAD_VALUE; - } - outValue[0] = value; - return NO_ERROR; -} void SurfaceTexture::abandon() { Mutex::Autolock lock(mMutex);