diff options
author | Andy McFadden <fadden@android.com> | 2012-09-17 18:27:17 -0700 |
---|---|---|
committer | Andy McFadden <fadden@android.com> | 2012-09-18 09:20:23 -0700 |
commit | 8dfa92fef9759a881e96ee58d59875d35023aab9 (patch) | |
tree | c004a49450a89c5ae204eb1d9d4398e44a4badab | |
parent | d870703d5566490cfdfb389d9336b2b8d3c6cc7a (diff) | |
download | frameworks_native-8dfa92fef9759a881e96ee58d59875d35023aab9.zip frameworks_native-8dfa92fef9759a881e96ee58d59875d35023aab9.tar.gz frameworks_native-8dfa92fef9759a881e96ee58d59875d35023aab9.tar.bz2 |
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
-rw-r--r-- | include/gui/ISurfaceComposer.h | 2 | ||||
-rw-r--r-- | include/gui/SurfaceComposerClient.h | 2 | ||||
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 6 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 10 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayDevice.cpp | 14 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayDevice.h | 8 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 12 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 3 |
8 files changed, 42 insertions, 15 deletions
diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h index f4af705..a20caf9 100644 --- a/include/gui/ISurfaceComposer.h +++ b/include/gui/ISurfaceComposer.h @@ -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. diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h index 57c72c9..7a14c6a 100644 --- a/include/gui/SurfaceComposerClient.h +++ b/include/gui/SurfaceComposerClient.h @@ -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. diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 6bcc41d..07d2b79 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -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; diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 9b43ae8..9cf9cb5 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -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) { diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index 2708a90..78024b8 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -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); } diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h index 4a3f0a0..e3b8d57 100644 --- a/services/surfaceflinger/DisplayDevice.h +++ b/services/surfaceflinger/DisplayDevice.h @@ -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 diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index bdd8c67..27677d6 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -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(), diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index a648621..e2bc69c 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -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); |