summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/ScreenCaptureOutput.cpp
diff options
context:
space:
mode:
author Gil Dekel <gildekel@google.com> 2025-03-03 17:08:43 -0500
committer Gil Dekel <gildekel@google.com> 2025-03-11 13:00:04 -0400
commitde4ce29c532ffb71b1d0b4b252e0fd9ca68e8d45 (patch)
tree877207eb17473699b35cd3ab234c8efb9cdd93ae /services/surfaceflinger/ScreenCaptureOutput.cpp
parent222571707f358a95ed3f60e61c4ff0959b9ae682 (diff)
SF: Remove *DisplayId::tryCast usage from ScreenCaptureOutput
Work towards DisplayId opaqueness by eliminating call-sites to APIs that parse the display ID values directly. One such site is ScreenCaptureOutput. Replace all calls to *DisplayId::tryCast with local calls to cached display variant. Flag: com.android.graphics.surfaceflinger.flags.stable_edid_ids Bug: 390690584 Test: libcompositionengine_test && libsurfaceflinger_unittest Change-Id: Ic83a2b2bfa6fc98b1d0fccc60f450d1587c2cc34
Diffstat (limited to 'services/surfaceflinger/ScreenCaptureOutput.cpp')
-rw-r--r--services/surfaceflinger/ScreenCaptureOutput.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/services/surfaceflinger/ScreenCaptureOutput.cpp b/services/surfaceflinger/ScreenCaptureOutput.cpp
index af6d4d30e4..2906bbd5b8 100644
--- a/services/surfaceflinger/ScreenCaptureOutput.cpp
+++ b/services/surfaceflinger/ScreenCaptureOutput.cpp
@@ -30,11 +30,12 @@ namespace android {
std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutputArgs args) {
std::shared_ptr<ScreenCaptureOutput> output = compositionengine::impl::createOutputTemplated<
ScreenCaptureOutput, compositionengine::CompositionEngine,
- /* sourceCrop */ const Rect, std::optional<DisplayId>,
+ /* sourceCrop */ const Rect, ftl::Optional<DisplayIdVariant>,
const compositionengine::Output::ColorProfile&,
/* layerAlpha */ float,
- /* regionSampling */ bool>(args.compositionEngine, args.sourceCrop, args.displayId,
- args.colorProfile, args.layerAlpha, args.regionSampling,
+ /* regionSampling */ bool>(args.compositionEngine, args.sourceCrop,
+ args.displayIdVariant, args.colorProfile, args.layerAlpha,
+ args.regionSampling,
args.dimInGammaSpaceForEnhancedScreenshots,
args.enableLocalTonemapping);
output->editState().isSecure = args.isSecure;
@@ -59,8 +60,8 @@ std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutp
{
std::string name = args.regionSampling ? "RegionSampling" : "ScreenCaptureOutput";
- if (args.displayId) {
- base::StringAppendF(&name, " for %" PRIu64, args.displayId.value().value);
+ if (const auto id = args.displayIdVariant.and_then(asDisplayIdOfType<DisplayId>)) {
+ base::StringAppendF(&name, " for %" PRIu64, id->value);
}
output->setName(name);
}
@@ -68,12 +69,12 @@ std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutp
}
ScreenCaptureOutput::ScreenCaptureOutput(
- const Rect sourceCrop, std::optional<DisplayId> displayId,
+ const Rect sourceCrop, ftl::Optional<DisplayIdVariant> displayIdVariant,
const compositionengine::Output::ColorProfile& colorProfile, float layerAlpha,
bool regionSampling, bool dimInGammaSpaceForEnhancedScreenshots,
bool enableLocalTonemapping)
: mSourceCrop(sourceCrop),
- mDisplayId(displayId),
+ mDisplayIdVariant(displayIdVariant),
mColorProfile(colorProfile),
mLayerAlpha(layerAlpha),
mRegionSampling(regionSampling),
@@ -137,12 +138,9 @@ ScreenCaptureOutput::generateLuts() {
}
std::vector<aidl::android::hardware::graphics::composer3::Luts> luts;
- if (mDisplayId) {
- const auto id = PhysicalDisplayId::tryCast(mDisplayId.value());
- if (id) {
- auto& hwc = getCompositionEngine().getHwComposer();
- hwc.getLuts(*id, buffers, &luts);
- }
+ if (const auto physicalDisplayId = mDisplayIdVariant.and_then(asPhysicalDisplayId)) {
+ auto& hwc = getCompositionEngine().getHwComposer();
+ hwc.getLuts(*physicalDisplayId, buffers, &luts);
}
if (buffers.size() == luts.size()) {