HWC2: Hook up setColorTransform/setLayerDataspace
Plumbs the setColorTransform and setLayerDataspace calls through the
HWC2 C++ shim and implements a trivial versions in the adapter,
which drops non-HAL_DATASPACE_UNKNOWN layers to client composition,
and which drops all layers to client composition if a color transform
is applied.
Bug: 22767098
Change-Id: Ifffd19b77cf3b33ec86fde3f72257f6b97b4dd79
diff --git a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
index 6fdb184..2e6206e 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
@@ -208,6 +208,7 @@
HWC2::Error setActiveConfig(hwc2_config_t configId);
HWC2::Error setClientTarget(buffer_handle_t target,
int32_t acquireFence, int32_t dataspace);
+ HWC2::Error setColorTransform(android_color_transform_t hint);
HWC2::Error setOutputBuffer(buffer_handle_t buffer,
int32_t releaseFence);
HWC2::Error setPowerMode(HWC2::PowerMode mode);
@@ -231,6 +232,8 @@
void addRetireFence(int fenceFd);
void addReleaseFences(const hwc_display_contents_1& hwcContents);
+ bool hasColorTransform() const;
+
std::string dump() const;
private:
@@ -359,6 +362,8 @@
FencedBuffer mClientTarget;
FencedBuffer mOutputBuffer;
+ bool mHasColorTransform;
+
std::multiset<std::shared_ptr<Layer>, SortLayersByZ> mLayers;
std::unordered_map<size_t, std::shared_ptr<Layer>> mHwc1LayerMap;
};
@@ -390,6 +395,17 @@
config, attribute, outValue);
}
+ static int32_t setColorTransformHook(hwc2_device_t* device,
+ hwc2_display_t display, const float* /*matrix*/,
+ int32_t /*android_color_transform_t*/ intHint) {
+ // We intentionally throw away the matrix, because if the hint is
+ // anything other than IDENTITY, we have to fall back to client
+ // composition anyway
+ auto hint = static_cast<android_color_transform_t>(intHint);
+ return callDisplayFunction(device, display, &Display::setColorTransform,
+ hint);
+ }
+
static int32_t setPowerModeHook(hwc2_device_t* device,
hwc2_display_t display, int32_t intMode) {
auto mode = static_cast<HWC2::PowerMode>(intMode);
@@ -467,6 +483,7 @@
HWC2::Error setBlendMode(HWC2::BlendMode mode);
HWC2::Error setColor(hwc_color_t color);
HWC2::Error setCompositionType(HWC2::Composition type);
+ HWC2::Error setDataspace(android_dataspace_t dataspace);
HWC2::Error setDisplayFrame(hwc_rect_t frame);
HWC2::Error setPlaneAlpha(float alpha);
HWC2::Error setSidebandStream(const native_handle_t* stream);
@@ -523,6 +540,7 @@
DeferredFence mReleaseFence;
size_t mHwc1Id;
+ bool mHasUnsupportedDataspace;
bool mHasUnsupportedPlaneAlpha;
};
@@ -562,6 +580,13 @@
&Layer::setCompositionType, type);
}
+ static int32_t setLayerDataspaceHook(hwc2_device_t* device,
+ hwc2_display_t display, hwc2_layer_t layer, int32_t intDataspace) {
+ auto dataspace = static_cast<android_dataspace_t>(intDataspace);
+ return callLayerFunction(device, display, layer, &Layer::setDataspace,
+ dataspace);
+ }
+
static int32_t setLayerTransformHook(hwc2_device_t* device,
hwc2_display_t display, hwc2_layer_t layer, int32_t intTransform) {
auto transform = static_cast<HWC2::Transform>(intTransform);