GL: Move private helper method next to the method that uses it.

In addition to being more readable, this will help future CLs that modify
these methods...

PiperOrigin-RevId: 584323686
This commit is contained in:
huangdarwin 2023-11-21 07:47:26 -08:00 committed by Copybara-Service
parent 6c68146efa
commit 0b22a7a0d8

View File

@ -570,6 +570,24 @@ public final class GlUtil {
return texId; return texId;
} }
/**
* Allocates a new texture, initialized with the {@link Bitmap bitmap} data.
*
* <p>The created texture will have the same size as the specified {@link Bitmap}.
*
* @param bitmap The {@link Bitmap} for which the texture is created.
* @return The texture identifier for the newly-allocated texture.
* @throws GlException If the texture allocation fails.
*/
public static int createTexture(Bitmap bitmap) throws GlException {
assertValidTextureSize(bitmap.getWidth(), bitmap.getHeight());
int texId = generateTexture();
bindTexture(GLES20.GL_TEXTURE_2D, texId);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, /* level= */ 0, bitmap, /* border= */ 0);
checkGlError();
return texId;
}
/** /**
* Allocates a new RGBA texture with the specified dimensions and color component precision. * Allocates a new RGBA texture with the specified dimensions and color component precision.
* *
@ -595,24 +613,6 @@ public final class GlUtil {
return createTextureUninitialized(width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE); return createTextureUninitialized(width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE);
} }
/**
* Allocates a new texture, initialized with the {@link Bitmap bitmap} data.
*
* <p>The created texture will have the same size as the specified {@link Bitmap}.
*
* @param bitmap The {@link Bitmap} for which the texture is created.
* @return The texture identifier for the newly-allocated texture.
* @throws GlException If the texture allocation fails.
*/
public static int createTexture(Bitmap bitmap) throws GlException {
assertValidTextureSize(bitmap.getWidth(), bitmap.getHeight());
int texId = generateTexture();
bindTexture(GLES20.GL_TEXTURE_2D, texId);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, /* level= */ 0, bitmap, /* border= */ 0);
checkGlError();
return texId;
}
/** /**
* Allocates a new RGBA texture with the specified dimensions and color component precision. * Allocates a new RGBA texture with the specified dimensions and color component precision.
* *