Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_GUI_SURFACETEXTURE_H |
| 18 | #define ANDROID_GUI_SURFACETEXTURE_H |
| 19 | |
| 20 | #include <EGL/egl.h> |
| 21 | #include <EGL/eglext.h> |
| 22 | #include <GLES2/gl2.h> |
| 23 | |
| 24 | #include <gui/ISurfaceTexture.h> |
| 25 | |
| 26 | #include <ui/GraphicBuffer.h> |
| 27 | |
| 28 | #include <utils/threads.h> |
Jamie Gennis | f7acf16 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 29 | #include <utils/Vector.h> |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 30 | |
| 31 | #define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture" |
| 32 | |
| 33 | namespace android { |
| 34 | // ---------------------------------------------------------------------------- |
| 35 | |
Jamie Gennis | f7acf16 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 36 | class IGraphicBufferAlloc; |
Mathias Agopian | 7f3289c | 2011-05-09 19:08:33 -0700 | [diff] [blame] | 37 | class String8; |
Jamie Gennis | f7acf16 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 38 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 39 | class SurfaceTexture : public BnSurfaceTexture { |
| 40 | public: |
Jamie Gennis | 96dcc97 | 2011-02-27 14:10:20 -0800 | [diff] [blame] | 41 | enum { MIN_UNDEQUEUED_BUFFERS = 2 }; |
Mathias Agopian | 402ff24 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 42 | enum { |
| 43 | MIN_ASYNC_BUFFER_SLOTS = MIN_UNDEQUEUED_BUFFERS + 1, |
| 44 | MIN_SYNC_BUFFER_SLOTS = MIN_UNDEQUEUED_BUFFERS |
| 45 | }; |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 46 | enum { NUM_BUFFER_SLOTS = 32 }; |
| 47 | |
Jamie Gennis | 376590d | 2011-01-13 14:43:36 -0800 | [diff] [blame] | 48 | struct FrameAvailableListener : public virtual RefBase { |
Jamie Gennis | bd5404d | 2011-06-26 18:27:47 -0700 | [diff] [blame] | 49 | // onFrameAvailable() is called from queueBuffer() each time an |
| 50 | // additional frame becomes available for consumption. This means that |
| 51 | // frames that are queued while in asynchronous mode only trigger the |
| 52 | // callback if no previous frames are pending. Frames queued while in |
| 53 | // synchronous mode always trigger the callback. |
| 54 | // |
| 55 | // This is called without any lock held and can be called concurrently |
| 56 | // by multiple threads. |
Jamie Gennis | 376590d | 2011-01-13 14:43:36 -0800 | [diff] [blame] | 57 | virtual void onFrameAvailable() = 0; |
| 58 | }; |
| 59 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 60 | // tex indicates the name OpenGL texture to which images are to be streamed. |
| 61 | // This texture name cannot be changed once the SurfaceTexture is created. |
Grace Kloba | 0904d0a | 2011-06-23 21:21:47 -0700 | [diff] [blame] | 62 | SurfaceTexture(GLuint tex, bool allowSynchronousMode = true); |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 63 | |
| 64 | virtual ~SurfaceTexture(); |
| 65 | |
| 66 | // setBufferCount updates the number of available buffer slots. After |
| 67 | // calling this all buffer slots are both unallocated and owned by the |
| 68 | // SurfaceTexture object (i.e. they are not owned by the client). |
| 69 | virtual status_t setBufferCount(int bufferCount); |
| 70 | |
Mathias Agopian | 0297dca | 2011-04-25 20:22:14 -0700 | [diff] [blame] | 71 | virtual sp<GraphicBuffer> requestBuffer(int buf); |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 72 | |
| 73 | // dequeueBuffer gets the next buffer slot index for the client to use. If a |
| 74 | // buffer slot is available then that slot index is written to the location |
| 75 | // pointed to by the buf argument and a status of OK is returned. If no |
| 76 | // slot is available then a status of -EBUSY is returned and buf is |
| 77 | // unmodified. |
Mathias Agopian | 0297dca | 2011-04-25 20:22:14 -0700 | [diff] [blame] | 78 | virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h, |
| 79 | uint32_t format, uint32_t usage); |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 80 | |
Eino-Ville Talvala | c5f94d8 | 2011-02-18 11:02:42 -0800 | [diff] [blame] | 81 | // queueBuffer returns a filled buffer to the SurfaceTexture. In addition, a |
| 82 | // timestamp must be provided for the buffer. The timestamp is in |
| 83 | // nanoseconds, and must be monotonically increasing. Its other semantics |
| 84 | // (zero point, etc) are client-dependent and should be documented by the |
| 85 | // client. |
| 86 | virtual status_t queueBuffer(int buf, int64_t timestamp); |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 87 | virtual void cancelBuffer(int buf); |
| 88 | virtual status_t setCrop(const Rect& reg); |
| 89 | virtual status_t setTransform(uint32_t transform); |
| 90 | |
Mathias Agopian | ed3894c | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 91 | virtual int query(int what, int* value); |
| 92 | |
Mathias Agopian | 402ff24 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 93 | // setSynchronousMode set whether dequeueBuffer is synchronous or |
| 94 | // asynchronous. In synchronous mode, dequeueBuffer blocks until |
| 95 | // a buffer is available, the currently bound buffer can be dequeued and |
| 96 | // queued buffers will be retired in order. |
| 97 | // The default mode is asynchronous. |
| 98 | virtual status_t setSynchronousMode(bool enabled); |
| 99 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 100 | // updateTexImage sets the image contents of the target texture to that of |
| 101 | // the most recently queued buffer. |
| 102 | // |
| 103 | // This call may only be made while the OpenGL ES context to which the |
| 104 | // target texture belongs is bound to the calling thread. |
| 105 | status_t updateTexImage(); |
| 106 | |
Mathias Agopian | 402ff24 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 107 | // setBufferCountServer set the buffer count. If the client has requested |
| 108 | // a buffer count using setBufferCount, the server-buffer count will |
| 109 | // take effect once the client sets the count back to zero. |
| 110 | status_t setBufferCountServer(int bufferCount); |
| 111 | |
Jamie Gennis | b598fb9 | 2011-01-09 16:33:17 -0800 | [diff] [blame] | 112 | // getTransformMatrix retrieves the 4x4 texture coordinate transform matrix |
| 113 | // associated with the texture image set by the most recent call to |
| 114 | // updateTexImage. |
| 115 | // |
| 116 | // This transform matrix maps 2D homogeneous texture coordinates of the form |
| 117 | // (s, t, 0, 1) with s and t in the inclusive range [0, 1] to the texture |
| 118 | // coordinate that should be used to sample that location from the texture. |
| 119 | // Sampling the texture outside of the range of this transform is undefined. |
| 120 | // |
| 121 | // This transform is necessary to compensate for transforms that the stream |
| 122 | // content producer may implicitly apply to the content. By forcing users of |
| 123 | // a SurfaceTexture to apply this transform we avoid performing an extra |
| 124 | // copy of the data that would be needed to hide the transform from the |
| 125 | // user. |
| 126 | // |
| 127 | // The matrix is stored in column-major order so that it may be passed |
| 128 | // directly to OpenGL ES via the glLoadMatrixf or glUniformMatrix4fv |
| 129 | // functions. |
| 130 | void getTransformMatrix(float mtx[16]); |
| 131 | |
Eino-Ville Talvala | c5f94d8 | 2011-02-18 11:02:42 -0800 | [diff] [blame] | 132 | // getTimestamp retrieves the timestamp associated with the texture image |
| 133 | // set by the most recent call to updateTexImage. |
| 134 | // |
| 135 | // The timestamp is in nanoseconds, and is monotonically increasing. Its |
| 136 | // other semantics (zero point, etc) are source-dependent and should be |
| 137 | // documented by the source. |
| 138 | int64_t getTimestamp(); |
| 139 | |
Jamie Gennis | 376590d | 2011-01-13 14:43:36 -0800 | [diff] [blame] | 140 | // setFrameAvailableListener sets the listener object that will be notified |
| 141 | // when a new frame becomes available. |
Pannag Sanketi | c9ec69e | 2011-06-24 09:56:27 -0700 | [diff] [blame] | 142 | void setFrameAvailableListener(const sp<FrameAvailableListener>& listener); |
Jamie Gennis | 376590d | 2011-01-13 14:43:36 -0800 | [diff] [blame] | 143 | |
Jamie Gennis | 83bac21 | 2011-02-02 15:31:47 -0800 | [diff] [blame] | 144 | // getAllocator retrieves the binder object that must be referenced as long |
| 145 | // as the GraphicBuffers dequeued from this SurfaceTexture are referenced. |
| 146 | // Holding this binder reference prevents SurfaceFlinger from freeing the |
| 147 | // buffers before the client is done with them. |
| 148 | sp<IBinder> getAllocator(); |
| 149 | |
Mathias Agopian | e5a1bff | 2011-03-31 19:10:24 -0700 | [diff] [blame] | 150 | // setDefaultBufferSize is used to set the size of buffers returned by |
| 151 | // requestBuffers when a with and height of zero is requested. |
| 152 | // A call to setDefaultBufferSize() may trigger requestBuffers() to |
| 153 | // be called from the client. |
| 154 | status_t setDefaultBufferSize(uint32_t w, uint32_t h); |
| 155 | |
Mathias Agopian | 27cd07c | 2011-04-11 21:19:55 -0700 | [diff] [blame] | 156 | // getCurrentBuffer returns the buffer associated with the current image. |
| 157 | sp<GraphicBuffer> getCurrentBuffer() const; |
| 158 | |
| 159 | // getCurrentTextureTarget returns the texture target of the current |
| 160 | // texture as returned by updateTexImage(). |
| 161 | GLenum getCurrentTextureTarget() const; |
| 162 | |
| 163 | // getCurrentCrop returns the cropping rectangle of the current buffer |
| 164 | Rect getCurrentCrop() const; |
| 165 | |
| 166 | // getCurrentTransform returns the transform of the current buffer |
| 167 | uint32_t getCurrentTransform() const; |
| 168 | |
Mathias Agopian | 7f3289c | 2011-05-09 19:08:33 -0700 | [diff] [blame] | 169 | // dump our state in a String |
| 170 | void dump(String8& result) const; |
| 171 | void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const; |
| 172 | |
Mathias Agopian | 27cd07c | 2011-04-11 21:19:55 -0700 | [diff] [blame] | 173 | protected: |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 174 | |
| 175 | // freeAllBuffers frees the resources (both GraphicBuffer and EGLImage) for |
| 176 | // all slots. |
| 177 | void freeAllBuffers(); |
Mathias Agopian | 27cd07c | 2011-04-11 21:19:55 -0700 | [diff] [blame] | 178 | static bool isExternalFormat(uint32_t format); |
| 179 | static GLenum getTextureTarget(uint32_t format); |
| 180 | |
| 181 | private: |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 182 | |
| 183 | // createImage creates a new EGLImage from a GraphicBuffer. |
| 184 | EGLImageKHR createImage(EGLDisplay dpy, |
| 185 | const sp<GraphicBuffer>& graphicBuffer); |
| 186 | |
Mathias Agopian | 402ff24 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 187 | status_t setBufferCountServerLocked(int bufferCount); |
| 188 | |
Jamie Gennis | eadfb67 | 2011-06-12 17:03:06 -0700 | [diff] [blame] | 189 | // computeCurrentTransformMatrix computes the transform matrix for the |
| 190 | // current texture. It uses mCurrentTransform and the current GraphicBuffer |
| 191 | // to compute this matrix and stores it in mCurrentTransformMatrix. |
| 192 | void computeCurrentTransformMatrix(); |
| 193 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 194 | enum { INVALID_BUFFER_SLOT = -1 }; |
| 195 | |
| 196 | struct BufferSlot { |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 197 | |
| 198 | BufferSlot() |
| 199 | : mEglImage(EGL_NO_IMAGE_KHR), |
| 200 | mEglDisplay(EGL_NO_DISPLAY), |
| 201 | mBufferState(BufferSlot::FREE), |
| 202 | mRequestBufferCalled(false), |
Jamie Gennis | a218715 | 2011-05-19 13:33:00 -0700 | [diff] [blame] | 203 | mTransform(0), |
| 204 | mTimestamp(0) { |
| 205 | mCrop.makeInvalid(); |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 208 | // mGraphicBuffer points to the buffer allocated for this slot or is NULL |
| 209 | // if no buffer has been allocated. |
| 210 | sp<GraphicBuffer> mGraphicBuffer; |
| 211 | |
| 212 | // mEglImage is the EGLImage created from mGraphicBuffer. |
| 213 | EGLImageKHR mEglImage; |
| 214 | |
| 215 | // mEglDisplay is the EGLDisplay used to create mEglImage. |
| 216 | EGLDisplay mEglDisplay; |
| 217 | |
Jamie Gennis | a218715 | 2011-05-19 13:33:00 -0700 | [diff] [blame] | 218 | // BufferState represents the different states in which a buffer slot |
| 219 | // can be. |
| 220 | enum BufferState { |
| 221 | // FREE indicates that the buffer is not currently being used and |
| 222 | // will not be used in the future until it gets dequeued and |
| 223 | // subseqently queued by the client. |
| 224 | FREE = 0, |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 225 | |
Jamie Gennis | a218715 | 2011-05-19 13:33:00 -0700 | [diff] [blame] | 226 | // DEQUEUED indicates that the buffer has been dequeued by the |
| 227 | // client, but has not yet been queued or canceled. The buffer is |
| 228 | // considered 'owned' by the client, and the server should not use |
| 229 | // it for anything. |
| 230 | // |
| 231 | // Note that when in synchronous-mode (mSynchronousMode == true), |
| 232 | // the buffer that's currently attached to the texture may be |
| 233 | // dequeued by the client. That means that the current buffer can |
| 234 | // be in either the DEQUEUED or QUEUED state. In asynchronous mode, |
| 235 | // however, the current buffer is always in the QUEUED state. |
| 236 | DEQUEUED = 1, |
| 237 | |
| 238 | // QUEUED indicates that the buffer has been queued by the client, |
| 239 | // and has not since been made available for the client to dequeue. |
| 240 | // Attaching the buffer to the texture does NOT transition the |
| 241 | // buffer away from the QUEUED state. However, in Synchronous mode |
| 242 | // the current buffer may be dequeued by the client under some |
| 243 | // circumstances. See the note about the current buffer in the |
| 244 | // documentation for DEQUEUED. |
| 245 | QUEUED = 2, |
| 246 | }; |
| 247 | |
| 248 | // mBufferState is the current state of this buffer slot. |
| 249 | BufferState mBufferState; |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 250 | |
| 251 | // mRequestBufferCalled is used for validating that the client did |
| 252 | // call requestBuffer() when told to do so. Technically this is not |
| 253 | // needed but useful for debugging and catching client bugs. |
| 254 | bool mRequestBufferCalled; |
| 255 | |
Jamie Gennis | a218715 | 2011-05-19 13:33:00 -0700 | [diff] [blame] | 256 | // mCrop is the current crop rectangle for this buffer slot. This gets |
| 257 | // set to mNextCrop each time queueBuffer gets called for this buffer. |
| 258 | Rect mCrop; |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 259 | |
Jamie Gennis | a218715 | 2011-05-19 13:33:00 -0700 | [diff] [blame] | 260 | // mTransform is the current transform flags for this buffer slot. This |
| 261 | // gets set to mNextTransform each time queueBuffer gets called for this |
| 262 | // slot. |
| 263 | uint32_t mTransform; |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 264 | |
Jamie Gennis | a218715 | 2011-05-19 13:33:00 -0700 | [diff] [blame] | 265 | // mTimestamp is the current timestamp for this buffer slot. This gets |
| 266 | // to set by queueBuffer each time this slot is queued. |
| 267 | int64_t mTimestamp; |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | // mSlots is the array of buffer slots that must be mirrored on the client |
| 271 | // side. This allows buffer ownership to be transferred between the client |
| 272 | // and server without sending a GraphicBuffer over binder. The entire array |
| 273 | // is initialized to NULL at construction time, and buffers are allocated |
| 274 | // for a slot when requestBuffer is called with that slot's index. |
| 275 | BufferSlot mSlots[NUM_BUFFER_SLOTS]; |
| 276 | |
Mathias Agopian | e5a1bff | 2011-03-31 19:10:24 -0700 | [diff] [blame] | 277 | // mDefaultWidth holds the default width of allocated buffers. It is used |
| 278 | // in requestBuffers() if a width and height of zero is specified. |
| 279 | uint32_t mDefaultWidth; |
| 280 | |
| 281 | // mDefaultHeight holds the default height of allocated buffers. It is used |
| 282 | // in requestBuffers() if a width and height of zero is specified. |
| 283 | uint32_t mDefaultHeight; |
| 284 | |
| 285 | // mPixelFormat holds the pixel format of allocated buffers. It is used |
| 286 | // in requestBuffers() if a format of zero is specified. |
| 287 | uint32_t mPixelFormat; |
| 288 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 289 | // mBufferCount is the number of buffer slots that the client and server |
Mathias Agopian | 402ff24 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 290 | // must maintain. It defaults to MIN_ASYNC_BUFFER_SLOTS and can be changed |
| 291 | // by calling setBufferCount or setBufferCountServer |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 292 | int mBufferCount; |
| 293 | |
Jamie Gennis | 4e03d32 | 2011-06-12 14:11:39 -0700 | [diff] [blame] | 294 | // mClientBufferCount is the number of buffer slots requested by the client. |
| 295 | // The default is zero, which means the client doesn't care how many buffers |
| 296 | // there is. |
Mathias Agopian | 402ff24 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 297 | int mClientBufferCount; |
| 298 | |
| 299 | // mServerBufferCount buffer count requested by the server-side |
| 300 | int mServerBufferCount; |
| 301 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 302 | // mCurrentTexture is the buffer slot index of the buffer that is currently |
Jamie Gennis | d369dc4 | 2011-01-09 13:25:39 -0800 | [diff] [blame] | 303 | // bound to the OpenGL texture. It is initialized to INVALID_BUFFER_SLOT, |
| 304 | // indicating that no buffer slot is currently bound to the texture. Note, |
| 305 | // however, that a value of INVALID_BUFFER_SLOT does not necessarily mean |
| 306 | // that no buffer is bound to the texture. A call to setBufferCount will |
| 307 | // reset mCurrentTexture to INVALID_BUFFER_SLOT. |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 308 | int mCurrentTexture; |
| 309 | |
Mathias Agopian | 27cd07c | 2011-04-11 21:19:55 -0700 | [diff] [blame] | 310 | // mCurrentTextureTarget is the GLES texture target to be used with the |
| 311 | // current texture. |
| 312 | GLenum mCurrentTextureTarget; |
| 313 | |
Jamie Gennis | f7acf16 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 314 | // mCurrentTextureBuf is the graphic buffer of the current texture. It's |
| 315 | // possible that this buffer is not associated with any buffer slot, so we |
| 316 | // must track it separately in order to properly use |
| 317 | // IGraphicBufferAlloc::freeAllGraphicBuffersExcept. |
| 318 | sp<GraphicBuffer> mCurrentTextureBuf; |
| 319 | |
Jamie Gennis | b598fb9 | 2011-01-09 16:33:17 -0800 | [diff] [blame] | 320 | // mCurrentCrop is the crop rectangle that applies to the current texture. |
| 321 | // It gets set to mLastQueuedCrop each time updateTexImage is called. |
| 322 | Rect mCurrentCrop; |
| 323 | |
| 324 | // mCurrentTransform is the transform identifier for the current texture. It |
| 325 | // gets set to mLastQueuedTransform each time updateTexImage is called. |
| 326 | uint32_t mCurrentTransform; |
| 327 | |
Jamie Gennis | eadfb67 | 2011-06-12 17:03:06 -0700 | [diff] [blame] | 328 | // mCurrentTransformMatrix is the transform matrix for the current texture. |
| 329 | // It gets computed by computeTransformMatrix each time updateTexImage is |
| 330 | // called. |
| 331 | float mCurrentTransformMatrix[16]; |
| 332 | |
Eino-Ville Talvala | c5f94d8 | 2011-02-18 11:02:42 -0800 | [diff] [blame] | 333 | // mCurrentTimestamp is the timestamp for the current texture. It |
| 334 | // gets set to mLastQueuedTimestamp each time updateTexImage is called. |
| 335 | int64_t mCurrentTimestamp; |
| 336 | |
Jamie Gennis | b598fb9 | 2011-01-09 16:33:17 -0800 | [diff] [blame] | 337 | // mNextCrop is the crop rectangle that will be used for the next buffer |
| 338 | // that gets queued. It is set by calling setCrop. |
| 339 | Rect mNextCrop; |
| 340 | |
| 341 | // mNextTransform is the transform identifier that will be used for the next |
| 342 | // buffer that gets queued. It is set by calling setTransform. |
| 343 | uint32_t mNextTransform; |
| 344 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 345 | // mTexName is the name of the OpenGL texture to which streamed images will |
Pannag Sanketi | c9ec69e | 2011-06-24 09:56:27 -0700 | [diff] [blame] | 346 | // be bound when updateTexImage is called. It is set at construction time |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 347 | // changed with a call to setTexName. |
| 348 | const GLuint mTexName; |
| 349 | |
Jamie Gennis | f7acf16 | 2011-01-12 18:30:40 -0800 | [diff] [blame] | 350 | // mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to |
| 351 | // allocate new GraphicBuffer objects. |
| 352 | sp<IGraphicBufferAlloc> mGraphicBufferAlloc; |
| 353 | |
Jamie Gennis | 376590d | 2011-01-13 14:43:36 -0800 | [diff] [blame] | 354 | // mFrameAvailableListener is the listener object that will be called when a |
| 355 | // new frame becomes available. If it is not NULL it will be called from |
| 356 | // queueBuffer. |
| 357 | sp<FrameAvailableListener> mFrameAvailableListener; |
| 358 | |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 359 | // mSynchronousMode whether we're in synchronous mode or not |
| 360 | bool mSynchronousMode; |
| 361 | |
Grace Kloba | 0904d0a | 2011-06-23 21:21:47 -0700 | [diff] [blame] | 362 | // mAllowSynchronousMode whether we allow synchronous mode or not |
| 363 | const bool mAllowSynchronousMode; |
| 364 | |
Mathias Agopian | 5bbb1cf | 2011-04-21 18:52:51 -0700 | [diff] [blame] | 365 | // mDequeueCondition condition used for dequeueBuffer in synchronous mode |
| 366 | mutable Condition mDequeueCondition; |
| 367 | |
| 368 | // mQueue is a FIFO of queued buffers used in synchronous mode |
| 369 | typedef Vector<int> Fifo; |
| 370 | Fifo mQueue; |
| 371 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 372 | // mMutex is the mutex used to prevent concurrent access to the member |
| 373 | // variables of SurfaceTexture objects. It must be locked whenever the |
| 374 | // member variables are accessed. |
Mathias Agopian | 27cd07c | 2011-04-11 21:19:55 -0700 | [diff] [blame] | 375 | mutable Mutex mMutex; |
Jamie Gennis | eadfb67 | 2011-06-12 17:03:06 -0700 | [diff] [blame] | 376 | |
Jamie Gennis | 68e4a7a | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 377 | }; |
| 378 | |
| 379 | // ---------------------------------------------------------------------------- |
| 380 | }; // namespace android |
| 381 | |
| 382 | #endif // ANDROID_GUI_SURFACETEXTURE_H |