From d763b5d9197e01662cafa376e1227e53e0463a3c Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 2 Jul 2009 18:11:53 -0700 Subject: get rid of references to MemoryDealer in SurfaceFlinger --- libs/surfaceflinger/SurfaceFlinger.cpp | 54 ++++++++++++++++------------------ 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'libs/surfaceflinger/SurfaceFlinger.cpp') diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index c38668113213..5ac1cfd932c9 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -31,8 +31,8 @@ #include #include -#include -#include +#include + #include #include #include @@ -217,9 +217,9 @@ overlay_control_device_t* SurfaceFlinger::getOverlayEngine() const return graphicPlane(0).displayHardware().getOverlayEngine(); } -sp SurfaceFlinger::getCblk() const +sp SurfaceFlinger::getCblk() const { - return mServerCblkMemory; + return mServerHeap; } sp SurfaceFlinger::createConnection() @@ -238,7 +238,7 @@ sp SurfaceFlinger::createConnection() return 0; } sp bclient = - new BClient(this, token, client->controlBlockMemory()); + new BClient(this, token, client->getControlBlockMemory()); return bclient; } @@ -301,7 +301,6 @@ void SurfaceFlinger::onFirstRef() mReadyToRunBarrier.wait(); } - static inline uint16_t pack565(int r, int g, int b) { return (r<<11)|(g<<5)|b; } @@ -311,17 +310,6 @@ status_t SurfaceFlinger::readyToRun() LOGI( "SurfaceFlinger's main thread ready to run. " "Initializing graphics H/W..."); - // create the shared control-block - mServerHeap = new MemoryDealer(4096, MemoryDealer::READ_ONLY); - LOGE_IF(mServerHeap==0, "can't create shared memory dealer"); - - mServerCblkMemory = mServerHeap->allocate(4096); - LOGE_IF(mServerCblkMemory==0, "can't create shared control block"); - - mServerCblk = static_cast(mServerCblkMemory->pointer()); - LOGE_IF(mServerCblk==0, "can't get to shared control block's address"); - new(mServerCblk) surface_flinger_cblk_t; - // we only support one display currently int dpy = 0; @@ -332,6 +320,16 @@ status_t SurfaceFlinger::readyToRun() plane.setDisplayHardware(hw); } + // create the shared control-block + mServerHeap = new MemoryHeapBase(4096, + MemoryHeapBase::READ_ONLY, "SurfaceFlinger read-only heap"); + LOGE_IF(mServerHeap==0, "can't create shared memory dealer"); + + mServerCblk = static_cast(mServerHeap->getBase()); + LOGE_IF(mServerCblk==0, "can't get to shared control block's address"); + + new(mServerCblk) surface_flinger_cblk_t; + // initialize primary screen // (other display should be initialized in the same manner, but // asynchronously, as they could come and go. None of this is supported @@ -1615,14 +1613,14 @@ Client::Client(ClientID clientID, const sp& flinger) : ctrlblk(0), cid(clientID), mPid(0), mBitmap(0), mFlinger(flinger) { const int pgsize = getpagesize(); - const int cblksize=((sizeof(per_client_cblk_t)+(pgsize-1))&~(pgsize-1)); - mCblkHeap = new MemoryDealer(cblksize); - mCblkMemory = mCblkHeap->allocate(cblksize); - if (mCblkMemory != 0) { - ctrlblk = static_cast(mCblkMemory->pointer()); - if (ctrlblk) { // construct the shared structure in-place. - new(ctrlblk) per_client_cblk_t; - } + const int cblksize = ((sizeof(per_client_cblk_t)+(pgsize-1))&~(pgsize-1)); + + mCblkHeap = new MemoryHeapBase(cblksize, 0, + "SurfaceFlinger Client control-block"); + + ctrlblk = static_cast(mCblkHeap->getBase()); + if (ctrlblk) { // construct the shared structure in-place. + new(ctrlblk) per_client_cblk_t; } } @@ -1685,7 +1683,7 @@ void Client::dump(const char* what) #pragma mark - #endif -BClient::BClient(SurfaceFlinger *flinger, ClientID cid, const sp& cblk) +BClient::BClient(SurfaceFlinger *flinger, ClientID cid, const sp& cblk) : mId(cid), mFlinger(flinger), mCblk(cblk) { } @@ -1695,8 +1693,8 @@ BClient::~BClient() { mFlinger->destroyConnection(mId); } -void BClient::getControlBlocks(sp* ctrl) const { - *ctrl = mCblk; +sp BClient::getControlBlock() const { + return mCblk; } sp BClient::createSurface( -- cgit v1.2.3-59-g8ed1b