mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Transformer GL: Explicitly label ignored values.
Refactor GlUtil.java to be a bit more readable. Also, reorder, inline, and rename a few things. Refactoring change only. No functional changes intended. PiperOrigin-RevId: 415283874
This commit is contained in:
parent
a1061edf7f
commit
69532deb7a
@ -314,8 +314,7 @@ public final class GlUtil {
|
|||||||
* @param textureId The ID of the texture to delete.
|
* @param textureId The ID of the texture to delete.
|
||||||
*/
|
*/
|
||||||
public static void deleteTexture(int textureId) {
|
public static void deleteTexture(int textureId) {
|
||||||
int[] textures = new int[] {textureId};
|
GLES20.glDeleteTextures(/* n= */ 1, new int[] {textureId}, /* offset= */ 0);
|
||||||
GLES20.glDeleteTextures(/* n= */ 1, textures, /* offset= */ 0);
|
|
||||||
checkGlError();
|
checkGlError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,21 +442,17 @@ public final class GlUtil {
|
|||||||
int[] length = new int[1];
|
int[] length = new int[1];
|
||||||
GLES20.glGetProgramiv(
|
GLES20.glGetProgramiv(
|
||||||
programId, GLES20.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, length, /* offset= */ 0);
|
programId, GLES20.GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, length, /* offset= */ 0);
|
||||||
|
|
||||||
int[] type = new int[1];
|
|
||||||
int[] size = new int[1];
|
|
||||||
byte[] nameBytes = new byte[length[0]];
|
byte[] nameBytes = new byte[length[0]];
|
||||||
int[] ignore = new int[1];
|
|
||||||
|
|
||||||
GLES20.glGetActiveAttrib(
|
GLES20.glGetActiveAttrib(
|
||||||
programId,
|
programId,
|
||||||
index,
|
index,
|
||||||
length[0],
|
length[0],
|
||||||
ignore,
|
/* unusedLength */ new int[1],
|
||||||
/* lengthOffset= */ 0,
|
/* lengthOffset= */ 0,
|
||||||
size,
|
/* unusedSize */ new int[1],
|
||||||
/* sizeOffset= */ 0,
|
/* sizeOffset= */ 0,
|
||||||
type,
|
/* unusedType */ new int[1],
|
||||||
/* typeOffset= */ 0,
|
/* typeOffset= */ 0,
|
||||||
nameBytes,
|
nameBytes,
|
||||||
/* nameOffset= */ 0);
|
/* nameOffset= */ 0);
|
||||||
@ -521,17 +516,15 @@ public final class GlUtil {
|
|||||||
programId, GLES20.GL_ACTIVE_UNIFORM_MAX_LENGTH, length, /* offset= */ 0);
|
programId, GLES20.GL_ACTIVE_UNIFORM_MAX_LENGTH, length, /* offset= */ 0);
|
||||||
|
|
||||||
int[] type = new int[1];
|
int[] type = new int[1];
|
||||||
int[] size = new int[1];
|
|
||||||
byte[] nameBytes = new byte[length[0]];
|
byte[] nameBytes = new byte[length[0]];
|
||||||
int[] ignore = new int[1];
|
|
||||||
|
|
||||||
GLES20.glGetActiveUniform(
|
GLES20.glGetActiveUniform(
|
||||||
programId,
|
programId,
|
||||||
index,
|
index,
|
||||||
length[0],
|
length[0],
|
||||||
ignore,
|
/* unusedLength */ new int[1],
|
||||||
/* lengthOffset= */ 0,
|
/* lengthOffset= */ 0,
|
||||||
size,
|
/* unusedSize */ new int[1],
|
||||||
/*sizeOffset= */ 0,
|
/*sizeOffset= */ 0,
|
||||||
type,
|
type,
|
||||||
/* typeOffset= */ 0,
|
/* typeOffset= */ 0,
|
||||||
@ -631,10 +624,12 @@ public final class GlUtil {
|
|||||||
public static EGLDisplay createEglDisplay() {
|
public static EGLDisplay createEglDisplay() {
|
||||||
EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
|
EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
|
||||||
checkEglException(!eglDisplay.equals(EGL14.EGL_NO_DISPLAY), "No EGL display.");
|
checkEglException(!eglDisplay.equals(EGL14.EGL_NO_DISPLAY), "No EGL display.");
|
||||||
int[] major = new int[1];
|
|
||||||
int[] minor = new int[1];
|
|
||||||
if (!EGL14.eglInitialize(
|
if (!EGL14.eglInitialize(
|
||||||
eglDisplay, major, /* majorOffset= */ 0, minor, /* minorOffset= */ 0)) {
|
eglDisplay,
|
||||||
|
/* unusedMajor */ new int[1],
|
||||||
|
/* majorOffset= */ 0,
|
||||||
|
/* unusedMinor */ new int[1],
|
||||||
|
/* minorOffset= */ 0)) {
|
||||||
throwGlException("Error in eglInitialize.");
|
throwGlException("Error in eglInitialize.");
|
||||||
}
|
}
|
||||||
checkGlError();
|
checkGlError();
|
||||||
@ -673,11 +668,11 @@ public final class GlUtil {
|
|||||||
@DoNotInline
|
@DoNotInline
|
||||||
public static void focusSurface(
|
public static void focusSurface(
|
||||||
EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface surface, int width, int height) {
|
EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface surface, int width, int height) {
|
||||||
int[] fbos = new int[1];
|
int[] boundFrameBuffer = new int[1];
|
||||||
GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, fbos, /* offset= */ 0);
|
GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, boundFrameBuffer, /* offset= */ 0);
|
||||||
int noFbo = 0;
|
int defaultFrameBuffer = 0;
|
||||||
if (fbos[0] != noFbo) {
|
if (boundFrameBuffer[0] != defaultFrameBuffer) {
|
||||||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, noFbo);
|
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, defaultFrameBuffer);
|
||||||
}
|
}
|
||||||
EGL14.eglMakeCurrent(eglDisplay, surface, surface, eglContext);
|
EGL14.eglMakeCurrent(eglDisplay, surface, surface, eglContext);
|
||||||
GLES20.glViewport(/* x= */ 0, /* y= */ 0, width, height);
|
GLES20.glViewport(/* x= */ 0, /* y= */ 0, width, height);
|
||||||
@ -708,24 +703,17 @@ public final class GlUtil {
|
|||||||
|
|
||||||
@DoNotInline
|
@DoNotInline
|
||||||
private static EGLConfig getEglConfig(EGLDisplay eglDisplay) {
|
private static EGLConfig getEglConfig(EGLDisplay eglDisplay) {
|
||||||
int redSize = 8;
|
|
||||||
int greenSize = 8;
|
|
||||||
int blueSize = 8;
|
|
||||||
int alphaSize = 8;
|
|
||||||
int depthSize = 0;
|
|
||||||
int stencilSize = 0;
|
|
||||||
int[] defaultConfiguration =
|
int[] defaultConfiguration =
|
||||||
new int[] {
|
new int[] {
|
||||||
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
|
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
|
||||||
EGL14.EGL_RED_SIZE, redSize,
|
EGL14.EGL_RED_SIZE, /* redSize= */ 8,
|
||||||
EGL14.EGL_GREEN_SIZE, greenSize,
|
EGL14.EGL_GREEN_SIZE, /* greenSize= */ 8,
|
||||||
EGL14.EGL_BLUE_SIZE, blueSize,
|
EGL14.EGL_BLUE_SIZE, /* blueSize= */ 8,
|
||||||
EGL14.EGL_ALPHA_SIZE, alphaSize,
|
EGL14.EGL_ALPHA_SIZE, /* alphaSize= */ 8,
|
||||||
EGL14.EGL_DEPTH_SIZE, depthSize,
|
EGL14.EGL_DEPTH_SIZE, /* depthSize= */ 0,
|
||||||
EGL14.EGL_STENCIL_SIZE, stencilSize,
|
EGL14.EGL_STENCIL_SIZE, /* stencilSize= */ 0,
|
||||||
EGL14.EGL_NONE
|
EGL14.EGL_NONE
|
||||||
};
|
};
|
||||||
int[] configsCount = new int[1];
|
|
||||||
EGLConfig[] eglConfigs = new EGLConfig[1];
|
EGLConfig[] eglConfigs = new EGLConfig[1];
|
||||||
if (!EGL14.eglChooseConfig(
|
if (!EGL14.eglChooseConfig(
|
||||||
eglDisplay,
|
eglDisplay,
|
||||||
@ -734,7 +722,7 @@ public final class GlUtil {
|
|||||||
eglConfigs,
|
eglConfigs,
|
||||||
/* configsOffset= */ 0,
|
/* configsOffset= */ 0,
|
||||||
/* config_size= */ 1,
|
/* config_size= */ 1,
|
||||||
configsCount,
|
/* unusedNumConfig */ new int[1],
|
||||||
/* num_configOffset= */ 0)) {
|
/* num_configOffset= */ 0)) {
|
||||||
throwGlException("eglChooseConfig failed.");
|
throwGlException("eglChooseConfig failed.");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user