Plumb display name into SurfaceFlinger

The Surface createDisplay() call takes a display name for debugging.
This change carries it through SurfaceFlinger and displays it in
the "dumpsys SurfaceFlinger" output.

Bug 7058158

Change-Id: I79f3474a8656ff1beb7b478e0dbf2c5de666118a
This commit is contained in:
Andy McFadden 2012-09-17 18:27:17 -07:00
parent d870703d55
commit 8dfa92fef9
8 changed files with 42 additions and 15 deletions

View File

@ -68,7 +68,7 @@ public:
/* create a display
* requires ACCESS_SURFACE_FLINGER permission.
*/
virtual sp<IBinder> createDisplay() = 0;
virtual sp<IBinder> createDisplay(const String8& displayName) = 0;
/* get the token for the existing default displays. possible values
* for id are eDisplayIdMain and eDisplayIdHdmi.

View File

@ -85,7 +85,7 @@ public:
);
//! Create a display
static sp<IBinder> createDisplay();
static sp<IBinder> createDisplay(const String8& displayName);
//! Get the token for the existing default displays.
//! Possible values for id are eDisplayIdMain and eDisplayIdHdmi.

View File

@ -179,10 +179,11 @@ public:
return result;
}
virtual sp<IBinder> createDisplay()
virtual sp<IBinder> createDisplay(const String8& displayName)
{
Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
data.writeString8(displayName);
remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
return reply.readStrongBinder();
}
@ -305,7 +306,8 @@ status_t BnSurfaceComposer::onTransact(
} break;
case CREATE_DISPLAY: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
sp<IBinder> display(createDisplay());
String8 displayName = data.readString8();
sp<IBinder> display(createDisplay(displayName));
reply->writeStrongBinder(display);
return NO_ERROR;
} break;

View File

@ -128,7 +128,7 @@ class Composer : public Singleton<Composer>
DisplayState& getDisplayStateLocked(const sp<IBinder>& token);
public:
sp<IBinder> createDisplay();
sp<IBinder> createDisplay(const String8& displayName);
sp<IBinder> getBuiltInDisplay(int32_t id);
status_t setPosition(const sp<SurfaceComposerClient>& client, SurfaceID id,
@ -168,8 +168,8 @@ ANDROID_SINGLETON_STATIC_INSTANCE(Composer);
// ---------------------------------------------------------------------------
sp<IBinder> Composer::createDisplay() {
return ComposerService::getComposerService()->createDisplay();
sp<IBinder> Composer::createDisplay(const String8& displayName) {
return ComposerService::getComposerService()->createDisplay(displayName);
}
sp<IBinder> Composer::getBuiltInDisplay(int32_t id) {
@ -442,8 +442,8 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
return result;
}
sp<IBinder> SurfaceComposerClient::createDisplay() {
return Composer::getInstance().createDisplay();
sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName) {
return Composer::getInstance().createDisplay(displayName);
}
sp<IBinder> SurfaceComposerClient::getBuiltInDisplay(int32_t id) {

View File

@ -149,6 +149,20 @@ void DisplayDevice::init(EGLConfig config)
// get an h/w composer ID
mHwcDisplayId = mFlinger->allocateHwcDisplayId(mType);
// Name the display. The name will be replaced shortly if the display
// was created with createDisplay().
switch (mType) {
case DISPLAY_PRIMARY:
mDisplayName = "Built-in Screen";
break;
case DISPLAY_EXTERNAL:
mDisplayName = "HDMI Screen";
break;
default:
mDisplayName = "Virtual Screen"; // e.g. Overlay #n
break;
}
// initialize the display orientation transform.
setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
}

View File

@ -118,11 +118,16 @@ public:
}
inline Rect bounds() const { return getBounds(); }
void setDisplayName(const String8& displayName) {
mDisplayName = displayName;
}
const String8& getDisplayName() const { return mDisplayName; }
static EGLBoolean makeCurrent(EGLDisplay dpy,
const sp<const DisplayDevice>& hw, EGLContext ctx);
/* ------------------------------------------------------------------------
* blank / unplank management
* blank / unblank management
*/
void releaseScreen() const;
void acquireScreen() const;
@ -160,6 +165,7 @@ private:
PixelFormat mFormat;
uint32_t mFlags;
mutable uint32_t mPageFlipCount;
String8 mDisplayName;
/*
* Can only accessed from the main thread, these members

View File

@ -159,7 +159,7 @@ sp<ISurfaceComposerClient> SurfaceFlinger::createConnection()
return bclient;
}
sp<IBinder> SurfaceFlinger::createDisplay()
sp<IBinder> SurfaceFlinger::createDisplay(const String8& displayName)
{
class DisplayToken : public BBinder {
sp<SurfaceFlinger> flinger;
@ -179,6 +179,7 @@ sp<IBinder> SurfaceFlinger::createDisplay()
Mutex::Autolock _l(mStateLock);
DisplayDeviceState info(DisplayDevice::DISPLAY_VIRTUAL);
info.displayName = displayName;
mCurrentState.displays.add(token, info);
return token;
@ -573,7 +574,7 @@ void SurfaceFlinger::connectDisplay(const sp<ISurfaceTexture>& surface) {
}
if (token == 0) {
token = createDisplay();
token = createDisplay(String8("Display from connectDisplay"));
}
{ // scope for the lock
@ -1047,6 +1048,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
hw->setLayerStack(state.layerStack);
hw->setProjection(state.orientation,
state.viewport, state.frame);
hw->setDisplayName(state.displayName);
mDisplays.add(display, hw);
if (hw->getDisplayType() < DisplayDevice::NUM_DISPLAY_TYPES) {
// notify the system that this display is now up
@ -2019,14 +2021,16 @@ void SurfaceFlinger::dumpAllLocked(
* Dump Display state
*/
snprintf(buffer, SIZE, "Displays (%d entries)\n", mDisplays.size());
result.append(buffer);
for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
const sp<const DisplayDevice>& hw(mDisplays[dpy]);
snprintf(buffer, SIZE,
"+ DisplayDevice[%u]\n"
"+ DisplayDevice[%u] '%s'\n"
" type=%x, layerStack=%u, (%4dx%4d), orient=%2d (type=%08x), "
"flips=%u, secure=%d, numLayers=%u, v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], "
"transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
dpy,
dpy, (const char*) hw->getDisplayName(),
hw->getDisplayType(), hw->getLayerStack(),
hw->getWidth(), hw->getHeight(),
hw->getOrientation(), hw->getTransform().getType(),

View File

@ -173,6 +173,7 @@ private:
Rect viewport;
Rect frame;
uint8_t orientation;
String8 displayName;
};
struct State {
@ -192,7 +193,7 @@ private:
*/
virtual sp<ISurfaceComposerClient> createConnection();
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
virtual sp<IBinder> createDisplay();
virtual sp<IBinder> createDisplay(const String8& displayName);
virtual sp<IBinder> getBuiltInDisplay(int32_t id);
virtual void setTransactionState(const Vector<ComposerState>& state,
const Vector<DisplayState>& displays, uint32_t flags);