Merge "SurfaceFlinger: update orientation via transactions" into ics-mr0

This commit is contained in:
Jamie Gennis
2011-10-12 13:03:11 -07:00
committed by Android (Google) Code Review
7 changed files with 67 additions and 102 deletions

View File

@ -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);

View File

@ -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