summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-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
6 files changed, 29 insertions, 52 deletions
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);