diff options
author | Jamie Gennis <jgennis@google.com> | 2011-10-12 13:03:11 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-12 13:03:11 -0700 |
commit | 075e4c3d2e6a8a9eb3506dfedc8da938fb65fb65 (patch) | |
tree | 3ad3b103a9c8f8d1447405e6475c7ccb2bc63229 | |
parent | 87228cd7bb9a39e2bb33a767d214c8d834f840df (diff) | |
parent | e2909e121c45d58fe587849b1474c80745fcd2b9 (diff) | |
download | frameworks_base-075e4c3d2e6a8a9eb3506dfedc8da938fb65fb65.zip frameworks_base-075e4c3d2e6a8a9eb3506dfedc8da938fb65fb65.tar.gz frameworks_base-075e4c3d2e6a8a9eb3506dfedc8da938fb65fb65.tar.bz2 |
Merge "SurfaceFlinger: update orientation via transactions" into ics-mr0
-rw-r--r-- | include/surfaceflinger/ISurfaceComposer.h | 12 | ||||
-rw-r--r-- | include/surfaceflinger/SurfaceComposerClient.h | 1 | ||||
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 55 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 39 | ||||
-rw-r--r-- | services/java/com/android/server/wm/WindowManagerService.java | 39 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 14 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 3 |
7 files changed, 64 insertions, 99 deletions
diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h index e0f4cf9..ea022a6 100644 --- a/include/surfaceflinger/ISurfaceComposer.h +++ b/include/surfaceflinger/ISurfaceComposer.h @@ -80,6 +80,7 @@ public: eOrientation90 = 1, eOrientation180 = 2, eOrientation270 = 3, + eOrientationUnchanged = 4, eOrientationSwapMask = 0x01 }; @@ -101,15 +102,8 @@ public: virtual sp<IMemoryHeap> getCblk() const = 0; /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */ - virtual void setTransactionState(const Vector<ComposerState>& state) = 0; - - /* [un]freeze display. requires ACCESS_SURFACE_FLINGER permission */ - virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags) = 0; - virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0; - - /* Set display orientation. requires ACCESS_SURFACE_FLINGER permission - * No flags are currently defined. Set flags to 0. */ - virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0; + virtual void setTransactionState(const Vector<ComposerState>& state, + int orientation) = 0; /* signal that we're done booting. * Requires ACCESS_SURFACE_FLINGER permission diff --git a/include/surfaceflinger/SurfaceComposerClient.h b/include/surfaceflinger/SurfaceComposerClient.h index ace0735..14e5b23 100644 --- a/include/surfaceflinger/SurfaceComposerClient.h +++ b/include/surfaceflinger/SurfaceComposerClient.h @@ -195,4 +195,3 @@ public: }; // namespace android #endif // ANDROID_SF_SURFACE_COMPOSER_CLIENT_H - diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 030a83e..eb90147 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -78,7 +78,8 @@ public: return interface_cast<IMemoryHeap>(reply.readStrongBinder()); } - virtual void setTransactionState(const Vector<ComposerState>& state) + virtual void setTransactionState(const Vector<ComposerState>& state, + int orientation) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); @@ -88,38 +89,8 @@ public: for ( ; b != e ; ++b ) { b->write(data); } - remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); - } - - virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags) - { - Parcel data, reply; - data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); - data.writeInt32(dpy); - data.writeInt32(flags); - remote()->transact(BnSurfaceComposer::FREEZE_DISPLAY, data, &reply); - return reply.readInt32(); - } - - virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) - { - Parcel data, reply; - data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); - data.writeInt32(dpy); - data.writeInt32(flags); - remote()->transact(BnSurfaceComposer::UNFREEZE_DISPLAY, data, &reply); - return reply.readInt32(); - } - - 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(); + remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply); } virtual void bootFinished() @@ -232,26 +203,8 @@ status_t BnSurfaceComposer::onTransact( s.read(data); state.add(s); } - setTransactionState(state); - } break; - case SET_ORIENTATION: { - CHECK_INTERFACE(ISurfaceComposer, data, reply); - DisplayID dpy = data.readInt32(); int orientation = data.readInt32(); - uint32_t flags = data.readInt32(); - reply->writeInt32( setOrientation(dpy, orientation, flags) ); - } break; - case FREEZE_DISPLAY: { - CHECK_INTERFACE(ISurfaceComposer, data, reply); - DisplayID dpy = data.readInt32(); - uint32_t flags = data.readInt32(); - reply->writeInt32( freezeDisplay(dpy, flags) ); - } break; - case UNFREEZE_DISPLAY: { - CHECK_INTERFACE(ISurfaceComposer, data, reply); - DisplayID dpy = data.readInt32(); - uint32_t flags = data.readInt32(); - reply->writeInt32( unfreezeDisplay(dpy, flags) ); + setTransactionState(state, orientation); } break; case BOOT_FINISHED: { CHECK_INTERFACE(ISurfaceComposer, data, reply); diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 00a4bf6..5f3d608 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -91,8 +91,10 @@ class Composer : public Singleton<Composer> mutable Mutex mLock; SortedVector<ComposerState> mStates; + int mOrientation; - Composer() : Singleton<Composer>() { } + Composer() : Singleton<Composer>(), + mOrientation(ISurfaceComposer::eOrientationUnchanged) { } void closeGlobalTransactionImpl(); @@ -119,6 +121,7 @@ public: status_t setFreezeTint( const sp<SurfaceComposerClient>& client, SurfaceID id, uint32_t tint); + status_t setOrientation(int orientation); static void closeGlobalTransaction() { Composer::getInstance().closeGlobalTransactionImpl(); @@ -133,14 +136,18 @@ void Composer::closeGlobalTransactionImpl() { sp<ISurfaceComposer> sm(getComposerService()); Vector<ComposerState> transaction; + int orientation; { // scope for the lock Mutex::Autolock _l(mLock); transaction = mStates; mStates.clear(); + + orientation = mOrientation; + mOrientation = ISurfaceComposer::eOrientationUnchanged; } - sm->setTransactionState(transaction); + sm->setTransactionState(transaction, orientation); } layer_state_t* Composer::getLayerStateLocked( @@ -260,6 +267,12 @@ status_t Composer::setFreezeTint(const sp<SurfaceComposerClient>& client, return NO_ERROR; } +status_t Composer::setOrientation(int orientation) { + Mutex::Autolock _l(mLock); + mOrientation = orientation; + return NO_ERROR; +} + // --------------------------------------------------------------------------- SurfaceComposerClient::SurfaceComposerClient() @@ -427,6 +440,12 @@ status_t SurfaceComposerClient::setMatrix(SurfaceID id, float dsdx, float dtdx, return getComposer().setMatrix(this, id, dsdx, dtdx, dsdy, dtdy); } +status_t SurfaceComposerClient::setOrientation(DisplayID dpy, + int orientation, uint32_t flags) +{ + return Composer::getInstance().setOrientation(orientation); +} + // ---------------------------------------------------------------------------- status_t SurfaceComposerClient::getDisplayInfo( @@ -491,21 +510,14 @@ ssize_t SurfaceComposerClient::getNumberOfDisplays() status_t SurfaceComposerClient::freezeDisplay(DisplayID dpy, uint32_t flags) { - sp<ISurfaceComposer> sm(getComposerService()); - return sm->freezeDisplay(dpy, flags); + // This has been made a no-op because it can cause Gralloc buffer deadlocks. + return NO_ERROR; } status_t SurfaceComposerClient::unfreezeDisplay(DisplayID dpy, uint32_t flags) { - sp<ISurfaceComposer> sm(getComposerService()); - return sm->unfreezeDisplay(dpy, flags); -} - -int SurfaceComposerClient::setOrientation(DisplayID dpy, - int orientation, uint32_t flags) -{ - sp<ISurfaceComposer> sm(getComposerService()); - return sm->setOrientation(dpy, orientation, flags); + // This has been made a no-op because it can cause Gralloc buffer deadlocks. + return NO_ERROR; } // ---------------------------------------------------------------------------- @@ -572,4 +584,3 @@ size_t ScreenshotClient::getSize() const { // ---------------------------------------------------------------------------- }; // namespace android - diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 06a6e98..595c256 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -5230,32 +5230,27 @@ public class WindowManagerService extends IWindowManager.Stub startFreezingDisplayLocked(inTransaction); mInputManager.setDisplayOrientation(0, rotation); - // NOTE: We disable the rotation in the emulator because - // it doesn't support hardware OpenGL emulation yet. - if (CUSTOM_SCREEN_ROTATION && mScreenRotationAnimation != null - && mScreenRotationAnimation.hasScreenshot()) { - Surface.freezeDisplay(0); + if (!inTransaction) { + if (SHOW_TRANSACTIONS) Slog.i(TAG, + ">>> OPEN TRANSACTION setRotationUnchecked"); + Surface.openTransaction(); + } + try { + // NOTE: We disable the rotation in the emulator because + // it doesn't support hardware OpenGL emulation yet. + if (CUSTOM_SCREEN_ROTATION && mScreenRotationAnimation != null + && mScreenRotationAnimation.hasScreenshot()) { + mScreenRotationAnimation.setRotation(rotation); + } + Surface.setOrientation(0, rotation); + } finally { if (!inTransaction) { + Surface.closeTransaction(); if (SHOW_TRANSACTIONS) Slog.i(TAG, - ">>> OPEN TRANSACTION setRotationUnchecked"); - Surface.openTransaction(); + "<<< CLOSE TRANSACTION setRotationUnchecked"); } - try { - if (mScreenRotationAnimation != null) { - mScreenRotationAnimation.setRotation(rotation); - } - } finally { - if (!inTransaction) { - Surface.closeTransaction(); - if (SHOW_TRANSACTIONS) Slog.i(TAG, - "<<< CLOSE TRANSACTION setRotationUnchecked"); - } - } - Surface.setOrientation(0, rotation); - Surface.unfreezeDisplay(0); - } else { - Surface.setOrientation(0, rotation); } + rebuildBlackFrame(inTransaction); for (int i=mWindows.size()-1; i>=0; i--) { diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 195ad2e..1441a54 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1234,10 +1234,22 @@ uint32_t SurfaceFlinger::setTransactionFlags(uint32_t flags) } -void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& state) { +void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& state, + int orientation) { Mutex::Autolock _l(mStateLock); uint32_t flags = 0; + if (mCurrentState.orientation != orientation) { + if (uint32_t(orientation)<=eOrientation270 || orientation==42) { + mCurrentState.orientation = orientation; + flags |= eTransactionNeeded; + mResizeTransationPending = true; + } else if (orientation != eOrientationUnchanged) { + LOGW("setTransactionState: ignoring unrecognized orientation: %d", + orientation); + } + } + const size_t count = state.size(); for (size_t i=0 ; i<count ; i++) { const ComposerState& s(state[i]); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 1cb9be2..0e642c1 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -167,7 +167,8 @@ public: virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc(); virtual sp<IMemoryHeap> getCblk() const; virtual void bootFinished(); - virtual void setTransactionState(const Vector<ComposerState>& state); + virtual void setTransactionState(const Vector<ComposerState>& state, + int orientation); 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, uint32_t flags); |