aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-08-16 23:46:27 +0200
committerJorge Ruesga <jorge@ruesga.com>2013-08-16 23:46:27 +0200
commit08b009e713d2bbe5577d4da4e02bf03cbe078b38 (patch)
treeb54e7f5391fb07a75a00f4c9c8f51eaef4829d8c /src
parent3c1c6d8f7f80a242a822bae20435852e147db02a (diff)
downloadandroid_packages_wallpapers_PhotoPhase-08b009e713d2bbe5577d4da4e02bf03cbe078b38.tar.gz
android_packages_wallpapers_PhotoPhase-08b009e713d2bbe5577d4da4e02bf03cbe078b38.tar.bz2
android_packages_wallpapers_PhotoPhase-08b009e713d2bbe5577d4da4e02bf03cbe078b38.zip
Revert 3c1c6d8f7f80a242a822bae20435852e147db02a
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src')
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java4
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseWallpaperWorld.java77
2 files changed, 26 insertions, 55 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java
index fbb4160..6432767 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseRenderer.java
@@ -290,7 +290,7 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer {
if (touchAction.compareTo(TouchAction.TRANSITION) == 0) {
try {
// Check if the frame has pending transitions
- if (mWorld.hasRunningTransition(frame)) {
+ if (!mWorld.hasRunningTransition(frame)) {
Log.w(TAG, "The frame has pending transitions " + frame.getTextureInfo().path);
return;
}
@@ -533,7 +533,6 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer {
if (mWorld != null) {
// Now draw the world (all the photo frames with effects)
mWorld.draw(mMVPMatrix);
- mWorld.deselectAllFinishedTransition(mMVPMatrix);
// Check if we have some pending transition or transition has exceed its timeout
if (!mWorld.hasRunningTransition() || firedTransitionTimeout()) {
@@ -541,6 +540,7 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer {
// Now start a delayed thread to generate the next effect
mHandler.removeCallbacks(mTransitionThread);
+ mWorld.deselectTransition(mMVPMatrix);
mLastRunningTransition = 0;
mHandler.postDelayed(mTransitionThread,
Preferences.General.Transitions.getTransitionInterval());
diff --git a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseWallpaperWorld.java b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseWallpaperWorld.java
index f8bb7d4..815ddc6 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseWallpaperWorld.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/PhotoPhaseWallpaperWorld.java
@@ -26,7 +26,6 @@ import android.util.Log;
import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil.GLESTextureInfo;
import org.cyanogenmod.wallpapers.photophase.model.Disposition;
import org.cyanogenmod.wallpapers.photophase.preferences.PreferencesProvider.Preferences;
-import org.cyanogenmod.wallpapers.photophase.transitions.NullTransition;
import org.cyanogenmod.wallpapers.photophase.transitions.Transition;
import org.cyanogenmod.wallpapers.photophase.transitions.Transitions;
import org.cyanogenmod.wallpapers.photophase.transitions.Transitions.TRANSITIONS;
@@ -56,6 +55,7 @@ public class PhotoPhaseWallpaperWorld {
private List<Integer> mTransitionsQueue;
private List<Integer> mUsedTransitionsQueue;
+ private int mCurrent;
private int mWidth;
private int mHeight;
@@ -73,6 +73,7 @@ public class PhotoPhaseWallpaperWorld {
super();
mContext = ctx;
mTextureManager = textureManager;
+ mCurrent = -1;
mUnusedTransitions = new ArrayList<Transition>();
mRecycled = false;
}
@@ -127,14 +128,10 @@ public class PhotoPhaseWallpaperWorld {
ensureTransitionsQueue();
// Get a random frame to which apply the transition
- PhotoFrame frame = null;
- int pos = -1;
- synchronized(mTransitions) {
- int item = Utils.getNextRandom(0, mTransitionsQueue.size() - 1);
- pos = mTransitionsQueue.remove(item).intValue();
- mUsedTransitionsQueue.add(Integer.valueOf(pos));
- frame = mPhotoFrames.get(pos);
- }
+ int item = Utils.getNextRandom(0, mTransitionsQueue.size() - 1);
+ int pos = mTransitionsQueue.remove(item).intValue();
+ mUsedTransitionsQueue.add(Integer.valueOf(pos));
+ PhotoFrame frame = mPhotoFrames.get(pos);
// Select the transition
selectTransition(frame, pos);
@@ -149,15 +146,10 @@ public class PhotoPhaseWallpaperWorld {
// Ensure queue
ensureTransitionsQueue();
- // Select the transition
- int pos = -1;
- synchronized(mTransitions) {
- pos = mPhotoFrames.indexOf(frame);
- if (mTransitionsQueue.contains(Integer.valueOf(pos))) {
- mTransitionsQueue.remove(Integer.valueOf(pos));
- mUsedTransitionsQueue.add(Integer.valueOf(pos));
- }
- }
+ // Get a random frame to which apply the transition
+ int pos = mPhotoFrames.indexOf(frame);
+ mTransitionsQueue.remove(Integer.valueOf(pos));
+ mUsedTransitionsQueue.add(Integer.valueOf(pos));
// Select the transition
selectTransition(frame, pos);
@@ -190,48 +182,34 @@ public class PhotoPhaseWallpaperWorld {
}
mTransitions.set(pos, transition);
transition.select(frame);
+ mCurrent = pos;
}
/**
- * Method that deselect all the finished transitions.
+ * Method that deselect the current transition.
*
* @param matrix The model-view-projection matrix
*/
- public void deselectAllFinishedTransition(float[] matrix) {
- if (mTransitions != null) {
- for (Transition transition : mTransitions) {
- if (!(transition instanceof NullTransition) && !transition.isRunning()) {
- deselectTransition(matrix, mTransitions.indexOf(transition));
- }
- }
- }
- }
-
- /**
- * Method that deselect a transition.
- *
- * @param matrix The model-view-projection matrix
- * @param pos The position of the transition
- */
- public void deselectTransition(float[] matrix, int pos) {
- if (pos >= 0 && pos < mTransitions.size()) {
+ public void deselectTransition(float[] matrix) {
+ if (mCurrent != -1 && mCurrent < mTransitions.size()) {
// Retrieve the finally target
- Transition currentTransition = mTransitions.get(pos);
+ Transition currentTransition = mTransitions.get(mCurrent);
PhotoFrame currentTarget = currentTransition.getTarget();
PhotoFrame finalTarget = currentTransition.getTransitionTarget();
mUnusedTransitions.add(currentTransition);
if (finalTarget != null) {
Transition transition = getOrCreateTransition(TRANSITIONS.NO_TRANSITION, finalTarget);
- mTransitions.set(pos, transition);
+ mTransitions.set(mCurrent, transition);
currentTarget.recycle();
- mPhotoFrames.set(pos, finalTarget);
+ mPhotoFrames.set(mCurrent, finalTarget);
transition.select(finalTarget);
// Draw the transition once
transition.apply(matrix);
}
+ mCurrent = -1;
}
}
@@ -248,6 +226,7 @@ public class PhotoPhaseWallpaperWorld {
mTransitions.remove(i);
}
}
+ mCurrent = -1;
if (mUnusedTransitions != null) {
int cc = mUnusedTransitions.size() - 1;
for (int i = cc; i >= 0; i--) {
@@ -284,11 +263,9 @@ public class PhotoPhaseWallpaperWorld {
*/
public boolean hasRunningTransition() {
if (mTransitions != null) {
- synchronized (mTransitions) {
- for (Transition transition : mTransitions) {
- if (transition.isRunning() && !(transition instanceof NullTransition)) {
- return true;
- }
+ for (Transition transition : mTransitions) {
+ if (transition.isRunning()) {
+ return true;
}
}
}
@@ -306,15 +283,9 @@ public class PhotoPhaseWallpaperWorld {
if (pos == -1) {
throw new NotFoundException();
}
- synchronized (mTransitions) {
- for (Transition transition : mTransitions) {
- if (!transition.isRunning() && !(transition instanceof NullTransition) &&
- transition.getTarget() != null && transition.getTarget().equals(frame)) {
- return true;
- }
- }
+ synchronized (mUsedTransitionsQueue) {
+ return mUsedTransitionsQueue.indexOf(Integer.valueOf(pos)) != -1;
}
- return false;
}
/**