am 07dee169: am 48ca08a2: am 43a7dcc1: am 265d3e9d: Merge "Clean-up ColorFade\'s shaders and buffers." into lmp-dev
* commit '07dee169f4efe8f5ab10a39ebf5a41563322cecd': Clean-up ColorFade's shaders and buffers.
This commit is contained in:
@@ -226,12 +226,15 @@ final class ColorFade {
|
|||||||
GLES20.GL_VERTEX_SHADER);
|
GLES20.GL_VERTEX_SHADER);
|
||||||
int fshader = loadShader(context, com.android.internal.R.raw.color_fade_frag,
|
int fshader = loadShader(context, com.android.internal.R.raw.color_fade_frag,
|
||||||
GLES20.GL_FRAGMENT_SHADER);
|
GLES20.GL_FRAGMENT_SHADER);
|
||||||
|
GLES20.glReleaseShaderCompiler();
|
||||||
if (vshader == 0 || fshader == 0) return false;
|
if (vshader == 0 || fshader == 0) return false;
|
||||||
|
|
||||||
mProgram = GLES20.glCreateProgram();
|
mProgram = GLES20.glCreateProgram();
|
||||||
|
|
||||||
GLES20.glAttachShader(mProgram, vshader);
|
GLES20.glAttachShader(mProgram, vshader);
|
||||||
GLES20.glAttachShader(mProgram, fshader);
|
GLES20.glAttachShader(mProgram, fshader);
|
||||||
|
GLES20.glDeleteShader(vshader);
|
||||||
|
GLES20.glDeleteShader(fshader);
|
||||||
|
|
||||||
GLES20.glLinkProgram(mProgram);
|
GLES20.glLinkProgram(mProgram);
|
||||||
|
|
||||||
@@ -254,6 +257,11 @@ final class ColorFade {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void destroyGLShaders() {
|
||||||
|
GLES20.glDeleteProgram(mProgram);
|
||||||
|
checkGlErrors("glDeleteProgram");
|
||||||
|
}
|
||||||
|
|
||||||
private boolean initGLBuffers() {
|
private boolean initGLBuffers() {
|
||||||
//Fill vertices
|
//Fill vertices
|
||||||
setQuad(mVertexBuffer, 0, 0, mDisplayWidth, mDisplayHeight);
|
setQuad(mVertexBuffer, 0, 0, mDisplayWidth, mDisplayHeight);
|
||||||
@@ -288,6 +296,11 @@ final class ColorFade {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void destroyGLBuffers() {
|
||||||
|
GLES20.glDeleteBuffers(2, mGLBuffers, 0);
|
||||||
|
checkGlErrors("glDeleteBuffers");
|
||||||
|
}
|
||||||
|
|
||||||
private static void setQuad(FloatBuffer vtx, float x, float y, float w, float h) {
|
private static void setQuad(FloatBuffer vtx, float x, float y, float w, float h) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.d(TAG, "setQuad: x=" + x + ", y=" + y + ", w=" + w + ", h=" + h);
|
Slog.d(TAG, "setQuad: x=" + x + ", y=" + y + ", w=" + w + ", h=" + h);
|
||||||
@@ -314,10 +327,20 @@ final class ColorFade {
|
|||||||
Slog.d(TAG, "dismiss");
|
Slog.d(TAG, "dismiss");
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyScreenshotTexture();
|
if (mPrepared) {
|
||||||
destroyEglSurface();
|
attachEglContext();
|
||||||
destroySurface();
|
try {
|
||||||
mPrepared = false;
|
destroyScreenshotTexture();
|
||||||
|
destroyGLShaders();
|
||||||
|
destroyGLBuffers();
|
||||||
|
destroyEglSurface();
|
||||||
|
} finally {
|
||||||
|
detachEglContext();
|
||||||
|
}
|
||||||
|
destroySurface();
|
||||||
|
GLES20.glFlush();
|
||||||
|
mPrepared = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -468,14 +491,8 @@ final class ColorFade {
|
|||||||
private void destroyScreenshotTexture() {
|
private void destroyScreenshotTexture() {
|
||||||
if (mTexNamesGenerated) {
|
if (mTexNamesGenerated) {
|
||||||
mTexNamesGenerated = false;
|
mTexNamesGenerated = false;
|
||||||
if (attachEglContext()) {
|
GLES20.glDeleteTextures(1, mTexNames, 0);
|
||||||
try {
|
checkGlErrors("glDeleteTextures");
|
||||||
GLES20.glDeleteTextures(1, mTexNames, 0);
|
|
||||||
checkGlErrors("glDeleteTextures");
|
|
||||||
} finally {
|
|
||||||
detachEglContext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user