diff options
Diffstat (limited to 'include/gui')
-rw-r--r-- | include/gui/ISurfaceTexture.h | 11 | ||||
-rw-r--r-- | include/gui/SurfaceTexture.h | 46 | ||||
-rw-r--r-- | include/gui/SurfaceTextureClient.h | 7 |
3 files changed, 61 insertions, 3 deletions
diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h index 168310c..d2d3bb8 100644 --- a/include/gui/ISurfaceTexture.h +++ b/include/gui/ISurfaceTexture.h @@ -36,6 +36,8 @@ class ISurfaceTexture : public IInterface public: DECLARE_META_INTERFACE(SurfaceTexture); + enum { BUFFER_NEEDS_REALLOCATION = 1 }; + // requestBuffer requests a new buffer for the given index. The server (i.e. // the ISurfaceTexture implementation) assigns the newly created buffer to // the given slot index, and the client is expected to mirror the @@ -56,14 +58,19 @@ public: // should call requestBuffer to assign a new buffer to that slot. The client // is expected to either call cancelBuffer on the dequeued slot or to fill // in the contents of its associated buffer contents and call queueBuffer. + // If dequeueBuffer return BUFFER_NEEDS_REALLOCATION, the client is + // expected to call requestBuffer immediately. virtual status_t dequeueBuffer(int *slot) = 0; // queueBuffer indicates that the client has finished filling in the // contents of the buffer associated with slot and transfers ownership of // that slot back to the server. It is not valid to call queueBuffer on a // slot that is not owned by the client or one for which a buffer associated - // via requestBuffer. - virtual status_t queueBuffer(int slot) = 0; + // via requestBuffer. In addition, a timestamp must be provided by the + // client for this buffer. The timestamp is measured in nanoseconds, and + // must be monotonically increasing. Its other properties (zero point, etc) + // are client-dependent, and should be documented by the client. + virtual status_t queueBuffer(int slot, int64_t timestamp) = 0; // cancelBuffer indicates that the client does not wish to fill in the // buffer associated with slot and transfers ownership of the slot back to diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h index 9bf38f7..585d288 100644 --- a/include/gui/SurfaceTexture.h +++ b/include/gui/SurfaceTexture.h @@ -66,7 +66,12 @@ public: // unmodified. virtual status_t dequeueBuffer(int *buf); - virtual status_t queueBuffer(int buf); + // queueBuffer returns a filled buffer to the SurfaceTexture. In addition, a + // timestamp must be provided for the buffer. The timestamp is in + // nanoseconds, and must be monotonically increasing. Its other semantics + // (zero point, etc) are client-dependent and should be documented by the + // client. + virtual status_t queueBuffer(int buf, int64_t timestamp); virtual void cancelBuffer(int buf); virtual status_t setCrop(const Rect& reg); virtual status_t setTransform(uint32_t transform); @@ -98,6 +103,14 @@ public: // functions. void getTransformMatrix(float mtx[16]); + // getTimestamp retrieves the timestamp associated with the texture image + // set by the most recent call to updateTexImage. + // + // The timestamp is in nanoseconds, and is monotonically increasing. Its + // other semantics (zero point, etc) are source-dependent and should be + // documented by the source. + int64_t getTimestamp(); + // setFrameAvailableListener sets the listener object that will be notified // when a new frame becomes available. void setFrameAvailableListener(const sp<FrameAvailableListener>& l); @@ -108,6 +121,12 @@ public: // buffers before the client is done with them. sp<IBinder> getAllocator(); + // setDefaultBufferSize is used to set the size of buffers returned by + // requestBuffers when a with and height of zero is requested. + // A call to setDefaultBufferSize() may trigger requestBuffers() to + // be called from the client. + status_t setDefaultBufferSize(uint32_t w, uint32_t h); + private: // freeAllBuffers frees the resources (both GraphicBuffer and EGLImage) for @@ -145,6 +164,23 @@ private: // for a slot when requestBuffer is called with that slot's index. BufferSlot mSlots[NUM_BUFFER_SLOTS]; + // mDefaultWidth holds the default width of allocated buffers. It is used + // in requestBuffers() if a width and height of zero is specified. + uint32_t mDefaultWidth; + + // mDefaultHeight holds the default height of allocated buffers. It is used + // in requestBuffers() if a width and height of zero is specified. + uint32_t mDefaultHeight; + + // mPixelFormat holds the pixel format of allocated buffers. It is used + // in requestBuffers() if a format of zero is specified. + uint32_t mPixelFormat; + + // mUseDefaultSize indicates whether or not the default size should be used + // that is, if the last requestBuffer has been called with both width + // and height null. + bool mUseDefaultSize; + // mBufferCount is the number of buffer slots that the client and server // must maintain. It defaults to MIN_BUFFER_SLOTS and can be changed by // calling setBufferCount. @@ -172,6 +208,10 @@ private: // gets set to mLastQueuedTransform each time updateTexImage is called. uint32_t mCurrentTransform; + // mCurrentTimestamp is the timestamp for the current texture. It + // gets set to mLastQueuedTimestamp each time updateTexImage is called. + int64_t mCurrentTimestamp; + // mLastQueued is the buffer slot index of the most recently enqueued buffer. // At construction time it is initialized to INVALID_BUFFER_SLOT, and is // updated each time queueBuffer is called. @@ -187,6 +227,10 @@ private: // queueBuffer gets called. uint32_t mLastQueuedTransform; + // mLastQueuedTimestamp is the timestamp for the buffer that was most + // recently queued. This gets set by queueBuffer. + int64_t mLastQueuedTimestamp; + // mNextCrop is the crop rectangle that will be used for the next buffer // that gets queued. It is set by calling setCrop. Rect mNextCrop; diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h index 7992105..df82bf2 100644 --- a/include/gui/SurfaceTextureClient.h +++ b/include/gui/SurfaceTextureClient.h @@ -63,6 +63,7 @@ private: int dispatchSetBufferCount(va_list args); int dispatchSetBuffersGeometry(va_list args); int dispatchSetBuffersTransform(va_list args); + int dispatchSetBuffersTimestamp(va_list args); int dispatchSetCrop(va_list args); int dispatchSetUsage(va_list args); @@ -71,6 +72,7 @@ private: int setBufferCount(int bufferCount); int setBuffersGeometry(int w, int h, int format); int setBuffersTransform(int transform); + int setBuffersTimestamp(int64_t timestamp); int setCrop(Rect const* rect); int setUsage(uint32_t reqUsage); @@ -114,6 +116,11 @@ private: // at the next deuque operation. It is initialized to 0. uint32_t mReqUsage; + // mTimestamp is the timestamp that will be used for the next buffer queue + // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that + // a timestamp is auto-generated when queueBuffer is called. + int64_t mTimestamp; + // 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. |