summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
author Dominik Laskowski <domlaskowski@google.com> 2022-04-07 10:44:12 -0700
committer Dominik Laskowski <domlaskowski@google.com> 2022-04-20 08:43:47 -0700
commit3c363247085f9ca75450a383b476312d96a490cc (patch)
tree75553a7fa10140da3f85aca509856dd9a7778ab4 /services/surfaceflinger/SurfaceFlinger.cpp
parent87d026acfc992c36b0f64a0061ba55add45f87df (diff)
SF: Clean up display lookup
Remove redundant functions. Phase out the "internal display" misnomer, which is confusing for foldables. Validate the DisplayPrimaries API against the connection type, rather than the active display. Bug: 182939859 Bug: 74619554 Test: Boot and fold/unfold Change-Id: Ibe69e3337806a3f269f355522bcf65eab974d7bb
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3bfc2cc2a3..f33ea5b983 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -582,14 +582,8 @@ void SurfaceFlinger::releaseVirtualDisplay(VirtualDisplayId displayId) {
std::vector<PhysicalDisplayId> SurfaceFlinger::getPhysicalDisplayIdsLocked() const {
std::vector<PhysicalDisplayId> displayIds;
displayIds.reserve(mPhysicalDisplayTokens.size());
- const auto defaultDisplayId = [this]() REQUIRES(mStateLock) {
- if (const auto display = getDefaultDisplayDeviceLocked()) {
- return display->getPhysicalId();
- }
- // fallback to the internal display id if the active display is unknown
- return getInternalDisplayIdLocked();
- }();
+ const auto defaultDisplayId = getDefaultDisplayDeviceLocked()->getPhysicalId();
displayIds.push_back(defaultDisplayId);
for (const auto& [id, token] : mPhysicalDisplayTokens) {
@@ -603,7 +597,7 @@ std::vector<PhysicalDisplayId> SurfaceFlinger::getPhysicalDisplayIdsLocked() con
status_t SurfaceFlinger::getPrimaryPhysicalDisplayId(PhysicalDisplayId* id) const {
Mutex::Autolock lock(mStateLock);
- *id = getInternalDisplayIdLocked();
+ *id = getPrimaryDisplayIdLocked();
return NO_ERROR;
}
@@ -1314,17 +1308,25 @@ std::vector<ColorMode> SurfaceFlinger::getDisplayColorModes(const DisplayDevice&
}
status_t SurfaceFlinger::getDisplayNativePrimaries(const sp<IBinder>& displayToken,
- ui::DisplayPrimaries &primaries) {
+ ui::DisplayPrimaries& primaries) {
if (!displayToken) {
return BAD_VALUE;
}
- // Currently we only support this API for a single internal display.
- if (getInternalDisplayToken() != displayToken) {
+ Mutex::Autolock lock(mStateLock);
+
+ const auto display = getDisplayDeviceLocked(displayToken);
+ if (!display) {
return NAME_NOT_FOUND;
}
- memcpy(&primaries, &mInternalDisplayPrimaries, sizeof(ui::DisplayPrimaries));
+ const auto connectionType = display->getConnectionType();
+ if (connectionType != ui::DisplayConnectionType::Internal) {
+ return INVALID_OPERATION;
+ }
+
+ // TODO(b/229846990): For now, assume that all internal displays have the same primaries.
+ primaries = mInternalDisplayPrimaries;
return NO_ERROR;
}
@@ -2820,7 +2822,7 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
}
if (const auto id = PhysicalDisplayId::tryCast(compositionDisplay->getId())) {
- creationArgs.isPrimary = id == getInternalDisplayIdLocked();
+ creationArgs.isPrimary = id == getPrimaryDisplayIdLocked();
if (useColorManagement) {
std::vector<ColorMode> modes = getHwComposer().getColorModes(*id);