Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: webrtc/api/java/android/org/webrtc/GlRectDrawer.java

Issue 1950953002: Revert of Android GlDrawer: Add frame size as argument to draw functions (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 // The keys are one of the fragments shaders above. 114 // The keys are one of the fragments shaders above.
115 private final Map<String, Shader> shaders = new IdentityHashMap<String, Shader >(); 115 private final Map<String, Shader> shaders = new IdentityHashMap<String, Shader >();
116 116
117 /** 117 /**
118 * Draw an OES texture frame with specified texture transformation matrix. Req uired resources are 118 * Draw an OES texture frame with specified texture transformation matrix. Req uired resources are
119 * allocated at the first call to this function. 119 * allocated at the first call to this function.
120 */ 120 */
121 @Override 121 @Override
122 public void drawOes(int oesTextureId, float[] texMatrix, int frameWidth, int f rameHeight, 122 public void drawOes(int oesTextureId, float[] texMatrix, int x, int y, int wid th, int height) {
123 int viewportX, int viewportY, int viewportWidth, int viewportHeight) {
124 prepareShader(OES_FRAGMENT_SHADER_STRING, texMatrix); 123 prepareShader(OES_FRAGMENT_SHADER_STRING, texMatrix);
125 GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 124 GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
126 // updateTexImage() may be called from another thread in another EGL context , so we need to 125 // updateTexImage() may be called from another thread in another EGL context , so we need to
127 // bind/unbind the texture in each draw call so that GLES understads it's a new texture. 126 // bind/unbind the texture in each draw call so that GLES understads it's a new texture.
128 GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, oesTextureId); 127 GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, oesTextureId);
129 drawRectangle(viewportX, viewportY, viewportWidth, viewportHeight); 128 drawRectangle(x, y, width, height);
130 GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0); 129 GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
131 } 130 }
132 131
133 /** 132 /**
134 * Draw a RGB(A) texture frame with specified texture transformation matrix. R equired resources 133 * Draw a RGB(A) texture frame with specified texture transformation matrix. R equired resources
135 * are allocated at the first call to this function. 134 * are allocated at the first call to this function.
136 */ 135 */
137 @Override 136 @Override
138 public void drawRgb(int textureId, float[] texMatrix, int frameWidth, int fram eHeight, 137 public void drawRgb(int textureId, float[] texMatrix, int x, int y, int width, int height) {
139 int viewportX, int viewportY, int viewportWidth, int viewportHeight) {
140 prepareShader(RGB_FRAGMENT_SHADER_STRING, texMatrix); 138 prepareShader(RGB_FRAGMENT_SHADER_STRING, texMatrix);
141 GLES20.glActiveTexture(GLES20.GL_TEXTURE0); 139 GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
142 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId); 140 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
143 drawRectangle(viewportX, viewportY, viewportWidth, viewportHeight); 141 drawRectangle(x, y, width, height);
144 // Unbind the texture as a precaution. 142 // Unbind the texture as a precaution.
145 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 143 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
146 } 144 }
147 145
148 /** 146 /**
149 * Draw a YUV frame with specified texture transformation matrix. Required res ources are 147 * Draw a YUV frame with specified texture transformation matrix. Required res ources are
150 * allocated at the first call to this function. 148 * allocated at the first call to this function.
151 */ 149 */
152 @Override 150 @Override
153 public void drawYuv(int[] yuvTextures, float[] texMatrix, int frameWidth, int frameHeight, 151 public void drawYuv(int[] yuvTextures, float[] texMatrix, int x, int y, int wi dth, int height) {
154 int viewportX, int viewportY, int viewportWidth, int viewportHeight) {
155 prepareShader(YUV_FRAGMENT_SHADER_STRING, texMatrix); 152 prepareShader(YUV_FRAGMENT_SHADER_STRING, texMatrix);
156 // Bind the textures. 153 // Bind the textures.
157 for (int i = 0; i < 3; ++i) { 154 for (int i = 0; i < 3; ++i) {
158 GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i); 155 GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i);
159 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, yuvTextures[i]); 156 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, yuvTextures[i]);
160 } 157 }
161 drawRectangle(viewportX, viewportY, viewportWidth, viewportHeight); 158 drawRectangle(x, y, width, height);
162 // Unbind the textures as a precaution.. 159 // Unbind the textures as a precaution..
163 for (int i = 0; i < 3; ++i) { 160 for (int i = 0; i < 3; ++i) {
164 GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i); 161 GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i);
165 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0); 162 GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
166 } 163 }
167 } 164 }
168 165
169 private void drawRectangle(int x, int y, int width, int height) { 166 private void drawRectangle(int x, int y, int width, int height) {
170 // Draw quad. 167 // Draw quad.
171 GLES20.glViewport(x, y, width, height); 168 GLES20.glViewport(x, y, width, height);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 * Release all GLES resources. This needs to be done manually, otherwise the r esources are leaked. 204 * Release all GLES resources. This needs to be done manually, otherwise the r esources are leaked.
208 */ 205 */
209 @Override 206 @Override
210 public void release() { 207 public void release() {
211 for (Shader shader : shaders.values()) { 208 for (Shader shader : shaders.values()) {
212 shader.glShader.release(); 209 shader.glShader.release();
213 } 210 }
214 shaders.clear(); 211 shaders.clear();
215 } 212 }
216 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698