diff --git a/configstore/1.2/Android.bp b/configstore/1.2/Android.bp index a20eb34dd8..cc5644ca80 100644 --- a/configstore/1.2/Android.bp +++ b/configstore/1.2/Android.bp @@ -12,6 +12,7 @@ hidl_interface { interfaces: [ "android.hardware.configstore@1.1", "android.hardware.configstore@1.0", + "android.hardware.graphics.common@1.1", "android.hidl.base@1.0", ], gen_java: true, diff --git a/configstore/1.2/ISurfaceFlingerConfigs.hal b/configstore/1.2/ISurfaceFlingerConfigs.hal index c32cc82910..c8791553a2 100644 --- a/configstore/1.2/ISurfaceFlingerConfigs.hal +++ b/configstore/1.2/ISurfaceFlingerConfigs.hal @@ -15,6 +15,8 @@ */ package android.hardware.configstore@1.2; +import android.hardware.graphics.common@1.1::Dataspace; +import android.hardware.graphics.common@1.1::PixelFormat; import @1.1::ISurfaceFlingerConfigs; import @1.0::OptionalBool; @@ -30,4 +32,27 @@ interface ISurfaceFlingerConfigs extends @1.1::ISurfaceFlingerConfigs { * return true. */ useColorManagement() generates (OptionalBool value); + + /** + * Returns the default data space and default pixel format that + * SurfaceFlinger expects to receive and output. + * To determine the default data space and default pixel format, + * there are a few things we recommend to consider: + * + * 1. Hardware composer's capability to composite contents with the + * data space and pixel format efficiently; + * 2. Hardware composer's ability to composite contents when sRGB contents + * and the chosen data space contents coexist; + * 3. For better blending, consider using pixel format where the alpha + * channel has as many bits as the RGB color channel. + * + * @return dataSpace is the default data space that SurfaceFlinger expects. + * The data space must not be Dataspace::UNKNOWN, if unspecified, + * the default data space is Dataspace::V0_SRGB; + * @return pixelFormat is the default pixel format that SurfaceFlinger + * expects. If unspecified, the default pixel format is + * PixelFormat::RGBA_8888. + */ + getCompositionPreference() + generates (Dataspace dataSpace, PixelFormat pixelFormat); }; diff --git a/configstore/1.2/default/SurfaceFlingerConfigs.cpp b/configstore/1.2/default/SurfaceFlingerConfigs.cpp index c7bd567fef..ae19dc0799 100644 --- a/configstore/1.2/default/SurfaceFlingerConfigs.cpp +++ b/configstore/1.2/default/SurfaceFlingerConfigs.cpp @@ -17,6 +17,7 @@ #include "SurfaceFlingerConfigs.h" #include +#include #include namespace android { @@ -25,6 +26,9 @@ namespace configstore { namespace V1_2 { namespace implementation { +using ::android::hardware::graphics::common::V1_1::Dataspace; +using ::android::hardware::graphics::common::V1_1::PixelFormat; + // ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs implementation. Return SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) { #ifdef VSYNC_EVENT_PHASE_OFFSET_NS @@ -199,6 +203,25 @@ Return SurfaceFlingerConfigs::useColorManagement(useColorManagement_cb _hi return Void(); } +#ifdef COMPOSITION_DATA_SPACE +static_assert(COMPOSITION_DATA_SPACE != 0, "Expected composition data space must not be UNKNOWN"); +#endif + +Return SurfaceFlingerConfigs::getCompositionPreference(getCompositionPreference_cb _hidl_cb) { + Dataspace dataSpace = Dataspace::V0_SRGB; + PixelFormat pixelFormat = PixelFormat::RGBA_8888; + +#ifdef COMPOSITION_DATA_SPACE + dataSpace = static_cast(COMPOSITION_DATA_SPACE); +#endif + +#ifdef COMPOSITION_PIXEL_FORMAT + pixelFormat = static_cast(COMPOSITION_PIXEL_FORMAT); +#endif + _hidl_cb(dataSpace, pixelFormat); + return Void(); +} + } // namespace implementation } // namespace V1_2 } // namespace configstore diff --git a/configstore/1.2/default/SurfaceFlingerConfigs.h b/configstore/1.2/default/SurfaceFlingerConfigs.h index fe787890f0..7dd8f6d2c9 100644 --- a/configstore/1.2/default/SurfaceFlingerConfigs.h +++ b/configstore/1.2/default/SurfaceFlingerConfigs.h @@ -52,6 +52,7 @@ struct SurfaceFlingerConfigs : public ISurfaceFlingerConfigs { // ::android::hardware::configstore::V1_2::ISurfaceFlingerConfigs follow implementation. Return useColorManagement(useColorManagement_cb _hidl_cb) override; + Return getCompositionPreference(getCompositionPreference_cb _hidl_cb) override; }; } // namespace implementation diff --git a/configstore/1.2/default/surfaceflinger.mk b/configstore/1.2/default/surfaceflinger.mk index 70be4501e1..f3239996d9 100644 --- a/configstore/1.2/default/surfaceflinger.mk +++ b/configstore/1.2/default/surfaceflinger.mk @@ -58,3 +58,11 @@ endif ifeq ($(TARGET_USE_COLOR_MANAGEMENT),true) LOCAL_CFLAGS += -DUSE_COLOR_MANAGEMENT endif + +ifneq ($(SF_COMPOSITION_DATA_SPACE),) + LOCAL_CFLAGS += -DCOMPOSITION_DATA_SPACE=$(SF_COMPOSITION_DATA_SPACE) +endif + +ifneq ($(SF_COMPOSITION_PIXEL_FORMAT),) + LOCAL_CFLAGS += -DCOMPOSITION_PIXEL_FORMAT=$(SF_COMPOSITION_PIXEL_FORMAT) +endif