Skip to content

Commit bb1e7d4

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge changes I7e973a35,Ib3386fcc into ics-mr1
* changes: SurfaceTexture: add EGL_KHR_fence_sync option SurfaceTexture: add a blit-to-FBO test
2 parents 6f1dd75 + 77cec61 commit bb1e7d4

File tree

4 files changed

+367
-171
lines changed

4 files changed

+367
-171
lines changed

include/gui/SurfaceTexture.h

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,16 @@ class SurfaceTexture : public BnSurfaceTexture {
6060
virtual void onFrameAvailable() = 0;
6161
};
6262

63-
// tex indicates the name OpenGL texture to which images are to be streamed.
64-
// This texture name cannot be changed once the SurfaceTexture is created.
63+
// SurfaceTexture constructs a new SurfaceTexture object. tex indicates the
64+
// name of the OpenGL ES texture to which images are to be streamed. This
65+
// texture name cannot be changed once the SurfaceTexture is created.
66+
// allowSynchronousMode specifies whether or not synchronous mode can be
67+
// enabled. texTarget specifies the OpenGL ES texture target to which the
68+
// texture will be bound in updateTexImage. useFenceSync specifies whether
69+
// fences should be used to synchronize access to buffers if that behavior
70+
// is enabled at compile-time.
6571
SurfaceTexture(GLuint tex, bool allowSynchronousMode = true,
66-
GLenum texTarget = GL_TEXTURE_EXTERNAL_OES);
72+
GLenum texTarget = GL_TEXTURE_EXTERNAL_OES, bool useFenceSync = true);
6773

6874
virtual ~SurfaceTexture();
6975

@@ -276,7 +282,8 @@ class SurfaceTexture : public BnSurfaceTexture {
276282
mTransform(0),
277283
mScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
278284
mTimestamp(0),
279-
mFrameNumber(0) {
285+
mFrameNumber(0),
286+
mFence(EGL_NO_SYNC_KHR) {
280287
mCrop.makeInvalid();
281288
}
282289

@@ -349,6 +356,11 @@ class SurfaceTexture : public BnSurfaceTexture {
349356
// mFrameNumber is the number of the queued frame for this slot.
350357
uint64_t mFrameNumber;
351358

359+
// mFence is the EGL sync object that must signal before the buffer
360+
// associated with this buffer slot may be dequeued. It is initialized
361+
// to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based
362+
// on a compile-time option) set to a new sync object in updateTexImage.
363+
EGLSyncKHR mFence;
352364
};
353365

354366
// mSlots is the array of buffer slots that must be mirrored on the client
@@ -472,6 +484,12 @@ class SurfaceTexture : public BnSurfaceTexture {
472484
// It is set by the setName method.
473485
String8 mName;
474486

487+
// mUseFenceSync indicates whether creation of the EGL_KHR_fence_sync
488+
// extension should be used to prevent buffers from being dequeued before
489+
// it's safe for them to be written. It gets set at construction time and
490+
// never changes.
491+
const bool mUseFenceSync;
492+
475493
// mMutex is the mutex used to prevent concurrent access to the member
476494
// variables of SurfaceTexture objects. It must be locked whenever the
477495
// member variables are accessed.

0 commit comments

Comments
 (0)