diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-10-03 23:52:22 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-10-03 23:52:22 +0200 |
commit | 059fa42d786915d7725e4fcf79f9de36e84f08c7 (patch) | |
tree | e2f4555011f9b61dcf25b3b2d3d8a4dee854cbdb /src/org/cyanogenmod/wallpapers/photophase/transitions | |
parent | 20574cf663cc4c24d4eb64a8f879632bcddf8828 (diff) | |
download | android_packages_wallpapers_PhotoPhase-059fa42d786915d7725e4fcf79f9de36e84f08c7.tar.gz android_packages_wallpapers_PhotoPhase-059fa42d786915d7725e4fcf79f9de36e84f08c7.tar.bz2 android_packages_wallpapers_PhotoPhase-059fa42d786915d7725e4fcf79f9de36e84f08c7.zip |
Change author and copyright
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/org/cyanogenmod/wallpapers/photophase/transitions')
9 files changed, 0 insertions, 2231 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/CubeTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/CubeTransition.java deleted file mode 100644 index bfe300b..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/CubeTransition.java +++ /dev/null @@ -1,479 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLES20; -import android.opengl.GLException; -import android.opengl.Matrix; -import android.os.SystemClock; - -import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil; -import org.cyanogenmod.wallpapers.photophase.utils.Utils; -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.R; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * A transition that applies a cube effect transition to the picture. - */ -public class CubeTransition extends Transition { - - /** - * The enumeration of all possibles window movements - */ - public enum WINDOW_MODES { - /** - * Open the picture from left to right - */ - LEFT_TO_RIGHT, - /** - * Open the picture from right to left - */ - RIGHT_TO_LEFT - } - - private static final int[] VERTEX_SHADER = {R.raw.default_vertex_shader, R.raw.default_vertex_shader}; - private static final int[] FRAGMENT_SHADER = {R.raw.default_fragment_shader, R.raw.default_fragment_shader}; - - private static final float TRANSITION_TIME = 1000.0f; - - private static final float SCALE_AMOUNT = 0.2f; - - private WINDOW_MODES mMode; - - private boolean mRunning; - private long mTime; - - private FloatBuffer mPositionBuffer; - private float[] mTranslationMatrix; - private float[] mVertex; - - private float mAmount; - - /** - * Constructor of <code>CubeTransition</code> - * - * @param ctx The current context - * @param tm The texture manager - */ - public CubeTransition(Context ctx, TextureManager tm) { - super(ctx, tm, VERTEX_SHADER, FRAGMENT_SHADER); - - // Initialized - mTranslationMatrix = new float[16]; - reset(); - } - - /** - * {@inheritDoc} - */ - @Override - public TRANSITIONS getType() { - return TRANSITIONS.WINDOW; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasTransitionTarget() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return mRunning; - } - - /** - * {@inheritDoc} - */ - @Override - public void select(PhotoFrame target) { - super.select(target); - mAmount = getAmount(); - - // Create the interal buffer - float[] vertex = target.getFrameVertex(); - if (mPositionBuffer == null) { - ByteBuffer bb = ByteBuffer.allocateDirect(vertex.length * 4); // (# of coordinate values * 4 bytes per float) - bb.order(ByteOrder.nativeOrder()); - mPositionBuffer = bb.asFloatBuffer(); - } - if (mVertex == null) { - mVertex = new float[vertex.length]; - } - - // Random mode - List<WINDOW_MODES> modes = - new ArrayList<CubeTransition.WINDOW_MODES>( - Arrays.asList(WINDOW_MODES.values())); - int low = 0; - int high = modes.size() - 1; - mMode = modes.get(Utils.getNextRandom(low, high)); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isSelectable(PhotoFrame frame) { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public void reset() { - mTime = -1; - mRunning = true; - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(float[] matrix) throws GLException { - // Check internal vars - if (mTarget == null || - mTarget.getPositionBuffer() == null || - mTarget.getTextureBuffer() == null) { - return; - } - if (mTransitionTarget == null || - mTransitionTarget.getPositionBuffer() == null || - mTransitionTarget.getTextureBuffer() == null) { - return; - } - - // Set the time the first time - if (mTime == -1) { - mTime = SystemClock.uptimeMillis(); - } - - // Calculate the delta time - final float delta = Math.min(SystemClock.uptimeMillis() - mTime, TRANSITION_TIME) / TRANSITION_TIME; - - // Apply the transition - if (delta < 1) { - applyDstTransition(delta, matrix); - applySrcTransition(delta, matrix); - } else { - applyFinalTransition(matrix); - } - - // Transition ending - if (delta == 1) { - mRunning = false; - } - } - - /** - * Apply the source transition - * - * @param delta The delta time - * @param matrix The model-view-projection matrix - */ - private void applySrcTransition(float delta, float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Set the program - useProgram(0); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // Set the input texture - int textureHandle = mTarget.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"); - - // Texture - FloatBuffer textureBuffer = mTarget.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[0], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - setInternalVertex(); - float interpolation = delta > 0.5f - ? 1 - delta - : delta; - float w = Math.abs(mVertex[6] - mVertex[4]); - switch (mMode) { - case RIGHT_TO_LEFT: - mVertex[1] -= interpolation * mAmount; - mVertex[5] += interpolation * mAmount; - mVertex[4] += w * delta; - mVertex[0] = mVertex[4]; - break; - case LEFT_TO_RIGHT: - mVertex[3] -= interpolation * mAmount; - mVertex[7] += interpolation * mAmount; - mVertex[6] -= w * delta; - mVertex[2] = mVertex[6]; - break; - default: - break; - } - mPositionBuffer.position(0); - mPositionBuffer.put(mVertex); - mPositionBuffer.position(0); - GLES20.glVertexAttribPointer(mPositionHandlers[0], 2, GLES20.GL_FLOAT, false, 0, mPositionBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[0]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Calculate the delta angle and the translation and rotate parameters - float angle = 0.0f; - float translateX = 0.0f; - float rotateY = 0.0f; - switch (mMode) { - case RIGHT_TO_LEFT: - angle = delta * 90; - rotateY = -1.0f; - translateX = mVertex[2] * -1; - break; - case LEFT_TO_RIGHT: - angle = delta * -90; - rotateY = -1.0f; - translateX = mVertex[0] * -1; - break; - - default: - break; - } - - // Apply the projection and view transformation - Matrix.setIdentityM(matrix, 0); - Matrix.translateM(mTranslationMatrix, 0, matrix, 0, -translateX, 0.0f, 0.0f); - Matrix.rotateM(mTranslationMatrix, 0, mTranslationMatrix, 0, angle, 0.0f, rotateY, 0.0f); - Matrix.translateM(mTranslationMatrix, 0, mTranslationMatrix, 0, translateX, 0.0f, 0.0f); - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[0], 1, false, mTranslationMatrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - - /** - * Apply the destination transition - * - * @param delta The delta time - * @param matrix The model-view-projection matrix - */ - private void applyDstTransition(float delta, float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Set the program - useProgram(1); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // Set the input texture - int textureHandle = mTransitionTarget.getTextureHandle(); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - GLESUtil.glesCheckError("glActiveTexture"); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle); - GLESUtil.glesCheckError("glBindTexture"); - GLES20.glUniform1i(mTextureHandlers[1], 0); - GLESUtil.glesCheckError("glBindTexture"); - - // Texture - FloatBuffer textureBuffer = mTransitionTarget.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[1], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - setInternalVertex(); - float interpolation = delta > 0.5f - ? 1 - delta - : delta; - float w = Math.abs(mVertex[6] - mVertex[4]); - switch (mMode) { - case LEFT_TO_RIGHT: - mVertex[1] -= interpolation * mAmount; - mVertex[5] += interpolation * mAmount; - mVertex[4] += w * (1 - delta); - mVertex[0] = mVertex[4]; - break; - case RIGHT_TO_LEFT: - mVertex[3] -= interpolation * mAmount; - mVertex[7] += interpolation * mAmount; - mVertex[6] -= w * (1 - delta); - mVertex[2] = mVertex[6]; - break; - default: - break; - } - mPositionBuffer.position(0); - mPositionBuffer.put(mVertex); - mPositionBuffer.position(0); - GLES20.glVertexAttribPointer(mPositionHandlers[1], 2, GLES20.GL_FLOAT, false, 0, mPositionBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Calculate the delta angle and the translation and rotate parameters - float angle = 0.0f; - float translateX = 0.0f; - float rotateY = 0.0f; - switch (mMode) { - case LEFT_TO_RIGHT: - angle = 90 - (delta * 90); - rotateY = -1.0f; - translateX = mVertex[2] * -1; - break; - case RIGHT_TO_LEFT: - angle = -90 + (delta * 90); - rotateY = -1.0f; - translateX = mVertex[0] * -1; - break; - - default: - break; - } - - // Apply the projection and view transformation - Matrix.setIdentityM(matrix, 0); - Matrix.translateM(mTranslationMatrix, 0, matrix, 0, -translateX, 0.0f, 0.0f); - Matrix.rotateM(mTranslationMatrix, 0, mTranslationMatrix, 0, angle, 0.0f, rotateY, 0.0f); - Matrix.translateM(mTranslationMatrix, 0, mTranslationMatrix, 0, translateX, 0.0f, 0.0f); - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[1], 1, false, mTranslationMatrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - - /** - * Apply the destination transition (just draw the image) - * - * @param matrix The model-view-projection matrix - */ - private void applyFinalTransition(float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Use our shader program - useProgram(1); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // Apply the projection and view transformation - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[1], 1, false, matrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Texture - FloatBuffer textureBuffer = mTransitionTarget.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[1], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - FloatBuffer positionBuffer = mTransitionTarget.getPositionBuffer(); - positionBuffer.position(0); - GLES20.glVertexAttribPointer(mPositionHandlers[1], 2, GLES20.GL_FLOAT, false, 0, positionBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Set the input texture - int textureHandle = mTransitionTarget.getTextureHandle(); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - GLESUtil.glesCheckError("glActiveTexture"); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle); - GLESUtil.glesCheckError("glBindTexture"); - GLES20.glUniform1i(mTextureHandlers[1], 0); - GLESUtil.glesCheckError("glUniform1i"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - - /** - * Method that prepares the internal vertex array - */ - private void setInternalVertex() { - float[] originalVertex = mTarget.getFrameVertex(); - System.arraycopy(originalVertex, 0, mVertex, 0, originalVertex.length); - } - - /** - * Return the scale amount to apply to the transition - * - * @return float The scale amount - */ - private float getAmount() { - return ((mTarget.getFrameWidth() * SCALE_AMOUNT) / 2); - } -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/FadeTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/FadeTransition.java deleted file mode 100644 index ce50fa4..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/FadeTransition.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLException; -import android.os.SystemClock; - -import org.cyanogenmod.wallpapers.photophase.Colors; -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.shapes.ColorShape; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -/** - * A transition that applies a fade transition to the picture. - */ -public class FadeTransition extends NullTransition { - - private static final float TRANSITION_TIME = 600.0f; - - private boolean mRunning; - private long mTime; - - ColorShape mOverlay; - - /** - * Constructor of <code>FadeTransition</code> - * - * @param ctx The current context - * @param tm The texture manager - */ - public FadeTransition(Context ctx, TextureManager tm) { - super(ctx, tm); - } - - /** - * {@inheritDoc} - */ - @Override - public TRANSITIONS getType() { - return TRANSITIONS.FADE; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasTransitionTarget() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return mRunning; - } - - /** - * {@inheritDoc} - */ - @Override - public void reset() { - super.reset(); - mTime = -1; - mRunning = true; - } - - /** - * {@inheritDoc} - */ - @Override - public void select(PhotoFrame target) { - super.select(target); - mOverlay = new ColorShape(mContext, target.getFrameVertex(), Colors.getBackground()); - mOverlay.setAlpha(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(float[] matrix) throws GLException { - // Check internal vars - if (mTarget == null || - mTarget.getPositionBuffer() == null || - mTarget.getTextureBuffer() == null) { - return; - } - if (mTransitionTarget == null || - mTransitionTarget.getPositionBuffer() == null || - mTransitionTarget.getTextureBuffer() == null) { - return; - } - - // Set the time the first time - if (mTime == -1) { - mTime = SystemClock.uptimeMillis(); - } - - final float delta = Math.min(SystemClock.uptimeMillis() - mTime, TRANSITION_TIME) / TRANSITION_TIME; - if (delta <= 0.5) { - // Draw the src target - draw(mTarget, matrix); - mOverlay.setAlpha(delta * 2.0f); - } else { - // Draw the dst target - draw(mTransitionTarget, matrix); - mOverlay.setAlpha((1 - delta) * 2.0f); - } - mOverlay.draw(matrix); - - // Transition ended - if (delta == 1) { - mRunning = false; - } - } - -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/FlipTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/FlipTransition.java deleted file mode 100644 index 8d0bf79..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/FlipTransition.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLES20; -import android.opengl.GLException; -import android.opengl.Matrix; -import android.os.SystemClock; - -import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil; -import org.cyanogenmod.wallpapers.photophase.utils.Utils; -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.R; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -import java.nio.FloatBuffer; - -/** - * A transition that applies a translation transition to the picture. - */ -public class FlipTransition extends Transition { - - /** - * The enumeration of all possibles translations movements - */ - public enum FLIP_MODES { - /** - * Flip the picture horizontally - */ - HORIZONTAL, - /** - * Flip the picture vertically - */ - VERTICAL - } - - private static final int[] VERTEX_SHADER = {R.raw.default_vertex_shader, R.raw.default_vertex_shader}; - private static final int[] FRAGMENT_SHADER = {R.raw.default_fragment_shader, R.raw.default_fragment_shader}; - - private static final float TRANSITION_TIME = 600.0f; - - private FLIP_MODES mMode; - - private float[] mTranslationMatrix; - - private boolean mRunning; - private long mTime; - - /** - * Constructor of <code>FlipTransition</code> - * - * @param ctx The current context - * @param tm The texture manager - */ - public FlipTransition(Context ctx, TextureManager tm) { - super(ctx, tm, VERTEX_SHADER, FRAGMENT_SHADER); - - // Initialized - mTranslationMatrix = new float[16]; - reset(); - } - - /** - * {@inheritDoc} - */ - @Override - public TRANSITIONS getType() { - return TRANSITIONS.FLIP; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasTransitionTarget() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return mRunning; - } - - /** - * {@inheritDoc} - */ - @Override - public void select(PhotoFrame target) { - super.select(target); - - // Random mode - FLIP_MODES[] modes = FLIP_MODES.values(); - int low = 0; - int high = modes.length - 1; - mMode = modes[Utils.getNextRandom(low, high)]; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isSelectable(PhotoFrame frame) { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public void reset() { - mTime = -1; - mRunning = true; - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(float[] matrix) throws GLException { - // Check internal vars - if (mTarget == null || - mTarget.getPositionBuffer() == null || - mTarget.getTextureBuffer() == null) { - return; - } - if (mTransitionTarget == null || - mTransitionTarget.getPositionBuffer() == null || - mTransitionTarget.getTextureBuffer() == null) { - return; - } - - // Set the time the first time - if (mTime == -1) { - mTime = SystemClock.uptimeMillis(); - } - - // Calculate the delta time - final float delta = Math.min(SystemClock.uptimeMillis() - mTime, TRANSITION_TIME) / TRANSITION_TIME; - - // Apply the transition - applyTransition(delta, matrix, delta <= 0.5 ? mTarget : mTransitionTarget); - - // Transition ending - if (delta == 1) { - mRunning = false; - } - } - - /** - * Apply the transition - * - * @param delta The delta time - * @param matrix The model-view-projection matrix - * @param target The photo frame target - */ - private void applyTransition(float delta, float[] matrix, PhotoFrame target) { - // Retrieve the index of the structures - int index = delta <= 0.5f ? 0 : 1; - - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Set the program - useProgram(index); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // 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[index], 0); - GLESUtil.glesCheckError("glBindTexture"); - - // Texture - FloatBuffer textureBuffer = target.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[index], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[index]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - FloatBuffer positionBuffer = target.getPositionBuffer(); - positionBuffer.position(0); - GLES20.glVertexAttribPointer(mPositionHandlers[index], 2, GLES20.GL_FLOAT, false, 0, positionBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[index]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Calculate the delta angle and the translation and rotate parameters - float angle = (delta * 90) / 0.5f; - if (index == 1) { - angle = 90 - ((delta - 0.5f) * 90) / 0.5f; - } - float translateX = 0.0f; - float translateY = 0.0f; - float rotateX = 0.0f; - float rotateY = 0.0f; - switch (mMode) { - case HORIZONTAL: - rotateY = -1.0f; - translateX = (mTarget.getFrameVertex()[2] - ((mTarget.getFrameVertex()[2] - mTarget.getFrameVertex()[0]) / 2)) * -1; - break; - case VERTICAL: - rotateX = -1.0f; - translateY = (mTarget.getFrameVertex()[5] - ((mTarget.getFrameVertex()[5] - mTarget.getFrameVertex()[1]) / 2)) * -1; - break; - - default: - break; - } - - // Apply the projection and view transformation - Matrix.setIdentityM(matrix, 0); - Matrix.translateM(mTranslationMatrix, 0, matrix, 0, -translateX, -translateY, 0.0f); - Matrix.rotateM(mTranslationMatrix, 0, mTranslationMatrix, 0, angle, rotateX, rotateY, 0.0f); - Matrix.translateM(mTranslationMatrix, 0, mTranslationMatrix, 0, translateX, translateY, 0.0f); - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[index], 1, false, mTranslationMatrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[index]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[index]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java deleted file mode 100644 index 24344d6..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/NullTransition.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLES20; -import android.opengl.GLException; - -import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil; -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.R; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -import java.nio.FloatBuffer; -/** - * A special transition that does nothing other than draw the {@link PhotoFrame} - * on the screen continually. No transition is done. - */ -public class NullTransition extends Transition { - - private static final int[] VERTEX_SHADER = {R.raw.default_vertex_shader}; - private static final int[] FRAGMENT_SHADER = {R.raw.default_fragment_shader}; - - /** - * Constructor of <code>NullTransition</code> - * - * @param ctx The current context - * @param tm The texture manager - */ - public NullTransition(Context ctx, TextureManager tm) { - super(ctx, tm, VERTEX_SHADER, FRAGMENT_SHADER); - } - - /** - * {@inheritDoc} - */ - @Override - public void select(PhotoFrame target) { - super.select(target); - } - - /** - * {@inheritDoc} - */ - @Override - public TRANSITIONS getType() { - return TRANSITIONS.NO_TRANSITION; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasTransitionTarget() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return mTarget == null || !mTarget.isLoaded(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isSelectable(PhotoFrame frame) { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public void reset() { - // Nothing to do - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(float[] matrix) throws GLException { - // Check internal vars - if (mTarget == null || - mTarget.getPositionBuffer() == null || - mTarget.getTextureBuffer() == null) { - return; - } - - // Draw the current target - draw(mTarget, matrix); - } - - /** - * Method that draws the picture texture - * - * @param target The target to draw - * @param matrix The model-view-projection matrix - */ - protected void draw(PhotoFrame target, float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Use our shader program - useProgram(0); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // 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, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // 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("glUniform1i"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/SwapTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/SwapTransition.java deleted file mode 100644 index d5cf15f..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/SwapTransition.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLException; -import android.os.SystemClock; - -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -/** - * A simple transition that swap an image after the transition time is ended. - */ -public class SwapTransition extends NullTransition { - - private static final float TRANSITION_TIME = 250.0f; - - private boolean mRunning; - private long mTime; - - /** - * Constructor of <code>SwapTransition</code> - * - * @param ctx The current context - * @param tm The texture manager - */ - public SwapTransition(Context ctx, TextureManager tm) { - super(ctx, tm); - } - - /** - * {@inheritDoc} - */ - @Override - public TRANSITIONS getType() { - return TRANSITIONS.SWAP; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasTransitionTarget() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return mRunning; - } - - /** - * {@inheritDoc} - */ - @Override - public void reset() { - super.reset(); - mTime = -1; - mRunning = true; - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(float[] matrix) throws GLException { - // Check internal vars - if (mTarget == null || - mTarget.getPositionBuffer() == null || - mTarget.getTextureBuffer() == null) { - return; - } - if (mTransitionTarget == null || - mTransitionTarget.getPositionBuffer() == null || - mTransitionTarget.getTextureBuffer() == null) { - return; - } - - // Set the time the first time - if (mTime == -1) { - mTime = SystemClock.uptimeMillis(); - } - - // Calculate the delta time - final float delta = Math.min(SystemClock.uptimeMillis() - mTime, TRANSITION_TIME) / TRANSITION_TIME; - - // Apply the transition - boolean ended = delta == 1; - draw(ended ? mTransitionTarget : mTarget, matrix); - mRunning = !ended; - } - -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/Transition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/Transition.java deleted file mode 100644 index cdd5438..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/Transition.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLES20; - -import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil; -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -/** - * The base class of all transitions that can be applied to the {@link PhotoFrame} classes. - */ -public abstract class Transition { - - public static final long MAX_TRANSTION_TIME = 1500L; - - protected final Context mContext; - private final TextureManager mTextureManager; - - protected int[] mProgramHandlers; - protected int[] mTextureHandlers; - protected int[] mPositionHandlers; - protected int[] mTextureCoordHandlers; - protected int[] mMVPMatrixHandlers; - - protected PhotoFrame mTarget; - protected PhotoFrame mTransitionTarget; - - private final int[] mVertexShader; - private final int[] mFragmentShader; - - /** - * Constructor of <code>Transition</code> - * - * @param ctx The current context - * @param tm The current texture manager - * @param vertexShader The vertex shaders of the programs - * @param fragmentShader The fragment shaders of the programs - */ - public Transition(Context ctx, TextureManager tm, int[] vertexShader, int[] fragmentShader) { - super(); - mContext = ctx; - mTextureManager = tm; - mVertexShader = vertexShader; - mFragmentShader = fragmentShader; - - // Compile every program - assert mVertexShader.length != mFragmentShader.length; - int cc = mVertexShader.length; - mProgramHandlers = new int[cc]; - mTextureHandlers = new int[cc]; - mPositionHandlers = new int[cc]; - mTextureCoordHandlers = new int[cc]; - mMVPMatrixHandlers = new int[cc]; - for (int i = 0; i < cc; i++) { - createProgram(i); - } - } - - /** - * Method that requests to apply this transition. - * - * @param target The target photo frame - */ - public void select(PhotoFrame target) { - mTarget = target; - if (hasTransitionTarget()) { - // Load the transition frame and request a picture for it - mTransitionTarget = - new PhotoFrame( - mContext, - mTextureManager, - mTarget.getFrameVertex(), - mTarget.getPhotoVertex(), - mTarget.getBackgroundColor()); - } - } - - /** - * Method that returns the target of the transition. - * - * @return PhotoFrame The target of the transition - */ - public PhotoFrame getTarget() { - return mTarget; - } - - /** - * Method that returns the transition target of the transition. - * - * @return PhotoFrame The transition target of the transition - */ - public PhotoFrame getTransitionTarget() { - return mTransitionTarget; - } - - /** - * Method that returns if the transition is selectable for the passed frame. - * - * @param frame The frame which the transition should be applied to - * @return boolean If the transition is selectable for the passed frame - */ - public abstract boolean isSelectable(PhotoFrame frame); - - /** - * Method that resets the current status of the transition. - */ - public abstract void reset(); - - /** - * Method that returns the type of transition. - * - * @return TRANSITIONS The type of transition - */ - public abstract TRANSITIONS getType(); - - /** - * Method that requests to apply this transition. - * - * @param matrix The model-view-projection matrix - */ - public abstract void apply(float[] matrix); - - /** - * Method that returns if the transition is being transition. - * - * @return boolean If the transition is being transition. - */ - public abstract boolean isRunning(); - - /** - * Method that return if the transition has a secondary target - * - * @return boolean If the transition has a secondary target - */ - public abstract boolean hasTransitionTarget(); - - /** - * Method that creates the program - */ - protected void createProgram(int index) { - mProgramHandlers[index] = - GLESUtil.createProgram( - mContext.getResources(), mVertexShader[index], mFragmentShader[index]); - mTextureHandlers[index] = - GLES20.glGetAttribLocation(mProgramHandlers[index], "sTexture"); - mPositionHandlers[index] = - GLES20.glGetAttribLocation(mProgramHandlers[index], "aPosition"); - GLESUtil.glesCheckError("glGetAttribLocation"); - mTextureCoordHandlers[index] = - GLES20.glGetAttribLocation(mProgramHandlers[index], "aTextureCoord"); - GLESUtil.glesCheckError("glGetAttribLocation"); - mMVPMatrixHandlers[index] = - GLES20.glGetUniformLocation(mProgramHandlers[index], "uMVPMatrix"); - GLESUtil.glesCheckError("glGetUniformLocation"); - } - - /** - * Method that set the program to use - * - * @param index The index of the program to use - */ - protected void useProgram(int index) { - if (!GLES20.glIsProgram(mProgramHandlers[index])) { - createProgram(index); - } - GLES20.glUseProgram(mProgramHandlers[index]); - GLESUtil.glesCheckError("glUseProgram()"); - } - - /** - * Method that requests to the transition to remove its internal references and resources. - */ - public void recycle() { - int cc = mProgramHandlers.length; - for (int i = 0; i < cc; i++) { - if (GLES20.glIsProgram(mProgramHandlers[i])) { - GLES20.glDeleteProgram(mProgramHandlers[i]); - GLESUtil.glesCheckError("glDeleteProgram"); - } - mProgramHandlers[i] = -1; - mTextureHandlers[i] = -1; - mPositionHandlers[i] = -1; - mTextureCoordHandlers[i] = -1; - mMVPMatrixHandlers[i] = -1; - } - mTransitionTarget = null; - mTarget = null; - } -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/Transitions.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/Transitions.java deleted file mode 100644 index 86dfeb8..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/Transitions.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; - -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.preferences.PreferencesProvider.Preferences; -import org.cyanogenmod.wallpapers.photophase.utils.Utils; - -import java.util.Arrays; -import java.util.List; - - -/** - * A class that manages all the supported transitions - */ -public class Transitions { - - /** - * Enumeration of the supported transitions - */ - public enum TRANSITIONS { - /** - * @see NullTransition - */ - NO_TRANSITION, - /** - * @see CubeTransition - */ - CUBE, - /** - * @see FadeTransition - */ - FADE, - /** - * @see FlipTransition - */ - FLIP, - /** - * @see SwapTransition - */ - SWAP, - /** - * @see TranslateTransition - */ - TRANSLATION, - /** - * @see WindowTransition - */ - WINDOW; - - /** - * Method that returns the transition from its ordinal position - * - * @param ordinal The ordinal position - * @return TRANSITIONS The transition or null if wasn't found - */ - public static TRANSITIONS fromOrdinal(int ordinal) { - for (TRANSITIONS transition : TRANSITIONS.values()) { - if (transition.ordinal() == ordinal) { - return transition; - } - } - return null; - } - - /** - * Method that the returns an array with all the valid transitions (NO_TRANSITION is not - * a valid one). - * - * @return TRANSITIONS[] The valid transitions - */ - public static TRANSITIONS[] getValidTranstions() { - TRANSITIONS[] src = TRANSITIONS.values(); - TRANSITIONS[] dst = new TRANSITIONS[src.length-1]; - System.arraycopy(src, 1, dst, 0, src.length-1); - return dst; - } - } - - /** - * Method that return the next type of transition to apply the picture. - * - * @param frame The frame which the translation will be applied to - * @return TRANSITIONS The next type of transition to apply - */ - public static TRANSITIONS getNextTypeOfTransition(PhotoFrame frame) { - // Get a transition based on the user preference - List<TRANSITIONS> transitions = - Arrays.asList(Preferences.General.Transitions.getTransitionTypes()); - TRANSITIONS nextTransition = null; - if (transitions.size() > 0) { - int low = 0; - int high = transitions.size() - 1; - int pos = Utils.getNextRandom(low, high); - nextTransition = transitions.get(pos); - } - if (nextTransition == null) { - return TRANSITIONS.NO_TRANSITION; - } - - // Select the transition if is available - if (nextTransition.compareTo(TRANSITIONS.SWAP) == 0) { - return TRANSITIONS.SWAP; - } else if (nextTransition.compareTo(TRANSITIONS.FADE) == 0) { - return TRANSITIONS.FADE; - } else if (nextTransition.compareTo(TRANSITIONS.TRANSLATION) == 0) { - return TRANSITIONS.TRANSLATION; - } else if (nextTransition.compareTo(TRANSITIONS.FLIP) == 0) { - return TRANSITIONS.FLIP; - } else if (nextTransition.compareTo(TRANSITIONS.WINDOW) == 0) { - return TRANSITIONS.WINDOW; - } else if (nextTransition.compareTo(TRANSITIONS.CUBE) == 0) { - return TRANSITIONS.CUBE; - } - return TRANSITIONS.NO_TRANSITION; - } - - /** - * Method that creates a new transition. - * - * @param ctx The current context - * @param tm The texture manager - * @param type The type of transition - * @param frame The frame which the translation will be applied to - * @return Transition The next transition to apply - */ - public static Transition createTransition( - Context ctx, TextureManager tm, TRANSITIONS type, PhotoFrame frame) { - if (type.compareTo(TRANSITIONS.SWAP) == 0) { - return new SwapTransition(ctx, tm); - } else if (type.compareTo(TRANSITIONS.FADE) == 0) { - return new FadeTransition(ctx, tm); - } else if (type.compareTo(TRANSITIONS.TRANSLATION) == 0) { - return new TranslateTransition(ctx, tm); - } else if (type.compareTo(TRANSITIONS.FLIP) == 0) { - return new FlipTransition(ctx, tm); - } else if (type.compareTo(TRANSITIONS.WINDOW) == 0) { - return new WindowTransition(ctx, tm); - } else if (type.compareTo(TRANSITIONS.CUBE) == 0) { - return new CubeTransition(ctx, tm); - } - return new NullTransition(ctx, tm); - } -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/TranslateTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/TranslateTransition.java deleted file mode 100644 index eb1080b..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/TranslateTransition.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLES20; -import android.opengl.GLException; -import android.opengl.Matrix; -import android.os.SystemClock; - -import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil; -import org.cyanogenmod.wallpapers.photophase.utils.Utils; -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.R; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -import java.nio.FloatBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * A transition that applies a translation transition to the picture. - */ -public class TranslateTransition extends Transition { - - /** - * The enumeration of all possibles translations movements - */ - public enum TRANSLATE_MODES { - /** - * Translate the picture from left to right - */ - LEFT_TO_RIGHT, - /** - * Translate the picture from right to left - */ - RIGHT_TO_LEFT, - /** - * Translate the picture from up to down - */ - UP_TO_DOWN, - /** - * Translate the picture from down to up - */ - DOWN_TO_UP - } - - private static final int[] VERTEX_SHADER = {R.raw.default_vertex_shader, R.raw.default_vertex_shader}; - private static final int[] FRAGMENT_SHADER = {R.raw.default_fragment_shader, R.raw.default_fragment_shader}; - - private static final float TRANSITION_TIME = 600.0f; - - private TRANSLATE_MODES mMode; - - private boolean mRunning; - private long mTime; - - /** - * Constructor of <code>TranslateTransition</code> - * - * @param ctx The current context - * @param tm The texture manager - */ - public TranslateTransition(Context ctx, TextureManager tm) { - super(ctx, tm, VERTEX_SHADER, FRAGMENT_SHADER); - - // Initialized - reset(); - } - - /** - * {@inheritDoc} - */ - @Override - public TRANSITIONS getType() { - return TRANSITIONS.TRANSLATION; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasTransitionTarget() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return mRunning; - } - - /** - * {@inheritDoc} - */ - @Override - public void select(PhotoFrame target) { - super.select(target); - - // Discard all non-supported modes - List<TRANSLATE_MODES> modes = - new ArrayList<TranslateTransition.TRANSLATE_MODES>( - Arrays.asList(TRANSLATE_MODES.values())); - float[] vertex = target.getFrameVertex(); - if (vertex[4] != -1.0f) { - modes.remove(TRANSLATE_MODES.RIGHT_TO_LEFT); - } - if (vertex[6] != 1.0f) { - modes.remove(TRANSLATE_MODES.LEFT_TO_RIGHT); - } - if (vertex[5] != 1.0f) { - modes.remove(TRANSLATE_MODES.DOWN_TO_UP); - } - if (vertex[1] != -1.0f) { - modes.remove(TRANSLATE_MODES.UP_TO_DOWN); - } - - // Random mode - int low = 0; - int high = modes.size() - 1; - mMode = modes.get(Utils.getNextRandom(low, high)); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isSelectable(PhotoFrame frame) { - float[] vertex = frame.getFrameVertex(); - if (vertex[4] == -1.0f || vertex[6] == 1.0f || - vertex[5] == 1.0f || vertex[1] == -1.0f) { - return true; - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public void reset() { - mTime = -1; - mRunning = true; - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(float[] matrix) throws GLException { - // Check internal vars - if (mTarget == null || - mTarget.getPositionBuffer() == null || - mTarget.getTextureBuffer() == null) { - return; - } - if (mTransitionTarget == null || - mTransitionTarget.getPositionBuffer() == null || - mTransitionTarget.getTextureBuffer() == null) { - return; - } - - // Set the time the first time - if (mTime == -1) { - mTime = SystemClock.uptimeMillis(); - } - - // Calculate the delta time - final float delta = Math.min(SystemClock.uptimeMillis() - mTime, TRANSITION_TIME) / TRANSITION_TIME; - - // Apply the transition - applyTransitionToDst(delta, matrix); - if (delta < 1) { - applyTransitionToSrc(delta, matrix); - } - - // Transition ending - if (delta == 1) { - mRunning = false; - } - } - - /** - * Apply the transition to the source frame - * - * @param delta The delta time - * @param matrix The model-view-projection matrix - */ - private void applyTransitionToSrc(float delta, float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Set the program - useProgram(0); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // Set the input texture - int textureHandle = mTarget.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"); - - // Texture - FloatBuffer textureBuffer = mTarget.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[0], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - FloatBuffer positionBuffer = mTarget.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"); - - // Calculate the delta distance - float distance = - (mMode.compareTo(TRANSLATE_MODES.LEFT_TO_RIGHT) == 0 || mMode.compareTo(TRANSLATE_MODES.RIGHT_TO_LEFT) == 0) - ? mTarget.getFrameWidth() - : mTarget.getFrameHeight(); - if (mMode.compareTo(TRANSLATE_MODES.RIGHT_TO_LEFT) == 0 || mMode.compareTo(TRANSLATE_MODES.DOWN_TO_UP) == 0) { - distance *= -1; - } - distance *= delta; - boolean vertical = (mMode.compareTo(TRANSLATE_MODES.UP_TO_DOWN) == 0 || mMode.compareTo(TRANSLATE_MODES.DOWN_TO_UP) == 0); - - // Apply the projection and view transformation - float[] translationMatrix = new float[16]; - if (vertical) { - Matrix.translateM(translationMatrix, 0, matrix, 0, 0.0f, distance, 0.0f); - } else { - Matrix.translateM(translationMatrix, 0, matrix, 0, distance, 0.0f, 0.0f); - } - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[0], 1, false, translationMatrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - - /** - * Apply the transition to the destination frame - * - * @param delta The delta time - * @param matrix The model-view-projection matrix - */ - private void applyTransitionToDst(float delta, float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Set the program - useProgram(1); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // Set the input texture - int textureHandle = mTransitionTarget.getTextureHandle(); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - GLESUtil.glesCheckError("glActiveTexture"); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle); - GLESUtil.glesCheckError("glBindTexture"); - GLES20.glUniform1i(mTextureHandlers[1], 0); - GLESUtil.glesCheckError("glUniform1i"); - - // Texture - FloatBuffer textureBuffer = mTransitionTarget.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[1], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - FloatBuffer positionBuffer = mTransitionTarget.getPositionBuffer(); - positionBuffer.position(0); - GLES20.glVertexAttribPointer(mPositionHandlers[1], 2, GLES20.GL_FLOAT, false, 0, positionBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Apply the projection and view transformation - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[1], 1, false, matrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - -} diff --git a/src/org/cyanogenmod/wallpapers/photophase/transitions/WindowTransition.java b/src/org/cyanogenmod/wallpapers/photophase/transitions/WindowTransition.java deleted file mode 100644 index b09cfaa..0000000 --- a/src/org/cyanogenmod/wallpapers/photophase/transitions/WindowTransition.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (C) 2013 The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.cyanogenmod.wallpapers.photophase.transitions; - -import android.content.Context; -import android.opengl.GLES20; -import android.opengl.GLException; -import android.opengl.Matrix; -import android.os.SystemClock; -import android.view.animation.AccelerateInterpolator; - -import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil; -import org.cyanogenmod.wallpapers.photophase.utils.Utils; -import org.cyanogenmod.wallpapers.photophase.PhotoFrame; -import org.cyanogenmod.wallpapers.photophase.R; -import org.cyanogenmod.wallpapers.photophase.TextureManager; -import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * A transition that applies a window effect transition to the picture. - */ -public class WindowTransition extends Transition { - - /** - * The enumeration of all possibles window movements - */ - public enum WINDOW_MODES { - /** - * Open the picture from left to right - */ - LEFT_TO_RIGHT, - /** - * Open the picture from right to left - */ - RIGHT_TO_LEFT - } - - private static final int[] VERTEX_SHADER = {R.raw.default_vertex_shader, R.raw.default_vertex_shader}; - private static final int[] FRAGMENT_SHADER = {R.raw.default_fragment_shader, R.raw.default_fragment_shader}; - - private static final float TRANSITION_TIME = 800.0f; - - private static final float SCALE_AMOUNT = 0.2f; - - private WINDOW_MODES mMode; - - private float[] mTranslationMatrix; - - private boolean mRunning; - private long mTime; - - private AccelerateInterpolator mInterpolation; - private float mAmount; - - /** - * Constructor of <code>WindowTransition</code> - * - * @param ctx The current context - * @param tm The texture manager - */ - public WindowTransition(Context ctx, TextureManager tm) { - super(ctx, tm, VERTEX_SHADER, FRAGMENT_SHADER); - - // Initialized - mTranslationMatrix = new float[16]; - reset(); - } - - /** - * {@inheritDoc} - */ - @Override - public TRANSITIONS getType() { - return TRANSITIONS.WINDOW; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasTransitionTarget() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return mRunning; - } - - /** - * {@inheritDoc} - */ - @Override - public void select(PhotoFrame target) { - super.select(target); - mInterpolation = new AccelerateInterpolator(); - mAmount = getAmount(); - - // Discard all non-supported modes - List<WINDOW_MODES> modes = - new ArrayList<WindowTransition.WINDOW_MODES>( - Arrays.asList(WINDOW_MODES.values())); - float[] vertex = target.getFrameVertex(); - if (vertex[4] != -1.0f) { - modes.remove(WINDOW_MODES.RIGHT_TO_LEFT); - } - if (vertex[6] != 1.0f) { - modes.remove(WINDOW_MODES.LEFT_TO_RIGHT); - } - - // Random mode - int low = 0; - int high = modes.size() - 1; - mMode = modes.get(Utils.getNextRandom(low, high)); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isSelectable(PhotoFrame frame) { - float[] vertex = frame.getFrameVertex(); - if (vertex[4] == -1.0f || vertex[6] == 1.0f) { - return true; - } - return false; - } - - /** - * {@inheritDoc} - */ - @Override - public void reset() { - mTime = -1; - mRunning = true; - } - - /** - * {@inheritDoc} - */ - @Override - public void apply(float[] matrix) throws GLException { - // Check internal vars - if (mTarget == null || - mTarget.getPositionBuffer() == null || - mTarget.getTextureBuffer() == null) { - return; - } - if (mTransitionTarget == null || - mTransitionTarget.getPositionBuffer() == null || - mTransitionTarget.getTextureBuffer() == null) { - return; - } - - // Set the time the first time - if (mTime == -1) { - mTime = SystemClock.uptimeMillis(); - } - - // Calculate the delta time - final float delta = Math.min(SystemClock.uptimeMillis() - mTime, TRANSITION_TIME) / TRANSITION_TIME; - - // Apply the transition - applyDstTransition(matrix); - if (delta < 1) { - applySrcTransition(delta, matrix); - } - - // Transition ending - if (delta == 1) { - mRunning = false; - } - } - - /** - * Apply the source transition - * - * @param delta The delta time - * @param matrix The model-view-projection matrix - * @param target The photo frame target - */ - private void applySrcTransition(float delta, float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Set the program - useProgram(0); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // Set the input texture - int textureHandle = mTarget.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"); - - // Texture - FloatBuffer textureBuffer = mTarget.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[0], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - float[] vertex = cloneVertex(); - float interpolation = mInterpolation.getInterpolation(delta); - switch (mMode) { - case LEFT_TO_RIGHT: - vertex[1] -= interpolation * mAmount; - vertex[5] += interpolation * mAmount; - break; - case RIGHT_TO_LEFT: - vertex[3] -= interpolation * mAmount; - vertex[7] += interpolation * mAmount; - break; - default: - break; - } - ByteBuffer bb = ByteBuffer.allocateDirect(vertex.length * 4); // (# of coordinate values * 4 bytes per float) - bb.order(ByteOrder.nativeOrder()); - FloatBuffer positionBuffer = bb.asFloatBuffer(); - positionBuffer.put(vertex); - positionBuffer.position(0); - GLES20.glVertexAttribPointer(mPositionHandlers[0], 2, GLES20.GL_FLOAT, false, 0, positionBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[0]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Calculate the delta angle and the translation and rotate parameters - float angle = 0.0f; - float translateX = 0.0f; - float rotateY = 0.0f; - switch (mMode) { - case LEFT_TO_RIGHT: - angle = delta * 90; - rotateY = -1.0f; - translateX = mTarget.getFrameVertex()[2] * -1; - break; - case RIGHT_TO_LEFT: - angle = delta * -90; - rotateY = -1.0f; - translateX = mTarget.getFrameVertex()[0] * -1; - break; - - default: - break; - } - - // Apply the projection and view transformation - Matrix.setIdentityM(matrix, 0); - Matrix.translateM(mTranslationMatrix, 0, matrix, 0, -translateX, 0.0f, 0.0f); - Matrix.rotateM(mTranslationMatrix, 0, mTranslationMatrix, 0, angle, 0.0f, rotateY, 0.0f); - Matrix.translateM(mTranslationMatrix, 0, mTranslationMatrix, 0, translateX, 0.0f, 0.0f); - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[0], 1, false, mTranslationMatrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[0]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - - /** - * Apply the destination transition (just draw the image) - * - * @param matrix The model-view-projection matrix - */ - private void applyDstTransition(float[] matrix) { - // Bind default FBO - GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0); - GLESUtil.glesCheckError("glBindFramebuffer"); - - // Use our shader program - useProgram(1); - - // Disable blending - GLES20.glDisable(GLES20.GL_BLEND); - GLESUtil.glesCheckError("glDisable"); - - // Apply the projection and view transformation - GLES20.glUniformMatrix4fv(mMVPMatrixHandlers[1], 1, false, matrix, 0); - GLESUtil.glesCheckError("glUniformMatrix4fv"); - - // Texture - FloatBuffer textureBuffer = mTransitionTarget.getTextureBuffer(); - textureBuffer.position(0); - GLES20.glVertexAttribPointer(mTextureCoordHandlers[1], 2, GLES20.GL_FLOAT, false, 0, textureBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Position - FloatBuffer positionBuffer = mTransitionTarget.getPositionBuffer(); - positionBuffer.position(0); - GLES20.glVertexAttribPointer(mPositionHandlers[1], 2, GLES20.GL_FLOAT, false, 0, positionBuffer); - GLESUtil.glesCheckError("glVertexAttribPointer"); - GLES20.glEnableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glEnableVertexAttribArray"); - - // Set the input texture - int textureHandle = mTransitionTarget.getTextureHandle(); - GLES20.glActiveTexture(GLES20.GL_TEXTURE0); - GLESUtil.glesCheckError("glActiveTexture"); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle); - GLESUtil.glesCheckError("glBindTexture"); - GLES20.glUniform1i(mTextureHandlers[1], 0); - GLESUtil.glesCheckError("glUniform1i"); - - // Draw - GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); - GLESUtil.glesCheckError("glDrawElements"); - - // Disable attributes - GLES20.glDisableVertexAttribArray(mPositionHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - GLES20.glDisableVertexAttribArray(mTextureCoordHandlers[1]); - GLESUtil.glesCheckError("glDisableVertexAttribArray"); - } - - /** - * Method that copy the vertex array - * - * @return The copy of the vertex - */ - private float[] cloneVertex() { - float[] originalVertex = mTarget.getFrameVertex(); - float[] vertex = new float[originalVertex.length]; - System.arraycopy(originalVertex, 0, vertex, 0, originalVertex.length); - return vertex; - } - - /** - * Return the scale amount to apply to the transition - * - * @return float The scale amount - */ - private float getAmount() { - return ((mTarget.getFrameWidth() * SCALE_AMOUNT) / 2); - } -} |