diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaceflinger/LayerBase.h | 2 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.cpp | 6 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.h | 10 | ||||
-rw-r--r-- | libs/surfaceflinger_client/Android.mk | 2 | ||||
-rw-r--r-- | libs/surfaceflinger_client/ISurfaceComposer.cpp | 4 | ||||
-rw-r--r-- | libs/surfaceflinger_client/ISurfaceComposerClient.cpp (renamed from libs/surfaceflinger_client/ISurfaceFlingerClient.cpp) | 38 | ||||
-rw-r--r-- | libs/surfaceflinger_client/SharedBufferStack.cpp | 10 | ||||
-rw-r--r-- | libs/surfaceflinger_client/Surface.cpp | 11 | ||||
-rw-r--r-- | libs/surfaceflinger_client/SurfaceComposerClient.cpp | 71 |
9 files changed, 84 insertions, 70 deletions
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index a78424e..2e2f2df 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -29,7 +29,7 @@ #include <ui/Region.h> #include <ui/Overlay.h> -#include <surfaceflinger/ISurfaceFlingerClient.h> +#include <surfaceflinger/ISurfaceComposerClient.h> #include <private/surfaceflinger/SharedBufferStack.h> #include <private/surfaceflinger/LayerState.h> diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index 5a6893f..fff0853 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -225,7 +225,7 @@ sp<IMemoryHeap> SurfaceFlinger::getCblk() const return mServerHeap; } -sp<ISurfaceFlingerClient> SurfaceFlinger::createConnection() +sp<ISurfaceComposerClient> SurfaceFlinger::createConnection() { Mutex::Autolock _l(mStateLock); uint32_t token = mTokens.acquire(); @@ -1230,7 +1230,7 @@ int SurfaceFlinger::setOrientation(DisplayID dpy, } sp<ISurface> SurfaceFlinger::createSurface(ClientID clientId, int pid, - const String8& name, ISurfaceFlingerClient::surface_data_t* params, + const String8& name, ISurfaceComposerClient::surface_data_t* params, DisplayID d, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) { @@ -1740,7 +1740,7 @@ sp<IMemoryHeap> BClient::getControlBlock() const { } sp<ISurface> BClient::createSurface( - ISurfaceFlingerClient::surface_data_t* params, int pid, + ISurfaceComposerClient::surface_data_t* params, int pid, const String8& name, DisplayID display, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h index 2558324..d8fe98c 100644 --- a/libs/surfaceflinger/SurfaceFlinger.h +++ b/libs/surfaceflinger/SurfaceFlinger.h @@ -32,7 +32,7 @@ #include <ui/PixelFormat.h> #include <surfaceflinger/ISurfaceComposer.h> -#include <surfaceflinger/ISurfaceFlingerClient.h> +#include <surfaceflinger/ISurfaceComposerClient.h> #include "Barrier.h" #include "Layer.h" @@ -158,7 +158,7 @@ public: virtual status_t dump(int fd, const Vector<String16>& args); // ISurfaceComposer interface - virtual sp<ISurfaceFlingerClient> createConnection(); + virtual sp<ISurfaceComposerClient> createConnection(); virtual sp<IMemoryHeap> getCblk() const; virtual void bootFinished(); virtual void openGlobalTransaction(); @@ -189,7 +189,7 @@ private: friend class LayerDim; sp<ISurface> createSurface(ClientID client, int pid, const String8& name, - ISurfaceFlingerClient::surface_data_t* params, + ISurfaceComposerClient::surface_data_t* params, DisplayID display, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags); @@ -393,14 +393,14 @@ public: // --------------------------------------------------------------------------- -class BClient : public BnSurfaceFlingerClient +class BClient : public BnSurfaceComposerClient { public: BClient(SurfaceFlinger *flinger, ClientID cid, const sp<IMemoryHeap>& cblk); ~BClient(); - // ISurfaceFlingerClient interface + // ISurfaceComposerClient interface virtual sp<IMemoryHeap> getControlBlock() const; virtual sp<ISurface> createSurface( diff --git a/libs/surfaceflinger_client/Android.mk b/libs/surfaceflinger_client/Android.mk index fe85b34..ce3c71a 100644 --- a/libs/surfaceflinger_client/Android.mk +++ b/libs/surfaceflinger_client/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ ISurfaceComposer.cpp \ ISurface.cpp \ - ISurfaceFlingerClient.cpp \ + ISurfaceComposerClient.cpp \ LayerState.cpp \ SharedBufferStack.cpp \ Surface.cpp \ diff --git a/libs/surfaceflinger_client/ISurfaceComposer.cpp b/libs/surfaceflinger_client/ISurfaceComposer.cpp index b6f4e24..50495c1 100644 --- a/libs/surfaceflinger_client/ISurfaceComposer.cpp +++ b/libs/surfaceflinger_client/ISurfaceComposer.cpp @@ -46,13 +46,13 @@ public: { } - virtual sp<ISurfaceFlingerClient> createConnection() + virtual sp<ISurfaceComposerClient> createConnection() { uint32_t n; Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply); - return interface_cast<ISurfaceFlingerClient>(reply.readStrongBinder()); + return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder()); } virtual sp<IMemoryHeap> getCblk() const diff --git a/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp b/libs/surfaceflinger_client/ISurfaceComposerClient.cpp index def96d7..67c7df8 100644 --- a/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp +++ b/libs/surfaceflinger_client/ISurfaceComposerClient.cpp @@ -30,7 +30,7 @@ #include <ui/Rect.h> #include <surfaceflinger/ISurface.h> -#include <surfaceflinger/ISurfaceFlingerClient.h> +#include <surfaceflinger/ISurfaceComposerClient.h> #include <private/surfaceflinger/LayerState.h> // --------------------------------------------------------------------------- @@ -56,18 +56,18 @@ enum { SET_STATE }; -class BpSurfaceFlingerClient : public BpInterface<ISurfaceFlingerClient> +class BpSurfaceComposerClient : public BpInterface<ISurfaceComposerClient> { public: - BpSurfaceFlingerClient(const sp<IBinder>& impl) - : BpInterface<ISurfaceFlingerClient>(impl) + BpSurfaceComposerClient(const sp<IBinder>& impl) + : BpInterface<ISurfaceComposerClient>(impl) { } virtual sp<IMemoryHeap> getControlBlock() const { Parcel data, reply; - data.writeInterfaceToken(ISurfaceFlingerClient::getInterfaceDescriptor()); + data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor()); remote()->transact(GET_CBLK, data, &reply); return interface_cast<IMemoryHeap>(reply.readStrongBinder()); } @@ -82,7 +82,7 @@ public: uint32_t flags) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceFlingerClient::getInterfaceDescriptor()); + data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor()); data.writeInt32(pid); data.writeString8(name); data.writeInt32(display); @@ -94,11 +94,11 @@ public: params->readFromParcel(reply); return interface_cast<ISurface>(reply.readStrongBinder()); } - + virtual status_t destroySurface(SurfaceID sid) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceFlingerClient::getInterfaceDescriptor()); + data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor()); data.writeInt32(sid); remote()->transact(DESTROY_SURFACE, data, &reply); return reply.readInt32(); @@ -107,7 +107,7 @@ public: virtual status_t setState(int32_t count, const layer_state_t* states) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceFlingerClient::getInterfaceDescriptor()); + data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor()); data.writeInt32(count); for (int i=0 ; i<count ; i++) states[i].write(data); @@ -116,18 +116,18 @@ public: } }; -IMPLEMENT_META_INTERFACE(SurfaceFlingerClient, "android.ui.ISurfaceFlingerClient"); +IMPLEMENT_META_INTERFACE(SurfaceComposerClient, "android.ui.ISurfaceComposerClient"); // ---------------------------------------------------------------------- -status_t BnSurfaceFlingerClient::onTransact( +status_t BnSurfaceComposerClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { // codes that don't require permission check switch(code) { case GET_CBLK: { - CHECK_INTERFACE(ISurfaceFlingerClient, data, reply); + CHECK_INTERFACE(ISurfaceComposerClient, data, reply); sp<IMemoryHeap> ctl(getControlBlock()); reply->writeStrongBinder(ctl->asBinder()); return NO_ERROR; @@ -135,7 +135,7 @@ status_t BnSurfaceFlingerClient::onTransact( } // these must be checked - + IPCThreadState* ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); const int uid = ipc->getCallingUid(); @@ -150,10 +150,10 @@ status_t BnSurfaceFlingerClient::onTransact( return PERMISSION_DENIED; } } - + switch(code) { case CREATE_SURFACE: { - CHECK_INTERFACE(ISurfaceFlingerClient, data, reply); + CHECK_INTERFACE(ISurfaceComposerClient, data, reply); surface_data_t params; int32_t pid = data.readInt32(); String8 name = data.readString8(); @@ -169,12 +169,12 @@ status_t BnSurfaceFlingerClient::onTransact( return NO_ERROR; } break; case DESTROY_SURFACE: { - CHECK_INTERFACE(ISurfaceFlingerClient, data, reply); + CHECK_INTERFACE(ISurfaceComposerClient, data, reply); reply->writeInt32( destroySurface( data.readInt32() ) ); return NO_ERROR; } break; case SET_STATE: { - CHECK_INTERFACE(ISurfaceFlingerClient, data, reply); + CHECK_INTERFACE(ISurfaceComposerClient, data, reply); int32_t count = data.readInt32(); layer_state_t* states = new layer_state_t[count]; for (int i=0 ; i<count ; i++) @@ -191,7 +191,7 @@ status_t BnSurfaceFlingerClient::onTransact( // ---------------------------------------------------------------------- -status_t ISurfaceFlingerClient::surface_data_t::readFromParcel(const Parcel& parcel) +status_t ISurfaceComposerClient::surface_data_t::readFromParcel(const Parcel& parcel) { token = parcel.readInt32(); identity = parcel.readInt32(); @@ -201,7 +201,7 @@ status_t ISurfaceFlingerClient::surface_data_t::readFromParcel(const Parcel& par return NO_ERROR; } -status_t ISurfaceFlingerClient::surface_data_t::writeToParcel(Parcel* parcel) const +status_t ISurfaceComposerClient::surface_data_t::writeToParcel(Parcel* parcel) const { parcel->writeInt32(token); parcel->writeInt32(identity); diff --git a/libs/surfaceflinger_client/SharedBufferStack.cpp b/libs/surfaceflinger_client/SharedBufferStack.cpp index 2577dc0..8d03145 100644 --- a/libs/surfaceflinger_client/SharedBufferStack.cpp +++ b/libs/surfaceflinger_client/SharedBufferStack.cpp @@ -49,10 +49,6 @@ status_t SharedClient::validate(size_t i) const { return surfaces[i].status; } -uint32_t SharedClient::getIdentity(size_t token) const { - return uint32_t(surfaces[token].identity); -} - // ---------------------------------------------------------------------------- @@ -161,6 +157,12 @@ status_t SharedBufferBase::getStatus() const return stack.status; } +int32_t SharedBufferBase::getIdentity() const +{ + SharedBufferStack& stack( *mSharedStack ); + return stack.identity; +} + size_t SharedBufferBase::getFrontBuffer() const { SharedBufferStack& stack( *mSharedStack ); diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp index 35a4e8b..ac4b198 100644 --- a/libs/surfaceflinger_client/Surface.cpp +++ b/libs/surfaceflinger_client/Surface.cpp @@ -104,7 +104,7 @@ static status_t copyBlt( SurfaceControl::SurfaceControl( const sp<SurfaceComposerClient>& client, const sp<ISurface>& surface, - const ISurfaceFlingerClient::surface_data_t& data, + const ISurfaceComposerClient::surface_data_t& data, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) : mClient(client), mSurface(surface), mToken(data.token), mIdentity(data.identity), @@ -278,7 +278,6 @@ sp<Surface> SurfaceControl::getSurface() const // Surface // ============================================================================ - Surface::Surface(const sp<SurfaceControl>& surface) : mSurface(surface->mSurface), mToken(surface->mToken), mIdentity(surface->mIdentity), @@ -369,7 +368,7 @@ status_t Surface::initCheck() const LOGE("cblk is null (surface id=%d, identity=%u)", mToken, mIdentity); return NO_INIT; } - return NO_ERROR; + return cblk->validate(mToken); } bool Surface::isValid() { @@ -386,9 +385,7 @@ status_t Surface::validate() const } // verify the identity of this surface - SharedClient const* cblk = mClient->getSharedClient(); - - uint32_t identity = cblk->getIdentity(mToken); + uint32_t identity = mSharedBufferClient->getIdentity(); // this is a bit of a (temporary) special case, identity==0 means that // no operation are allowed from the client (eg: dequeue/queue), this @@ -406,7 +403,7 @@ status_t Surface::validate() const } // check the surface didn't become invalid - status_t err = cblk->validate(mToken); + status_t err = mSharedBufferClient->getStatus(); if (err != NO_ERROR) { LOGE("surface (id=%d, identity=%u) is invalid, err=%d (%s)", mToken, mIdentity, err, strerror(-err)); diff --git a/libs/surfaceflinger_client/SurfaceComposerClient.cpp b/libs/surfaceflinger_client/SurfaceComposerClient.cpp index 8d39c85..0670d20 100644 --- a/libs/surfaceflinger_client/SurfaceComposerClient.cpp +++ b/libs/surfaceflinger_client/SurfaceComposerClient.cpp @@ -31,7 +31,7 @@ #include <ui/DisplayInfo.h> #include <surfaceflinger/ISurfaceComposer.h> -#include <surfaceflinger/ISurfaceFlingerClient.h> +#include <surfaceflinger/ISurfaceComposerClient.h> #include <surfaceflinger/ISurface.h> #include <surfaceflinger/SurfaceComposerClient.h> @@ -42,18 +42,14 @@ namespace android { // --------------------------------------------------------------------------- -class Composer : public Singleton<Composer> +class ComposerService : public Singleton<ComposerService> { // these are constants sp<ISurfaceComposer> mComposerService; sp<IMemoryHeap> mServerCblkMemory; surface_flinger_cblk_t volatile* mServerCblk; - Mutex mLock; - SortedVector< wp<SurfaceComposerClient> > mActiveConnections; - SortedVector<sp<SurfaceComposerClient> > mOpenTransactions; - - Composer() : Singleton<Composer>() { + ComposerService() : Singleton<ComposerService>() { const String16 name("SurfaceFlinger"); while (getService(name, &mComposerService) != NO_ERROR) { usleep(250000); @@ -63,6 +59,39 @@ class Composer : public Singleton<Composer> mServerCblkMemory->getBase()); } + friend class Singleton<ComposerService>; + +public: + static sp<ISurfaceComposer> getComposerService() { + return ComposerService::getInstance().mComposerService; + } + static surface_flinger_cblk_t const volatile * getControlBlock() { + return ComposerService::getInstance().mServerCblk; + } +}; + +ANDROID_SINGLETON_STATIC_INSTANCE(ComposerService); + + +static inline sp<ISurfaceComposer> getComposerService() { + return ComposerService::getComposerService(); +} + +static inline surface_flinger_cblk_t const volatile * get_cblk() { + return ComposerService::getControlBlock(); +} + +// --------------------------------------------------------------------------- + +class Composer : public Singleton<Composer> +{ + Mutex mLock; + SortedVector< wp<SurfaceComposerClient> > mActiveConnections; + SortedVector<sp<SurfaceComposerClient> > mOpenTransactions; + + Composer() : Singleton<Composer>() { + } + void addClientImpl(const sp<SurfaceComposerClient>& client) { Mutex::Autolock _l(mLock); mActiveConnections.add(client); @@ -102,7 +131,7 @@ class Composer : public Singleton<Composer> mOpenTransactions.clear(); mLock.unlock(); - sp<ISurfaceComposer> sm(mComposerService); + sp<ISurfaceComposer> sm(getComposerService()); sm->openGlobalTransaction(); const size_t N = clients.size(); for (size_t i=0; i<N; i++) { @@ -114,12 +143,6 @@ class Composer : public Singleton<Composer> friend class Singleton<Composer>; public: - static sp<ISurfaceComposer> getComposerService() { - return Composer::getInstance().mComposerService; - } - static surface_flinger_cblk_t const volatile * getControlBlock() { - return Composer::getInstance().mServerCblk; - } static void addClient(const sp<SurfaceComposerClient>& client) { Composer::getInstance().addClientImpl(client); } @@ -136,14 +159,6 @@ public: ANDROID_SINGLETON_STATIC_INSTANCE(Composer); -static inline sp<ISurfaceComposer> getComposerService() { - return Composer::getComposerService(); -} - -static inline surface_flinger_cblk_t const volatile * get_cblk() { - return Composer::getControlBlock(); -} - // --------------------------------------------------------------------------- static inline int compare_type( const layer_state_t& lhs, @@ -162,7 +177,7 @@ void SurfaceComposerClient::onFirstRef() { sp<ISurfaceComposer> sm(getComposerService()); if (sm != 0) { - sp<ISurfaceFlingerClient> conn = sm->createConnection(); + sp<ISurfaceComposerClient> conn = sm->createConnection(); if (conn != 0) { mClient = conn; Composer::addClient(this); @@ -199,7 +214,7 @@ status_t SurfaceComposerClient::linkToComposerDeath( void SurfaceComposerClient::dispose() { // this can be called more than once. - sp<ISurfaceFlingerClient> client; + sp<ISurfaceComposerClient> client; Mutex::Autolock _lm(mLock); if (mClient != 0) { Composer::removeClient(this); @@ -296,7 +311,7 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface( { sp<SurfaceControl> result; if (mStatus == NO_ERROR) { - ISurfaceFlingerClient::surface_data_t data; + ISurfaceComposerClient::surface_data_t data; sp<ISurface> surface = mClient->createSurface(&data, pid, name, display, w, h, format, flags); if (surface != 0) { @@ -558,8 +573,8 @@ SurfaceClient::SurfaceClient(const sp<IBinder>& conn) } void SurfaceClient::init(const sp<IBinder>& conn) { - mSignalServer = getComposerService(); - sp<ISurfaceFlingerClient> sf(interface_cast<ISurfaceFlingerClient>(conn)); + mComposerService = getComposerService(); + sp<ISurfaceComposerClient> sf(interface_cast<ISurfaceComposerClient>(conn)); if (sf != 0) { mConnection = conn; mControlMemory = sf->getControlBlock(); @@ -574,7 +589,7 @@ SharedClient* SurfaceClient::getSharedClient() const { return mControl; } void SurfaceClient::signalServer() const { - mSignalServer->signal(); + mComposerService->signal(); } // ---------------------------------------------------------------------------- |