From 21ad37528e537a8e0f640b769c6a1804c2c7a272 Mon Sep 17 00:00:00 2001 From: "guoweis@webrtc.org" Date: Fri, 27 Feb 2015 18:11:52 +0000 Subject: [PATCH] Ensure we set the right attrib for correct shader When using oesProgram, we still specify the yuvProgram for setting shader attributes. This should be changed to the correct shader program. BUG= R=glaznev@webrtc.org Review URL: https://webrtc-codereview.appspot.com/45379004 Cr-Commit-Position: refs/heads/master@{#8533} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8533 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../android/org/webrtc/VideoRendererGui.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java index 0a7e53180..05def7306 100644 --- a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java +++ b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java @@ -406,6 +406,8 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { long now = System.nanoTime(); + int currentProgram = 0; + I420Frame frameFromQueue; synchronized (frameToRenderQueue) { frameFromQueue = frameToRenderQueue.peek(); @@ -416,6 +418,7 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { if (rendererType == RendererType.RENDERER_YUV) { // YUV textures rendering. GLES20.glUseProgram(yuvProgram); + currentProgram = yuvProgram; for (int i = 0; i < 3; ++i) { GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i); @@ -430,9 +433,16 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { frameFromQueue.yuvPlanes[i]); } } + GLES20.glUniform1i( + GLES20.glGetUniformLocation(yuvProgram, "y_tex"), 0); + GLES20.glUniform1i( + GLES20.glGetUniformLocation(yuvProgram, "u_tex"), 1); + GLES20.glUniform1i( + GLES20.glGetUniformLocation(yuvProgram, "v_tex"), 2); } else { // External texture rendering. GLES20.glUseProgram(oesProgram); + currentProgram = oesProgram; if (frameFromQueue != null) { oesTexture = frameFromQueue.textureId; @@ -452,13 +462,7 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { } } - if (rendererType == RendererType.RENDERER_YUV) { - GLES20.glUniform1i(GLES20.glGetUniformLocation(yuvProgram, "y_tex"), 0); - GLES20.glUniform1i(GLES20.glGetUniformLocation(yuvProgram, "u_tex"), 1); - GLES20.glUniform1i(GLES20.glGetUniformLocation(yuvProgram, "v_tex"), 2); - } - - int posLocation = GLES20.glGetAttribLocation(yuvProgram, "in_pos"); + int posLocation = GLES20.glGetAttribLocation(currentProgram, "in_pos"); if (posLocation == -1) { throw new RuntimeException("Could not get attrib location for in_pos"); } @@ -466,7 +470,7 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { GLES20.glVertexAttribPointer( posLocation, 2, GLES20.GL_FLOAT, false, 0, textureVertices); - int texLocation = GLES20.glGetAttribLocation(yuvProgram, "in_tc"); + int texLocation = GLES20.glGetAttribLocation(currentProgram, "in_tc"); if (texLocation == -1) { throw new RuntimeException("Could not get attrib location for in_tc"); }