Support screenshots of HDR content
Previously screenshots always rendered to either an SDR or a wide gamut
colorspace. For screenshotting HDR content, this is only appropriate
when the resulting screenshot (a) never leaves the device and (b) the
relevant code has workarounds for the display to appropriately handle
its luminance range.
HDR screenshots will now have two paths:
* A standard path for rendering to HLG. HLG was chosen because the OOTF
shape is less hand-wavey than PQ's, does not require metadata, and
bands less at 8-bits of color.
* A special path for "display-native" screenshots. This is for
use-cases like screen rotation where there are stricter color accuracy
requirements for round-tripping.
Skia already encodes the resulting screenshot by supplying an HLG CICP
alongside a backwards-compatible transfer function, so it's only
sufficient to change how SurfaceFlinger renders.
Bug: 242324609
Bug: 276812775
Test: screencap binary
Test: rotation animation
Test: swiping in Recents
Change-Id: Ic9edb92391d3beb38d076fba8f15e3fdcc2b8f50
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index fee91a4..2322b70 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -897,11 +897,11 @@
SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(dataspace));
SAFE_PARCEL(output->writeBool, allowProtected);
SAFE_PARCEL(output->writeBool, grayscale);
-
SAFE_PARCEL(output->writeInt32, excludeHandles.size());
for (auto& excludeHandle : excludeHandles) {
SAFE_PARCEL(output->writeStrongBinder, excludeHandle);
}
+ SAFE_PARCEL(output->writeBool, hintForSeamlessTransition);
return NO_ERROR;
}
@@ -918,7 +918,6 @@
dataspace = static_cast<ui::Dataspace>(value);
SAFE_PARCEL(input->readBool, &allowProtected);
SAFE_PARCEL(input->readBool, &grayscale);
-
int32_t numExcludeHandles = 0;
SAFE_PARCEL_READ_SIZE(input->readInt32, &numExcludeHandles, input->dataSize());
excludeHandles.reserve(numExcludeHandles);
@@ -927,6 +926,7 @@
SAFE_PARCEL(input->readStrongBinder, &binder);
excludeHandles.emplace(binder);
}
+ SAFE_PARCEL(input->readBool, &hintForSeamlessTransition);
return NO_ERROR;
}