summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger_client
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-05-28 14:22:23 -0700
committerMathias Agopian <mathias@google.com>2010-05-28 17:19:16 -0700
commit770492cb2b19f6a36ad748cd05fbedfbb9a67dfa (patch)
tree3c87a789492e52b3c26b1de9608f42690b86c2cd /libs/surfaceflinger_client
parentcdfd5fe2c89a30a31f9de5a5481e8997f014a89b (diff)
downloadframeworks_base-770492cb2b19f6a36ad748cd05fbedfbb9a67dfa.zip
frameworks_base-770492cb2b19f6a36ad748cd05fbedfbb9a67dfa.tar.gz
frameworks_base-770492cb2b19f6a36ad748cd05fbedfbb9a67dfa.tar.bz2
more clean-up in preparation of bigger changes
the most important change here is the renaming of ISurfaceFlingerClient to ISurfaceComposerClient Change-Id: I94e18b0417f50e06f21377446639c61f65f959b3
Diffstat (limited to 'libs/surfaceflinger_client')
-rw-r--r--libs/surfaceflinger_client/Android.mk2
-rw-r--r--libs/surfaceflinger_client/ISurfaceComposer.cpp4
-rw-r--r--libs/surfaceflinger_client/ISurfaceComposerClient.cpp (renamed from libs/surfaceflinger_client/ISurfaceFlingerClient.cpp)38
-rw-r--r--libs/surfaceflinger_client/SharedBufferStack.cpp10
-rw-r--r--libs/surfaceflinger_client/Surface.cpp11
-rw-r--r--libs/surfaceflinger_client/SurfaceComposerClient.cpp71
6 files changed, 75 insertions, 61 deletions
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();
}
// ----------------------------------------------------------------------------