summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2013-09-19 12:49:13 -0700
committerEino-Ville Talvala <etalvala@google.com>2013-09-19 13:43:42 -0700
commita3402c33c61b55e8d068b8b4e06aae158fd1af4e (patch)
tree4b709dca585b2cb2d8890fe7e49767a021720d11 /core/jni
parent7cb93f4e227d603dadd065ea4173b6779279221e (diff)
downloadframeworks_base-a3402c33c61b55e8d068b8b4e06aae158fd1af4e.zip
frameworks_base-a3402c33c61b55e8d068b8b4e06aae158fd1af4e.tar.gz
frameworks_base-a3402c33c61b55e8d068b8b4e06aae158fd1af4e.tar.bz2
TextureView/GLES20Canvas: Support synchronous GLConsumers
Always update to the newest available frame from a GLConsumer. Otherwise, with a synchronous queue, rendering can fall behind and eventually deadlock with producer. Bug: 10830400 Change-Id: I7f1d752c80ae5dac892a26d82e86806c27f5d955
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index dc90da7..b720e73 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -878,6 +878,23 @@ static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject cl
sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, surface));
if (surfaceTexture->updateTexImage() == NO_ERROR) {
+ int64_t frameNumber = surfaceTexture->getFrameNumber();
+ // If the GLConsumer queue is in synchronous mode, need to discard all
+ // but latest frame, using the frame number to tell when we no longer
+ // have newer frames to target. Since we can't tell which mode it is in,
+ // do this unconditionally.
+ int dropCounter = 0;
+ while (surfaceTexture->updateTexImage() == NO_ERROR) {
+ int64_t newFrameNumber = surfaceTexture->getFrameNumber();
+ if (newFrameNumber == frameNumber) break;
+ frameNumber = newFrameNumber;
+ dropCounter++;
+ }
+ #if DEBUG_RENDERER
+ if (dropCounter > 0) {
+ RENDERER_LOGD("Dropped %d frames on texture layer update", dropCounter);
+ }
+ #endif
surfaceTexture->getTransformMatrix(transform);
GLenum renderTarget = surfaceTexture->getCurrentTextureTarget();