summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-10-17 14:50:47 -0700
committerBobby Georgescu <georgescu@google.com>2012-10-17 17:14:22 -0700
commit2ba8604e8f1a8faf0e692706c3103cc889142583 (patch)
tree6c8700c0959eeb4fefe4a829c3fbb08c27b98d22 /src/com/android/gallery3d/ui
parent591ba8d027d574f1e9fedaf878d3b7b41ebe4861 (diff)
downloadandroid_packages_apps_Snap-2ba8604e8f1a8faf0e692706c3103cc889142583.tar.gz
android_packages_apps_Snap-2ba8604e8f1a8faf0e692706c3103cc889142583.tar.bz2
android_packages_apps_Snap-2ba8604e8f1a8faf0e692706c3103cc889142583.zip
Big refactor, additions to state transition animations
Bug: 7362944 Refactored a lot of the state transitions code, adding support for definable transition animations and defining distinct outgoing and incoming animations. Change-Id: I31a69057ea1b72dd3185cec656e59b11fdb528c1
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/GLView.java40
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java2
-rw-r--r--src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java38
3 files changed, 44 insertions, 36 deletions
diff --git a/src/com/android/gallery3d/ui/GLView.java b/src/com/android/gallery3d/ui/GLView.java
index b91b71212..664012c5a 100644
--- a/src/com/android/gallery3d/ui/GLView.java
+++ b/src/com/android/gallery3d/ui/GLView.java
@@ -78,10 +78,8 @@ public class GLView {
protected int mScrollHeight = 0;
protected int mScrollWidth = 0;
- public static final int ANIM_TIME_OPENING = 400;
- private RawTexture mFadeOutTexture;
private float [] mBackgroundColor;
- private StateTransitionAnimation mTransition = new StateTransitionAnimation(ANIM_TIME_OPENING);
+ private StateTransitionAnimation mTransition;
public void startAnimation(CanvasAnimation animation) {
GLRoot root = getGLRoot();
@@ -223,22 +221,28 @@ public class GLView {
}
protected void render(GLCanvas canvas) {
- if (mTransition.calculate(AnimationTime.get())) invalidate();
- canvas.save();
+ boolean transitionActive = false;
+ if (mTransition != null && mTransition.calculate(AnimationTime.get())) {
+ invalidate();
+ transitionActive = mTransition.isActive();
+ }
renderBackground(canvas);
- if (mTransition.isActive()) mTransition.applyForegroundTransformation(this, canvas);
+ canvas.save();
+ if (transitionActive) {
+ mTransition.applyContentTransform(this, canvas);
+ }
for (int i = 0, n = getComponentCount(); i < n; ++i) {
renderChild(canvas, getComponent(i));
}
canvas.restore();
+ if (transitionActive) {
+ mTransition.applyOverlay(this, canvas);
+ }
}
- public void setFadeOutTexture(RawTexture texture) {
- mFadeOutTexture = texture;
- if (mFadeOutTexture != null) {
- TiledScreenNail.disableDrawPlaceholder();
- }
- mTransition.start();
+ public void setIntroAnimation(StateTransitionAnimation intro) {
+ mTransition = intro;
+ if (mTransition != null) mTransition.start();
}
public float [] getBackgroundColor() {
@@ -253,15 +257,9 @@ public class GLView {
if (mBackgroundColor != null) {
view.clearBuffer(mBackgroundColor);
}
- if (mFadeOutTexture != null) {
- if (!mTransition.isActive()) {
- mFadeOutTexture.recycle();
- mFadeOutTexture = null;
- TiledScreenNail.enableDrawPlaceholder();
- } else {
- mTransition.applyBackground(this, view, mFadeOutTexture);
- return;
- }
+ if (mTransition != null && mTransition.isActive()) {
+ mTransition.applyBackground(this, view);
+ return;
}
}
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index 0111847eb..6a4bcea87 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -67,7 +67,7 @@ class PositionController {
SNAPBACK_ANIMATION_TIME, // ANIM_KIND_SNAPBACK
400, // ANIM_KIND_SLIDE
300, // ANIM_KIND_ZOOM
- GLView.ANIM_TIME_OPENING, // ANIM_KIND_OPENING
+ 300, // ANIM_KIND_OPENING
0, // ANIM_KIND_FLING (the duration is calculated dynamically)
0, // ANIM_KIND_FLING_X (see the comment above)
0, // ANIM_KIND_DELETE (the duration is calculated dynamically)
diff --git a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
index 5152fc9bb..36e7f4b82 100644
--- a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
+++ b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java
@@ -6,7 +6,7 @@ import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.ui.GLRoot.OnGLIdleListener;
public class PreparePageFadeoutTexture implements OnGLIdleListener {
- private static final long TIMEOUT = 500;
+ private static final long TIMEOUT = 200;
public static final String KEY_FADE_TEXTURE = "fade_texture";
private RawTexture mTexture;
@@ -15,10 +15,20 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener {
private GLView mRootPane;
public PreparePageFadeoutTexture(GLView rootPane) {
- mTexture = new RawTexture(rootPane.getWidth(), rootPane.getHeight(), true);
+ int w = rootPane.getWidth();
+ int h = rootPane.getHeight();
+ if (w == 0 || h == 0) {
+ mCancelled = true;
+ return;
+ }
+ mTexture = new RawTexture(w, h, true);
mRootPane = rootPane;
}
+ public boolean isCancelled() {
+ return mCancelled;
+ }
+
public synchronized RawTexture get() {
if (mCancelled) {
return null;
@@ -32,25 +42,26 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener {
@Override
public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) {
- if(!mCancelled) {
+ if (!mCancelled) {
+ try {
canvas.beginRenderTarget(mTexture);
mRootPane.render(canvas);
canvas.endRenderTarget();
- } else {
+ } catch (RuntimeException e) {
mTexture = null;
}
- mResultReady.open();
- return false;
+ } else {
+ mTexture = null;
+ }
+ mResultReady.open();
+ return false;
}
- public static boolean prepareFadeOutTexture(AbstractGalleryActivity activity,
+ public static void prepareFadeOutTexture(AbstractGalleryActivity activity,
GLView rootPane) {
- if (rootPane.getWidth() == 0 || rootPane.getHeight() == 0) {
- // The view hasn't been measured yet, just abort the animation
- return false;
- }
- GLRoot root = activity.getGLRoot();
PreparePageFadeoutTexture task = new PreparePageFadeoutTexture(rootPane);
+ if (task.isCancelled()) return;
+ GLRoot root = activity.getGLRoot();
RawTexture texture = null;
root.unlockRenderThread();
try {
@@ -61,9 +72,8 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener {
}
if (texture == null) {
- return false;
+ return;
}
activity.getTransitionStore().put(KEY_FADE_TEXTURE, texture);
- return true;
}
}