GL: Update BitmapOverlayVideoProcessor naming conventions.
To be more readable and consistent with Transformer GL. Tested by running gl-demo with no crash. PiperOrigin-RevId: 421815519
This commit is contained in:
parent
a9e75d8e3a
commit
b7f5b5fac9
@ -15,19 +15,19 @@
|
|||||||
#extension GL_OES_EGL_image_external : require
|
#extension GL_OES_EGL_image_external : require
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
// External texture containing video decoder output.
|
// External texture containing video decoder output.
|
||||||
uniform samplerExternalOES tex_sampler_0;
|
uniform samplerExternalOES uTexSampler0;
|
||||||
// Texture containing the overlap bitmap.
|
// Texture containing the overlap bitmap.
|
||||||
uniform sampler2D tex_sampler_1;
|
uniform sampler2D uTexSampler1;
|
||||||
// Horizontal scaling factor for the overlap bitmap.
|
// Horizontal scaling factor for the overlap bitmap.
|
||||||
uniform float scaleX;
|
uniform float uScaleX;
|
||||||
// Vertical scaling factory for the overlap bitmap.
|
// Vertical scaling factory for the overlap bitmap.
|
||||||
uniform float scaleY;
|
uniform float uScaleY;
|
||||||
varying vec2 v_texcoord;
|
varying vec2 vTexCoords;
|
||||||
void main() {
|
void main() {
|
||||||
vec4 videoColor = texture2D(tex_sampler_0, v_texcoord);
|
vec4 videoColor = texture2D(uTexSampler0, vTexCoords);
|
||||||
vec4 overlayColor = texture2D(tex_sampler_1,
|
vec4 overlayColor = texture2D(uTexSampler1,
|
||||||
vec2(v_texcoord.x * scaleX,
|
vec2(vTexCoords.x * uScaleX,
|
||||||
v_texcoord.y * scaleY));
|
vTexCoords.y * uScaleY));
|
||||||
// Blend the video decoder output and the overlay bitmap.
|
// Blend the video decoder output and the overlay bitmap.
|
||||||
gl_FragColor = videoColor * (1.0 - overlayColor.a)
|
gl_FragColor = videoColor * (1.0 - overlayColor.a)
|
||||||
+ overlayColor * overlayColor.a;
|
+ overlayColor * overlayColor.a;
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
attribute vec4 a_position;
|
attribute vec4 aFramePosition;
|
||||||
attribute vec4 a_texcoord;
|
attribute vec4 aTexCoords;
|
||||||
uniform mat4 tex_transform;
|
uniform mat4 uTexTransform;
|
||||||
varying vec2 v_texcoord;
|
varying vec2 vTexCoords;
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = a_position;
|
gl_Position = aFramePosition;
|
||||||
v_texcoord = (tex_transform * a_texcoord).xy;
|
vTexCoords = (uTexTransform * aTexCoords).xy;
|
||||||
}
|
}
|
||||||
|
@ -86,9 +86,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
program.setBufferAttribute(
|
program.setBufferAttribute(
|
||||||
"a_position", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
|
"aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
|
||||||
program.setBufferAttribute(
|
program.setBufferAttribute(
|
||||||
"a_texcoord", GlUtil.getTextureCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
|
"aTexCoords", GlUtil.getTextureCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
|
||||||
GLES20.glGenTextures(1, textures, 0);
|
GLES20.glGenTextures(1, textures, 0);
|
||||||
GLES20.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
|
GLES20.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
|
||||||
GLES20.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
|
GLES20.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
|
||||||
@ -118,11 +118,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
// Run the shader program.
|
// Run the shader program.
|
||||||
GlUtil.Program program = checkNotNull(this.program);
|
GlUtil.Program program = checkNotNull(this.program);
|
||||||
program.setSamplerTexIdUniform("tex_sampler_0", frameTexture, /* unit= */ 0);
|
program.setSamplerTexIdUniform("uTexSampler0", frameTexture, /* unit= */ 0);
|
||||||
program.setSamplerTexIdUniform("tex_sampler_1", textures[0], /* unit= */ 1);
|
program.setSamplerTexIdUniform("uTexSampler1", textures[0], /* unit= */ 1);
|
||||||
program.setFloatUniform("scaleX", bitmapScaleX);
|
program.setFloatUniform("uScaleX", bitmapScaleX);
|
||||||
program.setFloatUniform("scaleY", bitmapScaleY);
|
program.setFloatUniform("uScaleY", bitmapScaleY);
|
||||||
program.setFloatsUniform("tex_transform", transformMatrix);
|
program.setFloatsUniform("uTexTransform", transformMatrix);
|
||||||
program.bindAttributesAndUniforms();
|
program.bindAttributesAndUniforms();
|
||||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, /* first= */ 0, /* count= */ 4);
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, /* first= */ 0, /* count= */ 4);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user