summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-01-04 11:40:14 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-04 11:40:14 -0800
commit6d978d6d2e49b253cc983e2543aec813686c4a7c (patch)
treeb09c7f5f1f3cec6ba18ab36d5d7fc79ce90e2211
parent1ffb17767b50c392e038695658cfc484766ad388 (diff)
parent352cc98b4621b76959af8f8a698fd75c6d6132e8 (diff)
downloadframeworks_base-6d978d6d2e49b253cc983e2543aec813686c4a7c.zip
frameworks_base-6d978d6d2e49b253cc983e2543aec813686c4a7c.tar.gz
frameworks_base-6d978d6d2e49b253cc983e2543aec813686c4a7c.tar.bz2
Merge "Few little fragment, wm tweaks."
-rw-r--r--core/java/android/app/Fragment.java4
-rw-r--r--core/java/android/app/FragmentManager.java2
-rw-r--r--services/java/com/android/server/ScreenRotationAnimation.java114
3 files changed, 73 insertions, 47 deletions
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index a920814..3141423 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -98,6 +98,7 @@ final class FragmentState implements Parcelable {
}
mInstance.setIndex(mIndex);
mInstance.mFromLayout = mFromLayout;
+ mInstance.mRestored = true;
mInstance.mFragmentId = mFragmentId;
mInstance.mContainerId = mContainerId;
mInstance.mTag = mTag;
@@ -363,6 +364,9 @@ public class Fragment implements ComponentCallbacks, OnCreateContextMenuListener
// Set to true when the view has actually been inflated in its layout.
boolean mInLayout;
+ // True if this fragment has been restored from previously saved state.
+ boolean mRestored;
+
// Number of active back stack entries this fragment is in.
int mBackStackNesting;
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 3c98d67..2609c46 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -690,7 +690,7 @@ final class FragmentManagerImpl extends FragmentManager {
ViewGroup container = null;
if (f.mContainerId != 0) {
container = (ViewGroup)mActivity.findViewById(f.mContainerId);
- if (container == null) {
+ if (container == null && !f.mRestored) {
throw new IllegalArgumentException("No view found for id 0x"
+ Integer.toHexString(f.mContainerId)
+ " for fragment " + f);
diff --git a/services/java/com/android/server/ScreenRotationAnimation.java b/services/java/com/android/server/ScreenRotationAnimation.java
index ced7c7b..19cc203 100644
--- a/services/java/com/android/server/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/ScreenRotationAnimation.java
@@ -40,6 +40,7 @@ class ScreenRotationAnimation {
final Context mContext;
final Display mDisplay;
Surface mSurface;
+ Surface mBlackSurface;
int mWidth, mHeight;
int mSnapshotRotation;
@@ -84,42 +85,55 @@ class ScreenRotationAnimation {
mOriginalHeight = mDisplayMetrics.heightPixels;
Surface.openTransaction();
- if (mSurface != null) {
- mSurface.destroy();
- mSurface = null;
- }
+
try {
mSurface = new Surface(session, 0, "FreezeSurface",
-1, mWidth, mHeight, PixelFormat.OPAQUE, 0);
+ mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 200);
} catch (Surface.OutOfResourcesException e) {
Slog.w(TAG, "Unable to allocate freeze surface", e);
}
- mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 200);
- setRotation(display.getRotation());
-
- Rect dirty = new Rect(0, 0, mWidth, mHeight);
- Canvas c = null;
- try {
- c = mSurface.lockCanvas(dirty);
- } catch (IllegalArgumentException e) {
- Slog.w(TAG, "Unable to lock surface", e);
- return;
- } catch (Surface.OutOfResourcesException e) {
- Slog.w(TAG, "Unable to lock surface", e);
- return;
- }
- if (c == null) {
- Slog.w(TAG, "Null surface");
- return;
+
+ if (false) {
+ try {
+ int size = mOriginalWidth > mOriginalHeight ? mOriginalWidth : mOriginalHeight;
+ mBlackSurface = new Surface(session, 0, "BlackSurface",
+ -1, size, size, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM);
+ mBlackSurface.setAlpha(1.0f);
+ mBlackSurface.setLayer(0);
+ } catch (Surface.OutOfResourcesException e) {
+ Slog.w(TAG, "Unable to allocate black surface", e);
+ }
}
+
+ setRotation(display.getRotation());
- if (screenshot != null) {
- c.drawBitmap(screenshot, 0, 0, new Paint(0));
- } else {
- c.drawColor(Color.GREEN);
+ if (mSurface != null) {
+ Rect dirty = new Rect(0, 0, mWidth, mHeight);
+ Canvas c = null;
+ try {
+ c = mSurface.lockCanvas(dirty);
+ } catch (IllegalArgumentException e) {
+ Slog.w(TAG, "Unable to lock surface", e);
+ return;
+ } catch (Surface.OutOfResourcesException e) {
+ Slog.w(TAG, "Unable to lock surface", e);
+ return;
+ }
+ if (c == null) {
+ Slog.w(TAG, "Null surface");
+ return;
+ }
+
+ if (screenshot != null) {
+ c.drawBitmap(screenshot, 0, 0, new Paint(0));
+ } else {
+ c.drawColor(Color.GREEN);
+ }
+
+ mSurface.unlockCanvasAndPost(c);
}
-
- mSurface.unlockCanvasAndPost(c);
+
Surface.closeTransaction();
if (screenshot != null) {
@@ -134,21 +148,23 @@ class ScreenRotationAnimation {
}
void setSnapshotTransform(Matrix matrix, float alpha) {
- matrix.getValues(mTmpFloats);
- mSurface.setPosition((int)mTmpFloats[Matrix.MTRANS_X],
- (int)mTmpFloats[Matrix.MTRANS_Y]);
- mSurface.setMatrix(
- mTmpFloats[Matrix.MSCALE_X], mTmpFloats[Matrix.MSKEW_Y],
- mTmpFloats[Matrix.MSKEW_X], mTmpFloats[Matrix.MSCALE_Y]);
- mSurface.setAlpha(alpha);
- if (DEBUG) {
- float[] srcPnts = new float[] { 0, 0, mWidth, mHeight };
- float[] dstPnts = new float[4];
- matrix.mapPoints(dstPnts, srcPnts);
- Slog.i(TAG, "Original : (" + srcPnts[0] + "," + srcPnts[1]
- + ")-(" + srcPnts[2] + "," + srcPnts[3] + ")");
- Slog.i(TAG, "Transformed: (" + dstPnts[0] + "," + dstPnts[1]
- + ")-(" + dstPnts[2] + "," + dstPnts[3] + ")");
+ if (mSurface != null) {
+ matrix.getValues(mTmpFloats);
+ mSurface.setPosition((int)mTmpFloats[Matrix.MTRANS_X],
+ (int)mTmpFloats[Matrix.MTRANS_Y]);
+ mSurface.setMatrix(
+ mTmpFloats[Matrix.MSCALE_X], mTmpFloats[Matrix.MSKEW_Y],
+ mTmpFloats[Matrix.MSKEW_X], mTmpFloats[Matrix.MSCALE_Y]);
+ mSurface.setAlpha(alpha);
+ if (DEBUG) {
+ float[] srcPnts = new float[] { 0, 0, mWidth, mHeight };
+ float[] dstPnts = new float[4];
+ matrix.mapPoints(dstPnts, srcPnts);
+ Slog.i(TAG, "Original : (" + srcPnts[0] + "," + srcPnts[1]
+ + ")-(" + srcPnts[2] + "," + srcPnts[3] + ")");
+ Slog.i(TAG, "Transformed: (" + dstPnts[0] + "," + dstPnts[1]
+ + ")-(" + dstPnts[2] + "," + dstPnts[3] + ")");
+ }
}
}
@@ -254,6 +270,10 @@ class ScreenRotationAnimation {
mSurface.destroy();
mSurface = null;
}
+ if (mBlackSurface != null) {
+ mBlackSurface.destroy();
+ mBlackSurface = null;
+ }
if (mExitAnimation != null) {
mExitAnimation.cancel();
mExitAnimation = null;
@@ -293,6 +313,10 @@ class ScreenRotationAnimation {
mSurface.destroy();
mSurface = null;
}
+ if (mBlackSurface != null) {
+ mBlackSurface.destroy();
+ mBlackSurface = null;
+ }
}
}
@@ -307,10 +331,8 @@ class ScreenRotationAnimation {
}
}
- if (mSurface != null) {
- mSnapshotFinalMatrix.setConcat(mExitTransformation.getMatrix(), mSnapshotInitialMatrix);
- setSnapshotTransform(mSnapshotFinalMatrix, mExitTransformation.getAlpha());
- }
+ mSnapshotFinalMatrix.setConcat(mExitTransformation.getMatrix(), mSnapshotInitialMatrix);
+ setSnapshotTransform(mSnapshotFinalMatrix, mExitTransformation.getAlpha());
return moreEnter || moreExit;
}