[Lut HAL backend] implementation 2nd patch
1. add gui/DisplayLuts.h structure. Mimic DisplayLuts.java.
2. add Lut parameter into Layer side. When SurfaceControl#setLuts is
called, in native code, the lut information is passed to
SurfaceFlinger and RenderEngine side via LayerState::eLutsChanged.
3. in OutputLayer::updateCompositionState, we compare the Lut
requested from the app and the Lut from the HWC to decide GPU
composition or not.
4. DPU or GPU composition? If the Lut from the app exactly matches the
Lut from the hwc, do DPU. Otherwise, GPU composition instead.
Bug: 329472856
Test: libcompositionengine_test
Flag: NONE HAL backend interface change
Change-Id: I8295fe419c6237d90b7ff9f02f62bafd6cd2cecf
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index 1df2ab1..5355a12 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -42,7 +42,8 @@
using AidlCapability = aidl::android::hardware::graphics::composer3::Capability;
using aidl::android::hardware::graphics::composer3::DisplayCapability;
using aidl::android::hardware::graphics::composer3::DisplayLuts;
-using aidl::android::hardware::graphics::composer3::Lut;
+using aidl::android::hardware::graphics::composer3::LutProperties;
+using aidl::android::hardware::graphics::composer3::Luts;
using aidl::android::hardware::graphics::composer3::OverlayProperties;
namespace android {
@@ -624,10 +625,18 @@
auto layer = getLayerById(layerIds[i]);
if (layer) {
auto& layerLut = tmpLuts[i];
- outLuts->emplace_or_replace(layer.get(), layerLut.lut.lutProperties);
- lutFileDescriptorMapper.emplace_or_replace(layer.get(),
- ndk::ScopedFileDescriptor(
- layerLut.lut.pfd.release()));
+ if (layerLut.luts.pfd.get() > 0 && layerLut.luts.offsets.has_value()) {
+ const auto& offsets = layerLut.luts.offsets.value();
+ std::vector<std::pair<int32_t, LutProperties>> lutOffsetsAndProperties;
+ lutOffsetsAndProperties.reserve(offsets.size());
+ std::transform(offsets.begin(), offsets.end(), layerLut.luts.lutProperties.begin(),
+ std::back_inserter(lutOffsetsAndProperties),
+ [](int32_t i, LutProperties j) { return std::make_pair(i, j); });
+ outLuts->emplace_or_replace(layer.get(), lutOffsetsAndProperties);
+ lutFileDescriptorMapper.emplace_or_replace(layer.get(),
+ ndk::ScopedFileDescriptor(
+ layerLut.luts.pfd.release()));
+ }
}
}
@@ -1069,7 +1078,7 @@
return static_cast<Error>(intError);
}
-Error Layer::setLuts(std::vector<Lut>& luts) {
+Error Layer::setLuts(aidl::android::hardware::graphics::composer3::Luts& luts) {
if (CC_UNLIKELY(!mDisplay)) {
return Error::BAD_DISPLAY;
}