summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/RegionSamplingThread.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2024-07-15 22:46:58 +0000
committer Alec Mouri <alecmouri@google.com> 2024-08-28 21:10:28 +0000
commit1b1853f92528a2214f0337decf4685250334a43c (patch)
tree1e9bd7edf505a1bdfb2da77e3b8252391f801d32 /services/surfaceflinger/RegionSamplingThread.cpp
parent2b96d359af29f34d5bf8ec631f1ea56104f0901e (diff)
Support capturing a gainmapped screenshot
This uses the gainmap concept from UltraHDR and ISO 21496-1 to produce screenshots that (a) can be rendered in HDR and (b) that are perfectly backwards-compatible on SDR displays are scenes where displaying SDR is preferable. The technical details of the screenshot process at a high level are: * A client requests that they want a gainmap attached to the screenshot result * SurfaceFlinger asks RenderEngine to perform three render passes * First, render the SDR base image, tonemapping using MouriMap * Second, render an HDR rendition. This is *also* tonemapped using MouriMap to the current display conditions. For HDR UI, this is effectively a no-op. For PQ and HLG content, this allows for approximating what is on-screen as closely as possible. Note that to preserve precision as much as possible, we require an FP16 framebuffer. * Finally, combine the SDR and HDR renditions into a gainmap * The client now receives the base image with the gainmap, as well as an HDR/SDR ratio. The client can use this information to generate gainmap metadata for encoding or round-tripping to the display. This MVP is sufficient for generating screenshots through adb screencap. Eventually, this can be used to integrate with the applications that want HDR screenshots, or to remove hacks that disable tonemapping during certain system animations. Bug: 329470026 Flag: com.android.graphics.surfaceflinger.flags.true_hdr_screenshots Test: builds Test: adb screencap Change-Id: I0434059d957bb6cc38d019743619d72dda72a269
Diffstat (limited to 'services/surfaceflinger/RegionSamplingThread.cpp')
-rw-r--r--services/surfaceflinger/RegionSamplingThread.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/services/surfaceflinger/RegionSamplingThread.cpp b/services/surfaceflinger/RegionSamplingThread.cpp
index 7712d38f43..06c2f26a6d 100644
--- a/services/surfaceflinger/RegionSamplingThread.cpp
+++ b/services/surfaceflinger/RegionSamplingThread.cpp
@@ -346,6 +346,7 @@ void RegionSamplingThread::captureSample() {
constexpr bool kRegionSampling = true;
constexpr bool kGrayscale = false;
constexpr bool kIsProtected = false;
+ constexpr bool kAttachGainmap = false;
SurfaceFlinger::RenderAreaBuilderVariant
renderAreaBuilder(std::in_place_type<DisplayRenderAreaBuilder>, sampledBounds,
@@ -358,15 +359,15 @@ void RegionSamplingThread::captureSample() {
std::vector<sp<LayerFE>> layerFEs;
auto displayState = mFlinger.getSnapshotsFromMainThread(renderAreaBuilder,
getLayerSnapshotsFn, layerFEs);
- fenceResult =
- mFlinger.captureScreenshot(renderAreaBuilder, buffer, kRegionSampling, kGrayscale,
- kIsProtected, nullptr, displayState, layerFEs)
- .get();
+ fenceResult = mFlinger.captureScreenshot(renderAreaBuilder, buffer, kRegionSampling,
+ kGrayscale, kIsProtected, kAttachGainmap, nullptr,
+ displayState, layerFEs)
+ .get();
} else {
- fenceResult =
- mFlinger.captureScreenshotLegacy(renderAreaBuilder, getLayerSnapshotsFn, buffer,
- kRegionSampling, kGrayscale, kIsProtected, nullptr)
- .get();
+ fenceResult = mFlinger.captureScreenshotLegacy(renderAreaBuilder, getLayerSnapshotsFn,
+ buffer, kRegionSampling, kGrayscale,
+ kIsProtected, kAttachGainmap, nullptr)
+ .get();
}
if (fenceResult.ok()) {
fenceResult.value()->waitForever(LOG_TAG);