diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 425b78bd68..94b16b4821 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -578,13 +578,13 @@ void SurfaceFlinger::destroyDisplay(const sp<IBinder>& displayToken) { const ssize_t index = mCurrentState.displays.indexOfKey(displayToken); if (index < 0) { - ALOGE("%s: Invalid display token %p", __FUNCTION__, displayToken.get()); + ALOGE("%s: Invalid display token %p", __func__, displayToken.get()); return; } const DisplayDeviceState& state = mCurrentState.displays.valueAt(index); if (state.physical) { - ALOGE("%s: Invalid operation on physical display", __FUNCTION__); + ALOGE("%s: Invalid operation on physical display", __func__); return; } mInterceptor->saveDisplayDeletion(state.sequenceId); @@ -1039,7 +1039,7 @@ status_t SurfaceFlinger::getDynamicDisplayInfo(const sp<IBinder>& displayToken, return INVALID_OPERATION; } - info->activeDisplayModeId = static_cast<int32_t>(display->getActiveMode()->getId().value()); + info->activeDisplayModeId = display->getActiveMode()->getId().value(); const auto& supportedModes = display->getSupportedModes(); info->supportedDisplayModes.clear(); @@ -1104,13 +1104,17 @@ status_t SurfaceFlinger::getDynamicDisplayInfo(const sp<IBinder>& displayToken, info->autoLowLatencyModeSupported = getHwComposer().hasDisplayCapability(*displayId, DisplayCapability::AUTO_LOW_LATENCY_MODE); - std::vector<hal::ContentType> types; - getHwComposer().getSupportedContentTypes(*displayId, &types); - info->gameContentTypeSupported = std::any_of(types.begin(), types.end(), [](auto type) { - return type == hal::ContentType::GAME; - }); - - info->preferredBootDisplayMode = display->getPreferredBootModeId(); + info->gameContentTypeSupported = + getHwComposer().supportsContentType(*displayId, hal::ContentType::GAME); + + info->preferredBootDisplayMode = static_cast<ui::DisplayModeId>(-1); + if (getHwComposer().getBootDisplayModeSupport()) { + if (const auto hwcId = getHwComposer().getPreferredBootDisplayMode(*displayId)) { + if (const auto modeId = display->translateModeId(*hwcId)) { + info->preferredBootDisplayMode = modeId->value(); + } + } + } return NO_ERROR; } @@ -1432,31 +1436,41 @@ status_t SurfaceFlinger::getBootDisplayModeSupport(bool* outSupport) const { return future.get(); } -status_t SurfaceFlinger::setBootDisplayMode(const sp<IBinder>& displayToken, ui::DisplayModeId id) { +status_t SurfaceFlinger::setBootDisplayMode(const sp<IBinder>& displayToken, + ui::DisplayModeId modeId) { + const char* const whence = __func__; auto future = mScheduler->schedule([=]() MAIN_THREAD -> status_t { - if (const auto displayDevice = getDisplayDeviceLocked(displayToken)) { - const auto mode = displayDevice->getMode(DisplayModeId{id}); - if (mode == nullptr) { - ALOGE("%s: invalid display mode (%d)", __FUNCTION__, id); - return BAD_VALUE; - } + const auto display = getDisplayDeviceLocked(displayToken); + if (!display) { + ALOGE("%s: Invalid display token %p", whence, displayToken.get()); + return NAME_NOT_FOUND; + } - return getHwComposer().setBootDisplayMode(displayDevice->getPhysicalId(), - mode->getHwcId()); - } else { - ALOGE("%s: Invalid display token %p", __FUNCTION__, displayToken.get()); + if (display->isVirtual()) { + ALOGE("%s: Invalid operation on virtual display", whence); + return INVALID_OPERATION; + } + + const auto displayId = display->getPhysicalId(); + const auto mode = display->getMode(DisplayModeId{modeId}); + if (!mode) { + ALOGE("%s: Invalid mode %d for display %s", whence, modeId, + to_string(displayId).c_str()); return BAD_VALUE; } + + return getHwComposer().setBootDisplayMode(displayId, mode->getHwcId()); }); return future.get(); } status_t SurfaceFlinger::clearBootDisplayMode(const sp<IBinder>& displayToken) { + const char* const whence = __func__; auto future = mScheduler->schedule([=]() MAIN_THREAD -> status_t { if (const auto displayId = getPhysicalDisplayIdLocked(displayToken)) { return getHwComposer().clearBootDisplayMode(*displayId); } else { - ALOGE("%s: Invalid display token %p", __FUNCTION__, displayToken.get()); + ALOGE("%s: Invalid display token %p", whence, displayToken.get()); return BAD_VALUE; } }); @@ -1504,7 +1518,7 @@ status_t SurfaceFlinger::overrideHdrTypes(const sp<IBinder>& displayToken, auto display = getDisplayDeviceLocked(displayToken); if (!display) { - ALOGE("%s: Invalid display token %p", __FUNCTION__, displayToken.get()); + ALOGE("%s: Invalid display token %p", __func__, displayToken.get()); return NAME_NOT_FOUND; } @@ -4805,7 +4819,7 @@ void SurfaceFlinger::initializeDisplays() { void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal::PowerMode mode) { if (display->isVirtual()) { - ALOGE("%s: Invalid operation on virtual display", __FUNCTION__); + ALOGE("%s: Invalid operation on virtual display", __func__); return; } |