update SF binder protocol to support setting display attributes
no change of functionality -- the old behavior is implemented on top of this new protocol. this new protocol will allow, eventually, to pass informations about displays and layer stacks. Change-Id: Ic6c2295e61ec8ecbc8ce01ab7664e35d928202fc
This commit is contained in:
parent
921e6ac4b7
commit
8b33f03232
@ -34,6 +34,7 @@ namespace android {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class ComposerState;
|
class ComposerState;
|
||||||
|
class DisplayState;
|
||||||
class IDisplayEventConnection;
|
class IDisplayEventConnection;
|
||||||
class IMemoryHeap;
|
class IMemoryHeap;
|
||||||
|
|
||||||
@ -104,8 +105,10 @@ public:
|
|||||||
virtual sp<IMemoryHeap> getCblk() const = 0;
|
virtual sp<IMemoryHeap> getCblk() const = 0;
|
||||||
|
|
||||||
/* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
|
/* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
|
||||||
virtual void setTransactionState(const Vector<ComposerState>& state,
|
virtual void setTransactionState(
|
||||||
int orientation, uint32_t flags) = 0;
|
const Vector<ComposerState>& state,
|
||||||
|
const Vector<DisplayState>& displays,
|
||||||
|
uint32_t flags) = 0;
|
||||||
|
|
||||||
/* signal that we're done booting.
|
/* signal that we're done booting.
|
||||||
* Requires ACCESS_SURFACE_FLINGER permission
|
* Requires ACCESS_SURFACE_FLINGER permission
|
||||||
|
@ -77,6 +77,17 @@ struct ComposerState {
|
|||||||
status_t read(const Parcel& input);
|
status_t read(const Parcel& input);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DisplayState {
|
||||||
|
int32_t displayId;
|
||||||
|
sp<ISurfaceTexture> surface;
|
||||||
|
uint32_t layerStack;
|
||||||
|
uint32_t orientation;
|
||||||
|
Rect viewport;
|
||||||
|
Rect frame;
|
||||||
|
status_t write(Parcel& output) const;
|
||||||
|
status_t read(const Parcel& input);
|
||||||
|
};
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
|
||||||
#endif // ANDROID_SF_LAYER_STATE_H
|
#endif // ANDROID_SF_LAYER_STATE_H
|
||||||
|
@ -76,18 +76,29 @@ public:
|
|||||||
return interface_cast<IMemoryHeap>(reply.readStrongBinder());
|
return interface_cast<IMemoryHeap>(reply.readStrongBinder());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setTransactionState(const Vector<ComposerState>& state,
|
virtual void setTransactionState(
|
||||||
int orientation, uint32_t flags)
|
const Vector<ComposerState>& state,
|
||||||
|
const Vector<DisplayState>& displays,
|
||||||
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
Parcel data, reply;
|
Parcel data, reply;
|
||||||
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
|
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
|
||||||
Vector<ComposerState>::const_iterator b(state.begin());
|
{
|
||||||
Vector<ComposerState>::const_iterator e(state.end());
|
Vector<ComposerState>::const_iterator b(state.begin());
|
||||||
data.writeInt32(state.size());
|
Vector<ComposerState>::const_iterator e(state.end());
|
||||||
for ( ; b != e ; ++b ) {
|
data.writeInt32(state.size());
|
||||||
b->write(data);
|
for ( ; b != e ; ++b ) {
|
||||||
|
b->write(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Vector<DisplayState>::const_iterator b(displays.begin());
|
||||||
|
Vector<DisplayState>::const_iterator e(displays.end());
|
||||||
|
data.writeInt32(displays.size());
|
||||||
|
for ( ; b != e ; ++b ) {
|
||||||
|
b->write(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data.writeInt32(orientation);
|
|
||||||
data.writeInt32(flags);
|
data.writeInt32(flags);
|
||||||
remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
|
remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
|
||||||
}
|
}
|
||||||
@ -244,9 +255,16 @@ status_t BnSurfaceComposer::onTransact(
|
|||||||
s.read(data);
|
s.read(data);
|
||||||
state.add(s);
|
state.add(s);
|
||||||
}
|
}
|
||||||
int orientation = data.readInt32();
|
count = data.readInt32();
|
||||||
|
DisplayState d;
|
||||||
|
Vector<DisplayState> displays;
|
||||||
|
displays.setCapacity(count);
|
||||||
|
for (size_t i=0 ; i<count ; i++) {
|
||||||
|
d.read(data);
|
||||||
|
displays.add(d);
|
||||||
|
}
|
||||||
uint32_t flags = data.readInt32();
|
uint32_t flags = data.readInt32();
|
||||||
setTransactionState(state, orientation, flags);
|
setTransactionState(state, displays, flags);
|
||||||
} break;
|
} break;
|
||||||
case BOOT_FINISHED: {
|
case BOOT_FINISHED: {
|
||||||
CHECK_INTERFACE(ISurfaceComposer, data, reply);
|
CHECK_INTERFACE(ISurfaceComposer, data, reply);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <utils/Errors.h>
|
#include <utils/Errors.h>
|
||||||
#include <binder/Parcel.h>
|
#include <binder/Parcel.h>
|
||||||
#include <gui/ISurfaceComposerClient.h>
|
#include <gui/ISurfaceComposerClient.h>
|
||||||
|
#include <gui/ISurfaceTexture.h>
|
||||||
#include <private/gui/LayerState.h>
|
#include <private/gui/LayerState.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
@ -69,4 +70,26 @@ status_t ComposerState::read(const Parcel& input) {
|
|||||||
return state.read(input);
|
return state.read(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t DisplayState::write(Parcel& output) const {
|
||||||
|
output.writeStrongBinder(surface->asBinder());
|
||||||
|
output.writeInt32(displayId);
|
||||||
|
output.writeInt32(layerStack);
|
||||||
|
output.writeInt32(orientation);
|
||||||
|
memcpy(output.writeInplace(sizeof(Rect)), &viewport, sizeof(Rect));
|
||||||
|
memcpy(output.writeInplace(sizeof(Rect)), &frame, sizeof(Rect));
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t DisplayState::read(const Parcel& input) {
|
||||||
|
surface = interface_cast<ISurfaceTexture>(input.readStrongBinder());
|
||||||
|
displayId = input.readInt32();
|
||||||
|
layerStack = input.readInt32();
|
||||||
|
orientation = input.readInt32();
|
||||||
|
memcpy(&viewport, input.readInplace(sizeof(Rect)), sizeof(Rect));
|
||||||
|
memcpy(&frame, input.readInplace(sizeof(Rect)), sizeof(Rect));
|
||||||
|
return NO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
@ -138,7 +138,7 @@ void Composer::closeGlobalTransactionImpl(bool synchronous) {
|
|||||||
sp<ISurfaceComposer> sm(getComposerService());
|
sp<ISurfaceComposer> sm(getComposerService());
|
||||||
|
|
||||||
Vector<ComposerState> transaction;
|
Vector<ComposerState> transaction;
|
||||||
int orientation;
|
Vector<DisplayState> displayTransaction;
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
|
||||||
{ // scope for the lock
|
{ // scope for the lock
|
||||||
@ -146,7 +146,11 @@ void Composer::closeGlobalTransactionImpl(bool synchronous) {
|
|||||||
transaction = mStates;
|
transaction = mStates;
|
||||||
mStates.clear();
|
mStates.clear();
|
||||||
|
|
||||||
orientation = mOrientation;
|
// FIXME: this should be the displays transaction state here
|
||||||
|
DisplayState item;
|
||||||
|
item.orientation = mOrientation;
|
||||||
|
displayTransaction.add(item);
|
||||||
|
|
||||||
mOrientation = ISurfaceComposer::eOrientationUnchanged;
|
mOrientation = ISurfaceComposer::eOrientationUnchanged;
|
||||||
|
|
||||||
if (synchronous || mForceSynchronous) {
|
if (synchronous || mForceSynchronous) {
|
||||||
@ -155,7 +159,7 @@ void Composer::closeGlobalTransactionImpl(bool synchronous) {
|
|||||||
mForceSynchronous = false;
|
mForceSynchronous = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sm->setTransactionState(transaction, orientation, flags);
|
sm->setTransactionState(transaction, displayTransaction, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
layer_state_t* Composer::getLayerStateLocked(
|
layer_state_t* Composer::getLayerStateLocked(
|
||||||
|
@ -143,7 +143,11 @@ void SurfaceFlinger::binderDied(const wp<IBinder>& who)
|
|||||||
|
|
||||||
// reset screen orientation
|
// reset screen orientation
|
||||||
Vector<ComposerState> state;
|
Vector<ComposerState> state;
|
||||||
setTransactionState(state, eOrientationDefault, 0);
|
Vector<DisplayState> displays;
|
||||||
|
DisplayState d;
|
||||||
|
d.orientation = eOrientationDefault;
|
||||||
|
displays.add(d);
|
||||||
|
setTransactionState(state, displays, 0);
|
||||||
|
|
||||||
// restart the boot-animation
|
// restart the boot-animation
|
||||||
startBootAnim();
|
startBootAnim();
|
||||||
@ -1325,10 +1329,19 @@ uint32_t SurfaceFlinger::setTransactionFlags(uint32_t flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& state,
|
void SurfaceFlinger::setTransactionState(
|
||||||
int orientation, uint32_t flags) {
|
const Vector<ComposerState>& state,
|
||||||
|
const Vector<DisplayState>& displays,
|
||||||
|
uint32_t flags)
|
||||||
|
{
|
||||||
Mutex::Autolock _l(mStateLock);
|
Mutex::Autolock _l(mStateLock);
|
||||||
|
|
||||||
|
int orientation = eOrientationUnchanged;
|
||||||
|
if (displays.size()) {
|
||||||
|
// TODO: handle all displays
|
||||||
|
orientation = displays[0].orientation;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t transactionFlags = 0;
|
uint32_t transactionFlags = 0;
|
||||||
if (mCurrentState.orientation != orientation) {
|
if (mCurrentState.orientation != orientation) {
|
||||||
if (uint32_t(orientation)<=eOrientation270 || orientation==42) {
|
if (uint32_t(orientation)<=eOrientation270 || orientation==42) {
|
||||||
|
@ -165,7 +165,7 @@ private:
|
|||||||
virtual sp<IMemoryHeap> getCblk() const;
|
virtual sp<IMemoryHeap> getCblk() const;
|
||||||
virtual void bootFinished();
|
virtual void bootFinished();
|
||||||
virtual void setTransactionState(const Vector<ComposerState>& state,
|
virtual void setTransactionState(const Vector<ComposerState>& state,
|
||||||
int orientation, uint32_t flags);
|
const Vector<DisplayState>& displays, uint32_t flags);
|
||||||
virtual bool authenticateSurfaceTexture(
|
virtual bool authenticateSurfaceTexture(
|
||||||
const sp<ISurfaceTexture>& surface) const;
|
const sp<ISurfaceTexture>& surface) const;
|
||||||
virtual sp<IDisplayEventConnection> createDisplayEventConnection();
|
virtual sp<IDisplayEventConnection> createDisplayEventConnection();
|
||||||
|
Loading…
Reference in New Issue
Block a user