diff options
author | Peiyong Lin <lpy@google.com> | 2018-08-31 14:13:36 -0700 |
---|---|---|
committer | Peiyong Lin <lpy@google.com> | 2018-09-06 12:24:21 -0700 |
commit | bfbaf8400e2379b3db71a1cc356d7c5dd7ec3b18 (patch) | |
tree | 3d630176d98a882f7c0bb41294424ca00e971a4e /configstore | |
parent | 2e133cf047e3c83c773a121ea002f1e5cfbf1428 (diff) |
[ConfigStore] Add getCompositionPreference.
In order to tell renderer to render into the best color space with the right
pixel format. We need to expose it as a composition preference. This patch adds
ConfigStore API to query such preference.
Typically, this API will return the default data space of a color space that
the panel is calibrated to, with the default pixel format that hardware
composer can composite to efficiently. However, devices can make tradeoff
between data space and pixel format.
BUG: 113530681
Test: Build, flash, boot
Change-Id: I0ea09e21e70843b50157ec617c87a42bb4ff7332
Diffstat (limited to 'configstore')
-rw-r--r-- | configstore/1.2/Android.bp | 1 | ||||
-rw-r--r-- | configstore/1.2/ISurfaceFlingerConfigs.hal | 25 | ||||
-rw-r--r-- | configstore/1.2/default/SurfaceFlingerConfigs.cpp | 23 | ||||
-rw-r--r-- | configstore/1.2/default/SurfaceFlingerConfigs.h | 1 | ||||
-rw-r--r-- | configstore/1.2/default/surfaceflinger.mk | 8 |
5 files changed, 58 insertions, 0 deletions
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 <android/hardware/configstore/1.1/types.h> +#include <android/hardware/graphics/common/1.1/types.h> #include <log/log.h> 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<void> SurfaceFlingerConfigs::vsyncEventPhaseOffsetNs(vsyncEventPhaseOffsetNs_cb _hidl_cb) { #ifdef VSYNC_EVENT_PHASE_OFFSET_NS @@ -199,6 +203,25 @@ Return<void> 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<void> SurfaceFlingerConfigs::getCompositionPreference(getCompositionPreference_cb _hidl_cb) { + Dataspace dataSpace = Dataspace::V0_SRGB; + PixelFormat pixelFormat = PixelFormat::RGBA_8888; + +#ifdef COMPOSITION_DATA_SPACE + dataSpace = static_cast<Dataspace>(COMPOSITION_DATA_SPACE); +#endif + +#ifdef COMPOSITION_PIXEL_FORMAT + pixelFormat = static_cast<PixelFormat>(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<void> useColorManagement(useColorManagement_cb _hidl_cb) override; + Return<void> 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 |