Skip to content

Commit 5a4fce8

Browse files
author
Su Hong Koo
committed
SF: Invoke DisplayDevice::animate*Overlay() on all displays
Right now HDR:SDR ratio and refresh rate overlays are only animated on active displays. This CL splits animateOverlay() into two, one for each of the overlay, and invokes it for for all physical and virtual displays in SurfaceFlinger. The animate function call should check for presence of the overlay so no pre-check is required. Flag: EXEMPT trivial refactor Bug: 255635821 Test: Tested on a foldable with hdr/sdr ratio using made you look Change-Id: I68f76bcbaecd2f0a1b429160fb6c119a6738ed8f
1 parent 8bdb01e commit 5a4fce8

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

services/surfaceflinger/DisplayDevice.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -475,23 +475,28 @@ void DisplayDevice::onVrrIdle(bool idle) {
475475
}
476476
}
477477

478-
void DisplayDevice::animateOverlay() {
478+
void DisplayDevice::animateRefreshRateOverlay() {
479479
if (mRefreshRateOverlay) {
480480
mRefreshRateOverlay->animate();
481481
}
482-
if (mHdrSdrRatioOverlay) {
483-
// hdr sdr ratio is designed to be on the top right of the screen,
484-
// therefore, we need to re-calculate the display's width and height
485-
if (mIsOrientationChanged) {
486-
auto width = getWidth();
487-
auto height = getHeight();
488-
if (mOrientation == ui::ROTATION_90 || mOrientation == ui::ROTATION_270) {
489-
std::swap(width, height);
490-
}
491-
mHdrSdrRatioOverlay->setViewport({width, height});
482+
}
483+
484+
void DisplayDevice::animateHdrSdrRatioOverlay() {
485+
if (!mHdrSdrRatioOverlay) {
486+
return;
487+
}
488+
489+
// hdr sdr ratio is designed to be on the top right of the screen,
490+
// therefore, we need to re-calculate the display's width and height
491+
if (mIsOrientationChanged) {
492+
auto width = getWidth();
493+
auto height = getHeight();
494+
if (mOrientation == ui::ROTATION_90 || mOrientation == ui::ROTATION_270) {
495+
std::swap(width, height);
492496
}
493-
mHdrSdrRatioOverlay->animate();
497+
mHdrSdrRatioOverlay->setViewport({width, height});
494498
}
499+
mHdrSdrRatioOverlay->animate();
495500
}
496501

497502
void DisplayDevice::adjustRefreshRate(Fps pacesetterDisplayRefreshRate) {

services/surfaceflinger/DisplayDevice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ class DisplayDevice : public RefBase {
220220
REQUIRES(kMainThreadContext);
221221
void updateRefreshRateOverlayRate(Fps refreshRate, Fps renderFps, bool setByHwc = false);
222222
bool isRefreshRateOverlayEnabled() const { return mRefreshRateOverlay != nullptr; }
223-
void animateOverlay();
223+
void animateRefreshRateOverlay();
224+
void animateHdrSdrRatioOverlay();
224225
bool onKernelTimerChanged(std::optional<DisplayModeId>, bool timerExpired);
225226
void onVrrIdle(bool idle);
226227

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,10 +2778,16 @@ bool SurfaceFlinger::commit(PhysicalDisplayId pacesetterId,
27782778
mPowerAdvisor->updateTargetWorkDuration(idealVsyncPeriod);
27792779
}
27802780

2781-
if (mRefreshRateOverlaySpinner || mHdrSdrRatioOverlay) {
2781+
if (mRefreshRateOverlaySpinner) {
27822782
Mutex::Autolock lock(mStateLock);
2783-
if (const auto display = getDefaultDisplayDeviceLocked()) {
2784-
display->animateOverlay();
2783+
for (const auto& [_, display] : mDisplays) {
2784+
display->animateRefreshRateOverlay();
2785+
}
2786+
}
2787+
if (mHdrSdrRatioOverlay) {
2788+
Mutex::Autolock lock(mStateLock);
2789+
for (const auto& [_, display] : mDisplays) {
2790+
display->animateHdrSdrRatioOverlay();
27852791
}
27862792
}
27872793

0 commit comments

Comments
 (0)