diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-08-24 20:00:51 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-08-27 14:40:17 -0700 |
commit | 9d4e3d2f42e93e2d12bacabe97d307d30c3c20dd (patch) | |
tree | 3db010ef45a3793c5b09887ae321b4a8095a5001 /libs/gui | |
parent | 225c66a48cdc3acef21ee380dc134449749d3cb3 (diff) | |
download | frameworks_native-9d4e3d2f42e93e2d12bacabe97d307d30c3c20dd.zip frameworks_native-9d4e3d2f42e93e2d12bacabe97d307d30c3c20dd.tar.gz frameworks_native-9d4e3d2f42e93e2d12bacabe97d307d30c3c20dd.tar.bz2 |
Banish DisplayID from the SurfaceFlinger API.
Use only display tokens in the API to refer to new displays.
Don't require the caller to specify the display when creating
a surface (since in general a surface could be shown on
any display).
This is intended to be a minimum change just to update the API.
Note that SurfaceFlinger still uses DisplayID in a few places
internally that might cause some features not to work properly
when there are multiple displays (LayerScreenshot, for example).
Change-Id: I3d91eec2da406eefd97bcd53655d403ad865a7e6
Diffstat (limited to 'libs/gui')
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 20 | ||||
-rw-r--r-- | libs/gui/ISurfaceComposerClient.cpp | 5 | ||||
-rw-r--r-- | libs/gui/Surface.cpp | 11 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 53 | ||||
-rw-r--r-- | libs/gui/tests/SurfaceTexture_test.cpp | 2 | ||||
-rw-r--r-- | libs/gui/tests/Surface_test.cpp | 7 |
6 files changed, 46 insertions, 52 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 76b23f3..6bcc41d 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -102,15 +102,15 @@ public: remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply); } - virtual status_t captureScreen(DisplayID dpy, - sp<IMemoryHeap>* heap, + virtual status_t captureScreen( + const sp<IBinder>& display, sp<IMemoryHeap>* heap, uint32_t* width, uint32_t* height, PixelFormat* format, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); - data.writeInt32(dpy); + data.writeStrongBinder(display); data.writeInt32(reqWidth); data.writeInt32(reqHeight); data.writeInt32(minLayerZ); @@ -210,18 +210,18 @@ public: remote()->transact(BnSurfaceComposer::UNBLANK, data, &reply); } - virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info) + virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); - data.writeInt32(dpy); + data.writeStrongBinder(display); 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) { + virtual void connectDisplay(const sp<ISurfaceTexture>& display) { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(display->asBinder()); @@ -274,7 +274,7 @@ status_t BnSurfaceComposer::onTransact( } break; case CAPTURE_SCREEN: { CHECK_INTERFACE(ISurfaceComposer, data, reply); - DisplayID dpy = data.readInt32(); + sp<IBinder> display = data.readStrongBinder(); uint32_t reqWidth = data.readInt32(); uint32_t reqHeight = data.readInt32(); uint32_t minLayerZ = data.readInt32(); @@ -282,7 +282,7 @@ status_t BnSurfaceComposer::onTransact( sp<IMemoryHeap> heap; uint32_t w, h; PixelFormat f; - status_t res = captureScreen(dpy, &heap, &w, &h, &f, + status_t res = captureScreen(display, &heap, &w, &h, &f, reqWidth, reqHeight, minLayerZ, maxLayerZ); reply->writeStrongBinder(heap->asBinder()); reply->writeInt32(w); @@ -327,8 +327,8 @@ status_t BnSurfaceComposer::onTransact( case GET_DISPLAY_INFO: { CHECK_INTERFACE(ISurfaceComposer, data, reply); DisplayInfo info; - DisplayID dpy = data.readInt32(); - status_t result = getDisplayInfo(dpy, &info); + sp<IBinder> display = data.readStrongBinder(); + status_t result = getDisplayInfo(display, &info); memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo)); reply->writeInt32(result); } break; diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp index ca9ed5b..8f7bc05 100644 --- a/libs/gui/ISurfaceComposerClient.cpp +++ b/libs/gui/ISurfaceComposerClient.cpp @@ -52,7 +52,6 @@ public: virtual sp<ISurface> createSurface( surface_data_t* params, const String8& name, - DisplayID display, uint32_t w, uint32_t h, PixelFormat format, @@ -61,7 +60,6 @@ public: Parcel data, reply; data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor()); data.writeString8(name); - data.writeInt32(display); data.writeInt32(w); data.writeInt32(h); data.writeInt32(format); @@ -93,12 +91,11 @@ status_t BnSurfaceComposerClient::onTransact( CHECK_INTERFACE(ISurfaceComposerClient, data, reply); surface_data_t params; String8 name = data.readString8(); - DisplayID display = data.readInt32(); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); PixelFormat format = data.readInt32(); uint32_t flags = data.readInt32(); - sp<ISurface> s = createSurface(¶ms, name, display, w, h, + sp<ISurface> s = createSurface(¶ms, name, w, h, format, flags); params.writeToParcel(reply); reply->writeStrongBinder(s->asBinder()); diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index b9cbfa6..33cc480 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -92,6 +92,12 @@ bool SurfaceControl::isSameSurface( return lhs->mSurface->asBinder() == rhs->mSurface->asBinder(); } +status_t SurfaceControl::setLayerStack(int32_t layerStack) { + status_t err = validate(); + if (err < 0) return err; + const sp<SurfaceComposerClient>& client(mClient); + return client->setLayerStack(mToken, layerStack); +} status_t SurfaceControl::setLayer(int32_t layer) { status_t err = validate(); if (err < 0) return err; @@ -299,8 +305,11 @@ void Surface::init(const sp<ISurfaceTexture>& surfaceTexture) setUsage(GraphicBuffer::USAGE_HW_RENDER); } + // TODO: the display metrics should come from the display manager DisplayInfo dinfo; - SurfaceComposerClient::getDisplayInfo(0, &dinfo); + sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay( + ISurfaceComposer::eDisplayIdMain); + SurfaceComposerClient::getDisplayInfo(display, &dinfo); const_cast<float&>(ANativeWindow::xdpi) = dinfo.xdpi; const_cast<float&>(ANativeWindow::ydpi) = dinfo.ydpi; const_cast<uint32_t&>(ANativeWindow::flags) = 0; diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 1e6e1bd..1b81e45 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -94,6 +94,7 @@ class Composer : public Singleton<Composer> public: sp<IBinder> createDisplay(); + sp<IBinder> getBuiltInDisplay(int32_t id); status_t setPosition(const sp<SurfaceComposerClient>& client, SurfaceID id, float x, float y); @@ -135,6 +136,10 @@ sp<IBinder> Composer::createDisplay() { return ComposerService::getComposerService()->createDisplay(); } +sp<IBinder> Composer::getBuiltInDisplay(int32_t id) { + return ComposerService::getComposerService()->getBuiltInDisplay(id); +} + void Composer::closeGlobalTransactionImpl(bool synchronous) { sp<ISurfaceComposer> sm(ComposerService::getComposerService()); @@ -403,25 +408,7 @@ void SurfaceComposerClient::dispose() { } sp<SurfaceControl> SurfaceComposerClient::createSurface( - DisplayID display, - uint32_t w, - uint32_t h, - PixelFormat format, - uint32_t flags) -{ - String8 name; - const size_t SIZE = 128; - char buffer[SIZE]; - snprintf(buffer, SIZE, "<pid_%d>", getpid()); - name.append(buffer); - - return SurfaceComposerClient::createSurface(name, display, - w, h, format, flags); -} - -sp<SurfaceControl> SurfaceComposerClient::createSurface( const String8& name, - DisplayID display, uint32_t w, uint32_t h, PixelFormat format, @@ -431,7 +418,7 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface( if (mStatus == NO_ERROR) { ISurfaceComposerClient::surface_data_t data; sp<ISurface> surface = mClient->createSurface(&data, name, - display, w, h, format, flags); + w, h, format, flags); if (surface != 0) { result = new SurfaceControl(this, surface, data); } @@ -443,6 +430,10 @@ sp<IBinder> SurfaceComposerClient::createDisplay() { return Composer::getInstance().createDisplay(); } +sp<IBinder> SurfaceComposerClient::getBuiltInDisplay(int32_t id) { + return Composer::getInstance().getBuiltInDisplay(id); +} + status_t SurfaceComposerClient::destroySurface(SurfaceID sid) { if (mStatus != NO_ERROR) return mStatus; @@ -517,12 +508,6 @@ status_t SurfaceComposerClient::setMatrix(SurfaceID id, float dsdx, float dtdx, return getComposer().setMatrix(this, id, dsdx, dtdx, dsdy, dtdy); } -status_t SurfaceComposerClient::setOrientation(DisplayID dpy, - int orientation, uint32_t flags) -{ - return Composer::getInstance().setOrientation(orientation); -} - // ---------------------------------------------------------------------------- void SurfaceComposerClient::setDisplaySurface(const sp<IBinder>& token, @@ -553,9 +538,9 @@ void SurfaceComposerClient::setDisplayFrame(const sp<IBinder>& token, // ---------------------------------------------------------------------------- status_t SurfaceComposerClient::getDisplayInfo( - DisplayID dpy, DisplayInfo* info) + const sp<IBinder>& display, DisplayInfo* info) { - return ComposerService::getComposerService()->getDisplayInfo(dpy, info); + return ComposerService::getComposerService()->getDisplayInfo(display, info); } // ---------------------------------------------------------------------------- @@ -564,30 +549,32 @@ ScreenshotClient::ScreenshotClient() : mWidth(0), mHeight(0), mFormat(PIXEL_FORMAT_NONE) { } -status_t ScreenshotClient::update() { +status_t ScreenshotClient::update(const sp<IBinder>& display) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); if (s == NULL) return NO_INIT; mHeap = 0; - return s->captureScreen(0, &mHeap, + return s->captureScreen(display, &mHeap, &mWidth, &mHeight, &mFormat, 0, 0, 0, -1UL); } -status_t ScreenshotClient::update(uint32_t reqWidth, uint32_t reqHeight) { +status_t ScreenshotClient::update(const sp<IBinder>& display, + uint32_t reqWidth, uint32_t reqHeight) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); if (s == NULL) return NO_INIT; mHeap = 0; - return s->captureScreen(0, &mHeap, + return s->captureScreen(display, &mHeap, &mWidth, &mHeight, &mFormat, reqWidth, reqHeight, 0, -1UL); } -status_t ScreenshotClient::update(uint32_t reqWidth, uint32_t reqHeight, +status_t ScreenshotClient::update(const sp<IBinder>& display, + uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ) { sp<ISurfaceComposer> s(ComposerService::getComposerService()); if (s == NULL) return NO_INIT; mHeap = 0; - return s->captureScreen(0, &mHeap, + return s->captureScreen(display, &mHeap, &mWidth, &mHeight, &mFormat, reqWidth, reqHeight, minLayerZ, maxLayerZ); } diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp index 0060cf7..04f4b55 100644 --- a/libs/gui/tests/SurfaceTexture_test.cpp +++ b/libs/gui/tests/SurfaceTexture_test.cpp @@ -83,7 +83,7 @@ protected: ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); mSurfaceControl = mComposerClient->createSurface( - String8("Test Surface"), 0, + String8("Test Surface"), getSurfaceWidth(), getSurfaceHeight(), PIXEL_FORMAT_RGB_888, 0); diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 5046bf5..545b547 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -33,7 +33,7 @@ protected: ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); mSurfaceControl = mComposerClient->createSurface( - String8("Test Surface"), 0, 32, 32, PIXEL_FORMAT_RGBA_8888, 0); + String8("Test Surface"), 32, 32, PIXEL_FORMAT_RGBA_8888, 0); ASSERT_TRUE(mSurfaceControl != NULL); ASSERT_TRUE(mSurfaceControl->isValid()); @@ -85,7 +85,8 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersSucceed) { uint32_t w=0, h=0; PixelFormat fmt=0; sp<ISurfaceComposer> sf(ComposerService::getComposerService()); - ASSERT_EQ(NO_ERROR, sf->captureScreen(0, &heap, &w, &h, &fmt, 64, 64, 0, + sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain)); + ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &heap, &w, &h, &fmt, 64, 64, 0, 0x7fffffff)); ASSERT_TRUE(heap != NULL); @@ -117,7 +118,7 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersSucceed) { } heap = 0; w = h = fmt = 0; - ASSERT_EQ(NO_ERROR, sf->captureScreen(0, &heap, &w, &h, &fmt, + ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &heap, &w, &h, &fmt, 64, 64, 0, 0x7fffffff)); ASSERT_TRUE(heap != NULL); } |