diff options
Diffstat (limited to 'include/gui/SurfaceTexture.h')
-rw-r--r-- | include/gui/SurfaceTexture.h | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h index 9bf38f7..96828c6 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,11 +121,34 @@ public: // buffers before the client is done with them. sp<IBinder> getAllocator(); -private: + // 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); + + // getCurrentBuffer returns the buffer associated with the current image. + sp<GraphicBuffer> getCurrentBuffer() const; + + // getCurrentTextureTarget returns the texture target of the current + // texture as returned by updateTexImage(). + GLenum getCurrentTextureTarget() const; + + // getCurrentCrop returns the cropping rectangle of the current buffer + Rect getCurrentCrop() const; + + // getCurrentTransform returns the transform of the current buffer + uint32_t getCurrentTransform() const; + +protected: // freeAllBuffers frees the resources (both GraphicBuffer and EGLImage) for // all slots. void freeAllBuffers(); + static bool isExternalFormat(uint32_t format); + static GLenum getTextureTarget(uint32_t format); + +private: // createImage creates a new EGLImage from a GraphicBuffer. EGLImageKHR createImage(EGLDisplay dpy, @@ -145,6 +181,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. @@ -158,6 +211,10 @@ private: // reset mCurrentTexture to INVALID_BUFFER_SLOT. int mCurrentTexture; + // mCurrentTextureTarget is the GLES texture target to be used with the + // current texture. + GLenum mCurrentTextureTarget; + // mCurrentTextureBuf is the graphic buffer of the current texture. It's // possible that this buffer is not associated with any buffer slot, so we // must track it separately in order to properly use @@ -172,6 +229,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 +248,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; @@ -204,12 +269,6 @@ private: // allocate new GraphicBuffer objects. sp<IGraphicBufferAlloc> mGraphicBufferAlloc; - // mAllocdBuffers is mirror of the list of buffers that SurfaceFlinger is - // referencing. This is kept so that gralloc implementations do not need to - // properly handle the case where SurfaceFlinger no longer holds a reference - // to a buffer, but other processes do. - Vector<sp<GraphicBuffer> > mAllocdBuffers; - // 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. @@ -218,7 +277,7 @@ private: // 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. - Mutex mMutex; + mutable Mutex mMutex; }; // ---------------------------------------------------------------------------- |