diff options
-rw-r--r-- | services/surfaceflinger/ScreenCaptureOutput.cpp | 22 | ||||
-rw-r--r-- | services/surfaceflinger/ScreenCaptureOutput.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 7 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 5 |
4 files changed, 30 insertions, 8 deletions
diff --git a/services/surfaceflinger/ScreenCaptureOutput.cpp b/services/surfaceflinger/ScreenCaptureOutput.cpp index 01038432de..ef9b457fc9 100644 --- a/services/surfaceflinger/ScreenCaptureOutput.cpp +++ b/services/surfaceflinger/ScreenCaptureOutput.cpp @@ -45,10 +45,9 @@ Rect getOrientedDisplaySpaceRect(ui::Rotation orientation, int reqWidth, int req std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutputArgs args) { std::shared_ptr<ScreenCaptureOutput> output = compositionengine::impl::createOutputTemplated< ScreenCaptureOutput, compositionengine::CompositionEngine, const RenderArea&, - const compositionengine::Output::ColorProfile&, bool>(args.compositionEngine, - args.renderArea, - args.colorProfile, - args.regionSampling); + const compositionengine::Output::ColorProfile&, + bool>(args.compositionEngine, args.renderArea, args.colorProfile, args.regionSampling, + args.dimInGammaSpaceForEnhancedScreenshots); output->editState().isSecure = args.renderArea.isSecure(); output->setCompositionEnabled(true); output->setLayerFilter({args.layerStack}); @@ -81,8 +80,11 @@ std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutp ScreenCaptureOutput::ScreenCaptureOutput( const RenderArea& renderArea, const compositionengine::Output::ColorProfile& colorProfile, - bool regionSampling) - : mRenderArea(renderArea), mColorProfile(colorProfile), mRegionSampling(regionSampling) {} + bool regionSampling, bool dimInGammaSpaceForEnhancedScreenshots) + : mRenderArea(renderArea), + mColorProfile(colorProfile), + mRegionSampling(regionSampling), + mDimInGammaSpaceForEnhancedScreenshots(dimInGammaSpaceForEnhancedScreenshots) {} void ScreenCaptureOutput::updateColorProfile(const compositionengine::CompositionRefreshArgs&) { auto& outputState = editState(); @@ -95,6 +97,14 @@ renderengine::DisplaySettings ScreenCaptureOutput::generateClientCompositionDisp auto clientCompositionDisplay = compositionengine::impl::Output::generateClientCompositionDisplaySettings(); clientCompositionDisplay.clip = mRenderArea.getSourceCrop(); + + auto renderIntent = static_cast<ui::RenderIntent>(clientCompositionDisplay.renderIntent); + if (mDimInGammaSpaceForEnhancedScreenshots && renderIntent != ui::RenderIntent::COLORIMETRIC && + renderIntent != ui::RenderIntent::TONE_MAP_COLORIMETRIC) { + clientCompositionDisplay.dimmingStage = + aidl::android::hardware::graphics::composer3::DimmingStage::GAMMA_OETF; + } + return clientCompositionDisplay; } diff --git a/services/surfaceflinger/ScreenCaptureOutput.h b/services/surfaceflinger/ScreenCaptureOutput.h index 159c2bf903..fc095def99 100644 --- a/services/surfaceflinger/ScreenCaptureOutput.h +++ b/services/surfaceflinger/ScreenCaptureOutput.h @@ -37,6 +37,7 @@ struct ScreenCaptureOutputArgs { float targetBrightness; bool regionSampling; bool treat170mAsSrgb; + bool dimInGammaSpaceForEnhancedScreenshots; }; // ScreenCaptureOutput is used to compose a set of layers into a preallocated buffer. @@ -47,7 +48,7 @@ class ScreenCaptureOutput : public compositionengine::impl::Output { public: ScreenCaptureOutput(const RenderArea& renderArea, const compositionengine::Output::ColorProfile& colorProfile, - bool regionSampling); + bool regionSampling, bool dimInGammaSpaceForEnhancedScreenshots); void updateColorProfile(const compositionengine::CompositionRefreshArgs&) override; @@ -63,6 +64,7 @@ private: const RenderArea& mRenderArea; const compositionengine::Output::ColorProfile& mColorProfile; const bool mRegionSampling; + const bool mDimInGammaSpaceForEnhancedScreenshots; }; std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutputArgs); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 9e6e934648..5c000ed8f5 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -452,6 +452,9 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI property_get("debug.sf.treat_170m_as_sRGB", value, "0"); mTreat170mAsSrgb = atoi(value); + property_get("debug.sf.dim_in_gamma_in_enhanced_screenshots", value, 0); + mDimInGammaSpaceForEnhancedScreenshots = atoi(value); + mIgnoreHwcPhysicalDisplayOrientation = base::GetBoolProperty("debug.sf.ignore_hwc_physical_display_orientation"s, false); @@ -7787,7 +7790,9 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl( .displayBrightnessNits = displayBrightnessNits, .targetBrightness = targetBrightness, .regionSampling = regionSampling, - .treat170mAsSrgb = mTreat170mAsSrgb}); + .treat170mAsSrgb = mTreat170mAsSrgb, + .dimInGammaSpaceForEnhancedScreenshots = + mDimInGammaSpaceForEnhancedScreenshots}); const float colorSaturation = grayscale ? 0 : 1; compositionengine::CompositionRefreshArgs refreshArgs{ diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 8ff11e2d1b..81c3f2f9d2 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -317,6 +317,11 @@ public: // on this behavior to increase contrast for some media sources. bool mTreat170mAsSrgb = false; + // If true, then screenshots with an enhanced render intent will dim in gamma space. + // The purpose is to ensure that screenshots appear correct during system animations for devices + // that require that dimming must occur in gamma space. + bool mDimInGammaSpaceForEnhancedScreenshots = false; + // Allows to ignore physical orientation provided through hwc API in favour of // 'ro.surface_flinger.primary_display_orientation'. // TODO(b/246793311): Clean up a temporary property |