diff options
author | 2021-12-29 11:53:36 -0500 | |
---|---|---|
committer | 2022-01-05 15:08:51 -0500 | |
commit | e5cff63e831dfb62478701e39b8f0d2a7fe5e320 (patch) | |
tree | ecdcee7a232c48e0af69ba1392f03234d16e8315 | |
parent | 515f038344603880698e2ae5058858fe3cc429f0 (diff) |
Query the new DisplayCapability for DISPLAY_DECORATION
This allows clients (i.e. SystemUi) to know whether to use
Composition.DISPLAY_DECORATION.
Bug: 193170859
Test: manual
Test: TODO (b/212697197)
Change-Id: I0d3e93bb04937f81e95ef77d196b861621bbdc8d
-rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 41 | ||||
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 6 | ||||
-rw-r--r-- | libs/gui/include/gui/ISurfaceComposer.h | 17 | ||||
-rw-r--r-- | libs/gui/include/gui/SurfaceComposerClient.h | 10 | ||||
-rw-r--r-- | libs/gui/tests/Surface_test.cpp | 5 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/Hal.h | 2 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 18 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 2 |
8 files changed, 101 insertions, 0 deletions
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 7f73013f6e..a931709dbd 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -1134,6 +1134,34 @@ public: return NO_ERROR; } + status_t getDisplayDecorationSupport(const sp<IBinder>& displayToken, + bool* outSupport) const override { + Parcel data, reply; + status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); + if (error != NO_ERROR) { + ALOGE("getDisplayDecorationSupport: failed to write interface token: %d", error); + return error; + } + error = data.writeStrongBinder(displayToken); + if (error != NO_ERROR) { + ALOGE("getDisplayDecorationSupport: failed to write display token: %d", error); + return error; + } + error = remote()->transact(BnSurfaceComposer::GET_DISPLAY_DECORATION_SUPPORT, data, &reply); + if (error != NO_ERROR) { + ALOGE("getDisplayDecorationSupport: failed to transact: %d", error); + return error; + } + bool support; + error = reply.readBool(&support); + if (error != NO_ERROR) { + ALOGE("getDisplayDecorationSupport: failed to read support: %d", error); + return error; + } + *outSupport = support; + return NO_ERROR; + } + status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy) override { Parcel data, reply; @@ -2016,6 +2044,19 @@ status_t BnSurfaceComposer::onTransact( return setGlobalShadowSettings(ambientColor, spotColor, lightPosY, lightPosZ, lightRadius); } + case GET_DISPLAY_DECORATION_SUPPORT: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); + sp<IBinder> displayToken; + status_t error = data.readNullableStrongBinder(&displayToken); + if (error != NO_ERROR) { + ALOGE("getDisplayDecorationSupport: failed to read display token: %d", error); + return error; + } + bool support = false; + error = getDisplayDecorationSupport(displayToken, &support); + reply->writeBool(support); + return error; + } case SET_FRAME_RATE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> binder; diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index cf04ec8051..665363627a 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -2218,6 +2218,12 @@ status_t SurfaceComposerClient::setGlobalShadowSettings(const half4& ambientColo lightRadius); } +bool SurfaceComposerClient::getDisplayDecorationSupport(const sp<IBinder>& displayToken) { + bool support = false; + ComposerService::getComposerService()->getDisplayDecorationSupport(displayToken, &support); + return support; +} + int SurfaceComposerClient::getGPUContextPriority() { return ComposerService::getComposerService()->getGPUContextPriority(); } diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h index 2546e4c753..69dce9d6ed 100644 --- a/libs/gui/include/gui/ISurfaceComposer.h +++ b/libs/gui/include/gui/ISurfaceComposer.h @@ -508,6 +508,22 @@ public: float lightRadius) = 0; /* + * Gets whether a display supports DISPLAY_DECORATION layers. + * + * displayToken + * The token of the display. + * outSupport + * An output parameter for whether the display supports + * DISPLAY_DECORATION layers. + * + * Returns NO_ERROR upon success. Otherwise, + * NAME_NOT_FOUND if the display is invalid, or + * BAD_VALUE if the output parameter is invalid. + */ + virtual status_t getDisplayDecorationSupport(const sp<IBinder>& displayToken, + bool* outSupport) const = 0; + + /* * Sets the intended frame rate for a surface. See ANativeWindow_setFrameRate() for more info. */ virtual status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate, @@ -628,6 +644,7 @@ public: ADD_WINDOW_INFOS_LISTENER, REMOVE_WINDOW_INFOS_LISTENER, GET_PRIMARY_PHYSICAL_DISPLAY_ID, + GET_DISPLAY_DECORATION_SUPPORT, // Always append new enum to the end. }; diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index 17b4846921..87606d6c8e 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -272,6 +272,16 @@ public: static status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor, float lightPosY, float lightPosZ, float lightRadius); + /* + * Returns whether a display supports DISPLAY_DECORATION layers. + * + * displayToken + * The token of the display. + * + * Returns whether a display supports DISPLAY_DECORATION layers. + */ + static bool getDisplayDecorationSupport(const sp<IBinder>& displayToken); + // ------------------------------------------------------------------------ // surface creation / destruction diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index d6ac3f9745..d5e089aae0 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -882,6 +882,11 @@ public: return NO_ERROR; } + status_t getDisplayDecorationSupport(const sp<IBinder>& /*displayToken*/, + bool* /*outSupport*/) const override { + return NO_ERROR; + } + status_t setFrameRate(const sp<IGraphicBufferProducer>& /*surface*/, float /*frameRate*/, int8_t /*compatibility*/, int8_t /*changeFrameRateStrategy*/) override { return NO_ERROR; diff --git a/services/surfaceflinger/DisplayHardware/Hal.h b/services/surfaceflinger/DisplayHardware/Hal.h index e33dc0f9a8..ee06e03d91 100644 --- a/services/surfaceflinger/DisplayHardware/Hal.h +++ b/services/surfaceflinger/DisplayHardware/Hal.h @@ -136,6 +136,8 @@ inline std::string to_string( return "AutoLowLatencyMode"; case aidl::android::hardware::graphics::composer3::DisplayCapability::SUSPEND: return "Suspend"; + case aidl::android::hardware::graphics::composer3::DisplayCapability::DISPLAY_DECORATION: + return "DisplayDecoration"; default: return "Unknown"; } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 89f3bd6fbb..d690ede655 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1748,6 +1748,23 @@ status_t SurfaceFlinger::notifyPowerBoost(int32_t boostId) { return NO_ERROR; } +status_t SurfaceFlinger::getDisplayDecorationSupport(const sp<IBinder>& displayToken, + bool* outSupport) const { + if (!displayToken || !outSupport) { + return BAD_VALUE; + } + + Mutex::Autolock lock(mStateLock); + + const auto displayId = getPhysicalDisplayIdLocked(displayToken); + if (!displayId) { + return NAME_NOT_FOUND; + } + *outSupport = + getHwComposer().hasDisplayCapability(*displayId, DisplayCapability::DISPLAY_DECORATION); + return NO_ERROR; +} + // ---------------------------------------------------------------------------- sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection( @@ -5339,6 +5356,7 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { // special permissions. case SET_FRAME_RATE: case GET_DISPLAY_BRIGHTNESS_SUPPORT: + case GET_DISPLAY_DECORATION_SUPPORT: // captureLayers and captureDisplay will handle the permission check in the function case CAPTURE_LAYERS: case CAPTURE_DISPLAY: diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index e1b52c5eae..2d1f9ba6cb 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -594,6 +594,8 @@ private: status_t notifyPowerBoost(int32_t boostId) override; status_t setGlobalShadowSettings(const half4& ambientColor, const half4& spotColor, float lightPosY, float lightPosZ, float lightRadius) override; + status_t getDisplayDecorationSupport(const sp<IBinder>& displayToken, + bool* outSupport) const override; status_t setFrameRate(const sp<IGraphicBufferProducer>& surface, float frameRate, int8_t compatibility, int8_t changeFrameRateStrategy) override; |