diff options
author | Yichi Chen <yichichen@google.com> | 2019-06-28 14:58:27 +0800 |
---|---|---|
committer | Yichi Chen <yichichen@google.com> | 2019-07-04 08:41:18 +0800 |
commit | da901bfc4f15723f0a7567ecd09742fd166df2f0 (patch) | |
tree | 398f9450270c04716ad841464f4b2dd6b8772b93 | |
parent | 57e206513f87b5af6b0a32ca6e9f245cd5b78040 (diff) |
SF: enable device-specific dataspace for color space agnostic surfaces
To reduce the DPU loading in color conversion, we enable device-specific
dataspace for color space agnostic surfaces. Since the type of surfaces
usually provide gray-level surfaces to users, it can be acceptable to
ignore the color conversion on them.
Bug: 134783740
Bug: 135140940
Test: Check ScreenDecorOverlays in expected dataspace
Test: Play HDR video on B1 and C2 and check dataspace
Change-Id: I7b11e11d2015eb5c8dfdc372e2c7ffcb40a2ac1d
6 files changed, 38 insertions, 3 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 459cd0af89..6d9dc97c5a 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -311,6 +311,9 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI wideColorGamutCompositionPixelFormat = static_cast<ui::PixelFormat>(wcg_composition_pixel_format(ui::PixelFormat::RGBA_8888)); + mColorSpaceAgnosticDataspace = + static_cast<ui::Dataspace>(color_space_agnostic_dataspace(Dataspace::UNKNOWN)); + useContextPriority = use_context_priority(true); auto tmpPrimaryDisplayOrientation = primary_display_orientation( @@ -1879,7 +1882,14 @@ void SurfaceFlinger::calculateWorkingSet() { RenderIntent renderIntent; pickColorMode(displayDevice, &colorMode, &targetDataspace, &renderIntent); display->setColorMode(colorMode, targetDataspace, renderIntent); + + if (isHdrColorMode(colorMode)) { + targetDataspace = Dataspace::UNKNOWN; + } else if (mColorSpaceAgnosticDataspace != Dataspace::UNKNOWN) { + targetDataspace = mColorSpaceAgnosticDataspace; + } } + for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) { if (layer->isHdrY410()) { layer->forceClientComposition(displayDevice); @@ -1906,9 +1916,7 @@ void SurfaceFlinger::calculateWorkingSet() { const auto& displayState = display->getState(); layer->setPerFrameData(displayDevice, displayState.transform, displayState.viewport, - displayDevice->getSupportedPerFrameMetadata(), - isHdrColorMode(displayState.colorMode) ? Dataspace::UNKNOWN - : targetDataspace); + displayDevice->getSupportedPerFrameMetadata(), targetDataspace); } } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 6d4b2d755c..556a4b9be5 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -1115,6 +1115,7 @@ private: ui::Dataspace mDefaultCompositionDataspace; ui::Dataspace mWideColorGamutCompositionDataspace; + ui::Dataspace mColorSpaceAgnosticDataspace; SurfaceFlingerBE mBE; std::unique_ptr<compositionengine::CompositionEngine> mCompositionEngine; diff --git a/services/surfaceflinger/SurfaceFlingerProperties.cpp b/services/surfaceflinger/SurfaceFlingerProperties.cpp index 2b33ba1746..237208d39f 100644 --- a/services/surfaceflinger/SurfaceFlingerProperties.cpp +++ b/services/surfaceflinger/SurfaceFlingerProperties.cpp @@ -218,6 +218,14 @@ int32_t wcg_composition_pixel_format(PixelFormat defaultValue) { return static_cast<int32_t>(defaultValue); } +int64_t color_space_agnostic_dataspace(Dataspace defaultValue) { + auto temp = SurfaceFlingerProperties::color_space_agnostic_dataspace(); + if (temp.has_value()) { + return *temp; + } + return static_cast<int64_t>(defaultValue); +} + int32_t set_idle_timer_ms(int32_t defaultValue) { auto temp = SurfaceFlingerProperties::set_idle_timer_ms(); if (temp.has_value()) { diff --git a/services/surfaceflinger/SurfaceFlingerProperties.h b/services/surfaceflinger/SurfaceFlingerProperties.h index 1964ccd582..b5418d6538 100644 --- a/services/surfaceflinger/SurfaceFlingerProperties.h +++ b/services/surfaceflinger/SurfaceFlingerProperties.h @@ -70,6 +70,9 @@ int64_t wcg_composition_dataspace( int32_t wcg_composition_pixel_format( android::hardware::graphics::common::V1_2::PixelFormat defaultValue); +int64_t color_space_agnostic_dataspace( + android::hardware::graphics::common::V1_2::Dataspace defaultValue); + int32_t set_idle_timer_ms(int32_t defaultValue); int32_t set_touch_timer_ms(int32_t defaultValue); diff --git a/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop b/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop index decabd5e88..f18f33c727 100644 --- a/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop +++ b/services/surfaceflinger/sysprop/SurfaceFlingerProperties.sysprop @@ -251,6 +251,20 @@ prop { prop_name: "ro.surface_flinger.wcg_composition_pixel_format" } +# colorSpaceAgnosticDataspace specifies the data space that +# SurfaceFlinger expects for surfaces which are color space agnostic. +# The variable works only when useColorManagement is specified. If +# unspecified, the data space follows what SurfaceFlinger expects for +# surfaces when useColorManagement is specified. + +prop { + api_name: "color_space_agnostic_dataspace" + type: Long + scope: System + access: Readonly + prop_name: "ro.surface_flinger.color_space_agnostic_dataspace" +} + # Return the native panel primary data. The data includes red, green, # blue and white. The primary format is CIE 1931 XYZ color space. # If unspecified, the primaries is sRGB gamut by default. diff --git a/services/surfaceflinger/sysprop/api/system-current.txt b/services/surfaceflinger/sysprop/api/system-current.txt index 6ae3ac15ee..89323c2ad0 100644 --- a/services/surfaceflinger/sysprop/api/system-current.txt +++ b/services/surfaceflinger/sysprop/api/system-current.txt @@ -2,6 +2,7 @@ package android.sysprop { public final class SurfaceFlingerProperties { + method public static java.util.Optional<java.lang.Long> color_space_agnostic_dataspace(); method public static java.util.Optional<java.lang.Long> default_composition_dataspace(); method public static java.util.Optional<java.lang.Integer> default_composition_pixel_format(); method public static java.util.List<java.lang.Double> display_primary_blue(); |