summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-07-25 18:56:13 -0700
committerMathias Agopian <mathias@google.com>2012-07-25 21:13:10 -0700
commitc666cae2d5995097ec49a87e375e2afdd92802b7 (patch)
tree235abd54f4c3c6ed2c6b59bbade55a6459f13ed8
parent028508cad5ef63ef9fbd42c14e76658e4fd9ebf2 (diff)
downloadframeworks_native-c666cae2d5995097ec49a87e375e2afdd92802b7.zip
frameworks_native-c666cae2d5995097ec49a87e375e2afdd92802b7.tar.gz
frameworks_native-c666cae2d5995097ec49a87e375e2afdd92802b7.tar.bz2
get rid of the shared-memory control block
Change-Id: If814060aca1d2ff2619d4adcd57296983d207f7f
-rw-r--r--include/gui/ISurfaceComposer.h10
-rw-r--r--include/gui/SurfaceComposerClient.h6
-rw-r--r--include/private/gui/ComposerService.h4
-rw-r--r--include/private/gui/SharedBufferStack.h59
-rw-r--r--include/ui/DisplayInfo.h22
-rw-r--r--libs/gui/ISurfaceComposer.cpp32
-rw-r--r--libs/gui/SurfaceComposerClient.cpp66
-rw-r--r--services/surfaceflinger/DisplayHardware.cpp34
-rw-r--r--services/surfaceflinger/DisplayHardware.h2
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp29
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h7
-rw-r--r--services/surfaceflinger/tests/Transaction_test.cpp8
12 files changed, 69 insertions, 210 deletions
diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h
index 0d4a76b..315a39b 100644
--- a/include/gui/ISurfaceComposer.h
+++ b/include/gui/ISurfaceComposer.h
@@ -35,6 +35,7 @@ namespace android {
class ComposerState;
class DisplayState;
+class DisplayInfo;
class IDisplayEventConnection;
class IMemoryHeap;
@@ -102,9 +103,6 @@ public:
*/
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,
@@ -145,6 +143,10 @@ public:
/* 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;
};
@@ -160,7 +162,7 @@ public:
BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
CREATE_CONNECTION,
CREATE_GRAPHIC_BUFFER_ALLOC,
- GET_CBLK,
+ GET_DISPLAY_INFO,
SET_TRANSACTION_STATE,
SET_ORIENTATION,
CAPTURE_SCREEN,
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index aef4223..b058b8d 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -97,14 +97,8 @@ public:
//! 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);
diff --git a/include/private/gui/ComposerService.h b/include/private/gui/ComposerService.h
index d04491a..c2761b8 100644
--- a/include/private/gui/ComposerService.h
+++ b/include/private/gui/ComposerService.h
@@ -30,7 +30,6 @@ namespace android {
class IMemoryHeap;
class ISurfaceComposer;
-class surface_flinger_cblk_t;
// ---------------------------------------------------------------------------
@@ -38,13 +37,10 @@ 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();
};
// ---------------------------------------------------------------------------
diff --git a/include/private/gui/SharedBufferStack.h b/include/private/gui/SharedBufferStack.h
deleted file mode 100644
index 0da03d1..0000000
--- a/include/private/gui/SharedBufferStack.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_SF_SHARED_BUFFER_STACK_H
-#define ANDROID_SF_SHARED_BUFFER_STACK_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <utils/Debug.h>
-
-namespace android {
-// ---------------------------------------------------------------------------
-
-#define NUM_DISPLAY_MAX 4
-
-struct display_cblk_t
-{
- uint16_t w;
- uint16_t h;
- uint8_t format;
- uint8_t orientation;
- uint8_t reserved[2];
- float fps;
- float density;
- float xdpi;
- float ydpi;
- uint32_t pad[2];
-};
-
-struct surface_flinger_cblk_t // 4KB max
-{
- uint8_t connected;
- uint8_t reserved[3];
- uint32_t pad[7];
- display_cblk_t displays[NUM_DISPLAY_MAX];
-};
-
-// ---------------------------------------------------------------------------
-
-COMPILE_TIME_ASSERT(sizeof(surface_flinger_cblk_t) <= 4096)
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-
-#endif /* ANDROID_SF_SHARED_BUFFER_STACK_H */
diff --git a/include/ui/DisplayInfo.h b/include/ui/DisplayInfo.h
index edd28a6..c7dc354 100644
--- a/include/ui/DisplayInfo.h
+++ b/include/ui/DisplayInfo.h
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
#ifndef ANDROID_UI_DISPLAY_INFO_H
#define ANDROID_UI_DISPLAY_INFO_H
@@ -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. */
@@ -45,8 +45,6 @@ enum {
DISPLAY_ORIENTATION_270 = 3
};
-
}; // namespace android
#endif // ANDROID_COMPOSER_DISPLAY_INFO_H
-
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 60341ff..4cc0262 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -68,14 +68,6 @@ public:
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,
@@ -219,6 +211,17 @@ public:
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());
@@ -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();
@@ -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 =
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 4930e33..1aecddb 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -38,7 +38,6 @@
#include <private/gui/ComposerService.h>
#include <private/gui/LayerState.h>
-#include <private/gui/SharedBufferStack.h>
namespace android {
// ---------------------------------------------------------------------------
@@ -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
@@ -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);
}
// ----------------------------------------------------------------------------
diff --git a/services/surfaceflinger/DisplayHardware.cpp b/services/surfaceflinger/DisplayHardware.cpp
index 067a54f..4b5d8ab 100644
--- a/services/surfaceflinger/DisplayHardware.cpp
+++ b/services/surfaceflinger/DisplayHardware.cpp
@@ -24,6 +24,7 @@
#include <utils/RefBase.h>
#include <utils/Log.h>
+#include <ui/DisplayInfo.h>
#include <ui/PixelFormat.h>
#include <GLES/gl.h>
@@ -31,7 +32,6 @@
#include <EGL/eglext.h>
#include <hardware/gralloc.h>
-#include <private/gui/SharedBufferStack.h>
#include "DisplayHardware/FramebufferSurface.h"
#include "DisplayHardware/DisplayHardwareBase.h"
@@ -148,6 +148,19 @@ EGLSurface DisplayHardware::getEGLSurface() const {
return mSurface;
}
+status_t DisplayHardware::getInfo(DisplayInfo* info) const {
+ info->w = getWidth();
+ info->h = getHeight();
+ info->xdpi = getDpiX();
+ info->ydpi = getDpiY();
+ info->fps = getRefreshRate();
+ info->density = getDensity();
+ info->orientation = getOrientation();
+ // TODO: this needs to go away (currently needed only by webkit)
+ getPixelFormatInfo(getFormat(), &info->pixelFormatInfo);
+ return NO_ERROR;
+}
+
void DisplayHardware::init(EGLConfig config)
{
ANativeWindow* const window = mNativeWindow.get();
@@ -226,17 +239,6 @@ void DisplayHardware::init(EGLConfig config)
mFormat = format;
mPageFlipCount = 0;
- // initialize the shared control block
- surface_flinger_cblk_t* const scblk = mFlinger->getControlBlock();
- scblk->connected |= 1 << mDisplayId;
- display_cblk_t* dcblk = &scblk->displays[mDisplayId];
- memset(dcblk, 0, sizeof(display_cblk_t));
- dcblk->format = format;
- dcblk->xdpi = mDpiX;
- dcblk->ydpi = mDpiY;
- dcblk->fps = mRefreshRate;
- dcblk->density = mDensity;
-
// initialize the display orientation transform.
DisplayHardware::setOrientation(ISurfaceComposer::eOrientationDefault);
}
@@ -365,13 +367,5 @@ status_t DisplayHardware::setOrientation(int orientation) {
h = tmp;
}
mOrientation = orientation;
-
- // update the shared control block
- surface_flinger_cblk_t* const scblk = mFlinger->getControlBlock();
- volatile display_cblk_t* dcblk = &scblk->displays[mDisplayId];
- dcblk->orientation = orientation;
- dcblk->w = w;
- dcblk->h = h;
-
return NO_ERROR;
}
diff --git a/services/surfaceflinger/DisplayHardware.h b/services/surfaceflinger/DisplayHardware.h
index 88a8c0d..98579b4 100644
--- a/services/surfaceflinger/DisplayHardware.h
+++ b/services/surfaceflinger/DisplayHardware.h
@@ -36,6 +36,7 @@
namespace android {
+class DisplayInfo;
class FramebufferSurface;
class LayerBase;
class SurfaceFlinger;
@@ -74,6 +75,7 @@ public:
uint32_t getFlags() const;
nsecs_t getRefreshPeriod() const;
nsecs_t getRefreshTimestamp() const;
+ status_t getInfo(DisplayInfo* info) const;
EGLSurface getEGLSurface() const;
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 992c779..192378f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -32,6 +32,8 @@
#include <binder/MemoryHeapBase.h>
#include <binder/PermissionCache.h>
+#include <ui/DisplayInfo.h>
+
#include <gui/IDisplayEventConnection.h>
#include <gui/BitTube.h>
#include <gui/SurfaceTextureClient.h>
@@ -45,7 +47,6 @@
#include <utils/Trace.h>
#include <private/android_filesystem_config.h>
-#include <private/gui/SharedBufferStack.h>
#include "clz.h"
#include "DdmConnection.h"
@@ -153,11 +154,6 @@ void SurfaceFlinger::binderDied(const wp<IBinder>& who)
startBootAnim();
}
-sp<IMemoryHeap> SurfaceFlinger::getCblk() const
-{
- return mServerHeap;
-}
-
sp<ISurfaceComposerClient> SurfaceFlinger::createConnection()
{
sp<ISurfaceComposerClient> bclient;
@@ -361,24 +357,11 @@ void SurfaceFlinger::initializeGL(EGLDisplay display, EGLSurface surface) {
ALOGI("GL_MAX_VIEWPORT_DIMS = %d x %d", mMaxViewportDims[0], mMaxViewportDims[1]);
}
-surface_flinger_cblk_t* SurfaceFlinger::getControlBlock() const {
- return mServerCblk;
-}
-
status_t SurfaceFlinger::readyToRun()
{
ALOGI( "SurfaceFlinger's main thread ready to run. "
"Initializing graphics H/W...");
- // create the shared control-block
- mServerHeap = new MemoryHeapBase(4096,
- MemoryHeapBase::READ_ONLY, "SurfaceFlinger read-only heap");
- ALOGE_IF(mServerHeap==0, "can't create shared memory dealer");
- mServerCblk = static_cast<surface_flinger_cblk_t*>(mServerHeap->getBase());
- ALOGE_IF(mServerCblk==0, "can't get to shared control block's address");
- new(mServerCblk) surface_flinger_cblk_t;
-
-
// initialize EGL
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, NULL, NULL);
@@ -485,6 +468,14 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
return false;
}
+status_t SurfaceFlinger::getDisplayInfo(DisplayID dpy, DisplayInfo* info) {
+ if (uint32_t(dpy) >= 2) {
+ return BAD_INDEX;
+ }
+ const DisplayHardware& hw(getDefaultDisplayHardware());
+ return hw.getInfo(info);
+}
+
// ----------------------------------------------------------------------------
sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection() {
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 6418122..c33f1a3 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -64,7 +64,6 @@ class LayerBaseClient;
class LayerDim;
class LayerScreenshot;
class SurfaceTextureClient;
-struct surface_flinger_cblk_t;
// ---------------------------------------------------------------------------
@@ -176,7 +175,6 @@ private:
*/
virtual sp<ISurfaceComposerClient> createConnection();
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
- virtual sp<IMemoryHeap> getCblk() const;
virtual void bootFinished();
virtual void setTransactionState(const Vector<ComposerState>& state,
const Vector<DisplayState>& displays, uint32_t flags);
@@ -193,6 +191,7 @@ private:
virtual void blank();
// called when screen is turning back on
virtual void unblank();
+ virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info);
virtual void connectDisplay(const sp<ISurfaceTexture> display);
/* ------------------------------------------------------------------------
@@ -382,8 +381,6 @@ private:
Region mInvalidateRegion;
// constant members (no synchronization needed for access)
- sp<IMemoryHeap> mServerHeap;
- surface_flinger_cblk_t* mServerCblk;
HWComposer* mHwc;
GLuint mWormholeTexName;
GLuint mProtectedTexName;
@@ -431,8 +428,6 @@ private:
EGLSurface getExternalDisplaySurface() const;
sp<SurfaceTextureClient> mExternalDisplayNativeWindow;
EGLSurface mExternalDisplaySurface;
-public:
- surface_flinger_cblk_t* getControlBlock() const;
};
// ---------------------------------------------------------------------------
diff --git a/services/surfaceflinger/tests/Transaction_test.cpp b/services/surfaceflinger/tests/Transaction_test.cpp
index 84ae0d9..e3a98ff 100644
--- a/services/surfaceflinger/tests/Transaction_test.cpp
+++ b/services/surfaceflinger/tests/Transaction_test.cpp
@@ -24,6 +24,7 @@
#include <private/gui/ComposerService.h>
#include <utils/String8.h>
+#include <ui/DisplayInfo.h>
namespace android {
@@ -92,8 +93,11 @@ protected:
mComposerClient = new SurfaceComposerClient;
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
- ssize_t displayWidth = mComposerClient->getDisplayWidth(0);
- ssize_t displayHeight = mComposerClient->getDisplayHeight(0);
+ DisplayInfo info;
+ SurfaceComposerClient::getDisplayInfo(0, &info);
+
+ ssize_t displayWidth = info.w;
+ ssize_t displayHeight = info.h;
// Background surface
mBGSurfaceControl = mComposerClient->createSurface(