diff options
author | Mathias Agopian <> | 2009-03-27 16:10:37 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-27 16:10:37 -0700 |
commit | 66b8ec99c5fc505877b3711a52e284bbb451f836 (patch) | |
tree | 7551907d6083bcd455632f84f528cbd4d06ffd04 | |
parent | 1e880dba106b14619c3eaf94c5dc2d1a943645bc (diff) | |
download | frameworks_base-66b8ec99c5fc505877b3711a52e284bbb451f836.zip frameworks_base-66b8ec99c5fc505877b3711a52e284bbb451f836.tar.gz frameworks_base-66b8ec99c5fc505877b3711a52e284bbb451f836.tar.bz2 |
AI 143171: am: CL 142873 fix [1732012] Only show screen rotation animation when triggered by sensor
Original author: mathias
Merged from: //branches/cupcake/...
Automated import of CL 143171
-rw-r--r-- | core/java/android/view/Surface.java | 19 | ||||
-rw-r--r-- | core/jni/android_view_Surface.cpp | 6 | ||||
-rw-r--r-- | include/ui/ISurfaceComposer.h | 7 | ||||
-rw-r--r-- | include/ui/SurfaceComposerClient.h | 2 | ||||
-rw-r--r-- | libs/surfaceflinger/OrientationAnimation.cpp | 31 | ||||
-rw-r--r-- | libs/surfaceflinger/OrientationAnimation.h | 18 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.cpp | 9 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.h | 3 | ||||
-rw-r--r-- | libs/ui/ISurfaceComposer.cpp | 6 | ||||
-rw-r--r-- | libs/ui/SurfaceComposerClient.cpp | 5 |
10 files changed, 73 insertions, 33 deletions
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 54ccf33..0178d63 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -118,6 +118,12 @@ public class Surface implements Parcelable { public static final int ROTATION_180 = 2; public static final int ROTATION_270 = 3; + /** + * Disable the orientation animation + * {@hide} + */ + public static final int FLAGS_ORIENTATION_ANIMATION_DISABLE = 0x000000001; + @SuppressWarnings("unused") private int mSurface; @SuppressWarnings("unused") @@ -226,10 +232,21 @@ public class Surface implements Parcelable { * set the orientation of the given display. * @param display * @param orientation + * @param flags + * {@hide} */ - public static native void setOrientation(int display, int orientation); + public static native void setOrientation(int display, int orientation, int flags); /** + * set the orientation of the given display. + * @param display + * @param orientation + */ + public static void setOrientation(int display, int orientation) { + setOrientation(display, orientation, 0); + } + + /** * set surface parameters. * needs to be inside open/closeTransaction block */ diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index 8baaa84..076775f 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -324,9 +324,9 @@ static void Surface_closeTransaction( } static void Surface_setOrientation( - JNIEnv* env, jobject clazz, jint display, jint orientation) + JNIEnv* env, jobject clazz, jint display, jint orientation, jint flags) { - int err = SurfaceComposerClient::setOrientation(display, orientation); + int err = SurfaceComposerClient::setOrientation(display, orientation, flags); if (err < 0) { doThrow(env, "java/lang/IllegalArgumentException", NULL); } @@ -565,7 +565,7 @@ static JNINativeMethod gSurfaceMethods[] = { {"unlockCanvas", "(Landroid/graphics/Canvas;)V", (void*)Surface_unlockCanvas }, {"openTransaction", "()V", (void*)Surface_openTransaction }, {"closeTransaction", "()V", (void*)Surface_closeTransaction }, - {"setOrientation", "(II)V", (void*)Surface_setOrientation }, + {"setOrientation", "(III)V", (void*)Surface_setOrientation }, {"freezeDisplay", "(I)V", (void*)Surface_freezeDisplay }, {"unfreezeDisplay", "(I)V", (void*)Surface_unfreezeDisplay }, {"setLayer", "(I)V", (void*)Surface_setLayer }, diff --git a/include/ui/ISurfaceComposer.h b/include/ui/ISurfaceComposer.h index f9eeb30..5c64b22 100644 --- a/include/ui/ISurfaceComposer.h +++ b/include/ui/ISurfaceComposer.h @@ -81,6 +81,11 @@ public: eOrientation270 = 3, eOrientationSwapMask = 0x01 }; + + // flags for setOrientation + enum { + eOrientationAnimationDisable = 0x00000001 + }; /* create connection with surface flinger, requires * ACCESS_SURFACE_FLINGER permission @@ -100,7 +105,7 @@ public: virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0; /* Set display orientation. recquires ACCESS_SURFACE_FLINGER permission */ - virtual int setOrientation(DisplayID dpy, int orientation) = 0; + virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0; /* signal that we're done booting. * recquires ACCESS_SURFACE_FLINGER permission diff --git a/include/ui/SurfaceComposerClient.h b/include/ui/SurfaceComposerClient.h index 5d9222d..76a3b55 100644 --- a/include/ui/SurfaceComposerClient.h +++ b/include/ui/SurfaceComposerClient.h @@ -97,7 +97,7 @@ public: static status_t unfreezeDisplay(DisplayID dpy, uint32_t flags = 0); //! Set the orientation of the given display - static int setOrientation(DisplayID dpy, int orientation); + static int setOrientation(DisplayID dpy, int orientation, uint32_t flags); // Query the number of displays static ssize_t getNumberOfDisplays(); diff --git a/libs/surfaceflinger/OrientationAnimation.cpp b/libs/surfaceflinger/OrientationAnimation.cpp index e59688e..70eec8d 100644 --- a/libs/surfaceflinger/OrientationAnimation.cpp +++ b/libs/surfaceflinger/OrientationAnimation.cpp @@ -44,10 +44,14 @@ OrientationAnimation::~OrientationAnimation() { } -void OrientationAnimation::onOrientationChanged() +void OrientationAnimation::onOrientationChanged(uint32_t type) { - if (mState == DONE) - mState = PREPARE; + if (mState == DONE) { + mType = type; + if (!(type & ISurfaceComposer::eOrientationAnimationDisable)) { + mState = PREPARE; + } + } } void OrientationAnimation::onAnimationFinished() @@ -82,14 +86,7 @@ bool OrientationAnimation::run_impl() bool OrientationAnimation::done() { - if (mFlinger->isFrozen()) { - // we are not allowed to draw, but pause a bit to make sure - // apps don't end up using the whole CPU, if they depend on - // surfaceflinger for synchronization. - usleep(8333); // 8.3ms ~ 120fps - return true; - } - return false; + return done_impl(); } bool OrientationAnimation::prepare() @@ -115,11 +112,13 @@ bool OrientationAnimation::prepare() LayerOrientationAnimBase* l; - l = new LayerOrientationAnim( - mFlinger.get(), 0, this, bitmap, bitmapIn); - - //l = new LayerOrientationAnimRotate( - // mFlinger.get(), 0, this, bitmap, bitmapIn); + if (mType & 0x80) { + l = new LayerOrientationAnimRotate( + mFlinger.get(), 0, this, bitmap, bitmapIn); + } else { + l = new LayerOrientationAnim( + mFlinger.get(), 0, this, bitmap, bitmapIn); + } l->initStates(w, h, 0); l->setLayer(INT_MAX-1); diff --git a/libs/surfaceflinger/OrientationAnimation.h b/libs/surfaceflinger/OrientationAnimation.h index b170dcb..cafa38d 100644 --- a/libs/surfaceflinger/OrientationAnimation.h +++ b/libs/surfaceflinger/OrientationAnimation.h @@ -36,11 +36,11 @@ public: OrientationAnimation(const sp<SurfaceFlinger>& flinger); virtual ~OrientationAnimation(); - void onOrientationChanged(); + void onOrientationChanged(uint32_t type); void onAnimationFinished(); inline bool run() { if (LIKELY(mState == DONE)) - return false; + return done_impl(); return run_impl(); } @@ -54,7 +54,18 @@ private: }; bool run_impl(); - bool done(); + inline bool done_impl() { + if (mFlinger->isFrozen()) { + // we are not allowed to draw, but pause a bit to make sure + // apps don't end up using the whole CPU, if they depend on + // surfaceflinger for synchronization. + usleep(8333); // 8.3ms ~ 120fps + return true; + } + return false; + } + + bool done(); bool prepare(); bool phase1(); bool phase2(); @@ -64,6 +75,7 @@ private: sp<MemoryDealer> mTemporaryDealer; LayerOrientationAnimBase* mLayerOrientationAnim; int mState; + uint32_t mType; }; // --------------------------------------------------------------------------- diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index 8499b67..de64f55 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -655,6 +655,7 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags) const int dpy = 0; const int orientation = mCurrentState.orientation; + const uint32_t type = mCurrentState.orientationType; GraphicPlane& plane(graphicPlane(dpy)); plane.setOrientation(orientation); @@ -673,8 +674,8 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags) mVisibleRegionsDirty = true; mDirtyRegion.set(hw.bounds()); - - mOrientationAnimation->onOrientationChanged(); + mFreezeDisplayTime = 0; + mOrientationAnimation->onOrientationChanged(type); } if (mCurrentState.freezeDisplay != mDrawingState.freezeDisplay) { @@ -1201,7 +1202,8 @@ status_t SurfaceFlinger::unfreezeDisplay(DisplayID dpy, uint32_t flags) return NO_ERROR; } -int SurfaceFlinger::setOrientation(DisplayID dpy, int orientation) +int SurfaceFlinger::setOrientation(DisplayID dpy, + int orientation, uint32_t flags) { if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT)) return BAD_VALUE; @@ -1209,6 +1211,7 @@ int SurfaceFlinger::setOrientation(DisplayID dpy, int orientation) Mutex::Autolock _l(mStateLock); if (mCurrentState.orientation != orientation) { if (uint32_t(orientation)<=eOrientation270 || orientation==42) { + mCurrentState.orientationType = flags; mCurrentState.orientation = orientation; setTransactionFlags(eTransactionNeeded); mTransactionCV.wait(mStateLock); diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h index 3c10481..e023182 100644 --- a/libs/surfaceflinger/SurfaceFlinger.h +++ b/libs/surfaceflinger/SurfaceFlinger.h @@ -167,7 +167,7 @@ public: virtual void closeGlobalTransaction(); virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags); virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags); - virtual int setOrientation(DisplayID dpy, int orientation); + virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags); virtual void signal() const; virtual status_t requestGPU(const sp<IGPUCallback>& callback, gpu_info_t* gpu); @@ -244,6 +244,7 @@ private: } LayerVector layersSortedByZ; uint8_t orientation; + uint8_t orientationType; uint8_t freezeDisplay; }; diff --git a/libs/ui/ISurfaceComposer.cpp b/libs/ui/ISurfaceComposer.cpp index 0fea6f9..76597e1 100644 --- a/libs/ui/ISurfaceComposer.cpp +++ b/libs/ui/ISurfaceComposer.cpp @@ -96,12 +96,13 @@ public: return reply.readInt32(); } - virtual int setOrientation(DisplayID dpy, int orientation) + virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeInt32(dpy); data.writeInt32(orientation); + data.writeInt32(flags); remote()->transact(BnSurfaceComposer::SET_ORIENTATION, data, &reply); return reply.readInt32(); } @@ -184,7 +185,8 @@ status_t BnSurfaceComposer::onTransact( case SET_ORIENTATION: { DisplayID dpy = data.readInt32(); int orientation = data.readInt32(); - reply->writeInt32( setOrientation(dpy, orientation) ); + uint32_t flags = data.readInt32(); + reply->writeInt32( setOrientation(dpy, orientation, flags) ); } break; case FREEZE_DISPLAY: { DisplayID dpy = data.readInt32(); diff --git a/libs/ui/SurfaceComposerClient.cpp b/libs/ui/SurfaceComposerClient.cpp index 9354a7a..fe803ff 100644 --- a/libs/ui/SurfaceComposerClient.cpp +++ b/libs/ui/SurfaceComposerClient.cpp @@ -813,10 +813,11 @@ status_t SurfaceComposerClient::unfreezeDisplay(DisplayID dpy, uint32_t flags) return sm->unfreezeDisplay(dpy, flags); } -int SurfaceComposerClient::setOrientation(DisplayID dpy, int orientation) +int SurfaceComposerClient::setOrientation(DisplayID dpy, + int orientation, uint32_t flags) { const sp<ISurfaceComposer>& sm(_get_surface_manager()); - return sm->setOrientation(dpy, orientation); + return sm->setOrientation(dpy, orientation, flags); } status_t SurfaceComposerClient::openTransaction() |