Skip to content

Commit

Permalink
get rid of the shared-memory control block
Browse files Browse the repository at this point in the history
Change-Id: If814060aca1d2ff2619d4adcd57296983d207f7f
  • Loading branch information
pixelflinger committed Jul 26, 2012
1 parent 028508c commit c666cae
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 210 deletions.
10 changes: 6 additions & 4 deletions include/gui/ISurfaceComposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace android {

class ComposerState;
class DisplayState;
class DisplayInfo;
class IDisplayEventConnection;
class IMemoryHeap;

Expand Down Expand Up @@ -102,9 +103,6 @@ class ISurfaceComposer : public IInterface
*/
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;

/* retrieve the control block */
virtual sp<IMemoryHeap> getCblk() const = 0;

/* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
virtual void setTransactionState(
const Vector<ComposerState>& state,
Expand Down Expand Up @@ -145,6 +143,10 @@ class ISurfaceComposer : public IInterface
/* triggers screen on and waits for it to complete */
virtual void unblank() = 0;

/* returns information about a physical screen. This is intended to be
* used by low-level native tests */
virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info) = 0;

/* connects to an external display */
virtual void connectDisplay(const sp<ISurfaceTexture> display) = 0;
};
Expand All @@ -160,7 +162,7 @@ class BnSurfaceComposer : public BnInterface<ISurfaceComposer>
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
CREATE_CONNECTION,
CREATE_GRAPHIC_BUFFER_ALLOC,
GET_CBLK,
GET_DISPLAY_INFO,
SET_TRANSACTION_STATE,
SET_ORIENTATION,
CAPTURE_SCREEN,
Expand Down
6 changes: 0 additions & 6 deletions include/gui/SurfaceComposerClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,8 @@ class SurfaceComposerClient : public RefBase
//! Set the orientation of the given display
static int setOrientation(DisplayID dpy, int orientation, uint32_t flags);

// Query the number of displays
static ssize_t getNumberOfDisplays();

// Get information about a display
static status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info);
static ssize_t getDisplayWidth(DisplayID dpy);
static ssize_t getDisplayHeight(DisplayID dpy);
static ssize_t getDisplayOrientation(DisplayID dpy);

status_t linkToComposerDeath(const sp<IBinder::DeathRecipient>& recipient,
void* cookie = NULL, uint32_t flags = 0);
Expand Down
4 changes: 0 additions & 4 deletions include/private/gui/ComposerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,17 @@ namespace android {

class IMemoryHeap;
class ISurfaceComposer;
class surface_flinger_cblk_t;

// ---------------------------------------------------------------------------

class ComposerService : public Singleton<ComposerService>
{
// these are constants
sp<ISurfaceComposer> mComposerService;
sp<IMemoryHeap> mServerCblkMemory;
surface_flinger_cblk_t volatile* mServerCblk;
ComposerService();
friend class Singleton<ComposerService>;
public:
static sp<ISurfaceComposer> getComposerService();
static surface_flinger_cblk_t const volatile * getControlBlock();
};

// ---------------------------------------------------------------------------
Expand Down
59 changes: 0 additions & 59 deletions include/private/gui/SharedBufferStack.h

This file was deleted.

22 changes: 10 additions & 12 deletions include/ui/DisplayInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/


#ifndef ANDROID_UI_DISPLAY_INFO_H
#define ANDROID_UI_DISPLAY_INFO_H

Expand All @@ -26,15 +25,16 @@
namespace android {

struct DisplayInfo {
uint32_t w;
uint32_t h;
PixelFormatInfo pixelFormatInfo;
uint8_t orientation;
uint8_t reserved[3];
float fps;
float density;
float xdpi;
float ydpi;
uint32_t w;
uint32_t h;
float xdpi;
float ydpi;
float fps;
float density;
uint8_t orientation;
uint8_t reserved[3];
// TODO: this needs to go away (currently needed only by webkit)
PixelFormatInfo pixelFormatInfo;
};

/* Display orientations as defined in Surface.java and ISurfaceComposer.h. */
Expand All @@ -45,8 +45,6 @@ enum {
DISPLAY_ORIENTATION_270 = 3
};


}; // namespace android

#endif // ANDROID_COMPOSER_DISPLAY_INFO_H

32 changes: 19 additions & 13 deletions libs/gui/ISurfaceComposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder());
}

virtual sp<IMemoryHeap> getCblk() const
{
Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
remote()->transact(BnSurfaceComposer::GET_CBLK, data, &reply);
return interface_cast<IMemoryHeap>(reply.readStrongBinder());
}

virtual void setTransactionState(
const Vector<ComposerState>& state,
const Vector<DisplayState>& displays,
Expand Down Expand Up @@ -219,6 +211,17 @@ class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
remote()->transact(BnSurfaceComposer::UNBLANK, data, &reply);
}

virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info)
{
Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
data.writeInt32(dpy);
remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
memcpy(info, reply.readInplace(sizeof(DisplayInfo)), sizeof(DisplayInfo));
return reply.readInt32();
}


virtual void connectDisplay(const sp<ISurfaceTexture> display) {
Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Expand Down Expand Up @@ -270,11 +273,6 @@ status_t BnSurfaceComposer::onTransact(
CHECK_INTERFACE(ISurfaceComposer, data, reply);
bootFinished();
} break;
case GET_CBLK: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
sp<IBinder> b = getCblk()->asBinder();
reply->writeStrongBinder(b);
} break;
case CAPTURE_SCREEN: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
DisplayID dpy = data.readInt32();
Expand Down Expand Up @@ -326,6 +324,14 @@ status_t BnSurfaceComposer::onTransact(
CHECK_INTERFACE(ISurfaceComposer, data, reply);
unblank();
} break;
case GET_DISPLAY_INFO: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
DisplayInfo info;
DisplayID dpy = data.readInt32();
status_t result = getDisplayInfo(dpy, &info);
memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo));
reply->writeInt32(result);
} break;
case CONNECT_DISPLAY: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
sp<ISurfaceTexture> surfaceTexture =
Expand Down
66 changes: 1 addition & 65 deletions libs/gui/SurfaceComposerClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#include <private/gui/ComposerService.h>
#include <private/gui/LayerState.h>
#include <private/gui/SharedBufferStack.h>

namespace android {
// ---------------------------------------------------------------------------
Expand All @@ -51,27 +50,16 @@ ComposerService::ComposerService()
while (getService(name, &mComposerService) != NO_ERROR) {
usleep(250000);
}
mServerCblkMemory = mComposerService->getCblk();
mServerCblk = static_cast<surface_flinger_cblk_t volatile *>(
mServerCblkMemory->getBase());
}

sp<ISurfaceComposer> ComposerService::getComposerService() {
return ComposerService::getInstance().mComposerService;
}

surface_flinger_cblk_t const volatile * ComposerService::getControlBlock() {
return ComposerService::getInstance().mServerCblk;
}

static inline sp<ISurfaceComposer> getComposerService() {
return ComposerService::getComposerService();
}

static inline surface_flinger_cblk_t const volatile * get_cblk() {
return ComposerService::getControlBlock();
}

// ---------------------------------------------------------------------------

// NOTE: this is NOT a member function (it's a friend defined with its
Expand Down Expand Up @@ -476,59 +464,7 @@ status_t SurfaceComposerClient::setOrientation(DisplayID dpy,
status_t SurfaceComposerClient::getDisplayInfo(
DisplayID dpy, DisplayInfo* info)
{
if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
return BAD_VALUE;

volatile surface_flinger_cblk_t const * cblk = get_cblk();
volatile display_cblk_t const * dcblk = cblk->displays + dpy;

info->w = dcblk->w;
info->h = dcblk->h;
info->orientation = dcblk->orientation;
info->xdpi = dcblk->xdpi;
info->ydpi = dcblk->ydpi;
info->fps = dcblk->fps;
info->density = dcblk->density;
return getPixelFormatInfo(dcblk->format, &(info->pixelFormatInfo));
}

ssize_t SurfaceComposerClient::getDisplayWidth(DisplayID dpy)
{
if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
return BAD_VALUE;
volatile surface_flinger_cblk_t const * cblk = get_cblk();
volatile display_cblk_t const * dcblk = cblk->displays + dpy;
return dcblk->w;
}

ssize_t SurfaceComposerClient::getDisplayHeight(DisplayID dpy)
{
if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
return BAD_VALUE;
volatile surface_flinger_cblk_t const * cblk = get_cblk();
volatile display_cblk_t const * dcblk = cblk->displays + dpy;
return dcblk->h;
}

ssize_t SurfaceComposerClient::getDisplayOrientation(DisplayID dpy)
{
if (uint32_t(dpy)>=NUM_DISPLAY_MAX)
return BAD_VALUE;
volatile surface_flinger_cblk_t const * cblk = get_cblk();
volatile display_cblk_t const * dcblk = cblk->displays + dpy;
return dcblk->orientation;
}

ssize_t SurfaceComposerClient::getNumberOfDisplays()
{
volatile surface_flinger_cblk_t const * cblk = get_cblk();
uint32_t connected = cblk->connected;
int n = 0;
while (connected) {
if (connected&1) n++;
connected >>= 1;
}
return n;
return getComposerService()->getDisplayInfo(dpy, info);
}

// ----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit c666cae

Please sign in to comment.