diff options
author | 2023-06-27 11:55:34 -0700 | |
---|---|---|
committer | 2023-07-14 01:26:47 +0000 | |
commit | 147581b17b562f0bd44a5cc903906784b45b20a9 (patch) | |
tree | fef13af2f9351b734b42ba2d134e5640a2860161 /services/surfaceflinger/DisplayDevice.cpp | |
parent | 1160ecdfa295225f9eec1a20212746e412ca5c29 (diff) |
Add new SF backdoor option: hdr/sdr ratio overlay
- follow how RefreshRateOverlay did in general.
- 1043 as new opcode to enable hdr/sdr ratio overlay.
- decouple SevenSegmentDrawer and SurfaceControlHandle helper classes
from RefreshRateOverlay.
- add corresponding SF backdoor test for validation.
- for non-HDR-supported device, we don't reject them to use SF backdoor
but 1.00 will be always shown on the screen if enabling.
Test: adb shell call service call SurfaceFlinger 1043 1; atest
SurfaceFlinger_test
Bug: 277957056
Change-Id: Ifce2d435f127b53ab9d01aba4e24ffd4fdb010a7
Diffstat (limited to 'services/surfaceflinger/DisplayDevice.cpp')
-rw-r--r-- | services/surfaceflinger/DisplayDevice.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp index f6ca9e2856..32bd890aee 100644 --- a/services/surfaceflinger/DisplayDevice.cpp +++ b/services/surfaceflinger/DisplayDevice.cpp @@ -37,11 +37,11 @@ #include <configstore/Utils.h> #include <log/log.h> #include <system/window.h> -#include <ui/GraphicTypes.h> #include "Display/DisplaySnapshot.h" #include "DisplayDevice.h" #include "FrontEnd/DisplayInfo.h" +#include "HdrSdrRatioOverlay.h" #include "Layer.h" #include "RefreshRateOverlay.h" #include "SurfaceFlinger.h" @@ -261,6 +261,9 @@ void DisplayDevice::setLayerFilter(ui::LayerFilter filter) { if (mRefreshRateOverlay) { mRefreshRateOverlay->setLayerStack(filter.layerStack); } + if (mHdrSdrRatioOverlay) { + mHdrSdrRatioOverlay->setLayerStack(filter.layerStack); + } } void DisplayDevice::setFlags(uint32_t flags) { @@ -274,10 +277,14 @@ void DisplayDevice::setDisplaySize(int width, int height) { if (mRefreshRateOverlay) { mRefreshRateOverlay->setViewport(size); } + if (mHdrSdrRatioOverlay) { + mHdrSdrRatioOverlay->setViewport(size); + } } void DisplayDevice::setProjection(ui::Rotation orientation, Rect layerStackSpaceRect, Rect orientedDisplaySpaceRect) { + mIsOrientationChanged = mOrientation != orientation; mOrientation = orientation; // We need to take care of display rotation for globalTransform for case if the panel is not @@ -411,6 +418,26 @@ HdrCapabilities DisplayDevice::getHdrCapabilities() const { capabilities.getDesiredMinLuminance()); } +void DisplayDevice::enableHdrSdrRatioOverlay(bool enable) { + if (!enable) { + mHdrSdrRatioOverlay.reset(); + return; + } + + mHdrSdrRatioOverlay = std::make_unique<HdrSdrRatioOverlay>(); + mHdrSdrRatioOverlay->setLayerStack(getLayerStack()); + mHdrSdrRatioOverlay->setViewport(getSize()); + updateHdrSdrRatioOverlayRatio(mHdrSdrRatio); +} + +void DisplayDevice::updateHdrSdrRatioOverlayRatio(float currentHdrSdrRatio) { + ATRACE_CALL(); + mHdrSdrRatio = currentHdrSdrRatio; + if (mHdrSdrRatioOverlay) { + mHdrSdrRatioOverlay->changeHdrSdrRatio(currentHdrSdrRatio); + } +} + void DisplayDevice::enableRefreshRateOverlay(bool enable, bool setByHwc, bool showSpinner, bool showRenderRate, bool showInMiddle) { if (!enable) { @@ -463,10 +490,23 @@ bool DisplayDevice::onKernelTimerChanged(std::optional<DisplayModeId> desiredMod return false; } -void DisplayDevice::animateRefreshRateOverlay() { +void DisplayDevice::animateOverlay() { if (mRefreshRateOverlay) { mRefreshRateOverlay->animate(); } + if (mHdrSdrRatioOverlay) { + // hdr sdr ratio is designed to be on the top right of the screen, + // therefore, we need to re-calculate the display's width and height + if (mIsOrientationChanged) { + auto width = getWidth(); + auto height = getHeight(); + if (mOrientation == ui::ROTATION_90 || mOrientation == ui::ROTATION_270) { + std::swap(width, height); + } + mHdrSdrRatioOverlay->setViewport({width, height}); + } + mHdrSdrRatioOverlay->animate(); + } } auto DisplayDevice::setDesiredActiveMode(const ActiveModeInfo& info, bool force) |