drm_hwcomposer: Don't use hwc2 interface for dataspace
Add dataspace related members to LayerProperties, and set these for
LayerCommand.dataspace.
Change-Id: I86edeaac7005b6fada42431c6d02e0346ae0a2f7
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index 902d612..12c091a 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -85,6 +85,51 @@
}
}
+std::optional<BufferColorSpace> AidlToColorSpace(
+ const std::optional<ParcelableDataspace>& dataspace) {
+ if (!dataspace) {
+ return std::nullopt;
+ }
+
+ int32_t standard = static_cast<int32_t>(dataspace->dataspace) &
+ static_cast<int32_t>(common::Dataspace::STANDARD_MASK);
+ switch (standard) {
+ case static_cast<int32_t>(common::Dataspace::STANDARD_BT709):
+ return BufferColorSpace::kItuRec709;
+ case static_cast<int32_t>(common::Dataspace::STANDARD_BT601_625):
+ case static_cast<int32_t>(common::Dataspace::STANDARD_BT601_625_UNADJUSTED):
+ case static_cast<int32_t>(common::Dataspace::STANDARD_BT601_525):
+ case static_cast<int32_t>(common::Dataspace::STANDARD_BT601_525_UNADJUSTED):
+ return BufferColorSpace::kItuRec601;
+ case static_cast<int32_t>(common::Dataspace::STANDARD_BT2020):
+ case static_cast<int32_t>(
+ common::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE):
+ return BufferColorSpace::kItuRec2020;
+ default:
+ ALOGE("Unsupported standard: %d", standard);
+ return std::nullopt;
+ }
+}
+
+std::optional<BufferSampleRange> AidlToSampleRange(
+ const std::optional<ParcelableDataspace>& dataspace) {
+ if (!dataspace) {
+ return std::nullopt;
+ }
+
+ int32_t sample_range = static_cast<int32_t>(dataspace->dataspace) &
+ static_cast<int32_t>(common::Dataspace::RANGE_MASK);
+ switch (sample_range) {
+ case static_cast<int32_t>(common::Dataspace::RANGE_FULL):
+ return BufferSampleRange::kFullRange;
+ case static_cast<int32_t>(common::Dataspace::RANGE_LIMITED):
+ return BufferSampleRange::kLimitedRange;
+ default:
+ ALOGE("Unsupported sample range: %d", sample_range);
+ return std::nullopt;
+ }
+}
+
} // namespace
ComposerClient::ComposerClient() {
@@ -333,14 +378,13 @@
}
HwcLayer::LayerProperties properties;
properties.blend_mode = AidlToBlendMode(command.blendMode);
+ properties.color_space = AidlToColorSpace(command.dataspace);
+ properties.sample_range = AidlToSampleRange(command.dataspace);
layer->SetLayerProperties(properties);
if (command.composition) {
ExecuteSetLayerComposition(display_id, layer_wrapper, *command.composition);
}
- if (command.dataspace) {
- ExecuteSetLayerDataspace(display_id, layer_wrapper, *command.dataspace);
- }
if (command.displayFrame) {
ExecuteSetLayerDisplayFrame(display_id, layer_wrapper,
*command.displayFrame);
@@ -1068,16 +1112,6 @@
}
}
-void ComposerClient::ExecuteSetLayerDataspace(
- int64_t /*display_id*/, HwcLayerWrapper& layer,
- const ParcelableDataspace& dataspace) {
- auto err = Hwc2toHwc3Error(
- layer.layer->SetLayerDataspace(Hwc3DataspaceToHwc2(dataspace.dataspace)));
- if (err != hwc3::Error::kNone) {
- cmd_result_writer_->AddError(err);
- }
-}
-
void ComposerClient::ExecuteSetLayerDisplayFrame(int64_t /*display_id*/,
HwcLayerWrapper& layer,
const common::Rect& rect) {