diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-08-06 01:47:05 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-08-06 01:47:05 +0200 |
commit | 6ab3912f76d8886ccfc88def25c18819a0594f07 (patch) | |
tree | b18b0800e82bdf4251c2bee8d892fcdfa9baf553 /src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java | |
parent | 660adfa9453ada61b8753dcac1adc5b9b0972b62 (diff) | |
download | android_packages_wallpapers_PhotoPhase-6ab3912f76d8886ccfc88def25c18819a0594f07.tar.gz android_packages_wallpapers_PhotoPhase-6ab3912f76d8886ccfc88def25c18819a0594f07.tar.bz2 android_packages_wallpapers_PhotoPhase-6ab3912f76d8886ccfc88def25c18819a0594f07.zip |
Support fot GPU image effects (#2)
Initial support of android.media.effects.
Note: Transitions are broken now, and must be fixed
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java')
-rw-r--r-- | src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java index 0332bc5..e88689d 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java +++ b/src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java @@ -101,9 +101,8 @@ public class NullTransition extends Transition { public void apply(float[] matrix) throws GLException { // Check internal vars if (mTarget == null || - mTarget.getPictureVertexBuffer() == null || - mTarget.getTextureBuffer() == null || - mTarget.getVertexOrderBuffer() == null) { + mTarget.getPositionBuffer() == null || + mTarget.getTextureBuffer() == null) { return; } @@ -114,54 +113,50 @@ public class NullTransition extends Transition { /** * Method that draws the picture texture * - * @param target + * @param target The target to draw * @param matrix The model-view-projection matrix */ protected void draw(PhotoFrame target, float[] matrix) { - // Set the program + // Bind default FBO + GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); + + // Use our shader program useProgram(0); - // Bind the texture - int textureHandle = target.getTextureHandle(); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - GLESUtil.glesCheckError("glActiveTexture"); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle); - GLESUtil.glesCheckError("glBindTexture"); + // Disable blending + GLES20.glDisable(GLES20.GL_BLEND); - // Position - FloatBuffer vertexBuffer = target.getPictureVertexBuffer(); - vertexBuffer.position(0); - GLES20.glVertexAttribPointer( - mPositionHandlers[0], - PhotoFrame.COORDS_PER_VERTER, - GLES20.GL_FLOAT, - false, - PhotoFrame.COORDS_PER_VERTER * 4, - vertexBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[0]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); + // Apply the projection and view transformation + GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[0], 1, false, matrix, 0); + GLESUtil.glesCheckError("glUniformMatrix4fv"); // Texture FloatBuffer textureBuffer = target.getTextureBuffer(); textureBuffer.position(0); - GLES20.glVertexAttribPointer( - mTextureCoordHandlers[0], - 2, - GLES20.GL_FLOAT, - false, - 2 * 4, - textureBuffer); + GLES20.glVertexAttribPointer(mTextureCoordHandlers[0], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); GLESUtil.glesCheckError("glVertexAttribPointer"); GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[0]); GLESUtil.glesCheckError("glEnableVertexAttribArray"); - // Apply the projection and view transformation - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[0], 1, false, matrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); + // Position + FloatBuffer positionBuffer = target.getPositionBuffer(); + positionBuffer.position(0); + GLES20.glVertexAttribPointer(mPositionHandlers[0], 2, GLES20.GL_FLOAT, false, 0, positionBuffer); + GLESUtil.glesCheckError("glVertexAttribPointer"); + GLES20.glEnableVertexAttribArray(mPositionHandlers[0]); + GLESUtil.glesCheckError("glEnableVertexAttribArray"); + + // Set the input texture + int textureHandle = target.getTextureHandle(); + GLES20.glActiveTexture(GLES20.GL_TEXTURE0); + GLESUtil.glesCheckError("glActiveTexture"); + GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle); + GLESUtil.glesCheckError("glBindTexture"); + GLES20.glUniform1i(mTextureHandlers[0], 0); + GLESUtil.glesCheckError("glBindTexture"); - // Draw the photo frame - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_FAN, 0, 4); + // Draw + GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); GLESUtil.glesCheckError("glDrawElements"); // Disable attributes |