ColorMode: multi-mode support through QDCM API with WCG
1. Select P3 HDR mode when HDR playback. Fall back to P3 SDR mode if
there is no P3 HDR mode. And after HDR video ends, go back to P3 SDR
mode or SRGB mode according to the current blend space.
2. When user switches mode by QDCM API, check the mode attributes to
see whether they match the current blend space and dynamic range. Apply
the mode only when the blend space and dynamic range match. Otherwise
cache the mode until the current blend space and dynamic range become
the same with that in the mode.
3. Print out the current active color mode name in dumpsys.
Change-Id: I46a4d25536c7e2b408e11e956f152f7a80528a43
Signed-off-by: Xu Yang <yangxu@codeaurora.org>
diff --git a/sdm/libs/hwc2/hwc_display_builtin.cpp b/sdm/libs/hwc2/hwc_display_builtin.cpp
index 0806241..dbac21a 100644
--- a/sdm/libs/hwc2/hwc_display_builtin.cpp
+++ b/sdm/libs/hwc2/hwc_display_builtin.cpp
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
+* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -189,7 +189,8 @@
SolidFillPrepare();
// Apply current Color Mode and Render Intent.
- if (color_mode_->ApplyCurrentColorModeWithRenderIntent() != HWC2::Error::None) {
+ if (color_mode_->ApplyCurrentColorModeWithRenderIntent(
+ static_cast<bool>(layer_stack_.flags.hdr_present)) != HWC2::Error::None) {
// Fallback to GPU Composition, if Color Mode can't be applied.
MarkLayersForClientComposition();
}
@@ -304,6 +305,25 @@
return status;
}
+HWC2::Error HWCDisplayBuiltIn::SetColorModeFromClientApi(int32_t color_mode_id) {
+ DisplayError error = kErrorNone;
+ std::string mode_string;
+
+ error = display_intf_->GetColorModeName(color_mode_id, &mode_string);
+ if (error) {
+ DLOGE("Failed to get mode name for mode %d", color_mode_id);
+ return HWC2::Error::BadParameter;
+ }
+
+ auto status = color_mode_->SetColorModeFromClientApi(mode_string);
+ if (status != HWC2::Error::None) {
+ DLOGE("Failed to set mode = %d", color_mode_id);
+ return status;
+ }
+
+ return status;
+}
+
HWC2::Error HWCDisplayBuiltIn::RestoreColorTransform() {
auto status = color_mode_->RestoreColorTransform();
if (status != HWC2::Error::None) {