Merge "[ConfigStore] Return data space and pixel format for wide color gamut."
diff --git a/configstore/1.2/ISurfaceFlingerConfigs.hal b/configstore/1.2/ISurfaceFlingerConfigs.hal
index 9553fca..e91b2c7 100644
--- a/configstore/1.2/ISurfaceFlingerConfigs.hal
+++ b/configstore/1.2/ISurfaceFlingerConfigs.hal
@@ -34,25 +34,39 @@
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:
+ * Returns the default data space and pixel format that SurfaceFlinger
+ * expects to receive and output as well as the wide color gamut data space
+ * and pixel format for wide color gamut surfaces.
+ * To determine the data space and pixel format, there are a few things
+ * we recommend to consider:
*
- * 1. Hardware composer's capability to composite contents with the
+ * 1. Hardware composer's capability to composite contents with the chosen
* data space and pixel format efficiently;
* 2. Hardware composer's ability to composite contents when sRGB contents
- * and the chosen data space contents coexist;
+ * and the chosen wide color gamut 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.
+ * 4. Memory consumption and efficient buffer compression when considering
+ * more bits in pixel format.
*
- * @return dataSpace is the default data space that SurfaceFlinger expects.
+ * @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.
+ * @return wcgDataspace is the data space that SurfaceFlinger expects for
+ * wide color gamut surfaces.
+ * When hasWideColorDisplay returns true, this API must return a
+ * valid wide color gamut data space.
+ * The data space must not be UNKNOWN, if unspecified, the data space
+ * is V0_SRGB by default, which essentially indicates there's no wide
+ * color gamut, meaning hasWideColorDisplay returns false.
+ * @return wcgPixelFormat is the pixel format that SurfaceFlinger expects for
+ * wide color gamut surfaces. If unspecified, the pixel format is
+ * PixelFormat::RGBA_8888 by default.
*/
getCompositionPreference()
- generates (Dataspace dataSpace, PixelFormat pixelFormat);
+ generates (Dataspace dataspace, PixelFormat pixelFormat,
+ Dataspace wcgDataspace, PixelFormat wcgPixelFormat);
};
diff --git a/configstore/1.2/default/SurfaceFlingerConfigs.cpp b/configstore/1.2/default/SurfaceFlingerConfigs.cpp
index b78d15e..c2cf374 100644
--- a/configstore/1.2/default/SurfaceFlingerConfigs.cpp
+++ b/configstore/1.2/default/SurfaceFlingerConfigs.cpp
@@ -203,22 +203,41 @@
return Void();
}
-#ifdef COMPOSITION_DATA_SPACE
-static_assert(COMPOSITION_DATA_SPACE != 0, "Expected composition data space must not be UNKNOWN");
+#ifdef DEFAULT_COMPOSITION_DATA_SPACE
+static_assert(DEFAULT_COMPOSITION_DATA_SPACE != 0,
+ "Default composition data space must not be UNKNOWN");
+#endif
+
+#ifdef WCG_COMPOSITION_DATA_SPACE
+static_assert(WCG_COMPOSITION_DATA_SPACE != 0,
+ "Wide color gamut 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;
+ Dataspace defaultDataspace = Dataspace::V0_SRGB;
+ PixelFormat defaultPixelFormat = PixelFormat::RGBA_8888;
-#ifdef COMPOSITION_DATA_SPACE
- dataSpace = static_cast<Dataspace>(COMPOSITION_DATA_SPACE);
+#ifdef DEFAULT_COMPOSITION_DATA_SPACE
+ defaultDataspace = static_cast<Dataspace>(DEFAULT_COMPOSITION_DATA_SPACE);
#endif
-#ifdef COMPOSITION_PIXEL_FORMAT
- pixelFormat = static_cast<PixelFormat>(COMPOSITION_PIXEL_FORMAT);
+#ifdef DEFAULT_COMPOSITION_PIXEL_FORMAT
+ defaultPixelFormat = static_cast<PixelFormat>(DEFAULT_COMPOSITION_PIXEL_FORMAT);
#endif
- _hidl_cb(dataSpace, pixelFormat);
+
+ Dataspace wideColorGamutDataspace = Dataspace::V0_SRGB;
+ PixelFormat wideColorGamutPixelFormat = PixelFormat::RGBA_8888;
+
+#ifdef WCG_COMPOSITION_DATA_SPACE
+ wideColorGamutDataspace = static_cast<Dataspace>(WCG_COMPOSITION_DATA_SPACE);
+#endif
+
+#ifdef WCG_COMPOSITION_PIXEL_FORMAT
+ wideColorGamutPixelFormat = static_cast<PixelFormat>(WCG_COMPOSITION_PIXEL_FORMAT);
+#endif
+
+ _hidl_cb(defaultDataspace, defaultPixelFormat, wideColorGamutDataspace,
+ wideColorGamutPixelFormat);
return Void();
}
diff --git a/configstore/1.2/default/surfaceflinger.mk b/configstore/1.2/default/surfaceflinger.mk
index f323999..dab6aa5 100644
--- a/configstore/1.2/default/surfaceflinger.mk
+++ b/configstore/1.2/default/surfaceflinger.mk
@@ -59,10 +59,18 @@
LOCAL_CFLAGS += -DUSE_COLOR_MANAGEMENT
endif
-ifneq ($(SF_COMPOSITION_DATA_SPACE),)
- LOCAL_CFLAGS += -DCOMPOSITION_DATA_SPACE=$(SF_COMPOSITION_DATA_SPACE)
+ifneq ($(SF_DEFAULT_COMPOSITION_DATA_SPACE),)
+ LOCAL_CFLAGS += -DDEFAULT_COMPOSITION_DATA_SPACE=$(SF_DEFAULT_COMPOSITION_DATA_SPACE)
endif
-ifneq ($(SF_COMPOSITION_PIXEL_FORMAT),)
- LOCAL_CFLAGS += -DCOMPOSITION_PIXEL_FORMAT=$(SF_COMPOSITION_PIXEL_FORMAT)
+ifneq ($(SF_DEFAULT_COMPOSITION_PIXEL_FORMAT),)
+ LOCAL_CFLAGS += -DDEFAULT_COMPOSITION_PIXEL_FORMAT=$(SF_DEFAULT_COMPOSITION_PIXEL_FORMAT)
+endif
+
+ifneq ($(SF_WCG_COMPOSITION_DATA_SPACE),)
+ LOCAL_CFLAGS += -DWCG_COMPOSITION_DATA_SPACE=$(SF_WCG_COMPOSITION_DATA_SPACE)
+endif
+
+ifneq ($(SF_WCG_COMPOSITION_PIXEL_FORMAT),)
+ LOCAL_CFLAGS += -DWCG_COMPOSITION_PIXEL_FORMAT=$(SF_WCG_COMPOSITION_PIXEL_FORMAT)
endif