summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/gui/ISurface.h2
-rw-r--r--include/gui/ISurfaceComposerClient.h11
-rw-r--r--include/gui/Surface.h12
-rw-r--r--include/gui/SurfaceComposerClient.h24
-rw-r--r--include/private/gui/LayerState.h4
-rw-r--r--libs/gui/ISurfaceComposerClient.cpp31
-rw-r--r--libs/gui/LayerState.cpp50
-rw-r--r--libs/gui/Surface.cpp70
-rw-r--r--libs/gui/SurfaceComposerClient.cpp70
-rw-r--r--services/surfaceflinger/Client.cpp29
-rw-r--r--services/surfaceflinger/Client.h11
-rw-r--r--services/surfaceflinger/LayerBase.cpp11
-rw-r--r--services/surfaceflinger/LayerBase.h5
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp18
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h7
15 files changed, 147 insertions, 208 deletions
diff --git a/include/gui/ISurface.h b/include/gui/ISurface.h
index ce6e715..5a928f2 100644
--- a/include/gui/ISurface.h
+++ b/include/gui/ISurface.h
@@ -29,8 +29,6 @@
namespace android {
-typedef int32_t SurfaceID;
-
class IGraphicBufferProducer;
class ISurface : public IInterface
diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h
index e256e33..23d1d4c 100644
--- a/include/gui/ISurfaceComposerClient.h
+++ b/include/gui/ISurfaceComposerClient.h
@@ -54,24 +54,17 @@ public:
eFXSurfaceMask = 0x000F0000,
};
- struct surface_data_t {
- int32_t token;
- int32_t identity;
- status_t readFromParcel(const Parcel& parcel);
- status_t writeToParcel(Parcel* parcel) const;
- };
-
/*
* Requires ACCESS_SURFACE_FLINGER permission
*/
- virtual sp<ISurface> createSurface(surface_data_t* data,
+ virtual sp<ISurface> createSurface(
const String8& name, uint32_t w, uint32_t h,
PixelFormat format, uint32_t flags) = 0;
/*
* Requires ACCESS_SURFACE_FLINGER permission
*/
- virtual status_t destroySurface(SurfaceID sid) = 0;
+ virtual status_t destroySurface(const sp<IBinder>& handle) = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/Surface.h b/include/gui/Surface.h
index 8654f76..27921df 100644
--- a/include/gui/Surface.h
+++ b/include/gui/Surface.h
@@ -50,13 +50,11 @@ public:
return (surface != 0) && surface->isValid();
}
bool isValid() {
- return mToken>=0 && mClient!=0;
+ return mSurface!=0 && mClient!=0;
}
static bool isSameSurface(
const sp<SurfaceControl>& lhs, const sp<SurfaceControl>& rhs);
- uint32_t getIdentity() const { return mIdentity; }
-
// release surface data from java
void clear();
@@ -87,8 +85,7 @@ private:
SurfaceControl(
const sp<SurfaceComposerClient>& client,
- const sp<ISurface>& surface,
- const ISurfaceComposerClient::surface_data_t& data);
+ const sp<ISurface>& surface);
~SurfaceControl();
@@ -96,11 +93,8 @@ private:
void destroy();
sp<SurfaceComposerClient> mClient;
- sp<ISurface> mSurface;
- SurfaceID mToken;
- uint32_t mIdentity;
+ sp<IBinder> mSurface;
mutable Mutex mLock;
-
mutable sp<Surface> mSurfaceData;
};
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index 22e6b14..dbdd3a9 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -108,18 +108,18 @@ public:
//! Flag the currently open transaction as an animation transaction.
static void setAnimationTransaction();
- status_t hide(SurfaceID id);
- status_t show(SurfaceID id);
- status_t setFlags(SurfaceID id, uint32_t flags, uint32_t mask);
- status_t setTransparentRegionHint(SurfaceID id, const Region& transparent);
- status_t setLayer(SurfaceID id, int32_t layer);
- status_t setAlpha(SurfaceID id, float alpha=1.0f);
- status_t setMatrix(SurfaceID id, float dsdx, float dtdx, float dsdy, float dtdy);
- status_t setPosition(SurfaceID id, float x, float y);
- status_t setSize(SurfaceID id, uint32_t w, uint32_t h);
- status_t setCrop(SurfaceID id, const Rect& crop);
- status_t setLayerStack(SurfaceID id, uint32_t layerStack);
- status_t destroySurface(SurfaceID sid);
+ status_t hide(const sp<IBinder>& id);
+ status_t show(const sp<IBinder>& id);
+ status_t setFlags(const sp<IBinder>& id, uint32_t flags, uint32_t mask);
+ status_t setTransparentRegionHint(const sp<IBinder>& id, const Region& transparent);
+ status_t setLayer(const sp<IBinder>& id, int32_t layer);
+ status_t setAlpha(const sp<IBinder>& id, float alpha=1.0f);
+ status_t setMatrix(const sp<IBinder>& id, float dsdx, float dtdx, float dsdy, float dtdy);
+ status_t setPosition(const sp<IBinder>& id, float x, float y);
+ status_t setSize(const sp<IBinder>& id, uint32_t w, uint32_t h);
+ status_t setCrop(const sp<IBinder>& id, const Rect& crop);
+ status_t setLayerStack(const sp<IBinder>& id, uint32_t layerStack);
+ status_t destroySurface(const sp<IBinder>& id);
static void setDisplaySurface(const sp<IBinder>& token,
const sp<IGraphicBufferProducer>& bufferProducer);
diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h
index 5b400ca..0798e17 100644
--- a/include/private/gui/LayerState.h
+++ b/include/private/gui/LayerState.h
@@ -51,7 +51,7 @@ struct layer_state_t {
};
layer_state_t()
- : surface(0), what(0),
+ : what(0),
x(0), y(0), z(0), w(0), h(0), layerStack(0),
alpha(0), flags(0), mask(0),
reserved(0)
@@ -70,7 +70,7 @@ struct layer_state_t {
float dsdy;
float dtdy;
};
- SurfaceID surface;
+ sp<IBinder> surface;
uint32_t what;
float x;
float y;
diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp
index 8f7bc05..101292d 100644
--- a/libs/gui/ISurfaceComposerClient.cpp
+++ b/libs/gui/ISurfaceComposerClient.cpp
@@ -50,8 +50,7 @@ public:
{
}
- virtual sp<ISurface> createSurface( surface_data_t* params,
- const String8& name,
+ virtual sp<ISurface> createSurface( const String8& name,
uint32_t w,
uint32_t h,
PixelFormat format,
@@ -65,15 +64,14 @@ public:
data.writeInt32(format);
data.writeInt32(flags);
remote()->transact(CREATE_SURFACE, data, &reply);
- params->readFromParcel(reply);
return interface_cast<ISurface>(reply.readStrongBinder());
}
- virtual status_t destroySurface(SurfaceID sid)
+ virtual status_t destroySurface(const sp<IBinder>& handle)
{
Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
- data.writeInt32(sid);
+ data.writeStrongBinder(handle);
remote()->transact(DESTROY_SURFACE, data, &reply);
return reply.readInt32();
}
@@ -89,21 +87,18 @@ status_t BnSurfaceComposerClient::onTransact(
switch(code) {
case CREATE_SURFACE: {
CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
- surface_data_t params;
String8 name = data.readString8();
uint32_t w = data.readInt32();
uint32_t h = data.readInt32();
PixelFormat format = data.readInt32();
uint32_t flags = data.readInt32();
- sp<ISurface> s = createSurface(&params, name, w, h,
- format, flags);
- params.writeToParcel(reply);
+ sp<ISurface> s = createSurface(name, w, h, format, flags);
reply->writeStrongBinder(s->asBinder());
return NO_ERROR;
} break;
case DESTROY_SURFACE: {
CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
- reply->writeInt32( destroySurface( data.readInt32() ) );
+ reply->writeInt32( destroySurface( data.readStrongBinder() ) );
return NO_ERROR;
} break;
default:
@@ -111,20 +106,4 @@ status_t BnSurfaceComposerClient::onTransact(
}
}
-// ----------------------------------------------------------------------
-
-status_t ISurfaceComposerClient::surface_data_t::readFromParcel(const Parcel& parcel)
-{
- token = parcel.readInt32();
- identity = parcel.readInt32();
- return NO_ERROR;
-}
-
-status_t ISurfaceComposerClient::surface_data_t::writeToParcel(Parcel* parcel) const
-{
- parcel->writeInt32(token);
- parcel->writeInt32(identity);
- return NO_ERROR;
-}
-
}; // namespace android
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 5e5edcd..acdbd77 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -24,29 +24,41 @@ namespace android {
status_t layer_state_t::write(Parcel& output) const
{
- status_t err;
-
- err = output.write(transparentRegion);
- if (err < NO_ERROR) return err;
-
- // NOTE: regions are at the end of the structure
- size_t size = sizeof(layer_state_t);
- size -= sizeof(transparentRegion);
- err = output.write(this, size);
- return err;
+ output.writeStrongBinder(surface);
+ output.writeInt32(what);
+ output.writeFloat(x);
+ output.writeFloat(y);
+ output.writeInt32(z);
+ output.writeInt32(w);
+ output.writeInt32(h);
+ output.writeInt32(layerStack);
+ output.writeFloat(alpha);
+ output.writeInt32(flags);
+ output.writeInt32(mask);
+ *reinterpret_cast<layer_state_t::matrix22_t *>(
+ output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
+ output.write(crop);
+ output.write(transparentRegion);
+ return NO_ERROR;
}
status_t layer_state_t::read(const Parcel& input)
{
- status_t err;
-
- err = input.read(transparentRegion);
- if (err < NO_ERROR) return err;
-
- // NOTE: regions are at the end of the structure
- size_t size = sizeof(layer_state_t);
- size -= sizeof(transparentRegion);
- input.read(this, size);
+ surface = input.readStrongBinder();
+ what = input.readInt32();
+ x = input.readFloat();
+ y = input.readFloat();
+ z = input.readInt32();
+ w = input.readInt32();
+ h = input.readInt32();
+ layerStack = input.readInt32();
+ alpha = input.readFloat();
+ flags = input.readInt32();
+ mask = input.readInt32();
+ matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(
+ input.readInplace(sizeof(layer_state_t::matrix22_t)));
+ input.read(crop);
+ input.read(transparentRegion);
return NO_ERROR;
}
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 51d37b3..81fc019 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -48,11 +48,12 @@ namespace android {
SurfaceControl::SurfaceControl(
const sp<SurfaceComposerClient>& client,
- const sp<ISurface>& surface,
- const ISurfaceComposerClient::surface_data_t& data)
- : mClient(client), mSurface(surface),
- mToken(data.token), mIdentity(data.identity)
+ const sp<ISurface>& surface)
+ : mClient(client)
{
+ if (surface != 0) {
+ mSurface = surface->asBinder();
+ }
}
SurfaceControl::~SurfaceControl()
@@ -63,9 +64,8 @@ SurfaceControl::~SurfaceControl()
void SurfaceControl::destroy()
{
if (isValid()) {
- mClient->destroySurface(mToken);
+ mClient->destroySurface(mSurface);
}
-
// clear all references and trigger an IPC now, to make sure things
// happen without delay, since these resources are quite heavy.
mClient.clear();
@@ -89,81 +89,81 @@ bool SurfaceControl::isSameSurface(
{
if (lhs == 0 || rhs == 0)
return false;
- return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
+ return lhs->mSurface == rhs->mSurface;
}
status_t SurfaceControl::setLayerStack(int32_t layerStack) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setLayerStack(mToken, layerStack);
+ return client->setLayerStack(mSurface, layerStack);
}
status_t SurfaceControl::setLayer(int32_t layer) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setLayer(mToken, layer);
+ return client->setLayer(mSurface, layer);
}
status_t SurfaceControl::setPosition(int32_t x, int32_t y) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setPosition(mToken, x, y);
+ return client->setPosition(mSurface, x, y);
}
status_t SurfaceControl::setSize(uint32_t w, uint32_t h) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setSize(mToken, w, h);
+ return client->setSize(mSurface, w, h);
}
status_t SurfaceControl::hide() {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->hide(mToken);
+ return client->hide(mSurface);
}
status_t SurfaceControl::show() {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->show(mToken);
+ return client->show(mSurface);
}
status_t SurfaceControl::setFlags(uint32_t flags, uint32_t mask) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setFlags(mToken, flags, mask);
+ return client->setFlags(mSurface, flags, mask);
}
status_t SurfaceControl::setTransparentRegionHint(const Region& transparent) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setTransparentRegionHint(mToken, transparent);
+ return client->setTransparentRegionHint(mSurface, transparent);
}
status_t SurfaceControl::setAlpha(float alpha) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setAlpha(mToken, alpha);
+ return client->setAlpha(mSurface, alpha);
}
status_t SurfaceControl::setMatrix(float dsdx, float dtdx, float dsdy, float dtdy) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setMatrix(mToken, dsdx, dtdx, dsdy, dtdy);
+ return client->setMatrix(mSurface, dsdx, dtdx, dsdy, dtdy);
}
status_t SurfaceControl::setCrop(const Rect& crop) {
status_t err = validate();
if (err < 0) return err;
const sp<SurfaceComposerClient>& client(mClient);
- return client->setCrop(mToken, crop);
+ return client->setCrop(mSurface, crop);
}
status_t SurfaceControl::validate() const
{
- if (mToken<0 || mClient==0) {
- ALOGE("invalid token (%d, identity=%u) or client (%p)",
- mToken, mIdentity, mClient.get());
+ if (mSurface==0 || mClient==0) {
+ ALOGE("invalid ISurface (%p) or client (%p)",
+ mSurface.get(), mClient.get());
return NO_INIT;
}
return NO_ERROR;
@@ -172,15 +172,12 @@ status_t SurfaceControl::validate() const
status_t SurfaceControl::writeSurfaceToParcel(
const sp<SurfaceControl>& control, Parcel* parcel)
{
- sp<ISurface> sur;
- uint32_t identity = 0;
+ sp<IBinder> sur;
if (SurfaceControl::isValid(control)) {
- sur = control->mSurface;
- identity = control->mIdentity;
+ sur = control->mSurface;
}
- parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL);
+ parcel->writeStrongBinder(sur);
parcel->writeStrongBinder(NULL); // NULL IGraphicBufferProducer in this case.
- parcel->writeInt32(identity);
return NO_ERROR;
}
@@ -198,13 +195,10 @@ sp<Surface> SurfaceControl::getSurface() const
// Surface
// ============================================================================
-// ---------------------------------------------------------------------------
-
Surface::Surface(const sp<SurfaceControl>& surface)
- : SurfaceTextureClient(),
- mSurface(surface->mSurface),
- mIdentity(surface->mIdentity)
+ : SurfaceTextureClient()
{
+ mSurface = interface_cast<ISurface>(surface->mSurface);
sp<IGraphicBufferProducer> st;
if (mSurface != NULL) {
st = mSurface->getSurfaceTexture();
@@ -223,15 +217,12 @@ Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
} else if (mSurface != NULL) {
st = mSurface->getSurfaceTexture();
}
-
- mIdentity = parcel.readInt32();
init(st);
}
Surface::Surface(const sp<IGraphicBufferProducer>& st)
: SurfaceTextureClient(),
- mSurface(NULL),
- mIdentity(0)
+ mSurface(NULL)
{
init(st);
}
@@ -245,19 +236,16 @@ status_t Surface::writeToParcel(
if (Surface::isValid(surface)) {
sur = surface->mSurface;
st = surface->getISurfaceTexture();
- identity = surface->mIdentity;
} else if (surface != 0 &&
(surface->mSurface != NULL ||
surface->getISurfaceTexture() != NULL)) {
ALOGE("Parceling invalid surface with non-NULL ISurface/IGraphicBufferProducer "
- "as NULL: mSurface = %p, bufferProducer = %p, mIdentity = %d, ",
- surface->mSurface.get(), surface->getISurfaceTexture().get(),
- surface->mIdentity);
+ "as NULL: mSurface = %p, bufferProducer = %p ",
+ surface->mSurface.get(), surface->getISurfaceTexture().get());
}
parcel->writeStrongBinder(sur != NULL ? sur->asBinder() : NULL);
parcel->writeStrongBinder(st != NULL ? st->asBinder() : NULL);
- parcel->writeInt32(identity);
return NO_ERROR;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 0c6881a..0bafc92 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -128,7 +128,7 @@ class Composer : public Singleton<Composer>
void setAnimationTransactionImpl();
layer_state_t* getLayerStateLocked(
- const sp<SurfaceComposerClient>& client, SurfaceID id);
+ const sp<SurfaceComposerClient>& client, const sp<IBinder>& id);
DisplayState& getDisplayStateLocked(const sp<IBinder>& token);
@@ -136,26 +136,26 @@ public:
sp<IBinder> createDisplay(const String8& displayName, bool secure);
sp<IBinder> getBuiltInDisplay(int32_t id);
- status_t setPosition(const sp<SurfaceComposerClient>& client, SurfaceID id,
+ status_t setPosition(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
float x, float y);
- status_t setSize(const sp<SurfaceComposerClient>& client, SurfaceID id,
+ status_t setSize(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
uint32_t w, uint32_t h);
- status_t setLayer(const sp<SurfaceComposerClient>& client, SurfaceID id,
+ status_t setLayer(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
int32_t z);
- status_t setFlags(const sp<SurfaceComposerClient>& client, SurfaceID id,
+ status_t setFlags(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
uint32_t flags, uint32_t mask);
status_t setTransparentRegionHint(
- const sp<SurfaceComposerClient>& client, SurfaceID id,
+ const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
const Region& transparentRegion);
- status_t setAlpha(const sp<SurfaceComposerClient>& client, SurfaceID id,
+ status_t setAlpha(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
float alpha);
- status_t setMatrix(const sp<SurfaceComposerClient>& client, SurfaceID id,
+ status_t setMatrix(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
float dsdx, float dtdx, float dsdy, float dtdy);
status_t setOrientation(int orientation);
- status_t setCrop(const sp<SurfaceComposerClient>& client, SurfaceID id,
+ status_t setCrop(const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
const Rect& crop);
status_t setLayerStack(const sp<SurfaceComposerClient>& client,
- SurfaceID id, uint32_t layerStack);
+ const sp<IBinder>& id, uint32_t layerStack);
void setDisplaySurface(const sp<IBinder>& token,
const sp<IGraphicBufferProducer>& bufferProducer);
@@ -241,7 +241,7 @@ void Composer::setAnimationTransactionImpl() {
}
layer_state_t* Composer::getLayerStateLocked(
- const sp<SurfaceComposerClient>& client, SurfaceID id) {
+ const sp<SurfaceComposerClient>& client, const sp<IBinder>& id) {
ComposerState s;
s.client = client->mClient;
@@ -258,7 +258,7 @@ layer_state_t* Composer::getLayerStateLocked(
}
status_t Composer::setPosition(const sp<SurfaceComposerClient>& client,
- SurfaceID id, float x, float y) {
+ const sp<IBinder>& id, float x, float y) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
if (!s)
@@ -270,7 +270,7 @@ status_t Composer::setPosition(const sp<SurfaceComposerClient>& client,
}
status_t Composer::setSize(const sp<SurfaceComposerClient>& client,
- SurfaceID id, uint32_t w, uint32_t h) {
+ const sp<IBinder>& id, uint32_t w, uint32_t h) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
if (!s)
@@ -286,7 +286,7 @@ status_t Composer::setSize(const sp<SurfaceComposerClient>& client,
}
status_t Composer::setLayer(const sp<SurfaceComposerClient>& client,
- SurfaceID id, int32_t z) {
+ const sp<IBinder>& id, int32_t z) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
if (!s)
@@ -297,7 +297,7 @@ status_t Composer::setLayer(const sp<SurfaceComposerClient>& client,
}
status_t Composer::setFlags(const sp<SurfaceComposerClient>& client,
- SurfaceID id, uint32_t flags,
+ const sp<IBinder>& id, uint32_t flags,
uint32_t mask) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
@@ -311,7 +311,7 @@ status_t Composer::setFlags(const sp<SurfaceComposerClient>& client,
}
status_t Composer::setTransparentRegionHint(
- const sp<SurfaceComposerClient>& client, SurfaceID id,
+ const sp<SurfaceComposerClient>& client, const sp<IBinder>& id,
const Region& transparentRegion) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
@@ -323,7 +323,7 @@ status_t Composer::setTransparentRegionHint(
}
status_t Composer::setAlpha(const sp<SurfaceComposerClient>& client,
- SurfaceID id, float alpha) {
+ const sp<IBinder>& id, float alpha) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
if (!s)
@@ -334,7 +334,7 @@ status_t Composer::setAlpha(const sp<SurfaceComposerClient>& client,
}
status_t Composer::setLayerStack(const sp<SurfaceComposerClient>& client,
- SurfaceID id, uint32_t layerStack) {
+ const sp<IBinder>& id, uint32_t layerStack) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
if (!s)
@@ -345,7 +345,7 @@ status_t Composer::setLayerStack(const sp<SurfaceComposerClient>& client,
}
status_t Composer::setMatrix(const sp<SurfaceComposerClient>& client,
- SurfaceID id, float dsdx, float dtdx,
+ const sp<IBinder>& id, float dsdx, float dtdx,
float dsdy, float dtdy) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
@@ -362,7 +362,7 @@ status_t Composer::setMatrix(const sp<SurfaceComposerClient>& client,
}
status_t Composer::setCrop(const sp<SurfaceComposerClient>& client,
- SurfaceID id, const Rect& crop) {
+ const sp<IBinder>& id, const Rect& crop) {
Mutex::Autolock _l(mLock);
layer_state_t* s = getLayerStateLocked(client, id);
if (!s)
@@ -472,11 +472,9 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
{
sp<SurfaceControl> result;
if (mStatus == NO_ERROR) {
- ISurfaceComposerClient::surface_data_t data;
- sp<ISurface> surface = mClient->createSurface(&data, name,
- w, h, format, flags);
+ sp<ISurface> surface = mClient->createSurface(name, w, h, format, flags);
if (surface != 0) {
- result = new SurfaceControl(this, surface, data);
+ result = new SurfaceControl(this, surface);
}
}
return result;
@@ -491,7 +489,7 @@ sp<IBinder> SurfaceComposerClient::getBuiltInDisplay(int32_t id) {
return Composer::getInstance().getBuiltInDisplay(id);
}
-status_t SurfaceComposerClient::destroySurface(SurfaceID sid) {
+status_t SurfaceComposerClient::destroySurface(const sp<IBinder>& sid) {
if (mStatus != NO_ERROR)
return mStatus;
status_t err = mClient->destroySurface(sid);
@@ -518,53 +516,53 @@ void SurfaceComposerClient::setAnimationTransaction() {
// ----------------------------------------------------------------------------
-status_t SurfaceComposerClient::setCrop(SurfaceID id, const Rect& crop) {
+status_t SurfaceComposerClient::setCrop(const sp<IBinder>& id, const Rect& crop) {
return getComposer().setCrop(this, id, crop);
}
-status_t SurfaceComposerClient::setPosition(SurfaceID id, float x, float y) {
+status_t SurfaceComposerClient::setPosition(const sp<IBinder>& id, float x, float y) {
return getComposer().setPosition(this, id, x, y);
}
-status_t SurfaceComposerClient::setSize(SurfaceID id, uint32_t w, uint32_t h) {
+status_t SurfaceComposerClient::setSize(const sp<IBinder>& id, uint32_t w, uint32_t h) {
return getComposer().setSize(this, id, w, h);
}
-status_t SurfaceComposerClient::setLayer(SurfaceID id, int32_t z) {
+status_t SurfaceComposerClient::setLayer(const sp<IBinder>& id, int32_t z) {
return getComposer().setLayer(this, id, z);
}
-status_t SurfaceComposerClient::hide(SurfaceID id) {
+status_t SurfaceComposerClient::hide(const sp<IBinder>& id) {
return getComposer().setFlags(this, id,
layer_state_t::eLayerHidden,
layer_state_t::eLayerHidden);
}
-status_t SurfaceComposerClient::show(SurfaceID id) {
+status_t SurfaceComposerClient::show(const sp<IBinder>& id) {
return getComposer().setFlags(this, id,
0,
layer_state_t::eLayerHidden);
}
-status_t SurfaceComposerClient::setFlags(SurfaceID id, uint32_t flags,
+status_t SurfaceComposerClient::setFlags(const sp<IBinder>& id, uint32_t flags,
uint32_t mask) {
return getComposer().setFlags(this, id, flags, mask);
}
-status_t SurfaceComposerClient::setTransparentRegionHint(SurfaceID id,
+status_t SurfaceComposerClient::setTransparentRegionHint(const sp<IBinder>& id,
const Region& transparentRegion) {
return getComposer().setTransparentRegionHint(this, id, transparentRegion);
}
-status_t SurfaceComposerClient::setAlpha(SurfaceID id, float alpha) {
+status_t SurfaceComposerClient::setAlpha(const sp<IBinder>& id, float alpha) {
return getComposer().setAlpha(this, id, alpha);
}
-status_t SurfaceComposerClient::setLayerStack(SurfaceID id, uint32_t layerStack) {
+status_t SurfaceComposerClient::setLayerStack(const sp<IBinder>& id, uint32_t layerStack) {
return getComposer().setLayerStack(this, id, layerStack);
}
-status_t SurfaceComposerClient::setMatrix(SurfaceID id, float dsdx, float dtdx,
+status_t SurfaceComposerClient::setMatrix(const sp<IBinder>& id, float dsdx, float dtdx,
float dsdy, float dtdy) {
return getComposer().setMatrix(this, id, dsdx, dtdx, dsdy, dtdy);
}
diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp
index c28254f..0f56f99 100644
--- a/services/surfaceflinger/Client.cpp
+++ b/services/surfaceflinger/Client.cpp
@@ -35,7 +35,7 @@ const String16 sAccessSurfaceFlinger("android.permission.ACCESS_SURFACE_FLINGER"
// ---------------------------------------------------------------------------
Client::Client(const sp<SurfaceFlinger>& flinger)
- : mFlinger(flinger), mNameGenerator(1)
+ : mFlinger(flinger)
{
}
@@ -54,12 +54,10 @@ status_t Client::initCheck() const {
return NO_ERROR;
}
-size_t Client::attachLayer(const sp<LayerBaseClient>& layer)
+void Client::attachLayer(const sp<IBinder>& handle, const sp<LayerBaseClient>& layer)
{
Mutex::Autolock _l(mLock);
- size_t name = mNameGenerator++;
- mLayers.add(name, layer);
- return name;
+ mLayers.add(handle, layer);
}
void Client::detachLayer(const LayerBaseClient* layer)
@@ -74,14 +72,14 @@ void Client::detachLayer(const LayerBaseClient* layer)
}
}
}
-sp<LayerBaseClient> Client::getLayerUser(int32_t i) const
+sp<LayerBaseClient> Client::getLayerUser(const sp<IBinder>& handle) const
{
Mutex::Autolock _l(mLock);
sp<LayerBaseClient> lbc;
- wp<LayerBaseClient> layer(mLayers.valueFor(i));
+ wp<LayerBaseClient> layer(mLayers.valueFor(handle));
if (layer != 0) {
lbc = layer.promote();
- ALOGE_IF(lbc==0, "getLayerUser(name=%d) is dead", int(i));
+ ALOGE_IF(lbc==0, "getLayerUser(name=%p) is dead", handle.get());
}
return lbc;
}
@@ -109,7 +107,6 @@ status_t Client::onTransact(
sp<ISurface> Client::createSurface(
- ISurfaceComposerClient::surface_data_t* params,
const String8& name,
uint32_t w, uint32_t h, PixelFormat format,
uint32_t flags)
@@ -122,7 +119,6 @@ sp<ISurface> Client::createSurface(
class MessageCreateLayer : public MessageBase {
sp<ISurface> result;
SurfaceFlinger* flinger;
- ISurfaceComposerClient::surface_data_t* params;
Client* client;
const String8& name;
uint32_t w, h;
@@ -130,29 +126,28 @@ sp<ISurface> Client::createSurface(
uint32_t flags;
public:
MessageCreateLayer(SurfaceFlinger* flinger,
- ISurfaceComposerClient::surface_data_t* params,
const String8& name, Client* client,
uint32_t w, uint32_t h, PixelFormat format,
uint32_t flags)
- : flinger(flinger), params(params), client(client), name(name),
+ : flinger(flinger), client(client), name(name),
w(w), h(h), format(format), flags(flags)
{
}
sp<ISurface> getResult() const { return result; }
virtual bool handler() {
- result = flinger->createLayer(params, name, client,
- w, h, format, flags);
+ result = flinger->createLayer(name, client, w, h, format, flags);
return true;
}
};
sp<MessageBase> msg = new MessageCreateLayer(mFlinger.get(),
- params, name, this, w, h, format, flags);
+ name, this, w, h, format, flags);
mFlinger->postMessageSync(msg);
return static_cast<MessageCreateLayer*>( msg.get() )->getResult();
}
-status_t Client::destroySurface(SurfaceID sid) {
- return mFlinger->onLayerRemoved(this, sid);
+
+status_t Client::destroySurface(const sp<IBinder>& handle) {
+ return mFlinger->onLayerRemoved(this, handle);
}
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/Client.h b/services/surfaceflinger/Client.h
index d6c6931..e6a7165 100644
--- a/services/surfaceflinger/Client.h
+++ b/services/surfaceflinger/Client.h
@@ -44,20 +44,20 @@ public:
status_t initCheck() const;
// protected by SurfaceFlinger::mStateLock
- size_t attachLayer(const sp<LayerBaseClient>& layer);
+ void attachLayer(const sp<IBinder>& handle, const sp<LayerBaseClient>& layer);
void detachLayer(const LayerBaseClient* layer);
- sp<LayerBaseClient> getLayerUser(int32_t i) const;
+ sp<LayerBaseClient> getLayerUser(const sp<IBinder>& handle) const;
private:
// ISurfaceComposerClient interface
virtual sp<ISurface> createSurface(
- surface_data_t* params, const String8& name,
+ const String8& name,
uint32_t w, uint32_t h,PixelFormat format,
uint32_t flags);
- virtual status_t destroySurface(SurfaceID surfaceId);
+ virtual status_t destroySurface(const sp<IBinder>& handle);
virtual status_t onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
@@ -66,8 +66,7 @@ private:
sp<SurfaceFlinger> mFlinger;
// protected by mLock
- DefaultKeyedVector< size_t, wp<LayerBaseClient> > mLayers;
- size_t mNameGenerator;
+ DefaultKeyedVector< wp<IBinder>, wp<LayerBaseClient> > mLayers;
// thread-safe
mutable Mutex mLock;
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 54c51bb..dfdbf30 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -483,14 +483,11 @@ sp<Layer> LayerBase::getLayer() const {
// ---------------------------------------------------------------------------
-int32_t LayerBaseClient::sIdentity = 1;
-
LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger,
const sp<Client>& client)
: LayerBase(flinger),
mHasSurface(false),
- mClientRef(client),
- mIdentity(uint32_t(android_atomic_inc(&sIdentity)))
+ mClientRef(client)
{
}
@@ -540,12 +537,8 @@ wp<IBinder> LayerBaseClient::getSurfaceTextureBinder() const {
void LayerBaseClient::dump(String8& result, char* buffer, size_t SIZE) const
{
LayerBase::dump(result, buffer, SIZE);
-
sp<Client> client(mClientRef.promote());
- snprintf(buffer, SIZE,
- " client=%p, identity=%u\n",
- client.get(), getIdentity());
-
+ snprintf(buffer, SIZE, " client=%p\n", client.get());
result.append(buffer);
}
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index 47473e7..c2624df 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -347,8 +347,6 @@ public:
virtual const char* getTypeId() const { return "LayerBaseClient"; }
- uint32_t getIdentity() const { return mIdentity; }
-
protected:
virtual void dump(String8& result, char* scratch, size_t size) const;
virtual void shortDump(String8& result, char* scratch, size_t size) const;
@@ -379,9 +377,6 @@ private:
wp<IBinder> mClientSurfaceBinder;
const wp<Client> mClientRef;
- // only read
- const uint32_t mIdentity;
- static int32_t sIdentity;
};
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index caabf1d..efcef92 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1682,17 +1682,16 @@ void SurfaceFlinger::drawWormhole(const sp<const DisplayDevice>& hw,
}
}
-ssize_t SurfaceFlinger::addClientLayer(const sp<Client>& client,
+void SurfaceFlinger::addClientLayer(const sp<Client>& client,
+ const sp<IBinder>& handle,
const sp<LayerBaseClient>& lbc)
{
// attach this layer to the client
- size_t name = client->attachLayer(lbc);
+ client->attachLayer(handle, lbc);
// add this layer to the current state list
Mutex::Autolock _l(mStateLock);
mCurrentState.layersSortedByZ.add(lbc);
-
- return ssize_t(name);
}
status_t SurfaceFlinger::removeLayer(const sp<LayerBase>& layer)
@@ -1933,10 +1932,9 @@ uint32_t SurfaceFlinger::setClientStateLocked(
}
sp<ISurface> SurfaceFlinger::createLayer(
- ISurfaceComposerClient::surface_data_t* params,
const String8& name,
const sp<Client>& client,
- uint32_t w, uint32_t h, PixelFormat format,
+ uint32_t w, uint32_t h, PixelFormat format,
uint32_t flags)
{
sp<LayerBaseClient> layer;
@@ -1965,11 +1963,9 @@ sp<ISurface> SurfaceFlinger::createLayer(
if (layer != 0) {
layer->initStates(w, h, flags);
layer->setName(name);
- ssize_t token = addClientLayer(client, layer);
surfaceHandle = layer->getSurface();
if (surfaceHandle != 0) {
- params->token = token;
- params->identity = layer->getIdentity();
+ addClientLayer(client, surfaceHandle->asBinder(), layer);
}
setTransactionFlags(eTransactionNeeded);
}
@@ -2027,7 +2023,7 @@ sp<LayerScreenshot> SurfaceFlinger::createScreenshotLayer(
return layer;
}
-status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, SurfaceID sid)
+status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle)
{
/*
* called by the window manager, when a surface should be marked for
@@ -2040,7 +2036,7 @@ status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, SurfaceID sid)
status_t err = NAME_NOT_FOUND;
Mutex::Autolock _l(mStateLock);
- sp<LayerBaseClient> layer = client->getLayerUser(sid);
+ sp<LayerBaseClient> layer = client->getLayerUser(handle);
if (layer != 0) {
err = purgatorizeLayer_l(layer);
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 72dd652..3cda6c0 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -267,8 +267,7 @@ private:
/* ------------------------------------------------------------------------
* Layer management
*/
- sp<ISurface> createLayer(ISurfaceComposerClient::surface_data_t* params,
- const String8& name, const sp<Client>& client,
+ sp<ISurface> createLayer(const String8& name, const sp<Client>& client,
uint32_t w, uint32_t h, PixelFormat format, uint32_t flags);
sp<Layer> createNormalLayer(const sp<Client>& client,
@@ -284,7 +283,7 @@ private:
// ISurfaceComposerClient::destroySurface()
// The specified layer is first placed in a purgatory list
// until all references from the client are released.
- status_t onLayerRemoved(const sp<Client>& client, SurfaceID sid);
+ status_t onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle);
// called when all clients have released all their references to
// this layer meaning it is entirely safe to destroy all
@@ -295,7 +294,7 @@ private:
status_t removeLayer(const sp<LayerBase>& layer);
// add a layer to SurfaceFlinger
- ssize_t addClientLayer(const sp<Client>& client,
+ void addClientLayer(const sp<Client>& client, const sp<IBinder>& handle,
const sp<LayerBaseClient>& lbc);
status_t removeLayer_l(const sp<LayerBase>& layer);