diff options
53 files changed, 1092 insertions, 1111 deletions
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp index 3a3df08534..01f7d30a42 100644 --- a/cmds/flatland/GLHelper.cpp +++ b/cmds/flatland/GLHelper.cpp @@ -19,7 +19,7 @@ #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #include <gui/SurfaceComposerClient.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> namespace android { @@ -227,15 +227,15 @@ bool GLHelper::computeWindowScale(uint32_t w, uint32_t h, float* scale) { return false; } - DisplayConfig config; - status_t err = mSurfaceComposerClient->getActiveDisplayConfig(dpy, &config); + ui::DisplayMode mode; + status_t err = mSurfaceComposerClient->getActiveDisplayMode(dpy, &mode); if (err != NO_ERROR) { - fprintf(stderr, "SurfaceComposer::getActiveDisplayConfig failed: %#x\n", err); + fprintf(stderr, "SurfaceComposer::getActiveDisplayMode failed: %#x\n", err); return false; } - float scaleX = static_cast<float>(config.resolution.getWidth()) / w; - float scaleY = static_cast<float>(config.resolution.getHeight()) / h; + float scaleX = static_cast<float>(mode.resolution.getWidth()) / w; + float scaleY = static_cast<float>(mode.resolution.getHeight()) / h; *scale = scaleX < scaleY ? scaleX : scaleY; return true; diff --git a/libs/gui/DisplayEventDispatcher.cpp b/libs/gui/DisplayEventDispatcher.cpp index 2ad484add3..5c9949b549 100644 --- a/libs/gui/DisplayEventDispatcher.cpp +++ b/libs/gui/DisplayEventDispatcher.cpp @@ -184,9 +184,9 @@ bool DisplayEventDispatcher::processPendingEvents(nsecs_t* outTimestamp, case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG: dispatchHotplug(ev.header.timestamp, ev.header.displayId, ev.hotplug.connected); break; - case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: - dispatchConfigChanged(ev.header.timestamp, ev.header.displayId, - ev.config.configId, ev.config.vsyncPeriod); + case DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE: + dispatchModeChanged(ev.header.timestamp, ev.header.displayId, + ev.modeChange.modeId, ev.modeChange.vsyncPeriod); break; case DisplayEventReceiver::DISPLAY_EVENT_NULL: dispatchNullEvent(ev.header.timestamp, ev.header.displayId); diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index f68f3e134e..10d48a35bf 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -36,8 +36,8 @@ #include <system/graphics.h> -#include <ui/DisplayConfig.h> #include <ui/DisplayInfo.h> +#include <ui/DisplayMode.h> #include <ui/DisplayStatInfo.h> #include <ui/DisplayState.h> #include <ui/HdrCapabilities.h> @@ -333,20 +333,19 @@ public: return reply.read(*info); } - status_t getDisplayConfigs(const sp<IBinder>& display, - Vector<DisplayConfig>* configs) override { + status_t getDisplayModes(const sp<IBinder>& display, Vector<ui::DisplayMode>* modes) override { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(display); - remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply); + remote()->transact(BnSurfaceComposer::GET_DISPLAY_MODES, data, &reply); const status_t result = reply.readInt32(); if (result == NO_ERROR) { - const size_t numConfigs = reply.readUint32(); - configs->clear(); - configs->resize(numConfigs); - for (size_t c = 0; c < numConfigs; ++c) { - memcpy(&(configs->editItemAt(c)), reply.readInplace(sizeof(DisplayConfig)), - sizeof(DisplayConfig)); + const size_t numModes = reply.readUint32(); + modes->clear(); + modes->resize(numModes); + for (size_t i = 0; i < numModes; i++) { + memcpy(&(modes->editItemAt(i)), reply.readInplace(sizeof(ui::DisplayMode)), + sizeof(ui::DisplayMode)); } } return result; @@ -366,11 +365,11 @@ public: return result; } - int getActiveConfig(const sp<IBinder>& display) override { + int getActiveDisplayModeId(const sp<IBinder>& display) override { Parcel data, reply; data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeStrongBinder(display); - remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply); + remote()->transact(BnSurfaceComposer::GET_ACTIVE_DISPLAY_MODE, data, &reply); return reply.readInt32(); } @@ -882,71 +881,70 @@ public: return error; } - status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, int32_t defaultConfig, - bool allowGroupSwitching, float primaryRefreshRateMin, - float primaryRefreshRateMax, - float appRequestRefreshRateMin, - float appRequestRefreshRateMax) override { + status_t setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, size_t defaultMode, + bool allowGroupSwitching, float primaryRefreshRateMin, + float primaryRefreshRateMax, float appRequestRefreshRateMin, + float appRequestRefreshRateMax) override { Parcel data, reply; status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to writeInterfaceToken: %d", result); + ALOGE("setDesiredDisplayModeSpecs: failed to writeInterfaceToken: %d", result); return result; } result = data.writeStrongBinder(displayToken); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result); + ALOGE("setDesiredDisplayModeSpecs: failed to write display token: %d", result); return result; } - result = data.writeInt32(defaultConfig); + result = data.writeInt32(defaultMode); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result); + ALOGE("setDesiredDisplayModeSpecs failed to write defaultMode: %d", result); return result; } result = data.writeBool(allowGroupSwitching); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs failed to write allowGroupSwitching: %d", result); + ALOGE("setDesiredDisplayModeSpecs failed to write allowGroupSwitching: %d", result); return result; } result = data.writeFloat(primaryRefreshRateMin); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMin: %d", result); + ALOGE("setDesiredDisplayModeSpecs failed to write primaryRefreshRateMin: %d", result); return result; } result = data.writeFloat(primaryRefreshRateMax); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs failed to write primaryRefreshRateMax: %d", result); + ALOGE("setDesiredDisplayModeSpecs failed to write primaryRefreshRateMax: %d", result); return result; } result = data.writeFloat(appRequestRefreshRateMin); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMin: %d", + ALOGE("setDesiredDisplayModeSpecs failed to write appRequestRefreshRateMin: %d", result); return result; } result = data.writeFloat(appRequestRefreshRateMax); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs failed to write appRequestRefreshRateMax: %d", + ALOGE("setDesiredDisplayModeSpecs failed to write appRequestRefreshRateMax: %d", result); return result; } - result = remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_CONFIG_SPECS, data, - &reply); + result = + remote()->transact(BnSurfaceComposer::SET_DESIRED_DISPLAY_MODE_SPECS, data, &reply); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs failed to transact: %d", result); + ALOGE("setDesiredDisplayModeSpecs failed to transact: %d", result); return result; } return reply.readInt32(); } - status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, - int32_t* outDefaultConfig, bool* outAllowGroupSwitching, - float* outPrimaryRefreshRateMin, - float* outPrimaryRefreshRateMax, - float* outAppRequestRefreshRateMin, - float* outAppRequestRefreshRateMax) override { - if (!outDefaultConfig || !outAllowGroupSwitching || !outPrimaryRefreshRateMin || + status_t getDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, size_t* outDefaultMode, + bool* outAllowGroupSwitching, + float* outPrimaryRefreshRateMin, + float* outPrimaryRefreshRateMax, + float* outAppRequestRefreshRateMin, + float* outAppRequestRefreshRateMax) override { + if (!outDefaultMode || !outAllowGroupSwitching || !outPrimaryRefreshRateMin || !outPrimaryRefreshRateMax || !outAppRequestRefreshRateMin || !outAppRequestRefreshRateMax) { return BAD_VALUE; @@ -954,50 +952,55 @@ public: Parcel data, reply; status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to writeInterfaceToken: %d", result); + ALOGE("getDesiredDisplayModeSpecs failed to writeInterfaceToken: %d", result); return result; } result = data.writeStrongBinder(displayToken); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to writeStrongBinder: %d", result); + ALOGE("getDesiredDisplayModeSpecs failed to writeStrongBinder: %d", result); return result; } - result = remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_CONFIG_SPECS, data, - &reply); + result = + remote()->transact(BnSurfaceComposer::GET_DESIRED_DISPLAY_MODE_SPECS, data, &reply); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result); + ALOGE("getDesiredDisplayModeSpecs failed to transact: %d", result); return result; } - result = reply.readInt32(outDefaultConfig); + int32_t defaultMode; + result = reply.readInt32(&defaultMode); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result); + ALOGE("getDesiredDisplayModeSpecs failed to read defaultMode: %d", result); return result; } + if (defaultMode < 0) { + ALOGE("%s: defaultMode must be non-negative but it was %d", __func__, defaultMode); + return BAD_VALUE; + } + *outDefaultMode = static_cast<size_t>(defaultMode); + result = reply.readBool(outAllowGroupSwitching); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to read allowGroupSwitching: %d", result); + ALOGE("getDesiredDisplayModeSpecs failed to read allowGroupSwitching: %d", result); return result; } result = reply.readFloat(outPrimaryRefreshRateMin); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMin: %d", result); + ALOGE("getDesiredDisplayModeSpecs failed to read primaryRefreshRateMin: %d", result); return result; } result = reply.readFloat(outPrimaryRefreshRateMax); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to read primaryRefreshRateMax: %d", result); + ALOGE("getDesiredDisplayModeSpecs failed to read primaryRefreshRateMax: %d", result); return result; } result = reply.readFloat(outAppRequestRefreshRateMin); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMin: %d", - result); + ALOGE("getDesiredDisplayModeSpecs failed to read appRequestRefreshRateMin: %d", result); return result; } result = reply.readFloat(outAppRequestRefreshRateMax); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs failed to read appRequestRefreshRateMax: %d", - result); + ALOGE("getDesiredDisplayModeSpecs failed to read appRequestRefreshRateMax: %d", result); return result; } return reply.readInt32(); @@ -1430,17 +1433,17 @@ status_t BnSurfaceComposer::onTransact( if (result != NO_ERROR) return result; return reply->write(info); } - case GET_DISPLAY_CONFIGS: { + case GET_DISPLAY_MODES: { CHECK_INTERFACE(ISurfaceComposer, data, reply); - Vector<DisplayConfig> configs; + Vector<ui::DisplayMode> modes; const sp<IBinder> display = data.readStrongBinder(); - const status_t result = getDisplayConfigs(display, &configs); + const status_t result = getDisplayModes(display, &modes); reply->writeInt32(result); if (result == NO_ERROR) { - reply->writeUint32(static_cast<uint32_t>(configs.size())); - for (size_t c = 0; c < configs.size(); ++c) { - memcpy(reply->writeInplace(sizeof(DisplayConfig)), &configs[c], - sizeof(DisplayConfig)); + reply->writeUint32(static_cast<uint32_t>(modes.size())); + for (size_t i = 0; i < modes.size(); i++) { + memcpy(reply->writeInplace(sizeof(ui::DisplayMode)), &modes[i], + sizeof(ui::DisplayMode)); } } return NO_ERROR; @@ -1457,10 +1460,10 @@ status_t BnSurfaceComposer::onTransact( } return NO_ERROR; } - case GET_ACTIVE_CONFIG: { + case GET_ACTIVE_DISPLAY_MODE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); - int id = getActiveConfig(display); + int id = getActiveDisplayModeId(display); reply->writeInt32(id); return NO_ERROR; } @@ -1844,56 +1847,59 @@ status_t BnSurfaceComposer::onTransact( } return removeRegionSamplingListener(listener); } - case SET_DESIRED_DISPLAY_CONFIG_SPECS: { + case SET_DESIRED_DISPLAY_MODE_SPECS: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> displayToken = data.readStrongBinder(); - int32_t defaultConfig; - status_t result = data.readInt32(&defaultConfig); + int32_t defaultMode; + status_t result = data.readInt32(&defaultMode); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result); + ALOGE("setDesiredDisplayModeSpecs: failed to read defaultMode: %d", result); return result; } + if (defaultMode < 0) { + ALOGE("%s: defaultMode must be non-negative but it was %d", __func__, defaultMode); + return BAD_VALUE; + } bool allowGroupSwitching; result = data.readBool(&allowGroupSwitching); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to read allowGroupSwitching: %d", - result); + ALOGE("setDesiredDisplayModeSpecs: failed to read allowGroupSwitching: %d", result); return result; } float primaryRefreshRateMin; result = data.readFloat(&primaryRefreshRateMin); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMin: %d", + ALOGE("setDesiredDisplayModeSpecs: failed to read primaryRefreshRateMin: %d", result); return result; } float primaryRefreshRateMax; result = data.readFloat(&primaryRefreshRateMax); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to read primaryRefreshRateMax: %d", + ALOGE("setDesiredDisplayModeSpecs: failed to read primaryRefreshRateMax: %d", result); return result; } float appRequestRefreshRateMin; result = data.readFloat(&appRequestRefreshRateMin); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMin: %d", + ALOGE("setDesiredDisplayModeSpecs: failed to read appRequestRefreshRateMin: %d", result); return result; } float appRequestRefreshRateMax; result = data.readFloat(&appRequestRefreshRateMax); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to read appRequestRefreshRateMax: %d", + ALOGE("setDesiredDisplayModeSpecs: failed to read appRequestRefreshRateMax: %d", result); return result; } - result = setDesiredDisplayConfigSpecs(displayToken, defaultConfig, allowGroupSwitching, - primaryRefreshRateMin, primaryRefreshRateMax, - appRequestRefreshRateMin, - appRequestRefreshRateMax); + result = setDesiredDisplayModeSpecs(displayToken, static_cast<size_t>(defaultMode), + allowGroupSwitching, primaryRefreshRateMin, + primaryRefreshRateMax, appRequestRefreshRateMin, + appRequestRefreshRateMax); if (result != NO_ERROR) { - ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: " + ALOGE("setDesiredDisplayModeSpecs: failed to call setDesiredDisplayModeSpecs: " "%d", result); return result; @@ -1901,10 +1907,10 @@ status_t BnSurfaceComposer::onTransact( reply->writeInt32(result); return result; } - case GET_DESIRED_DISPLAY_CONFIG_SPECS: { + case GET_DESIRED_DISPLAY_MODE_SPECS: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> displayToken = data.readStrongBinder(); - int32_t defaultConfig; + size_t defaultMode; bool allowGroupSwitching; float primaryRefreshRateMin; float primaryRefreshRateMax; @@ -1912,49 +1918,49 @@ status_t BnSurfaceComposer::onTransact( float appRequestRefreshRateMax; status_t result = - getDesiredDisplayConfigSpecs(displayToken, &defaultConfig, &allowGroupSwitching, - &primaryRefreshRateMin, &primaryRefreshRateMax, - &appRequestRefreshRateMin, - &appRequestRefreshRateMax); + getDesiredDisplayModeSpecs(displayToken, &defaultMode, &allowGroupSwitching, + &primaryRefreshRateMin, &primaryRefreshRateMax, + &appRequestRefreshRateMin, + &appRequestRefreshRateMax); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: " + ALOGE("getDesiredDisplayModeSpecs: failed to get getDesiredDisplayModeSpecs: " "%d", result); return result; } - result = reply->writeInt32(defaultConfig); + result = reply->writeInt32(static_cast<int32_t>(defaultMode)); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result); + ALOGE("getDesiredDisplayModeSpecs: failed to write defaultMode: %d", result); return result; } result = reply->writeBool(allowGroupSwitching); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs: failed to write allowGroupSwitching: %d", + ALOGE("getDesiredDisplayModeSpecs: failed to write allowGroupSwitching: %d", result); return result; } result = reply->writeFloat(primaryRefreshRateMin); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMin: %d", + ALOGE("getDesiredDisplayModeSpecs: failed to write primaryRefreshRateMin: %d", result); return result; } result = reply->writeFloat(primaryRefreshRateMax); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs: failed to write primaryRefreshRateMax: %d", + ALOGE("getDesiredDisplayModeSpecs: failed to write primaryRefreshRateMax: %d", result); return result; } result = reply->writeFloat(appRequestRefreshRateMin); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMin: %d", + ALOGE("getDesiredDisplayModeSpecs: failed to write appRequestRefreshRateMin: %d", result); return result; } result = reply->writeFloat(appRequestRefreshRateMax); if (result != NO_ERROR) { - ALOGE("getDesiredDisplayConfigSpecs: failed to write appRequestRefreshRateMax: %d", + ALOGE("getDesiredDisplayModeSpecs: failed to write appRequestRefreshRateMax: %d", result); return result; } diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 550803d453..4493a21fc3 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -39,7 +39,7 @@ #include <gui/LayerState.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #ifndef NO_INPUT #include <input/InputWindow.h> @@ -1802,52 +1802,51 @@ status_t SurfaceComposerClient::getDisplayInfo(const sp<IBinder>& display, Displ return ComposerService::getComposerService()->getDisplayInfo(display, info); } -status_t SurfaceComposerClient::getDisplayConfigs(const sp<IBinder>& display, - Vector<DisplayConfig>* configs) { - return ComposerService::getComposerService()->getDisplayConfigs(display, configs); +status_t SurfaceComposerClient::getDisplayModes(const sp<IBinder>& display, + Vector<ui::DisplayMode>* modes) { + return ComposerService::getComposerService()->getDisplayModes(display, modes); } -status_t SurfaceComposerClient::getActiveDisplayConfig(const sp<IBinder>& display, - DisplayConfig* config) { - Vector<DisplayConfig> configs; - status_t result = getDisplayConfigs(display, &configs); +status_t SurfaceComposerClient::getActiveDisplayMode(const sp<IBinder>& display, + ui::DisplayMode* mode) { + Vector<ui::DisplayMode> modes; + status_t result = getDisplayModes(display, &modes); if (result != NO_ERROR) { return result; } - int activeId = getActiveConfig(display); + int activeId = getActiveDisplayModeId(display); if (activeId < 0) { - ALOGE("No active configuration found"); + ALOGE("No active mode found"); return NAME_NOT_FOUND; } - *config = configs[static_cast<size_t>(activeId)]; + *mode = modes[static_cast<size_t>(activeId)]; return NO_ERROR; } -int SurfaceComposerClient::getActiveConfig(const sp<IBinder>& display) { - return ComposerService::getComposerService()->getActiveConfig(display); +int SurfaceComposerClient::getActiveDisplayModeId(const sp<IBinder>& display) { + return ComposerService::getComposerService()->getActiveDisplayModeId(display); } -status_t SurfaceComposerClient::setDesiredDisplayConfigSpecs( - const sp<IBinder>& displayToken, int32_t defaultConfig, bool allowGroupSwitching, +status_t SurfaceComposerClient::setDesiredDisplayModeSpecs( + const sp<IBinder>& displayToken, size_t defaultMode, bool allowGroupSwitching, float primaryRefreshRateMin, float primaryRefreshRateMax, float appRequestRefreshRateMin, float appRequestRefreshRateMax) { return ComposerService::getComposerService() - ->setDesiredDisplayConfigSpecs(displayToken, defaultConfig, allowGroupSwitching, - primaryRefreshRateMin, primaryRefreshRateMax, - appRequestRefreshRateMin, appRequestRefreshRateMax); + ->setDesiredDisplayModeSpecs(displayToken, defaultMode, allowGroupSwitching, + primaryRefreshRateMin, primaryRefreshRateMax, + appRequestRefreshRateMin, appRequestRefreshRateMax); } -status_t SurfaceComposerClient::getDesiredDisplayConfigSpecs( - const sp<IBinder>& displayToken, int32_t* outDefaultConfig, bool* outAllowGroupSwitching, +status_t SurfaceComposerClient::getDesiredDisplayModeSpecs( + const sp<IBinder>& displayToken, size_t* outDefaultMode, bool* outAllowGroupSwitching, float* outPrimaryRefreshRateMin, float* outPrimaryRefreshRateMax, float* outAppRequestRefreshRateMin, float* outAppRequestRefreshRateMax) { return ComposerService::getComposerService() - ->getDesiredDisplayConfigSpecs(displayToken, outDefaultConfig, outAllowGroupSwitching, - outPrimaryRefreshRateMin, outPrimaryRefreshRateMax, - outAppRequestRefreshRateMin, - outAppRequestRefreshRateMax); + ->getDesiredDisplayModeSpecs(displayToken, outDefaultMode, outAllowGroupSwitching, + outPrimaryRefreshRateMin, outPrimaryRefreshRateMax, + outAppRequestRefreshRateMin, outAppRequestRefreshRateMax); } status_t SurfaceComposerClient::getDisplayColorModes(const sp<IBinder>& display, diff --git a/libs/gui/include/gui/DisplayEventDispatcher.h b/libs/gui/include/gui/DisplayEventDispatcher.h index 4175a49853..43b9feb295 100644 --- a/libs/gui/include/gui/DisplayEventDispatcher.h +++ b/libs/gui/include/gui/DisplayEventDispatcher.h @@ -73,8 +73,8 @@ private: VsyncEventData vsyncEventData) = 0; virtual void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) = 0; - virtual void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId, - int32_t configId, nsecs_t vsyncPeriod) = 0; + virtual void dispatchModeChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t modeId, + nsecs_t vsyncPeriod) = 0; // AChoreographer-specific hook for processing null-events so that looper // can be properly poked. virtual void dispatchNullEvent(nsecs_t timestamp, PhysicalDisplayId displayId) = 0; diff --git a/libs/gui/include/gui/DisplayEventReceiver.h b/libs/gui/include/gui/DisplayEventReceiver.h index 3191fc9ab5..7179a20d22 100644 --- a/libs/gui/include/gui/DisplayEventReceiver.h +++ b/libs/gui/include/gui/DisplayEventReceiver.h @@ -52,7 +52,7 @@ public: enum { DISPLAY_EVENT_VSYNC = fourcc('v', 's', 'y', 'n'), DISPLAY_EVENT_HOTPLUG = fourcc('p', 'l', 'u', 'g'), - DISPLAY_EVENT_CONFIG_CHANGED = fourcc('c', 'o', 'n', 'f'), + DISPLAY_EVENT_MODE_CHANGE = fourcc('m', 'o', 'd', 'e'), DISPLAY_EVENT_NULL = fourcc('n', 'u', 'l', 'l'), DISPLAY_EVENT_FRAME_RATE_OVERRIDE = fourcc('r', 'a', 't', 'e'), DISPLAY_EVENT_FRAME_RATE_OVERRIDE_FLUSH = fourcc('f', 'l', 's', 'h'), @@ -82,8 +82,8 @@ public: bool connected; }; - struct Config { - int32_t configId; + struct ModeChange { + int32_t modeId; nsecs_t vsyncPeriod __attribute__((aligned(8))); }; @@ -96,7 +96,7 @@ public: union { VSync vsync; Hotplug hotplug; - Config config; + ModeChange modeChange; FrameRateOverride frameRateOverride; }; }; @@ -106,7 +106,7 @@ public: * DisplayEventReceiver creates and registers an event connection with * SurfaceFlinger. VSync events are disabled by default. Call setVSyncRate * or requestNextVsync to receive them. - * To receive ConfigChanged and/or FrameRateOverrides events specify this in + * To receive ModeChanged and/or FrameRateOverrides events specify this in * the constructor. Other events start being delivered immediately. */ explicit DisplayEventReceiver( diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h index 81ff6b0d8d..6d1a3ab334 100644 --- a/libs/gui/include/gui/ISurfaceComposer.h +++ b/libs/gui/include/gui/ISurfaceComposer.h @@ -54,7 +54,6 @@ namespace android { struct client_cache_t; struct ComposerState; struct DisplayCaptureArgs; -struct DisplayConfig; struct DisplayInfo; struct DisplayStatInfo; struct DisplayState; @@ -73,6 +72,7 @@ using gui::IScreenCaptureListener; namespace ui { +struct DisplayMode; struct DisplayState; } // namespace ui @@ -112,7 +112,7 @@ public: }; enum class EventRegistration { - configChanged = 1 << 0, + modeChanged = 1 << 0, frameRateOverride = 1 << 1, }; @@ -207,15 +207,15 @@ public: virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo*) = 0; /** - * Get configurations supported by given physical display. + * Get modes supported by given physical display. */ - virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>*) = 0; + virtual status_t getDisplayModes(const sp<IBinder>& display, Vector<ui::DisplayMode>*) = 0; /** - * Get the index into configurations returned by getDisplayConfigs, - * corresponding to the active configuration. + * Get the index into modes returned by getDisplayModes, + * corresponding to the active mode. */ - virtual int getActiveConfig(const sp<IBinder>& display) = 0; + virtual int getActiveDisplayModeId(const sp<IBinder>& display) = 0; virtual status_t getDisplayColorModes(const sp<IBinder>& display, Vector<ui::ColorMode>* outColorModes) = 0; @@ -386,34 +386,31 @@ public: /* Sets the refresh rate boundaries for the display. * * The primary refresh rate range represents display manager's general guidance on the display - * configs we'll consider when switching refresh rates. Unless we get an explicit signal from an + * modes we'll consider when switching refresh rates. Unless we get an explicit signal from an * app, we should stay within this range. * - * The app request refresh rate range allows us to consider more display configs when switching + * The app request refresh rate range allows us to consider more display modes when switching * refresh rates. Although we should generally stay within the primary range, specific * considerations, such as layer frame rate settings specified via the setFrameRate() api, may * cause us to go outside the primary range. We never go outside the app request range. The app * request range will be greater than or equal to the primary refresh rate range, never smaller. * - * defaultConfig is used to narrow the list of display configs SurfaceFlinger will consider - * switching between. Only configs with a config group and resolution matching defaultConfig - * will be considered for switching. The defaultConfig index corresponds to the list of configs - * returned from getDisplayConfigs(). - */ - virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, - int32_t defaultConfig, bool allowGroupSwitching, - float primaryRefreshRateMin, - float primaryRefreshRateMax, - float appRequestRefreshRateMin, - float appRequestRefreshRateMax) = 0; - - virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, - int32_t* outDefaultConfig, - bool* outAllowGroupSwitching, - float* outPrimaryRefreshRateMin, - float* outPrimaryRefreshRateMax, - float* outAppRequestRefreshRateMin, - float* outAppRequestRefreshRateMax) = 0; + * defaultMode is used to narrow the list of display modes SurfaceFlinger will consider + * switching between. Only modes with a mode group and resolution matching defaultMode + * will be considered for switching. The defaultMode index corresponds to the list of modes + * returned from getDisplayModes(). + */ + virtual status_t setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, size_t defaultMode, + bool allowGroupSwitching, + float primaryRefreshRateMin, + float primaryRefreshRateMax, + float appRequestRefreshRateMin, + float appRequestRefreshRateMax) = 0; + + virtual status_t getDesiredDisplayModeSpecs( + const sp<IBinder>& displayToken, size_t* outDefaultMode, bool* outAllowGroupSwitching, + float* outPrimaryRefreshRateMin, float* outPrimaryRefreshRateMax, + float* outAppRequestRefreshRateMin, float* outAppRequestRefreshRateMax) = 0; /* * Gets whether brightness operations are supported on a display. * @@ -527,8 +524,8 @@ public: SET_TRANSACTION_STATE, AUTHENTICATE_SURFACE, GET_SUPPORTED_FRAME_TIMESTAMPS, - GET_DISPLAY_CONFIGS, - GET_ACTIVE_CONFIG, + GET_DISPLAY_MODES, + GET_ACTIVE_DISPLAY_MODE, GET_DISPLAY_STATE, CAPTURE_DISPLAY, CAPTURE_LAYERS, @@ -554,8 +551,8 @@ public: GET_PHYSICAL_DISPLAY_IDS, ADD_REGION_SAMPLING_LISTENER, REMOVE_REGION_SAMPLING_LISTENER, - SET_DESIRED_DISPLAY_CONFIG_SPECS, - GET_DESIRED_DISPLAY_CONFIG_SPECS, + SET_DESIRED_DISPLAY_MODE_SPECS, + GET_DESIRED_DISPLAY_MODE_SPECS, GET_DISPLAY_BRIGHTNESS_SUPPORT, SET_DISPLAY_BRIGHTNESS, CAPTURE_DISPLAY_BY_ID, diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h index e7abfe6172..bd9f066f96 100644 --- a/libs/gui/include/gui/SurfaceComposerClient.h +++ b/libs/gui/include/gui/SurfaceComposerClient.h @@ -110,30 +110,29 @@ public: // Get immutable information about given physical display. static status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo*); - // Get configurations supported by given physical display. - static status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>*); + // Get modes supported by given physical display. + static status_t getDisplayModes(const sp<IBinder>& display, Vector<ui::DisplayMode>*); - // Get the ID of the active DisplayConfig, as getDisplayConfigs index. - static int getActiveConfig(const sp<IBinder>& display); + // Get the ID of the active DisplayMode, as getDisplayModes index. + static int getActiveDisplayModeId(const sp<IBinder>& display); - // Shorthand for getDisplayConfigs element at getActiveConfig index. - static status_t getActiveDisplayConfig(const sp<IBinder>& display, DisplayConfig*); + // Shorthand for getDisplayModes element at getActiveDisplayModeId index. + static status_t getActiveDisplayMode(const sp<IBinder>& display, ui::DisplayMode*); // Sets the refresh rate boundaries for the display. - static status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, - int32_t defaultConfig, bool allowGroupSwitching, - float primaryRefreshRateMin, - float primaryRefreshRateMax, - float appRequestRefreshRateMin, - float appRequestRefreshRateMax); + static status_t setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, size_t defaultMode, + bool allowGroupSwitching, + float primaryRefreshRateMin, + float primaryRefreshRateMax, + float appRequestRefreshRateMin, + float appRequestRefreshRateMax); // Gets the refresh rate boundaries for the display. - static status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, - int32_t* outDefaultConfig, - bool* outAllowGroupSwitching, - float* outPrimaryRefreshRateMin, - float* outPrimaryRefreshRateMax, - float* outAppRequestRefreshRateMin, - float* outAppRequestRefreshRateMax); + static status_t getDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, + size_t* outDefaultMode, bool* outAllowGroupSwitching, + float* outPrimaryRefreshRateMin, + float* outPrimaryRefreshRateMax, + float* outAppRequestRefreshRateMin, + float* outAppRequestRefreshRateMax); // Gets the list of supported color modes for the given display static status_t getDisplayColorModes(const sp<IBinder>& display, diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp index 70e656da9b..5447b7659b 100644 --- a/libs/gui/tests/BLASTBufferQueue_test.cpp +++ b/libs/gui/tests/BLASTBufferQueue_test.cpp @@ -28,7 +28,7 @@ #include <gui/SurfaceComposerClient.h> #include <gui/SyncScreenCaptureListener.h> #include <private/gui/ComposerService.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <ui/GraphicBuffer.h> #include <ui/GraphicTypes.h> #include <ui/Transform.h> @@ -107,9 +107,9 @@ protected: t.apply(); t.clear(); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(mDisplayToken, &config)); - const ui::Size& resolution = config.resolution; + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(mDisplayToken, &mode)); + const ui::Size& resolution = mode.resolution; mDisplayWidth = resolution.getWidth(); mDisplayHeight = resolution.getHeight(); diff --git a/libs/gui/tests/DisplayEventStructLayout_test.cpp b/libs/gui/tests/DisplayEventStructLayout_test.cpp index c5093e2d88..7dbba31ba8 100644 --- a/libs/gui/tests/DisplayEventStructLayout_test.cpp +++ b/libs/gui/tests/DisplayEventStructLayout_test.cpp @@ -25,7 +25,7 @@ namespace android::test { TEST(DisplayEventStructLayoutTest, TestEventAlignment) { CHECK_OFFSET(DisplayEventReceiver::Event, vsync, 24); CHECK_OFFSET(DisplayEventReceiver::Event, hotplug, 24); - CHECK_OFFSET(DisplayEventReceiver::Event, config, 24); + CHECK_OFFSET(DisplayEventReceiver::Event, modeChange, 24); CHECK_OFFSET(DisplayEventReceiver::Event::Header, type, 0); CHECK_OFFSET(DisplayEventReceiver::Event::Header, displayId, 8); @@ -38,8 +38,8 @@ TEST(DisplayEventStructLayoutTest, TestEventAlignment) { CHECK_OFFSET(DisplayEventReceiver::Event::Hotplug, connected, 0); - CHECK_OFFSET(DisplayEventReceiver::Event::Config, configId, 0); - CHECK_OFFSET(DisplayEventReceiver::Event::Config, vsyncPeriod, 8); + CHECK_OFFSET(DisplayEventReceiver::Event::ModeChange, modeId, 0); + CHECK_OFFSET(DisplayEventReceiver::Event::ModeChange, vsyncPeriod, 8); CHECK_OFFSET(DisplayEventReceiver::Event::FrameRateOverride, uid, 0); CHECK_OFFSET(DisplayEventReceiver::Event::FrameRateOverride, frameRateHz, 8); diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp index 31cbbdc75c..d65a40baf6 100644 --- a/libs/gui/tests/EndToEndNativeInputTest.cpp +++ b/libs/gui/tests/EndToEndNativeInputTest.cpp @@ -41,7 +41,7 @@ #include <input/InputTransport.h> #include <input/InputWindow.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <ui/Rect.h> #include <ui/Region.h> @@ -272,13 +272,13 @@ public: const auto display = mComposerClient->getInternalDisplayToken(); ASSERT_NE(display, nullptr); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, mComposerClient->getActiveDisplayConfig(display, &config)); + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, mComposerClient->getActiveDisplayMode(display, &mode)); // After a new buffer is queued, SurfaceFlinger is notified and will // latch the new buffer on next vsync. Let's heuristically wait for 3 // vsyncs. - mBufferPostDelay = static_cast<int32_t>(1e6 / config.refreshRate) * 3; + mBufferPostDelay = static_cast<int32_t>(1e6 / mode.refreshRate) * 3; } void TearDown() { diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp index 3f7a5b1785..80e4c770dc 100644 --- a/libs/gui/tests/Surface_test.cpp +++ b/libs/gui/tests/Surface_test.cpp @@ -737,7 +737,7 @@ public: status_t getDisplayInfo(const sp<IBinder>& /*display*/, DisplayInfo*) override { return NO_ERROR; } - status_t getDisplayConfigs(const sp<IBinder>& /*display*/, Vector<DisplayConfig>*) override { + status_t getDisplayModes(const sp<IBinder>& /*display*/, Vector<ui::DisplayMode>*) override { return NO_ERROR; } status_t getDisplayState(const sp<IBinder>& /*display*/, ui::DisplayState*) override { @@ -745,7 +745,7 @@ public: } status_t getDisplayStats(const sp<IBinder>& /*display*/, DisplayStatInfo* /*stats*/) override { return NO_ERROR; } - int getActiveConfig(const sp<IBinder>& /*display*/) override { return 0; } + int getActiveDisplayModeId(const sp<IBinder>& /*display*/) override { return 0; } status_t getDisplayColorModes(const sp<IBinder>& /*display*/, Vector<ColorMode>* /*outColorModes*/) override { return NO_ERROR; @@ -843,21 +843,21 @@ public: const sp<IRegionSamplingListener>& /*listener*/) override { return NO_ERROR; } - status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& /*displayToken*/, - int32_t /*defaultConfig*/, bool /*allowGroupSwitching*/, - float /*primaryRefreshRateMin*/, - float /*primaryRefreshRateMax*/, - float /*appRequestRefreshRateMin*/, - float /*appRequestRefreshRateMax*/) { + status_t setDesiredDisplayModeSpecs(const sp<IBinder>& /*displayToken*/, size_t /*defaultMode*/, + bool /*allowGroupSwitching*/, + float /*primaryRefreshRateMin*/, + float /*primaryRefreshRateMax*/, + float /*appRequestRefreshRateMin*/, + float /*appRequestRefreshRateMax*/) { return NO_ERROR; } - status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& /*displayToken*/, - int32_t* /*outDefaultConfig*/, - bool* /*outAllowGroupSwitching*/, - float* /*outPrimaryRefreshRateMin*/, - float* /*outPrimaryRefreshRateMax*/, - float* /*outAppRequestRefreshRateMin*/, - float* /*outAppRequestRefreshRateMax*/) override { + status_t getDesiredDisplayModeSpecs(const sp<IBinder>& /*displayToken*/, + size_t* /*outDefaultMode*/, + bool* /*outAllowGroupSwitching*/, + float* /*outPrimaryRefreshRateMin*/, + float* /*outPrimaryRefreshRateMax*/, + float* /*outAppRequestRefreshRateMin*/, + float* /*outAppRequestRefreshRateMax*/) override { return NO_ERROR; }; status_t notifyPowerBoost(int32_t /*boostId*/) override { return NO_ERROR; } diff --git a/libs/nativedisplay/AChoreographer.cpp b/libs/nativedisplay/AChoreographer.cpp index 6b085a3292..dc2dd297c5 100644 --- a/libs/nativedisplay/AChoreographer.cpp +++ b/libs/nativedisplay/AChoreographer.cpp @@ -138,8 +138,8 @@ private: void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count, VsyncEventData vsyncEventData) override; void dispatchHotplug(nsecs_t timestamp, PhysicalDisplayId displayId, bool connected) override; - void dispatchConfigChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t configId, - nsecs_t vsyncPeriod) override; + void dispatchModeChanged(nsecs_t timestamp, PhysicalDisplayId displayId, int32_t modeId, + nsecs_t vsyncPeriod) override; void dispatchNullEvent(nsecs_t, PhysicalDisplayId) override; void dispatchFrameRateOverrides(nsecs_t timestamp, PhysicalDisplayId displayId, std::vector<FrameRateOverride> overrides) override; @@ -382,8 +382,8 @@ void Choreographer::dispatchHotplug(nsecs_t, PhysicalDisplayId displayId, bool c this, to_string(displayId).c_str(), toString(connected)); } -void Choreographer::dispatchConfigChanged(nsecs_t, PhysicalDisplayId, int32_t, nsecs_t) { - LOG_ALWAYS_FATAL("dispatchConfigChanged was called but was never registered"); +void Choreographer::dispatchModeChanged(nsecs_t, PhysicalDisplayId, int32_t, nsecs_t) { + LOG_ALWAYS_FATAL("dispatchModeChanged was called but was never registered"); } void Choreographer::dispatchFrameRateOverrides(nsecs_t, PhysicalDisplayId, diff --git a/libs/nativedisplay/ADisplay.cpp b/libs/nativedisplay/ADisplay.cpp index 277635cd34..c595aa6309 100644 --- a/libs/nativedisplay/ADisplay.cpp +++ b/libs/nativedisplay/ADisplay.cpp @@ -16,8 +16,8 @@ #include <apex/display.h> #include <gui/SurfaceComposerClient.h> -#include <ui/DisplayConfig.h> #include <ui/DisplayInfo.h> +#include <ui/DisplayMode.h> #include <ui/GraphicTypes.h> #include <ui/PixelFormat.h> @@ -134,8 +134,8 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) { return NO_INIT; } - std::vector<DisplayConfigImpl> configsPerDisplay[size]; - int numConfigs = 0; + std::vector<DisplayConfigImpl> modesPerDisplay[size]; + int numModes = 0; for (int i = 0; i < size; ++i) { const sp<IBinder> token = SurfaceComposerClient::getPhysicalDisplayToken(ids[i]); @@ -145,23 +145,23 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) { return status; } - Vector<DisplayConfig> configs; - if (const status_t status = SurfaceComposerClient::getDisplayConfigs(token, &configs); + Vector<ui::DisplayMode> modes; + if (const status_t status = SurfaceComposerClient::getDisplayModes(token, &modes); status != OK) { return status; } - if (configs.empty()) { + if (modes.empty()) { return NO_INIT; } - numConfigs += configs.size(); - configsPerDisplay[i].reserve(configs.size()); - for (int j = 0; j < configs.size(); ++j) { - const DisplayConfig& config = configs[j]; - configsPerDisplay[i].emplace_back( - DisplayConfigImpl{config.resolution.getWidth(), config.resolution.getHeight(), - info.density, config.refreshRate, config.sfVsyncOffset, - config.appVsyncOffset}); + numModes += modes.size(); + modesPerDisplay[i].reserve(modes.size()); + for (int j = 0; j < modes.size(); ++j) { + const ui::DisplayMode& mode = modes[j]; + modesPerDisplay[i].emplace_back( + DisplayConfigImpl{mode.resolution.getWidth(), mode.resolution.getHeight(), + info.density, mode.refreshRate, mode.sfVsyncOffset, + mode.appVsyncOffset}); } } @@ -192,7 +192,7 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) { // contiguous block of DisplayConfigImpls specific to that display. DisplayImpl** const impls = reinterpret_cast<DisplayImpl**>( malloc((sizeof(DisplayImpl) + sizeof(DisplayImpl*)) * size + - sizeof(DisplayConfigImpl) * numConfigs)); + sizeof(DisplayConfigImpl) * numModes)); DisplayImpl* const displayData = reinterpret_cast<DisplayImpl*>(impls + size); DisplayConfigImpl* configData = reinterpret_cast<DisplayConfigImpl*>(displayData + size); @@ -200,7 +200,7 @@ int ADisplay_acquirePhysicalDisplays(ADisplay*** outDisplays) { const PhysicalDisplayId id = ids[i]; const ADisplayType type = (internalId == id) ? ADisplayType::DISPLAY_TYPE_INTERNAL : ADisplayType::DISPLAY_TYPE_EXTERNAL; - const std::vector<DisplayConfigImpl>& configs = configsPerDisplay[i]; + const std::vector<DisplayConfigImpl>& configs = modesPerDisplay[i]; memcpy(configData, configs.data(), sizeof(DisplayConfigImpl) * configs.size()); displayData[i] = DisplayImpl{id, @@ -257,7 +257,7 @@ int ADisplay_getCurrentConfig(ADisplay* display, ADisplayConfig** outConfig) { CHECK_NOT_NULL(display); sp<IBinder> token = getToken(display); - const int index = SurfaceComposerClient::getActiveConfig(token); + const int index = SurfaceComposerClient::getActiveDisplayModeId(token); if (index < 0) { return index; } diff --git a/libs/ui/include/ui/DisplayConfig.h b/libs/ui/include/ui/DisplayMode.h index d6fbaab387..145d7efd19 100644 --- a/libs/ui/include/ui/DisplayConfig.h +++ b/libs/ui/include/ui/DisplayMode.h @@ -21,10 +21,10 @@ #include <ui/Size.h> #include <utils/Timers.h> -namespace android { +namespace android::ui { -// Configuration supported by physical display. -struct DisplayConfig { +// Mode supported by physical display. +struct DisplayMode { ui::Size resolution; float xDpi = 0; float yDpi = 0; @@ -33,9 +33,9 @@ struct DisplayConfig { nsecs_t appVsyncOffset = 0; nsecs_t sfVsyncOffset = 0; nsecs_t presentationDeadline = 0; - int configGroup = -1; + int group = -1; }; -static_assert(std::is_trivially_copyable_v<DisplayConfig>); +static_assert(std::is_trivially_copyable_v<DisplayMode>); -} // namespace android +} // namespace android::ui diff --git a/libs/ui/include_vndk/ui/DisplayConfig.h b/libs/ui/include_vndk/ui/DisplayConfig.h deleted file mode 120000 index 1450319502..0000000000 --- a/libs/ui/include_vndk/ui/DisplayConfig.h +++ /dev/null @@ -1 +0,0 @@ -../../include/ui/DisplayConfig.h
\ No newline at end of file diff --git a/libs/ui/include_vndk/ui/DisplayMode.h b/libs/ui/include_vndk/ui/DisplayMode.h new file mode 120000 index 0000000000..c87754a682 --- /dev/null +++ b/libs/ui/include_vndk/ui/DisplayMode.h @@ -0,0 +1 @@ +../../include/ui/DisplayMode.h
\ No newline at end of file diff --git a/opengl/tests/lib/WindowSurface.cpp b/opengl/tests/lib/WindowSurface.cpp index dfb9c92b5f..fd4522e757 100644 --- a/opengl/tests/lib/WindowSurface.cpp +++ b/opengl/tests/lib/WindowSurface.cpp @@ -21,7 +21,7 @@ #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <ui/DisplayState.h> using namespace android; @@ -42,10 +42,10 @@ WindowSurface::WindowSurface() { return; } - DisplayConfig displayConfig; - err = SurfaceComposerClient::getActiveDisplayConfig(displayToken, &displayConfig); + ui::DisplayMode displayMode; + err = SurfaceComposerClient::getActiveDisplayMode(displayToken, &displayMode); if (err != NO_ERROR) { - fprintf(stderr, "ERROR: unable to get active display config\n"); + fprintf(stderr, "ERROR: unable to get active display mode\n"); return; } @@ -56,7 +56,7 @@ WindowSurface::WindowSurface() { return; } - const ui::Size& resolution = displayConfig.resolution; + const ui::Size& resolution = displayMode.resolution; auto width = resolution.getWidth(); auto height = resolution.getHeight(); diff --git a/services/automotive/display/AutomotiveDisplayProxyService.cpp b/services/automotive/display/AutomotiveDisplayProxyService.cpp index 321bb8342d..d6fc69562b 100644 --- a/services/automotive/display/AutomotiveDisplayProxyService.cpp +++ b/services/automotive/display/AutomotiveDisplayProxyService.cpp @@ -41,10 +41,10 @@ AutomotiveDisplayProxyService::getIGraphicBufferProducer(uint64_t id) { } // Get the resolution from stored display state. - DisplayConfig displayConfig = {}; - auto err = SurfaceComposerClient::getActiveDisplayConfig(displayToken, &displayConfig); + ui::DisplayMode displayMode = {}; + auto err = SurfaceComposerClient::getActiveDisplayMode(displayToken, &displayMode); if (err != NO_ERROR) { - ALOGE("Failed to get display configuration of %lX. " + ALOGE("Failed to get display mode of %lX. " "This display will be ignored.", (unsigned long)id); return nullptr; } @@ -57,8 +57,8 @@ AutomotiveDisplayProxyService::getIGraphicBufferProducer(uint64_t id) { return nullptr; } - auto displayWidth = displayConfig.resolution.getWidth(); - auto displayHeight = displayConfig.resolution.getHeight(); + auto displayWidth = displayMode.resolution.getWidth(); + auto displayHeight = displayMode.resolution.getHeight(); if ((displayState.orientation != ui::ROTATION_0) && (displayState.orientation != ui::ROTATION_180)) { std::swap(displayWidth, displayHeight); @@ -161,10 +161,10 @@ Return<void> AutomotiveDisplayProxyService::getDisplayInfo(uint64_t id, getDispl if (displayToken == nullptr) { ALOGE("Given display id, 0x%lX, is invalid.", (unsigned long)id); } else { - DisplayConfig displayConfig = {}; - auto err = SurfaceComposerClient::getActiveDisplayConfig(displayToken, &displayConfig); + ui::DisplayMode displayMode = {}; + auto err = SurfaceComposerClient::getActiveDisplayMode(displayToken, &displayMode); if (err != NO_ERROR) { - ALOGW("Failed to get display configuration of %lX. " + ALOGW("Failed to get display mode of %lX. " "This display will be ignored.", (unsigned long)id); } @@ -175,7 +175,7 @@ Return<void> AutomotiveDisplayProxyService::getDisplayInfo(uint64_t id, getDispl "This display will be ignored.", (unsigned long)id); } - activeConfig.setToExternal((uint8_t*)&displayConfig, sizeof(DisplayConfig)); + activeConfig.setToExternal((uint8_t*)&displayMode, sizeof(ui::DisplayMode)); activeState.setToExternal((uint8_t*)&displayState, sizeof(DisplayState)); } diff --git a/services/automotive/display/include/AutomotiveDisplayProxyService.h b/services/automotive/display/include/AutomotiveDisplayProxyService.h index e2fc0d2eec..4482b9beea 100644 --- a/services/automotive/display/include/AutomotiveDisplayProxyService.h +++ b/services/automotive/display/include/AutomotiveDisplayProxyService.h @@ -20,7 +20,7 @@ #include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <ui/DisplayState.h> #include <tuple> #include <vector> diff --git a/services/surfaceflinger/DisplayHardware/DisplayMode.h b/services/surfaceflinger/DisplayHardware/DisplayMode.h index 31d1245ed0..1f0f3c3c33 100644 --- a/services/surfaceflinger/DisplayHardware/DisplayMode.h +++ b/services/surfaceflinger/DisplayHardware/DisplayMode.h @@ -86,8 +86,8 @@ public: return *this; } - Builder& setConfigGroup(int32_t configGroup) { - mDisplayMode->mConfigGroup = configGroup; + Builder& setGroup(int32_t group) { + mDisplayMode->mGroup = group; return *this; } @@ -119,7 +119,10 @@ public: nsecs_t getVsyncPeriod() const { return mFps.getPeriodNsecs(); } float getDpiX() const { return mDpiX; } float getDpiY() const { return mDpiY; } - int32_t getConfigGroup() const { return mConfigGroup; } + + // Switches between modes in the same group are seamless, i.e. + // without visual interruptions such as a black screen. + int32_t getGroup() const { return mGroup; } private: explicit DisplayMode(hal::HWConfigId id) : mHwcId(id) {} @@ -132,15 +135,15 @@ private: Fps mFps; float mDpiX = -1; float mDpiY = -1; - int32_t mConfigGroup = -1; + int32_t mGroup = -1; }; inline std::string to_string(const DisplayMode& mode) { return base::StringPrintf("{id=%zu, hwcId=%d, width=%d, height=%d, refreshRate=%s, " - "dpiX=%.2f, dpiY=%.2f, configGroup=%d}", + "dpiX=%.2f, dpiY=%.2f, group=%d}", mode.getId().value(), mode.getHwcId(), mode.getWidth(), mode.getHeight(), to_string(mode.getFps()).c_str(), mode.getDpiX(), - mode.getDpiY(), mode.getConfigGroup()); + mode.getDpiY(), mode.getGroup()); } } // namespace android
\ No newline at end of file diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp index f90c130992..bfe9b4a3bb 100644 --- a/services/surfaceflinger/Scheduler/EventThread.cpp +++ b/services/surfaceflinger/Scheduler/EventThread.cpp @@ -90,9 +90,9 @@ std::string toString(const DisplayEventReceiver::Event& event) { return StringPrintf("VSync{displayId=%s, count=%u, expectedVSyncTimestamp=%" PRId64 "}", to_string(event.header.displayId).c_str(), event.vsync.count, event.vsync.expectedVSyncTimestamp); - case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: - return StringPrintf("ConfigChanged{displayId=%s, configId=%u}", - to_string(event.header.displayId).c_str(), event.config.configId); + case DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE: + return StringPrintf("ModeChanged{displayId=%s, modeId=%u}", + to_string(event.header.displayId).c_str(), event.modeChange.modeId); default: return "Event{}"; } @@ -118,12 +118,12 @@ DisplayEventReceiver::Event makeVSync(PhysicalDisplayId displayId, nsecs_t times return event; } -DisplayEventReceiver::Event makeConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId, - nsecs_t vsyncPeriod) { +DisplayEventReceiver::Event makeModeChanged(PhysicalDisplayId displayId, DisplayModeId modeId, + nsecs_t vsyncPeriod) { DisplayEventReceiver::Event event; - event.header = {DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED, displayId, systemTime()}; - event.config.configId = configId.value(); - event.config.vsyncPeriod = vsyncPeriod; + event.header = {DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE, displayId, systemTime()}; + event.modeChange.modeId = modeId.value(); + event.modeChange.vsyncPeriod = vsyncPeriod; return event; } @@ -373,11 +373,11 @@ void EventThread::onHotplugReceived(PhysicalDisplayId displayId, bool connected) mCondition.notify_all(); } -void EventThread::onConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId, - nsecs_t vsyncPeriod) { +void EventThread::onModeChanged(PhysicalDisplayId displayId, DisplayModeId modeId, + nsecs_t vsyncPeriod) { std::lock_guard<std::mutex> lock(mMutex); - mPendingEvents.push_back(makeConfigChanged(displayId, configId, vsyncPeriod)); + mPendingEvents.push_back(makeModeChanged(displayId, modeId, vsyncPeriod)); mCondition.notify_all(); } @@ -518,9 +518,9 @@ bool EventThread::shouldConsumeEvent(const DisplayEventReceiver::Event& event, case DisplayEventReceiver::DISPLAY_EVENT_HOTPLUG: return true; - case DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED: { + case DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE: { return connection->mEventRegistration.test( - ISurfaceComposer::EventRegistration::configChanged); + ISurfaceComposer::EventRegistration::modeChanged); } case DisplayEventReceiver::DISPLAY_EVENT_VSYNC: diff --git a/services/surfaceflinger/Scheduler/EventThread.h b/services/surfaceflinger/Scheduler/EventThread.h index 15efe219c0..35406041a8 100644 --- a/services/surfaceflinger/Scheduler/EventThread.h +++ b/services/surfaceflinger/Scheduler/EventThread.h @@ -123,9 +123,9 @@ public: virtual void onHotplugReceived(PhysicalDisplayId displayId, bool connected) = 0; - // called when SF changes the active config and apps needs to be notified about the change - virtual void onConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId, - nsecs_t vsyncPeriod) = 0; + // called when SF changes the active mode and apps needs to be notified about the change + virtual void onModeChanged(PhysicalDisplayId displayId, DisplayModeId modeId, + nsecs_t vsyncPeriod) = 0; // called when SF updates the Frame Rate Override list virtual void onFrameRateOverridesChanged(PhysicalDisplayId displayId, @@ -173,8 +173,8 @@ public: void onHotplugReceived(PhysicalDisplayId displayId, bool connected) override; - void onConfigChanged(PhysicalDisplayId displayId, DisplayModeId configId, - nsecs_t vsyncPeriod) override; + void onModeChanged(PhysicalDisplayId displayId, DisplayModeId modeId, + nsecs_t vsyncPeriod) override; void onFrameRateOverridesChanged(PhysicalDisplayId displayId, std::vector<FrameRateOverride> overrides) override; diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp index 7ef531df63..ea92ad88bb 100644 --- a/services/surfaceflinger/Scheduler/LayerHistory.cpp +++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp @@ -102,7 +102,7 @@ void LayerHistory::record(Layer* layer, nsecs_t presentTime, nsecs_t now, LOG_FATAL_IF(it == mLayerInfos.end(), "%s: unknown layer %p", __FUNCTION__, layer); const auto& info = it->second; - info->setLastPresentTime(presentTime, now, updateType, mConfigChangePending); + info->setLastPresentTime(presentTime, now, updateType, mModeChangePending); // Activate layer if inactive. if (const auto end = activeLayers().end(); it >= end) { diff --git a/services/surfaceflinger/Scheduler/LayerHistory.h b/services/surfaceflinger/Scheduler/LayerHistory.h index bae9b5a41a..05ecc705cc 100644 --- a/services/surfaceflinger/Scheduler/LayerHistory.h +++ b/services/surfaceflinger/Scheduler/LayerHistory.h @@ -51,8 +51,8 @@ public: // Sets the display size. Client is responsible for synchronization. void setDisplayArea(uint32_t displayArea) { mDisplayArea = displayArea; } - // Sets whether a config change is pending to be applied - void setConfigChangePending(bool pending) { mConfigChangePending = pending; } + // Sets whether a mode change is pending to be applied + void setModeChangePending(bool pending) { mModeChangePending = pending; } // Represents which layer activity is recorded enum class LayerUpdateType { @@ -109,8 +109,8 @@ private: // Whether to use priority sent from WindowManager to determine the relevancy of the layer. const bool mUseFrameRatePriority; - // Whether a config change is in progress or not - std::atomic<bool> mConfigChangePending = false; + // Whether a mode change is in progress or not + std::atomic<bool> mModeChangePending = false; }; } // namespace scheduler diff --git a/services/surfaceflinger/Scheduler/LayerInfo.cpp b/services/surfaceflinger/Scheduler/LayerInfo.cpp index 4324855b70..4b4cdaea09 100644 --- a/services/surfaceflinger/Scheduler/LayerInfo.cpp +++ b/services/surfaceflinger/Scheduler/LayerInfo.cpp @@ -44,7 +44,7 @@ LayerInfo::LayerInfo(const std::string& name, LayerHistory::LayerVoteType defaul mRefreshRateHistory(name) {} void LayerInfo::setLastPresentTime(nsecs_t lastPresentTime, nsecs_t now, LayerUpdateType updateType, - bool pendingConfigChange) { + bool pendingModeChange) { lastPresentTime = std::max(lastPresentTime, static_cast<nsecs_t>(0)); mLastUpdatedTime = std::max(lastPresentTime, now); @@ -56,7 +56,7 @@ void LayerInfo::setLastPresentTime(nsecs_t lastPresentTime, nsecs_t now, LayerUp case LayerUpdateType::Buffer: FrameTimeData frameTime = {.presentTime = lastPresentTime, .queueTime = mLastUpdatedTime, - .pendingConfigChange = pendingConfigChange}; + .pendingModeChange = pendingModeChange}; mFrameTimes.push_back(frameTime); if (mFrameTimes.size() > HISTORY_SIZE) { mFrameTimes.pop_front(); @@ -124,11 +124,11 @@ bool LayerInfo::hasEnoughDataForHeuristic() const { } std::optional<nsecs_t> LayerInfo::calculateAverageFrameTime() const { - // Ignore frames captured during a config change - const bool isDuringConfigChange = + // Ignore frames captured during a mode change + const bool isDuringModeChange = std::any_of(mFrameTimes.begin(), mFrameTimes.end(), - [](auto frame) { return frame.pendingConfigChange; }); - if (isDuringConfigChange) { + [](const auto& frame) { return frame.pendingModeChange; }); + if (isDuringModeChange) { return std::nullopt; } diff --git a/services/surfaceflinger/Scheduler/LayerInfo.h b/services/surfaceflinger/Scheduler/LayerInfo.h index e32ba099f6..40c0214408 100644 --- a/services/surfaceflinger/Scheduler/LayerInfo.h +++ b/services/surfaceflinger/Scheduler/LayerInfo.h @@ -80,7 +80,7 @@ public: // the layer was last updated. If the present time is farther in the future than the // updated time, the updated time is the present time. void setLastPresentTime(nsecs_t lastPresentTime, nsecs_t now, LayerUpdateType updateType, - bool pendingConfigChange); + bool pendingModeChange); // Sets an explicit layer vote. This usually comes directly from the application via // ANativeWindow_setFrameRate API @@ -124,7 +124,7 @@ private: struct FrameTimeData { nsecs_t presentTime; // desiredPresentTime, if provided nsecs_t queueTime; // buffer queue time - bool pendingConfigChange; + bool pendingModeChange; }; // Holds information about the calculated and reported refresh rate diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp index 81ffe0f20e..e7a44a70d5 100644 --- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp @@ -40,13 +40,13 @@ std::string formatLayerInfo(const RefreshRateConfigs::LayerRequirement& layer, f to_string(layer.desiredRefreshRate).c_str()); } -std::vector<Fps> constructKnownFrameRates(const DisplayModes& configs) { +std::vector<Fps> constructKnownFrameRates(const DisplayModes& modes) { std::vector<Fps> knownFrameRates = {Fps(24.0f), Fps(30.0f), Fps(45.0f), Fps(60.0f), Fps(72.0f)}; - knownFrameRates.reserve(knownFrameRates.size() + configs.size()); + knownFrameRates.reserve(knownFrameRates.size() + modes.size()); // Add all supported refresh rates to the set - for (const auto& config : configs) { - const auto refreshRate = Fps::fromPeriodNsecs(config->getVsyncPeriod()); + for (const auto& mode : modes) { + const auto refreshRate = Fps::fromPeriodNsecs(mode->getVsyncPeriod()); knownFrameRates.emplace_back(refreshRate); } @@ -65,8 +65,8 @@ using RefreshRate = RefreshRateConfigs::RefreshRate; std::string RefreshRate::toString() const { return base::StringPrintf("{id=%zu, hwcId=%d, fps=%.2f, width=%d, height=%d group=%d}", - getConfigId().value(), hwcConfig->getHwcId(), getFps().getValue(), - hwcConfig->getWidth(), hwcConfig->getHeight(), getConfigGroup()); + getModeId().value(), mode->getHwcId(), getFps().getValue(), + mode->getWidth(), mode->getHeight(), getModeGroup()); } std::string RefreshRateConfigs::layerVoteTypeString(LayerVoteType vote) { @@ -89,9 +89,9 @@ std::string RefreshRateConfigs::layerVoteTypeString(LayerVoteType vote) { } std::string RefreshRateConfigs::Policy::toString() const { - return base::StringPrintf("default config ID: %zu, allowGroupSwitching = %d" + return base::StringPrintf("default mode ID: %zu, allowGroupSwitching = %d" ", primary range: %s, app request range: %s", - defaultConfig.value(), allowGroupSwitching, + defaultMode.value(), allowGroupSwitching, primaryRange.toString().c_str(), appRequestRange.toString().c_str()); } @@ -291,7 +291,7 @@ RefreshRate RefreshRateConfigs::getBestRefreshRate(const std::vector<LayerRequir scores.emplace_back(RefreshRateScore{refreshRate, 0.0f}); } - const auto& defaultConfig = mRefreshRates.at(policy->defaultConfig); + const auto& defaultMode = mRefreshRates.at(policy->defaultMode); for (const auto& layer : layers) { ALOGV("Calculating score for %s (%s, weight %.2f)", layer.name.c_str(), @@ -303,11 +303,11 @@ RefreshRate RefreshRateConfigs::getBestRefreshRate(const std::vector<LayerRequir auto weight = layer.weight; for (auto i = 0u; i < scores.size(); i++) { - const bool isSeamlessSwitch = scores[i].refreshRate->getConfigGroup() == - mCurrentRefreshRate->getConfigGroup(); + const bool isSeamlessSwitch = + scores[i].refreshRate->getModeGroup() == mCurrentRefreshRate->getModeGroup(); if (layer.seamlessness == Seamlessness::OnlySeamless && !isSeamlessSwitch) { - ALOGV("%s ignores %s to avoid non-seamless switch. Current config = %s", + ALOGV("%s ignores %s to avoid non-seamless switch. Current mode = %s", formatLayerInfo(layer, weight).c_str(), scores[i].refreshRate->toString().c_str(), mCurrentRefreshRate->toString().c_str()); @@ -317,26 +317,25 @@ RefreshRate RefreshRateConfigs::getBestRefreshRate(const std::vector<LayerRequir if (layer.seamlessness == Seamlessness::SeamedAndSeamless && !isSeamlessSwitch && !layer.focused) { ALOGV("%s ignores %s because it's not focused and the switch is going to be seamed." - " Current config = %s", + " Current mode = %s", formatLayerInfo(layer, weight).c_str(), scores[i].refreshRate->toString().c_str(), mCurrentRefreshRate->toString().c_str()); continue; } - // Layers with default seamlessness vote for the current config group if + // Layers with default seamlessness vote for the current mode group if // there are layers with seamlessness=SeamedAndSeamless and for the default - // config group otherwise. In second case, if the current config group is different + // mode group otherwise. In second case, if the current mode group is different // from the default, this means a layer with seamlessness=SeamedAndSeamless has just // disappeared. const bool isInPolicyForDefault = seamedLayers > 0 - ? scores[i].refreshRate->getConfigGroup() == - mCurrentRefreshRate->getConfigGroup() - : scores[i].refreshRate->getConfigGroup() == defaultConfig->getConfigGroup(); + ? scores[i].refreshRate->getModeGroup() == mCurrentRefreshRate->getModeGroup() + : scores[i].refreshRate->getModeGroup() == defaultMode->getModeGroup(); if (layer.seamlessness == Seamlessness::Default && !isInPolicyForDefault && !layer.focused) { - ALOGV("%s ignores %s. Current config = %s", formatLayerInfo(layer, weight).c_str(), + ALOGV("%s ignores %s. Current mode = %s", formatLayerInfo(layer, weight).c_str(), scores[i].refreshRate->toString().c_str(), mCurrentRefreshRate->toString().c_str()); continue; @@ -548,12 +547,12 @@ std::optional<Fps> RefreshRateConfigs::onKernelTimerChanged( const RefreshRate& RefreshRateConfigs::getMinRefreshRateByPolicyLocked() const { for (auto refreshRate : mPrimaryRefreshRates) { - if (mCurrentRefreshRate->getConfigGroup() == refreshRate->getConfigGroup()) { + if (mCurrentRefreshRate->getModeGroup() == refreshRate->getModeGroup()) { return *refreshRate; } } - ALOGE("Can't find min refresh rate by policy with the same config group" - " as the current config %s", + ALOGE("Can't find min refresh rate by policy with the same mode group" + " as the current mode %s", mCurrentRefreshRate->toString().c_str()); // Defaulting to the lowest refresh rate return *mPrimaryRefreshRates.front(); @@ -567,12 +566,12 @@ RefreshRate RefreshRateConfigs::getMaxRefreshRateByPolicy() const { const RefreshRate& RefreshRateConfigs::getMaxRefreshRateByPolicyLocked() const { for (auto it = mPrimaryRefreshRates.rbegin(); it != mPrimaryRefreshRates.rend(); it++) { const auto& refreshRate = (**it); - if (mCurrentRefreshRate->getConfigGroup() == refreshRate.getConfigGroup()) { + if (mCurrentRefreshRate->getModeGroup() == refreshRate.getModeGroup()) { return refreshRate; } } - ALOGE("Can't find max refresh rate by policy with the same config group" - " as the current config %s", + ALOGE("Can't find max refresh rate by policy with the same mode group" + " as the current mode %s", mCurrentRefreshRate->toString().c_str()); // Defaulting to the highest refresh rate return *mPrimaryRefreshRates.back(); @@ -593,50 +592,50 @@ const RefreshRate& RefreshRateConfigs::getCurrentRefreshRateByPolicyLocked() con mCurrentRefreshRate) != mAppRequestRefreshRates.end()) { return *mCurrentRefreshRate; } - return *mRefreshRates.at(getCurrentPolicyLocked()->defaultConfig); + return *mRefreshRates.at(getCurrentPolicyLocked()->defaultMode); } -void RefreshRateConfigs::setCurrentConfigId(DisplayModeId configId) { +void RefreshRateConfigs::setCurrentModeId(DisplayModeId modeId) { std::lock_guard lock(mLock); - mCurrentRefreshRate = mRefreshRates.at(configId).get(); + mCurrentRefreshRate = mRefreshRates.at(modeId).get(); } -RefreshRateConfigs::RefreshRateConfigs(const DisplayModes& configs, DisplayModeId currentConfigId, +RefreshRateConfigs::RefreshRateConfigs(const DisplayModes& modes, DisplayModeId currentModeId, bool enableFrameRateOverride) - : mKnownFrameRates(constructKnownFrameRates(configs)), + : mKnownFrameRates(constructKnownFrameRates(modes)), mEnableFrameRateOverride(enableFrameRateOverride) { - updateDisplayConfigs(configs, currentConfigId); + updateDisplayModes(modes, currentModeId); } -void RefreshRateConfigs::updateDisplayConfigs(const DisplayModes& configs, - DisplayModeId currentConfigId) { +void RefreshRateConfigs::updateDisplayModes(const DisplayModes& modes, + DisplayModeId currentModeId) { std::lock_guard lock(mLock); - LOG_ALWAYS_FATAL_IF(configs.empty()); - LOG_ALWAYS_FATAL_IF(currentConfigId.value() >= configs.size()); + LOG_ALWAYS_FATAL_IF(modes.empty()); + LOG_ALWAYS_FATAL_IF(currentModeId.value() >= modes.size()); mRefreshRates.clear(); - for (const auto& config : configs) { - const auto configId = config->getId(); - const auto fps = Fps::fromPeriodNsecs(config->getVsyncPeriod()); - mRefreshRates.emplace(configId, - std::make_unique<RefreshRate>(configId, config, fps, + for (const auto& mode : modes) { + const auto modeId = mode->getId(); + const auto fps = Fps::fromPeriodNsecs(mode->getVsyncPeriod()); + mRefreshRates.emplace(modeId, + std::make_unique<RefreshRate>(modeId, mode, fps, RefreshRate::ConstructorTag(0))); - if (configId == currentConfigId) { - mCurrentRefreshRate = mRefreshRates.at(configId).get(); + if (modeId == currentModeId) { + mCurrentRefreshRate = mRefreshRates.at(modeId).get(); } } - std::vector<const RefreshRate*> sortedConfigs; - getSortedRefreshRateListLocked([](const RefreshRate&) { return true; }, &sortedConfigs); - mDisplayManagerPolicy.defaultConfig = currentConfigId; - mMinSupportedRefreshRate = sortedConfigs.front(); - mMaxSupportedRefreshRate = sortedConfigs.back(); + std::vector<const RefreshRate*> sortedModes; + getSortedRefreshRateListLocked([](const RefreshRate&) { return true; }, &sortedModes); + mDisplayManagerPolicy.defaultMode = currentModeId; + mMinSupportedRefreshRate = sortedModes.front(); + mMaxSupportedRefreshRate = sortedModes.back(); mSupportsFrameRateOverride = false; if (mEnableFrameRateOverride) { - for (const auto& config1 : sortedConfigs) { - for (const auto& config2 : sortedConfigs) { - if (getFrameRateDivider(config1->getFps(), config2->getFps()) >= 2) { + for (const auto& mode1 : sortedModes) { + for (const auto& mode2 : sortedModes) { + if (getFrameRateDivider(mode1->getFps(), mode2->getFps()) >= 2) { mSupportsFrameRateOverride = true; break; } @@ -648,15 +647,15 @@ void RefreshRateConfigs::updateDisplayConfigs(const DisplayModes& configs, } bool RefreshRateConfigs::isPolicyValidLocked(const Policy& policy) const { - // defaultConfig must be a valid config, and within the given refresh rate range. - auto iter = mRefreshRates.find(policy.defaultConfig); + // defaultMode must be a valid mode, and within the given refresh rate range. + auto iter = mRefreshRates.find(policy.defaultMode); if (iter == mRefreshRates.end()) { - ALOGE("Default config is not found."); + ALOGE("Default mode is not found."); return false; } const RefreshRate& refreshRate = *iter->second; if (!refreshRate.inPolicy(policy.primaryRange.min, policy.primaryRange.max)) { - ALOGE("Default config is not in the primary range."); + ALOGE("Default mode is not in the primary range."); return false; } return policy.appRequestRange.min.lessThanOrEqualWithMargin(policy.primaryRange.min) && @@ -706,10 +705,10 @@ RefreshRateConfigs::Policy RefreshRateConfigs::getDisplayManagerPolicy() const { return mDisplayManagerPolicy; } -bool RefreshRateConfigs::isConfigAllowed(DisplayModeId config) const { +bool RefreshRateConfigs::isModeAllowed(DisplayModeId modeId) const { std::lock_guard lock(mLock); for (const RefreshRate* refreshRate : mAppRequestRefreshRates) { - if (refreshRate->configId == config) { + if (refreshRate->modeId == modeId) { return true; } } @@ -723,60 +722,59 @@ void RefreshRateConfigs::getSortedRefreshRateListLocked( outRefreshRates->reserve(mRefreshRates.size()); for (const auto& [type, refreshRate] : mRefreshRates) { if (shouldAddRefreshRate(*refreshRate)) { - ALOGV("getSortedRefreshRateListLocked: config %zu added to list policy", - refreshRate->configId.value()); + ALOGV("getSortedRefreshRateListLocked: mode %zu added to list policy", + refreshRate->modeId.value()); outRefreshRates->push_back(refreshRate.get()); } } std::sort(outRefreshRates->begin(), outRefreshRates->end(), [](const auto refreshRate1, const auto refreshRate2) { - if (refreshRate1->hwcConfig->getVsyncPeriod() != - refreshRate2->hwcConfig->getVsyncPeriod()) { - return refreshRate1->hwcConfig->getVsyncPeriod() > - refreshRate2->hwcConfig->getVsyncPeriod(); + if (refreshRate1->mode->getVsyncPeriod() != + refreshRate2->mode->getVsyncPeriod()) { + return refreshRate1->mode->getVsyncPeriod() > + refreshRate2->mode->getVsyncPeriod(); } else { - return refreshRate1->hwcConfig->getConfigGroup() > - refreshRate2->hwcConfig->getConfigGroup(); + return refreshRate1->mode->getGroup() > refreshRate2->mode->getGroup(); } }); } void RefreshRateConfigs::constructAvailableRefreshRates() { - // Filter configs based on current policy and sort based on vsync period + // Filter modes based on current policy and sort based on vsync period const Policy* policy = getCurrentPolicyLocked(); - const auto& defaultConfig = mRefreshRates.at(policy->defaultConfig)->hwcConfig; + const auto& defaultMode = mRefreshRates.at(policy->defaultMode)->mode; ALOGV("constructAvailableRefreshRates: %s ", policy->toString().c_str()); - auto filterRefreshRates = [&](Fps min, Fps max, const char* listName, - std::vector<const RefreshRate*>* - outRefreshRates) REQUIRES(mLock) { - getSortedRefreshRateListLocked( - [&](const RefreshRate& refreshRate) REQUIRES(mLock) { - const auto& hwcConfig = refreshRate.hwcConfig; - - return hwcConfig->getHeight() == defaultConfig->getHeight() && - hwcConfig->getWidth() == defaultConfig->getWidth() && - hwcConfig->getDpiX() == defaultConfig->getDpiX() && - hwcConfig->getDpiY() == defaultConfig->getDpiY() && - (policy->allowGroupSwitching || - hwcConfig->getConfigGroup() == defaultConfig->getConfigGroup()) && - refreshRate.inPolicy(min, max); - }, - outRefreshRates); - - LOG_ALWAYS_FATAL_IF(outRefreshRates->empty(), - "No matching configs for %s range: min=%s max=%s", listName, - to_string(min).c_str(), to_string(max).c_str()); - auto stringifyRefreshRates = [&]() -> std::string { - std::string str; - for (auto refreshRate : *outRefreshRates) { - base::StringAppendF(&str, "%s ", refreshRate->getName().c_str()); - } - return str; - }; - ALOGV("%s refresh rates: %s", listName, stringifyRefreshRates().c_str()); - }; + auto filterRefreshRates = + [&](Fps min, Fps max, const char* listName, + std::vector<const RefreshRate*>* outRefreshRates) REQUIRES(mLock) { + getSortedRefreshRateListLocked( + [&](const RefreshRate& refreshRate) REQUIRES(mLock) { + const auto& mode = refreshRate.mode; + + return mode->getHeight() == defaultMode->getHeight() && + mode->getWidth() == defaultMode->getWidth() && + mode->getDpiX() == defaultMode->getDpiX() && + mode->getDpiY() == defaultMode->getDpiY() && + (policy->allowGroupSwitching || + mode->getGroup() == defaultMode->getGroup()) && + refreshRate.inPolicy(min, max); + }, + outRefreshRates); + + LOG_ALWAYS_FATAL_IF(outRefreshRates->empty(), + "No matching modes for %s range: min=%s max=%s", listName, + to_string(min).c_str(), to_string(max).c_str()); + auto stringifyRefreshRates = [&]() -> std::string { + std::string str; + for (auto refreshRate : *outRefreshRates) { + base::StringAppendF(&str, "%s ", refreshRate->getName().c_str()); + } + return str; + }; + ALOGV("%s refresh rates: %s", listName, stringifyRefreshRates().c_str()); + }; filterRefreshRates(policy->primaryRange.min, policy->primaryRange.max, "primary", &mPrimaryRefreshRates); @@ -845,20 +843,20 @@ int RefreshRateConfigs::getRefreshRateDivider(Fps frameRate) const { void RefreshRateConfigs::dump(std::string& result) const { std::lock_guard lock(mLock); - base::StringAppendF(&result, "DesiredDisplayConfigSpecs (DisplayManager): %s\n\n", + base::StringAppendF(&result, "DesiredDisplayModeSpecs (DisplayManager): %s\n\n", mDisplayManagerPolicy.toString().c_str()); scheduler::RefreshRateConfigs::Policy currentPolicy = *getCurrentPolicyLocked(); if (mOverridePolicy && currentPolicy != mDisplayManagerPolicy) { - base::StringAppendF(&result, "DesiredDisplayConfigSpecs (Override): %s\n\n", + base::StringAppendF(&result, "DesiredDisplayModeSpecs (Override): %s\n\n", currentPolicy.toString().c_str()); } - auto config = mCurrentRefreshRate->hwcConfig; - base::StringAppendF(&result, "Current config: %s\n", mCurrentRefreshRate->toString().c_str()); + auto mode = mCurrentRefreshRate->mode; + base::StringAppendF(&result, "Current mode: %s\n", mCurrentRefreshRate->toString().c_str()); result.append("Refresh rates:\n"); for (const auto& [id, refreshRate] : mRefreshRates) { - config = refreshRate->hwcConfig; + mode = refreshRate->mode; base::StringAppendF(&result, "\t%s\n", refreshRate->toString().c_str()); } diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h index 0c7dc0515c..2bc22b43f7 100644 --- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h +++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h @@ -64,12 +64,12 @@ public: }; public: - RefreshRate(DisplayModeId configId, DisplayModePtr config, Fps fps, ConstructorTag) - : configId(configId), hwcConfig(config), fps(std::move(fps)) {} + RefreshRate(DisplayModeId modeId, DisplayModePtr mode, Fps fps, ConstructorTag) + : modeId(modeId), mode(mode), fps(std::move(fps)) {} - DisplayModeId getConfigId() const { return configId; } - nsecs_t getVsyncPeriod() const { return hwcConfig->getVsyncPeriod(); } - int32_t getConfigGroup() const { return hwcConfig->getConfigGroup(); } + DisplayModeId getModeId() const { return modeId; } + nsecs_t getVsyncPeriod() const { return mode->getVsyncPeriod(); } + int32_t getModeGroup() const { return mode->getGroup(); } std::string getName() const { return to_string(fps); } Fps getFps() const { return fps; } @@ -81,7 +81,7 @@ public: } bool operator!=(const RefreshRate& other) const { - return configId != other.configId || hwcConfig != other.hwcConfig; + return modeId != other.modeId || mode != other.mode; } bool operator<(const RefreshRate& other) const { @@ -99,11 +99,8 @@ public: friend RefreshRateConfigs; friend class RefreshRateConfigsTest; - // This config ID corresponds to the position of the config in the vector that is stored - // on the device. - const DisplayModeId configId; - // The config itself - DisplayModePtr hwcConfig; + const DisplayModeId modeId; + DisplayModePtr mode; // Refresh rate in frames per second const Fps fps{0.0f}; }; @@ -131,16 +128,16 @@ public: static constexpr int kAllowGroupSwitchingDefault = false; public: - // The default config, used to ensure we only initiate display config switches within the - // same config group as defaultConfigId's group. - DisplayModeId defaultConfig; - // Whether or not we switch config groups to get the best frame rate. + // The default mode, used to ensure we only initiate display mode switches within the + // same mode group as defaultMode's group. + DisplayModeId defaultMode; + // Whether or not we switch mode groups to get the best frame rate. bool allowGroupSwitching = kAllowGroupSwitchingDefault; // The primary refresh rate range represents display manager's general guidance on the - // display configs we'll consider when switching refresh rates. Unless we get an explicit + // display modes we'll consider when switching refresh rates. Unless we get an explicit // signal from an app, we should stay within this range. FpsRange primaryRange; - // The app request refresh rate range allows us to consider more display configs when + // The app request refresh rate range allows us to consider more display modes when // switching refresh rates. Although we should generally stay within the primary range, // specific considerations, such as layer frame rate settings specified via the // setFrameRate() api, may cause us to go outside the primary range. We never go outside the @@ -150,25 +147,25 @@ public: Policy() = default; - Policy(DisplayModeId defaultConfig, const FpsRange& range) - : Policy(defaultConfig, kAllowGroupSwitchingDefault, range, range) {} + Policy(DisplayModeId defaultMode, const FpsRange& range) + : Policy(defaultMode, kAllowGroupSwitchingDefault, range, range) {} - Policy(DisplayModeId defaultConfig, bool allowGroupSwitching, const FpsRange& range) - : Policy(defaultConfig, allowGroupSwitching, range, range) {} + Policy(DisplayModeId defaultMode, bool allowGroupSwitching, const FpsRange& range) + : Policy(defaultMode, allowGroupSwitching, range, range) {} - Policy(DisplayModeId defaultConfig, const FpsRange& primaryRange, + Policy(DisplayModeId defaultMode, const FpsRange& primaryRange, const FpsRange& appRequestRange) - : Policy(defaultConfig, kAllowGroupSwitchingDefault, primaryRange, appRequestRange) {} + : Policy(defaultMode, kAllowGroupSwitchingDefault, primaryRange, appRequestRange) {} - Policy(DisplayModeId defaultConfig, bool allowGroupSwitching, const FpsRange& primaryRange, + Policy(DisplayModeId defaultMode, bool allowGroupSwitching, const FpsRange& primaryRange, const FpsRange& appRequestRange) - : defaultConfig(defaultConfig), + : defaultMode(defaultMode), allowGroupSwitching(allowGroupSwitching), primaryRange(primaryRange), appRequestRange(appRequestRange) {} bool operator==(const Policy& other) const { - return defaultConfig == other.defaultConfig && primaryRange == other.primaryRange && + return defaultMode == other.defaultMode && primaryRange == other.primaryRange && appRequestRange == other.appRequestRange && allowGroupSwitching == other.allowGroupSwitching; } @@ -200,8 +197,8 @@ public: // Gets the display manager policy, regardless of whether an override policy is active. Policy getDisplayManagerPolicy() const EXCLUDES(mLock); - // Returns true if config is allowed by the current policy. - bool isConfigAllowed(DisplayModeId config) const EXCLUDES(mLock); + // Returns true if mode is allowed by the current policy. + bool isModeAllowed(DisplayModeId) const EXCLUDES(mLock); // Describes the different options the layer voted for refresh rate enum class LayerVoteType { @@ -270,7 +267,7 @@ public: return {mMinSupportedRefreshRate->getFps(), mMaxSupportedRefreshRate->getFps()}; } - std::optional<Fps> onKernelTimerChanged(std::optional<DisplayModeId> desiredActiveConfigId, + std::optional<Fps> onKernelTimerChanged(std::optional<DisplayModeId> desiredActiveModeId, bool timerExpired) const EXCLUDES(mLock); // Returns the highest refresh rate according to the current policy. May change at runtime. Only @@ -286,14 +283,14 @@ public: // Returns the refresh rate that corresponds to a DisplayModeId. This may change at // runtime. - // TODO(b/159590486) An invalid config id may be given here if the dipslay configs have changed. - RefreshRate getRefreshRateFromConfigId(DisplayModeId configId) const EXCLUDES(mLock) { + // TODO(b/159590486) An invalid mode id may be given here if the dipslay modes have changed. + RefreshRate getRefreshRateFromModeId(DisplayModeId modeId) const EXCLUDES(mLock) { std::lock_guard lock(mLock); - return *mRefreshRates.at(configId); + return *mRefreshRates.at(modeId); }; - // Stores the current configId the device operates at - void setCurrentConfigId(DisplayModeId configId) EXCLUDES(mLock); + // Stores the current modeId the device operates at + void setCurrentModeId(DisplayModeId) EXCLUDES(mLock); // Returns a string that represents the layer vote type static std::string layerVoteTypeString(LayerVoteType vote); @@ -301,14 +298,13 @@ public: // Returns a known frame rate that is the closest to frameRate Fps findClosestKnownFrameRate(Fps frameRate) const; - RefreshRateConfigs(const DisplayModes& configs, DisplayModeId currentConfigId, + RefreshRateConfigs(const DisplayModes& modes, DisplayModeId currentModeId, bool enableFrameRateOverride = false); - void updateDisplayConfigs(const DisplayModes& configs, DisplayModeId currentConfig) - EXCLUDES(mLock); + void updateDisplayModes(const DisplayModes& mode, DisplayModeId currentModeId) EXCLUDES(mLock); - // Returns whether switching configs (refresh rate or resolution) is possible. - // TODO(b/158780872): Consider HAL support, and skip frame rate detection if the configs only + // Returns whether switching modes (refresh rate or resolution) is possible. + // TODO(b/158780872): Consider HAL support, and skip frame rate detection if the modes only // differ in resolution. bool canSwitch() const EXCLUDES(mLock) { std::lock_guard lock(mLock); @@ -387,7 +383,7 @@ private: float calculateLayerScoreLocked(const LayerRequirement&, const RefreshRate&, bool isSeamlessSwitch) const REQUIRES(mLock); - // The list of refresh rates, indexed by display config ID. This may change after this + // The list of refresh rates, indexed by display modes ID. This may change after this // object is initialized. AllRefreshRatesMapType mRefreshRates GUARDED_BY(mLock); @@ -399,7 +395,7 @@ private: // vsyncPeriod (the first element is the lowest refresh rate). std::vector<const RefreshRate*> mAppRequestRefreshRates GUARDED_BY(mLock); - // The current config. This will change at runtime. This is set by SurfaceFlinger on + // The current display mode. This will change at runtime. This is set by SurfaceFlinger on // the main thread, and read by the Scheduler (and other objects) on other threads. const RefreshRate* mCurrentRefreshRate GUARDED_BY(mLock); diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp index d8612098ec..98132701d1 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.cpp +++ b/services/surfaceflinger/Scheduler/Scheduler.cpp @@ -348,55 +348,53 @@ void Scheduler::onFrameRateOverridesChanged(ConnectionHandle handle, PhysicalDis thread->onFrameRateOverridesChanged(displayId, std::move(overrides)); } -void Scheduler::onPrimaryDisplayConfigChanged(ConnectionHandle handle, PhysicalDisplayId displayId, - DisplayModeId configId, nsecs_t vsyncPeriod) { +void Scheduler::onPrimaryDisplayModeChanged(ConnectionHandle handle, PhysicalDisplayId displayId, + DisplayModeId modeId, nsecs_t vsyncPeriod) { { std::lock_guard<std::mutex> lock(mFeatureStateLock); - // Cache the last reported config for primary display. - mFeatures.cachedConfigChangedParams = {handle, displayId, configId, vsyncPeriod}; + // Cache the last reported modes for primary display. + mFeatures.cachedModeChangedParams = {handle, displayId, modeId, vsyncPeriod}; } - onNonPrimaryDisplayConfigChanged(handle, displayId, configId, vsyncPeriod); + onNonPrimaryDisplayModeChanged(handle, displayId, modeId, vsyncPeriod); } -void Scheduler::dispatchCachedReportedConfig() { +void Scheduler::dispatchCachedReportedMode() { // Check optional fields first. - if (!mFeatures.configId.has_value()) { - ALOGW("No config ID found, not dispatching cached config."); + if (!mFeatures.modeId.has_value()) { + ALOGW("No mode ID found, not dispatching cached mode."); return; } - if (!mFeatures.cachedConfigChangedParams.has_value()) { - ALOGW("No config changed params found, not dispatching cached config."); + if (!mFeatures.cachedModeChangedParams.has_value()) { + ALOGW("No mode changed params found, not dispatching cached mode."); return; } - const auto configId = *mFeatures.configId; - const auto vsyncPeriod = - mRefreshRateConfigs.getRefreshRateFromConfigId(configId).getVsyncPeriod(); + const auto modeId = *mFeatures.modeId; + const auto vsyncPeriod = mRefreshRateConfigs.getRefreshRateFromModeId(modeId).getVsyncPeriod(); - // If there is no change from cached config, there is no need to dispatch an event - if (configId == mFeatures.cachedConfigChangedParams->configId && - vsyncPeriod == mFeatures.cachedConfigChangedParams->vsyncPeriod) { + // If there is no change from cached mode, there is no need to dispatch an event + if (modeId == mFeatures.cachedModeChangedParams->modeId && + vsyncPeriod == mFeatures.cachedModeChangedParams->vsyncPeriod) { return; } - mFeatures.cachedConfigChangedParams->configId = configId; - mFeatures.cachedConfigChangedParams->vsyncPeriod = vsyncPeriod; - onNonPrimaryDisplayConfigChanged(mFeatures.cachedConfigChangedParams->handle, - mFeatures.cachedConfigChangedParams->displayId, - mFeatures.cachedConfigChangedParams->configId, - mFeatures.cachedConfigChangedParams->vsyncPeriod); + mFeatures.cachedModeChangedParams->modeId = modeId; + mFeatures.cachedModeChangedParams->vsyncPeriod = vsyncPeriod; + onNonPrimaryDisplayModeChanged(mFeatures.cachedModeChangedParams->handle, + mFeatures.cachedModeChangedParams->displayId, + mFeatures.cachedModeChangedParams->modeId, + mFeatures.cachedModeChangedParams->vsyncPeriod); } -void Scheduler::onNonPrimaryDisplayConfigChanged(ConnectionHandle handle, - PhysicalDisplayId displayId, - DisplayModeId configId, nsecs_t vsyncPeriod) { +void Scheduler::onNonPrimaryDisplayModeChanged(ConnectionHandle handle, PhysicalDisplayId displayId, + DisplayModeId modeId, nsecs_t vsyncPeriod) { android::EventThread* thread; { std::lock_guard<std::mutex> lock(mConnectionsLock); RETURN_IF_INVALID_HANDLE(handle); thread = mConnections[handle].thread.get(); } - thread->onConfigChanged(displayId, configId, vsyncPeriod); + thread->onModeChanged(displayId, modeId, vsyncPeriod); } size_t Scheduler::getEventThreadConnectionCount(ConnectionHandle handle) { @@ -590,9 +588,9 @@ void Scheduler::recordLayerHistory(Layer* layer, nsecs_t presentTime, } } -void Scheduler::setConfigChangePending(bool pending) { +void Scheduler::setModeChangePending(bool pending) { if (mLayerHistory) { - mLayerHistory->setConfigChangePending(pending); + mLayerHistory->setModeChangePending(pending); } } @@ -603,7 +601,7 @@ void Scheduler::chooseRefreshRateForContent() { scheduler::LayerHistory::Summary summary = mLayerHistory->summarize(systemTime()); scheduler::RefreshRateConfigs::GlobalSignals consideredSignals; - DisplayModeId newConfigId; + DisplayModeId newModeId; bool frameRateChanged; bool frameRateOverridesChanged; { @@ -613,28 +611,28 @@ void Scheduler::chooseRefreshRateForContent() { } mFeatures.contentRequirements = summary; - newConfigId = calculateRefreshRateConfigIndexType(&consideredSignals); - auto newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); + newModeId = calculateRefreshRateModeId(&consideredSignals); + auto newRefreshRate = mRefreshRateConfigs.getRefreshRateFromModeId(newModeId); frameRateOverridesChanged = updateFrameRateOverrides(consideredSignals, newRefreshRate.getFps()); - if (mFeatures.configId == newConfigId) { - // We don't need to change the config, but we might need to send an event - // about a config change, since it was suppressed due to a previous idleConsidered + if (mFeatures.modeId == newModeId) { + // We don't need to change the display mode, but we might need to send an event + // about a mode change, since it was suppressed due to a previous idleConsidered if (!consideredSignals.idle) { - dispatchCachedReportedConfig(); + dispatchCachedReportedMode(); } frameRateChanged = false; } else { - mFeatures.configId = newConfigId; + mFeatures.modeId = newModeId; frameRateChanged = true; } } if (frameRateChanged) { - auto newRefreshRate = mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); + auto newRefreshRate = mRefreshRateConfigs.getRefreshRateFromModeId(newModeId); mSchedulerCallback.changeRefreshRate(newRefreshRate, - consideredSignals.idle ? ConfigEvent::None - : ConfigEvent::Changed); + consideredSignals.idle ? ModeEvent::None + : ModeEvent::Changed); } if (frameRateOverridesChanged) { mSchedulerCallback.triggerOnFrameRateOverridesChanged(); @@ -783,7 +781,7 @@ bool Scheduler::updateFrameRateOverrides( template <class T> bool Scheduler::handleTimerStateChanged(T* currentState, T newState) { - DisplayModeId newConfigId; + DisplayModeId newModeId; bool refreshRateChanged = false; bool frameRateOverridesChanged; scheduler::RefreshRateConfigs::GlobalSignals consideredSignals; @@ -793,29 +791,27 @@ bool Scheduler::handleTimerStateChanged(T* currentState, T newState) { return false; } *currentState = newState; - newConfigId = calculateRefreshRateConfigIndexType(&consideredSignals); - const RefreshRate& newRefreshRate = - mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); + newModeId = calculateRefreshRateModeId(&consideredSignals); + const RefreshRate& newRefreshRate = mRefreshRateConfigs.getRefreshRateFromModeId(newModeId); frameRateOverridesChanged = updateFrameRateOverrides(consideredSignals, newRefreshRate.getFps()); - if (mFeatures.configId == newConfigId) { - // We don't need to change the config, but we might need to send an event - // about a config change, since it was suppressed due to a previous idleConsidered + if (mFeatures.modeId == newModeId) { + // We don't need to change the display mode, but we might need to send an event + // about a mode change, since it was suppressed due to a previous idleConsidered if (!consideredSignals.idle) { - dispatchCachedReportedConfig(); + dispatchCachedReportedMode(); } } else { - mFeatures.configId = newConfigId; + mFeatures.modeId = newModeId; refreshRateChanged = true; } } if (refreshRateChanged) { - const RefreshRate& newRefreshRate = - mRefreshRateConfigs.getRefreshRateFromConfigId(newConfigId); + const RefreshRate& newRefreshRate = mRefreshRateConfigs.getRefreshRateFromModeId(newModeId); mSchedulerCallback.changeRefreshRate(newRefreshRate, - consideredSignals.idle ? ConfigEvent::None - : ConfigEvent::Changed); + consideredSignals.idle ? ModeEvent::None + : ModeEvent::Changed); } if (frameRateOverridesChanged) { mSchedulerCallback.triggerOnFrameRateOverridesChanged(); @@ -823,7 +819,7 @@ bool Scheduler::handleTimerStateChanged(T* currentState, T newState) { return consideredSignals.touch; } -DisplayModeId Scheduler::calculateRefreshRateConfigIndexType( +DisplayModeId Scheduler::calculateRefreshRateModeId( scheduler::RefreshRateConfigs::GlobalSignals* consideredSignals) { ATRACE_CALL(); if (consideredSignals) *consideredSignals = {}; @@ -833,7 +829,7 @@ DisplayModeId Scheduler::calculateRefreshRateConfigIndexType( if (mDisplayPowerTimer && (!mFeatures.isDisplayPowerStateNormal || mFeatures.displayPowerTimer == TimerState::Reset)) { - return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getConfigId(); + return mRefreshRateConfigs.getMaxRefreshRateByPolicy().getModeId(); } const bool touchActive = mTouchTimer && mFeatures.touch == TouchState::Active; @@ -842,16 +838,16 @@ DisplayModeId Scheduler::calculateRefreshRateConfigIndexType( return mRefreshRateConfigs .getBestRefreshRate(mFeatures.contentRequirements, {.touch = touchActive, .idle = idle}, consideredSignals) - .getConfigId(); + .getModeId(); } -std::optional<DisplayModeId> Scheduler::getPreferredConfigId() { +std::optional<DisplayModeId> Scheduler::getPreferredModeId() { std::lock_guard<std::mutex> lock(mFeatureStateLock); - // Make sure that the default config ID is first updated, before returned. - if (mFeatures.configId.has_value()) { - mFeatures.configId = calculateRefreshRateConfigIndexType(); + // Make sure that the default mode ID is first updated, before returned. + if (mFeatures.modeId.has_value()) { + mFeatures.modeId = calculateRefreshRateModeId(); } - return mFeatures.configId; + return mFeatures.modeId; } void Scheduler::onNewVsyncPeriodChangeTimeline(const hal::VsyncPeriodChangeTimeline& timeline) { diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h index 340ca8e88d..5237516f17 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.h +++ b/services/surfaceflinger/Scheduler/Scheduler.h @@ -70,7 +70,7 @@ protected: class Scheduler { public: using RefreshRate = scheduler::RefreshRateConfigs::RefreshRate; - using ConfigEvent = scheduler::RefreshRateConfigEvent; + using ModeEvent = scheduler::RefreshRateConfigEvent; Scheduler(const scheduler::RefreshRateConfigs&, ISchedulerCallback&); ~Scheduler(); @@ -87,10 +87,10 @@ public: sp<EventThreadConnection> getEventConnection(ConnectionHandle); void onHotplugReceived(ConnectionHandle, PhysicalDisplayId, bool connected); - void onPrimaryDisplayConfigChanged(ConnectionHandle, PhysicalDisplayId, DisplayModeId configId, - nsecs_t vsyncPeriod) EXCLUDES(mFeatureStateLock); - void onNonPrimaryDisplayConfigChanged(ConnectionHandle, PhysicalDisplayId, - DisplayModeId configId, nsecs_t vsyncPeriod); + void onPrimaryDisplayModeChanged(ConnectionHandle, PhysicalDisplayId, DisplayModeId, + nsecs_t vsyncPeriod) EXCLUDES(mFeatureStateLock); + void onNonPrimaryDisplayModeChanged(ConnectionHandle, PhysicalDisplayId, DisplayModeId, + nsecs_t vsyncPeriod); void onScreenAcquired(ConnectionHandle); void onScreenReleased(ConnectionHandle); @@ -128,7 +128,7 @@ public: // Layers are registered on creation, and unregistered when the weak reference expires. void registerLayer(Layer*); void recordLayerHistory(Layer*, nsecs_t presentTime, LayerHistory::LayerUpdateType updateType); - void setConfigChangePending(bool pending); + void setModeChangePending(bool pending); // Detects content using layer history, and selects a matching refresh rate. void chooseRefreshRateForContent(); @@ -153,7 +153,7 @@ public: void dumpVsync(std::string&) const; // Get the appropriate refresh for current conditions. - std::optional<DisplayModeId> getPreferredConfigId(); + std::optional<DisplayModeId> getPreferredModeId(); // Notifies the scheduler about a refresh rate timeline change. void onNewVsyncPeriodChangeTimeline(const hal::VsyncPeriodChangeTimeline& timeline); @@ -227,11 +227,11 @@ private: // This function checks whether individual features that are affecting the refresh rate // selection were initialized, prioritizes them, and calculates the DisplayModeId // for the suggested refresh rate. - DisplayModeId calculateRefreshRateConfigIndexType( + DisplayModeId calculateRefreshRateModeId( scheduler::RefreshRateConfigs::GlobalSignals* consideredSignals = nullptr) REQUIRES(mFeatureStateLock); - void dispatchCachedReportedConfig() REQUIRES(mFeatureStateLock); + void dispatchCachedReportedMode() REQUIRES(mFeatureStateLock); bool updateFrameRateOverrides(scheduler::RefreshRateConfigs::GlobalSignals consideredSignals, Fps displayRefreshRate) REQUIRES(mFeatureStateLock) EXCLUDES(mFrameRateOverridesMutex); @@ -283,20 +283,20 @@ private: TouchState touch = TouchState::Inactive; TimerState displayPowerTimer = TimerState::Expired; - std::optional<DisplayModeId> configId; + std::optional<DisplayModeId> modeId; LayerHistory::Summary contentRequirements; bool isDisplayPowerStateNormal = true; - // Used to cache the last parameters of onPrimaryDisplayConfigChanged - struct ConfigChangedParams { + // Used to cache the last parameters of onPrimaryDisplayModeChanged + struct ModeChangedParams { ConnectionHandle handle; PhysicalDisplayId displayId; - DisplayModeId configId; + DisplayModeId modeId; nsecs_t vsyncPeriod; }; - std::optional<ConfigChangedParams> cachedConfigChangedParams; + std::optional<ModeChangedParams> cachedModeChangedParams; } mFeatures GUARDED_BY(mFeatureStateLock); const scheduler::RefreshRateConfigs& mRefreshRateConfigs; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e9b587510a..39f9e9f1d7 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -67,9 +67,9 @@ #include <sys/types.h> #include <ui/ColorSpace.h> #include <ui/DebugUtils.h> -#include <ui/DisplayConfig.h> #include <ui/DisplayId.h> #include <ui/DisplayInfo.h> +#include <ui/DisplayMode.h> #include <ui/DisplayStatInfo.h> #include <ui/DisplayState.h> #include <ui/GraphicBufferAllocator.h> @@ -887,9 +887,9 @@ status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& displayToken, Display return NO_ERROR; } -status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, - Vector<DisplayConfig>* configs) { - if (!displayToken || !configs) { +status_t SurfaceFlinger::getDisplayModes(const sp<IBinder>& displayToken, + Vector<ui::DisplayMode>* modes) { + if (!displayToken || !modes) { return BAD_VALUE; } @@ -900,16 +900,16 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, return NAME_NOT_FOUND; } - configs->clear(); + modes->clear(); - for (const auto& mode : display->getSupportedModes()) { - DisplayConfig config; + for (const auto& supportedMode : display->getSupportedModes()) { + ui::DisplayMode mode; - auto width = mode->getWidth(); - auto height = mode->getHeight(); + auto width = supportedMode->getWidth(); + auto height = supportedMode->getHeight(); - auto xDpi = mode->getDpiX(); - auto yDpi = mode->getDpiY(); + auto xDpi = supportedMode->getDpiX(); + auto yDpi = supportedMode->getDpiY(); if (display->isPrimary() && (internalDisplayOrientation == ui::ROTATION_90 || @@ -918,24 +918,24 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, std::swap(xDpi, yDpi); } - config.resolution = ui::Size(width, height); + mode.resolution = ui::Size(width, height); if (mEmulatedDisplayDensity) { - config.xDpi = mEmulatedDisplayDensity; - config.yDpi = mEmulatedDisplayDensity; + mode.xDpi = mEmulatedDisplayDensity; + mode.yDpi = mEmulatedDisplayDensity; } else { - config.xDpi = xDpi; - config.yDpi = yDpi; + mode.xDpi = xDpi; + mode.yDpi = yDpi; } - const nsecs_t period = mode->getVsyncPeriod(); - config.refreshRate = Fps::fromPeriodNsecs(period).getValue(); + const nsecs_t period = supportedMode->getVsyncPeriod(); + mode.refreshRate = Fps::fromPeriodNsecs(period).getValue(); const auto vsyncConfigSet = - mVsyncConfiguration->getConfigsForRefreshRate(Fps(config.refreshRate)); - config.appVsyncOffset = vsyncConfigSet.late.appOffset; - config.sfVsyncOffset = vsyncConfigSet.late.sfOffset; - config.configGroup = mode->getConfigGroup(); + mVsyncConfiguration->getConfigsForRefreshRate(Fps(mode.refreshRate)); + mode.appVsyncOffset = vsyncConfigSet.late.appOffset; + mode.sfVsyncOffset = vsyncConfigSet.late.sfOffset; + mode.group = supportedMode->getGroup(); // This is how far in advance a buffer must be queued for // presentation at a given time. If you want a buffer to appear @@ -949,9 +949,9 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken, // // We add an additional 1ms to allow for processing time and // differences between the ideal and actual refresh rate. - config.presentationDeadline = period - config.sfVsyncOffset + 1000000; + mode.presentationDeadline = period - mode.sfVsyncOffset + 1000000; - configs->push_back(config); + modes->push_back(mode); } return NO_ERROR; @@ -966,15 +966,15 @@ status_t SurfaceFlinger::getDisplayStats(const sp<IBinder>&, DisplayStatInfo* st return NO_ERROR; } -int SurfaceFlinger::getActiveConfig(const sp<IBinder>& displayToken) { - int activeConfig; +int SurfaceFlinger::getActiveDisplayModeId(const sp<IBinder>& displayToken) { + int activeMode; bool isPrimary; { Mutex::Autolock lock(mStateLock); if (const auto display = getDisplayDeviceLocked(displayToken)) { - activeConfig = display->getActiveMode()->getId().value(); + activeMode = display->getActiveMode()->getId().value(); isPrimary = display->isPrimary(); } else { ALOGE("%s: Invalid display token %p", __FUNCTION__, displayToken.get()); @@ -983,36 +983,35 @@ int SurfaceFlinger::getActiveConfig(const sp<IBinder>& displayToken) { } if (isPrimary) { - if (const auto config = getDesiredActiveConfig()) { - return config->configId.value(); + if (const auto mode = getDesiredActiveMode()) { + return mode->modeId.value(); } } - return activeConfig; + return activeMode; } -void SurfaceFlinger::setDesiredActiveConfig(const ActiveConfigInfo& info) { +void SurfaceFlinger::setDesiredActiveMode(const ActiveModeInfo& info) { ATRACE_CALL(); - auto refreshRate = mRefreshRateConfigs->getRefreshRateFromConfigId(info.configId); - ALOGV("setDesiredActiveConfig(%s)", refreshRate.getName().c_str()); - - std::lock_guard<std::mutex> lock(mActiveConfigLock); - if (mDesiredActiveConfigChanged) { - // If a config change is pending, just cache the latest request in - // mDesiredActiveConfig - const Scheduler::ConfigEvent prevConfig = mDesiredActiveConfig.event; - mDesiredActiveConfig = info; - mDesiredActiveConfig.event = mDesiredActiveConfig.event | prevConfig; + auto refreshRate = mRefreshRateConfigs->getRefreshRateFromModeId(info.modeId); + ALOGV("%s(%s)", __func__, refreshRate.getName().c_str()); + + std::lock_guard<std::mutex> lock(mActiveModeLock); + if (mDesiredActiveModeChanged) { + // If a mode change is pending, just cache the latest request in mDesiredActiveMode + const Scheduler::ModeEvent prevConfig = mDesiredActiveMode.event; + mDesiredActiveMode = info; + mDesiredActiveMode.event = mDesiredActiveMode.event | prevConfig; } else { - // Check if we are already at the desired config + // Check if we are already at the desired mode const auto display = getDefaultDisplayDeviceLocked(); - if (!display || display->getActiveMode()->getId() == refreshRate.getConfigId()) { + if (!display || display->getActiveMode()->getId() == refreshRate.getModeId()) { return; } - // Initiate a config change. - mDesiredActiveConfigChanged = true; - mDesiredActiveConfig = info; + // Initiate a mode change. + mDesiredActiveModeChanged = true; + mDesiredActiveMode = info; // This will trigger HWC refresh without resetting the idle timer. repaintEverythingForHWC(); @@ -1024,7 +1023,7 @@ void SurfaceFlinger::setDesiredActiveConfig(const ActiveConfigInfo& info) { modulateVsync(&VsyncModulator::onRefreshRateChangeInitiated); updatePhaseConfiguration(refreshRate.getFps()); - mScheduler->setConfigChangePending(true); + mScheduler->setModeChangePending(true); } if (mRefreshRateOverlay) { @@ -1032,7 +1031,7 @@ void SurfaceFlinger::setDesiredActiveConfig(const ActiveConfigInfo& info) { } } -status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& displayToken, int modeId) { +status_t SurfaceFlinger::setActiveMode(const sp<IBinder>& displayToken, int modeId) { ATRACE_CALL(); if (!displayToken) { @@ -1042,13 +1041,13 @@ status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& displayToken, int mo auto future = schedule([=]() -> status_t { const auto display = ON_MAIN_THREAD(getDisplayDeviceLocked(displayToken)); if (!display) { - ALOGE("Attempt to set allowed display configs for invalid display token %p", + ALOGE("Attempt to set allowed display modes for invalid display token %p", displayToken.get()); return NAME_NOT_FOUND; } if (display->isVirtual()) { - ALOGW("Attempt to set allowed display configs for virtual display"); + ALOGW("Attempt to set allowed display modes for virtual display"); return INVALID_OPERATION; } @@ -1067,13 +1066,13 @@ status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& displayToken, int mo {fps, fps}}; constexpr bool kOverridePolicy = false; - return setDesiredDisplayConfigSpecsInternal(display, policy, kOverridePolicy); + return setDesiredDisplayModeSpecsInternal(display, policy, kOverridePolicy); }); return future.get(); } -void SurfaceFlinger::setActiveConfigInternal() { +void SurfaceFlinger::setActiveModeInternal() { ATRACE_CALL(); const auto display = getDefaultDisplayDeviceLocked(); @@ -1081,21 +1080,21 @@ void SurfaceFlinger::setActiveConfigInternal() { return; } - const auto upcomingConfig = display->getMode(mUpcomingActiveConfig.configId); - if (!upcomingConfig) { - ALOGW("Upcoming active config is no longer supported. ConfigId = %zu", - mUpcomingActiveConfig.configId.value()); + const auto upcomingMode = display->getMode(mUpcomingActiveMode.modeId); + if (!upcomingMode) { + ALOGW("Upcoming active mode is no longer supported. Mode ID = %zu", + mUpcomingActiveMode.modeId.value()); // TODO(b/159590486) Handle the error better. Some parts of SurfaceFlinger may - // have been already updated with the upcoming active config. + // have been already updated with the upcoming active mode. return; } const Fps oldRefreshRate = display->getActiveMode()->getFps(); - std::lock_guard<std::mutex> lock(mActiveConfigLock); - mRefreshRateConfigs->setCurrentConfigId(mUpcomingActiveConfig.configId); - display->setActiveMode(mUpcomingActiveConfig.configId); + std::lock_guard<std::mutex> lock(mActiveModeLock); + mRefreshRateConfigs->setCurrentModeId(mUpcomingActiveMode.modeId); + display->setActiveMode(mUpcomingActiveMode.modeId); - const Fps refreshRate = upcomingConfig->getFps(); + const Fps refreshRate = upcomingMode->getFps(); mRefreshRateStats->setRefreshRate(refreshRate); @@ -1105,71 +1104,71 @@ void SurfaceFlinger::setActiveConfigInternal() { updatePhaseConfiguration(refreshRate); ATRACE_INT("ActiveConfigFPS", refreshRate.getValue()); - if (mUpcomingActiveConfig.event != Scheduler::ConfigEvent::None) { + if (mUpcomingActiveMode.event != Scheduler::ModeEvent::None) { const nsecs_t vsyncPeriod = refreshRate.getPeriodNsecs(); const auto physicalId = display->getPhysicalId(); - mScheduler->onPrimaryDisplayConfigChanged(mAppConnectionHandle, physicalId, - mUpcomingActiveConfig.configId, vsyncPeriod); + mScheduler->onPrimaryDisplayModeChanged(mAppConnectionHandle, physicalId, + mUpcomingActiveMode.modeId, vsyncPeriod); } } -void SurfaceFlinger::clearDesiredActiveConfigState() { - std::lock_guard<std::mutex> lock(mActiveConfigLock); - mDesiredActiveConfig.event = Scheduler::ConfigEvent::None; - mDesiredActiveConfigChanged = false; - mScheduler->setConfigChangePending(false); +void SurfaceFlinger::clearDesiredActiveModeState() { + std::lock_guard<std::mutex> lock(mActiveModeLock); + mDesiredActiveMode.event = Scheduler::ModeEvent::None; + mDesiredActiveModeChanged = false; + mScheduler->setModeChangePending(false); } -void SurfaceFlinger::desiredActiveConfigChangeDone() { - const auto modeId = getDesiredActiveConfig()->configId; +void SurfaceFlinger::desiredActiveModeChangeDone() { + const auto modeId = getDesiredActiveMode()->modeId; - clearDesiredActiveConfigState(); + clearDesiredActiveModeState(); const auto refreshRate = getDefaultDisplayDeviceLocked()->getMode(modeId)->getFps(); mScheduler->resyncToHardwareVsync(true, refreshRate.getPeriodNsecs()); updatePhaseConfiguration(refreshRate); } -void SurfaceFlinger::performSetActiveConfig() { +void SurfaceFlinger::performSetActiveMode() { ATRACE_CALL(); ALOGV("%s", __FUNCTION__); // Store the local variable to release the lock. - const auto desiredActiveConfig = getDesiredActiveConfig(); - if (!desiredActiveConfig) { - // No desired active config pending to be applied + const auto desiredActiveMode = getDesiredActiveMode(); + if (!desiredActiveMode) { + // No desired active mode pending to be applied return; } const auto display = getDefaultDisplayDeviceLocked(); - const auto desiredConfig = display->getMode(desiredActiveConfig->configId); - if (!desiredConfig) { - ALOGW("Desired display config is no longer supported. Config ID = %zu", - desiredActiveConfig->configId.value()); - clearDesiredActiveConfigState(); + const auto desiredMode = display->getMode(desiredActiveMode->modeId); + if (!desiredMode) { + ALOGW("Desired display mode is no longer supported. Mode ID = %zu", + desiredActiveMode->modeId.value()); + clearDesiredActiveModeState(); return; } - const auto refreshRate = desiredConfig->getFps(); - ALOGV("performSetActiveConfig changing active config to %zu(%s)", - desiredConfig->getId().value(), to_string(refreshRate).c_str()); + const auto refreshRate = desiredMode->getFps(); + ALOGV("%s changing active mode to %zu(%s)", __FUNCTION__, desiredMode->getId().value(), + to_string(refreshRate).c_str()); - if (!display || display->getActiveMode()->getId() == desiredActiveConfig->configId) { + if (!display || display->getActiveMode()->getId() == desiredActiveMode->modeId) { // display is not valid or we are already in the requested mode // on both cases there is nothing left to do - desiredActiveConfigChangeDone(); + desiredActiveModeChangeDone(); return; } - // Desired active config was set, it is different than the config currently in use, however - // allowed configs might have changed by the time we process the refresh. - // Make sure the desired config is still allowed - if (!isDisplayConfigAllowed(desiredActiveConfig->configId)) { - desiredActiveConfigChangeDone(); + // Desired active mode was set, it is different than the mode currently in use, however + // allowed modes might have changed by the time we process the refresh. + // Make sure the desired mode is still allowed + if (!isDisplayModeAllowed(desiredActiveMode->modeId)) { + desiredActiveModeChangeDone(); return; } - mUpcomingActiveConfig = *desiredActiveConfig; + mUpcomingActiveMode = *desiredActiveMode; - ATRACE_INT("ActiveConfigFPS_HWC", refreshRate.getValue()); + ATRACE_INT("ActiveModeFPS_HWC", refreshRate.getValue()); // TODO(b/142753666) use constrains hal::VsyncPeriodChangeConstraints constraints; @@ -1178,7 +1177,7 @@ void SurfaceFlinger::performSetActiveConfig() { hal::VsyncPeriodChangeTimeline outTimeline; const auto status = - display->initiateModeChange(mUpcomingActiveConfig.configId, constraints, &outTimeline); + display->initiateModeChange(mUpcomingActiveMode.modeId, constraints, &outTimeline); if (status != NO_ERROR) { // initiateModeChange may fail if a hotplug event is just about // to be sent. We just log the error in this case. @@ -1188,7 +1187,7 @@ void SurfaceFlinger::performSetActiveConfig() { mScheduler->onNewVsyncPeriodChangeTimeline(outTimeline); // Scheduler will submit an empty frame to HWC if needed. - mSetActiveConfigPending = true; + mSetActiveModePending = true; } status_t SurfaceFlinger::getDisplayColorModes(const sp<IBinder>& displayToken, @@ -1627,12 +1626,12 @@ void SurfaceFlinger::getCompositorTiming(CompositorTiming* compositorTiming) { *compositorTiming = getBE().mCompositorTiming; } -bool SurfaceFlinger::isDisplayConfigAllowed(DisplayModeId configId) const { - return mRefreshRateConfigs->isConfigAllowed(configId); +bool SurfaceFlinger::isDisplayModeAllowed(DisplayModeId modeId) const { + return mRefreshRateConfigs->isModeAllowed(modeId); } void SurfaceFlinger::changeRefreshRateLocked(const RefreshRate& refreshRate, - Scheduler::ConfigEvent event) { + Scheduler::ModeEvent event) { const auto display = getDefaultDisplayDeviceLocked(); if (!display || mBootStage != BootStage::FINISHED) { return; @@ -1640,13 +1639,13 @@ void SurfaceFlinger::changeRefreshRateLocked(const RefreshRate& refreshRate, ATRACE_CALL(); // Don't do any updating if the current fps is the same as the new one. - if (!isDisplayConfigAllowed(refreshRate.getConfigId())) { - ALOGV("Skipping config %zu as it is not part of allowed configs", - refreshRate.getConfigId().value()); + if (!isDisplayModeAllowed(refreshRate.getModeId())) { + ALOGV("Skipping mode %zu as it is not part of allowed modes", + refreshRate.getModeId().value()); return; } - setDesiredActiveConfig({refreshRate.getConfigId(), event}); + setDesiredActiveMode({refreshRate.getModeId(), event}); } void SurfaceFlinger::onHotplugReceived(int32_t sequenceId, hal::HWDisplayId hwcDisplayId, @@ -1829,18 +1828,18 @@ void SurfaceFlinger::onMessageInvalidate(int64_t vsyncId, nsecs_t expectedVSyncT mGpuFrameMissedCount++; } - // If we are in the middle of a config change and the fence hasn't + // If we are in the middle of a mode change and the fence hasn't // fired yet just wait for the next invalidate - if (mSetActiveConfigPending) { + if (mSetActiveModePending) { if (framePending) { mEventQueue->invalidate(); return; } // We received the present fence from the HWC, so we assume it successfully updated - // the config, hence we update SF. - mSetActiveConfigPending = false; - ON_MAIN_THREAD(setActiveConfigInternal()); + // the mode, hence we update SF. + mSetActiveModePending = false; + ON_MAIN_THREAD(setActiveModeInternal()); } if (framePending) { @@ -1920,7 +1919,7 @@ void SurfaceFlinger::onMessageInvalidate(int64_t vsyncId, nsecs_t expectedVSyncT mScheduler->chooseRefreshRateForContent(); } - ON_MAIN_THREAD(performSetActiveConfig()); + ON_MAIN_THREAD(performSetActiveMode()); updateCursorAsync(); updateInputFlinger(); @@ -2370,7 +2369,7 @@ DisplayModes SurfaceFlinger::loadSupportedDisplayModes(PhysicalDisplayId display .setVsyncPeriod(hwcMode.vsyncPeriod) .setDpiX(hwcMode.dpiX) .setDpiY(hwcMode.dpiY) - .setConfigGroup(hwcMode.configGroup) + .setGroup(hwcMode.configGroup) .build()); } return modes; @@ -2391,7 +2390,7 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { if (event.connection == hal::Connection::CONNECTED) { auto supportedModes = loadSupportedDisplayModes(displayId); const auto activeModeHwcId = getHwComposer().getActiveMode(displayId); - LOG_ALWAYS_FATAL_IF(!activeModeHwcId, "HWC returned no active config"); + LOG_ALWAYS_FATAL_IF(!activeModeHwcId, "HWC returned no active mode"); const auto activeMode = *std::find_if(supportedModes.begin(), supportedModes.end(), [activeModeHwcId](const DisplayModePtr& mode) { @@ -2675,9 +2674,8 @@ void SurfaceFlinger::processDisplayChanged(const wp<IBinder>& displayToken, // TODO(b/175678251) Call a listener instead. if (currentState.physical->hwcDisplayId == getHwComposer().getInternalHwcDisplayId()) { - mRefreshRateConfigs - ->updateDisplayConfigs(currentState.physical->supportedModes, - currentState.physical->activeMode->getId()); + mRefreshRateConfigs->updateDisplayModes(currentState.physical->supportedModes, + currentState.physical->activeMode->getId()); mVsyncConfiguration->reset(); updatePhaseConfiguration(mRefreshRateConfigs->getCurrentRefreshRate().getFps()); if (mRefreshRateOverlay) { @@ -2935,8 +2933,7 @@ void SurfaceFlinger::updateCursorAsync() { mCompositionEngine->updateCursorAsync(refreshArgs); } -void SurfaceFlinger::changeRefreshRate(const RefreshRate& refreshRate, - Scheduler::ConfigEvent event) { +void SurfaceFlinger::changeRefreshRate(const RefreshRate& refreshRate, Scheduler::ModeEvent event) { // If this is called from the main thread mStateLock must be locked before // Currently the only way to call this function from the main thread is from // Scheduler::chooseRefreshRateForContent @@ -2996,16 +2993,16 @@ void SurfaceFlinger::initScheduler(const DisplayDeviceState& displayState) { mRegionSamplingThread = new RegionSamplingThread(*this, *mScheduler, RegionSamplingThread::EnvironmentTimingTunables()); - // Dispatch a config change request for the primary display on scheduler + // Dispatch a mode change request for the primary display on scheduler // initialization, so that the EventThreads always contain a reference to a // prior configuration. // // This is a bit hacky, but this avoids a back-pointer into the main SF // classes from EventThread, and there should be no run-time binder cost // anyway since there are no connected apps at this point. - mScheduler->onPrimaryDisplayConfigChanged(mAppConnectionHandle, displayId, - displayState.physical->activeMode->getId(), - vsyncPeriod); + mScheduler->onPrimaryDisplayModeChanged(mAppConnectionHandle, displayId, + displayState.physical->activeMode->getId(), + vsyncPeriod); static auto ignorePresentFences = base::GetBoolProperty("debug.sf.vsync_reactor_ignore_present_fences"s, false); mScheduler->setIgnorePresentFences( @@ -4532,8 +4529,8 @@ void SurfaceFlinger::dumpVSync(std::string& result) const { mRefreshRateConfigs->dump(result); - StringAppendF(&result, "(config override by backdoor: %s)\n\n", - mDebugDisplayConfigSetByBackdoor ? "yes" : "no"); + StringAppendF(&result, "(mode override by backdoor: %s)\n\n", + mDebugDisplayModeSetByBackdoor ? "yes" : "no"); mScheduler->dump(mAppConnectionHandle, result); mScheduler->dumpVsync(result); @@ -4952,8 +4949,8 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { case ENABLE_VSYNC_INJECTIONS: case GET_ANIMATION_FRAME_STATS: case GET_HDR_CAPABILITIES: - case SET_DESIRED_DISPLAY_CONFIG_SPECS: - case GET_DESIRED_DISPLAY_CONFIG_SPECS: + case SET_DESIRED_DISPLAY_MODE_SPECS: + case GET_DESIRED_DISPLAY_MODE_SPECS: case SET_ACTIVE_COLOR_MODE: case GET_AUTO_LOW_LATENCY_MODE_SUPPORT: case SET_AUTO_LOW_LATENCY_MODE: @@ -4995,13 +4992,13 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { // information, so it is OK to pass them. case AUTHENTICATE_SURFACE: case GET_ACTIVE_COLOR_MODE: - case GET_ACTIVE_CONFIG: + case GET_ACTIVE_DISPLAY_MODE: case GET_PHYSICAL_DISPLAY_IDS: case GET_PHYSICAL_DISPLAY_TOKEN: case GET_DISPLAY_COLOR_MODES: case GET_DISPLAY_NATIVE_PRIMARIES: case GET_DISPLAY_INFO: - case GET_DISPLAY_CONFIGS: + case GET_DISPLAY_MODES: case GET_DISPLAY_STATE: case GET_DISPLAY_STATS: case GET_SUPPORTED_FRAME_TIMESTAMPS: @@ -5375,7 +5372,7 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r } case 1035: { const int modeId = data.readInt32(); - mDebugDisplayConfigSetByBackdoor = false; + mDebugDisplayModeSetByBackdoor = false; const auto displayId = getInternalDisplayId(); if (!displayId) { @@ -5383,12 +5380,12 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r return NO_ERROR; } - status_t result = setActiveConfig(getPhysicalDisplayToken(*displayId), modeId); + status_t result = setActiveMode(getPhysicalDisplayToken(*displayId), modeId); if (result != NO_ERROR) { return result; } - mDebugDisplayConfigSetByBackdoor = true; + mDebugDisplayModeSetByBackdoor = true; return NO_ERROR; } @@ -5467,14 +5464,13 @@ void SurfaceFlinger::kernelTimerChanged(bool expired) { // Update the overlay on the main thread to avoid race conditions with // mRefreshRateConfigs->getCurrentRefreshRate() static_cast<void>(schedule([=] { - const auto desiredActiveConfig = getDesiredActiveConfig(); - const std::optional<DisplayModeId> desiredConfigId = desiredActiveConfig - ? std::make_optional(desiredActiveConfig->configId) - : std::nullopt; + const auto desiredActiveMode = getDesiredActiveMode(); + const std::optional<DisplayModeId> desiredModeId = + desiredActiveMode ? std::make_optional(desiredActiveMode->modeId) : std::nullopt; const bool timerExpired = mKernelIdleTimerEnabled && expired; const auto newRefreshRate = - mRefreshRateConfigs->onKernelTimerChanged(desiredConfigId, timerExpired); + mRefreshRateConfigs->onKernelTimerChanged(desiredModeId, timerExpired); if (newRefreshRate) { if (Mutex::Autolock lock(mStateLock); mRefreshRateOverlay) { mRefreshRateOverlay->changeRefreshRate(*newRefreshRate); @@ -6061,7 +6057,7 @@ void SurfaceFlinger::traverseLayersInLayerStack(ui::LayerStack layerStack, const } } -status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( +status_t SurfaceFlinger::setDesiredDisplayModeSpecsInternal( const sp<DisplayDevice>& display, const std::optional<scheduler::RefreshRateConfigs::Policy>& policy, bool overridePolicy) { Mutex::Autolock lock(mStateLock); @@ -6071,10 +6067,10 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( LOG_ALWAYS_FATAL_IF(!policy && !overridePolicy, "Can only clear the override policy"); if (!display->isPrimary()) { - // TODO(b/144711714): For non-primary displays we should be able to set an active config + // TODO(b/144711714): For non-primary displays we should be able to set an active mode // as well. For now, just call directly to initiateModeChange but ideally - // it should go thru setDesiredActiveConfig, similar to primary display. - ALOGV("setAllowedDisplayConfigsInternal for non-primary display"); + // it should go thru setDesiredActiveMode, similar to primary display. + ALOGV("%s for non-primary display", __func__); const auto displayId = display->getPhysicalId(); hal::VsyncPeriodChangeConstraints constraints; @@ -6082,23 +6078,22 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( constraints.seamlessRequired = false; hal::VsyncPeriodChangeTimeline timeline = {0, 0, 0}; - if (display->initiateModeChange(policy->defaultConfig, constraints, &timeline) != - NO_ERROR) { + if (display->initiateModeChange(policy->defaultMode, constraints, &timeline) != NO_ERROR) { return BAD_VALUE; } if (timeline.refreshRequired) { repaintEverythingForHWC(); } - display->setActiveMode(policy->defaultConfig); - const nsecs_t vsyncPeriod = display->getMode(policy->defaultConfig)->getVsyncPeriod(); - mScheduler->onNonPrimaryDisplayConfigChanged(mAppConnectionHandle, displayId, - policy->defaultConfig, vsyncPeriod); + display->setActiveMode(policy->defaultMode); + const nsecs_t vsyncPeriod = display->getMode(policy->defaultMode)->getVsyncPeriod(); + mScheduler->onNonPrimaryDisplayModeChanged(mAppConnectionHandle, displayId, + policy->defaultMode, vsyncPeriod); return NO_ERROR; } - if (mDebugDisplayConfigSetByBackdoor) { - // ignore this request as config is overridden by backdoor + if (mDebugDisplayModeSetByBackdoor) { + // ignore this request as mode is overridden by backdoor return NO_ERROR; } @@ -6113,42 +6108,43 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal( } scheduler::RefreshRateConfigs::Policy currentPolicy = mRefreshRateConfigs->getCurrentPolicy(); - ALOGV("Setting desired display config specs: %s", currentPolicy.toString().c_str()); + ALOGV("Setting desired display mode specs: %s", currentPolicy.toString().c_str()); // TODO(b/140204874): Leave the event in until we do proper testing with all apps that might // be depending in this callback. - const auto activeConfig = display->getActiveMode(); - const nsecs_t vsyncPeriod = activeConfig->getVsyncPeriod(); + const auto activeMode = display->getActiveMode(); + const nsecs_t vsyncPeriod = activeMode->getVsyncPeriod(); const auto physicalId = display->getPhysicalId(); - mScheduler->onPrimaryDisplayConfigChanged(mAppConnectionHandle, physicalId, - activeConfig->getId(), vsyncPeriod); + mScheduler->onPrimaryDisplayModeChanged(mAppConnectionHandle, physicalId, activeMode->getId(), + vsyncPeriod); toggleKernelIdleTimer(); - auto configId = mScheduler->getPreferredConfigId(); - auto preferredRefreshRate = configId - ? mRefreshRateConfigs->getRefreshRateFromConfigId(*configId) - // NOTE: Choose the default config ID, if Scheduler doesn't have one in mind. - : mRefreshRateConfigs->getRefreshRateFromConfigId(currentPolicy.defaultConfig); - ALOGV("trying to switch to Scheduler preferred config %zu (%s)", - preferredRefreshRate.getConfigId().value(), preferredRefreshRate.getName().c_str()); - - if (isDisplayConfigAllowed(preferredRefreshRate.getConfigId())) { - ALOGV("switching to Scheduler preferred config %zu", - preferredRefreshRate.getConfigId().value()); - setDesiredActiveConfig( - {preferredRefreshRate.getConfigId(), Scheduler::ConfigEvent::Changed}); + auto modeId = mScheduler->getPreferredModeId(); + auto preferredRefreshRate = modeId + ? mRefreshRateConfigs->getRefreshRateFromModeId(*modeId) + // NOTE: Choose the default mode ID, if Scheduler doesn't have one in mind. + : mRefreshRateConfigs->getRefreshRateFromModeId(currentPolicy.defaultMode); + ALOGV("trying to switch to Scheduler preferred mode %zu (%s)", + preferredRefreshRate.getModeId().value(), preferredRefreshRate.getName().c_str()); + + if (isDisplayModeAllowed(preferredRefreshRate.getModeId())) { + ALOGV("switching to Scheduler preferred display mode %zu", + preferredRefreshRate.getModeId().value()); + setDesiredActiveMode({preferredRefreshRate.getModeId(), Scheduler::ModeEvent::Changed}); } else { - LOG_ALWAYS_FATAL("Desired config not allowed: %zu", - preferredRefreshRate.getConfigId().value()); + LOG_ALWAYS_FATAL("Desired display mode not allowed: %zu", + preferredRefreshRate.getModeId().value()); } return NO_ERROR; } -status_t SurfaceFlinger::setDesiredDisplayConfigSpecs( - const sp<IBinder>& displayToken, int32_t defaultConfig, bool allowGroupSwitching, - float primaryRefreshRateMin, float primaryRefreshRateMax, float appRequestRefreshRateMin, - float appRequestRefreshRateMax) { +status_t SurfaceFlinger::setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, + size_t defaultMode, bool allowGroupSwitching, + float primaryRefreshRateMin, + float primaryRefreshRateMax, + float appRequestRefreshRateMin, + float appRequestRefreshRateMax) { ATRACE_CALL(); if (!displayToken) { @@ -6158,34 +6154,34 @@ status_t SurfaceFlinger::setDesiredDisplayConfigSpecs( auto future = schedule([=]() -> status_t { const auto display = ON_MAIN_THREAD(getDisplayDeviceLocked(displayToken)); if (!display) { - ALOGE("Attempt to set desired display configs for invalid display token %p", + ALOGE("Attempt to set desired display modes for invalid display token %p", displayToken.get()); return NAME_NOT_FOUND; } else if (display->isVirtual()) { - ALOGW("Attempt to set desired display configs for virtual display"); + ALOGW("Attempt to set desired display modes for virtual display"); return INVALID_OPERATION; } else { using Policy = scheduler::RefreshRateConfigs::Policy; - const Policy policy{DisplayModeId(defaultConfig), + const Policy policy{DisplayModeId(defaultMode), allowGroupSwitching, {Fps(primaryRefreshRateMin), Fps(primaryRefreshRateMax)}, {Fps(appRequestRefreshRateMin), Fps(appRequestRefreshRateMax)}}; constexpr bool kOverridePolicy = false; - return setDesiredDisplayConfigSpecsInternal(display, policy, kOverridePolicy); + return setDesiredDisplayModeSpecsInternal(display, policy, kOverridePolicy); } }); return future.get(); } -status_t SurfaceFlinger::getDesiredDisplayConfigSpecs( - const sp<IBinder>& displayToken, int32_t* outDefaultConfig, bool* outAllowGroupSwitching, +status_t SurfaceFlinger::getDesiredDisplayModeSpecs( + const sp<IBinder>& displayToken, size_t* outDefaultMode, bool* outAllowGroupSwitching, float* outPrimaryRefreshRateMin, float* outPrimaryRefreshRateMax, float* outAppRequestRefreshRateMin, float* outAppRequestRefreshRateMax) { ATRACE_CALL(); - if (!displayToken || !outDefaultConfig || !outPrimaryRefreshRateMin || + if (!displayToken || !outDefaultMode || !outPrimaryRefreshRateMin || !outPrimaryRefreshRateMax || !outAppRequestRefreshRateMin || !outAppRequestRefreshRateMax) { return BAD_VALUE; } @@ -6199,7 +6195,7 @@ status_t SurfaceFlinger::getDesiredDisplayConfigSpecs( if (display->isPrimary()) { scheduler::RefreshRateConfigs::Policy policy = mRefreshRateConfigs->getDisplayManagerPolicy(); - *outDefaultConfig = policy.defaultConfig.value(); + *outDefaultMode = policy.defaultMode.value(); *outAllowGroupSwitching = policy.allowGroupSwitching; *outPrimaryRefreshRateMin = policy.primaryRange.min.getValue(); *outPrimaryRefreshRateMax = policy.primaryRange.max.getValue(); @@ -6210,7 +6206,7 @@ status_t SurfaceFlinger::getDesiredDisplayConfigSpecs( return INVALID_OPERATION; } else { const auto activeMode = display->getActiveMode(); - *outDefaultConfig = activeMode->getId().value(); + *outDefaultMode = activeMode->getId().value(); *outAllowGroupSwitching = false; auto vsyncPeriod = activeMode->getVsyncPeriod(); *outPrimaryRefreshRateMin = Fps::fromPeriodNsecs(vsyncPeriod).getValue(); @@ -6340,16 +6336,15 @@ status_t SurfaceFlinger::acquireFrameRateFlexibilityToken(sp<IBinder>* outToken) const auto display = ON_MAIN_THREAD(getDefaultDisplayDeviceLocked()); // This is a little racy, but not in a way that hurts anything. As we grab the - // defaultConfig from the display manager policy, we could be setting a new display - // manager policy, leaving us using a stale defaultConfig. The defaultConfig doesn't + // defaultMode from the display manager policy, we could be setting a new display + // manager policy, leaving us using a stale defaultMode. The defaultMode doesn't // matter for the override policy though, since we set allowGroupSwitching to // true, so it's not a problem. scheduler::RefreshRateConfigs::Policy overridePolicy; - overridePolicy.defaultConfig = - mRefreshRateConfigs->getDisplayManagerPolicy().defaultConfig; + overridePolicy.defaultMode = mRefreshRateConfigs->getDisplayManagerPolicy().defaultMode; overridePolicy.allowGroupSwitching = true; constexpr bool kOverridePolicy = true; - result = setDesiredDisplayConfigSpecsInternal(display, overridePolicy, kOverridePolicy); + result = setDesiredDisplayModeSpecsInternal(display, overridePolicy, kOverridePolicy); } if (result == NO_ERROR) { @@ -6389,7 +6384,7 @@ void SurfaceFlinger::onFrameRateFlexibilityTokenReleased() { if (mFrameRateFlexibilityTokenCount == 0) { const auto display = ON_MAIN_THREAD(getDefaultDisplayDeviceLocked()); constexpr bool kOverridePolicy = true; - status_t result = setDesiredDisplayConfigSpecsInternal(display, {}, kOverridePolicy); + status_t result = setDesiredDisplayModeSpecsInternal(display, {}, kOverridePolicy); LOG_ALWAYS_FATAL_IF(result < 0, "Failed releasing frame rate flexibility token"); } })); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 66fc4f0d18..4f00491c89 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -414,12 +414,12 @@ private: void traverseInReverseZOrder(const LayerVector::Visitor& visitor) const; }; - struct ActiveConfigInfo { - DisplayModeId configId; - Scheduler::ConfigEvent event = Scheduler::ConfigEvent::None; + struct ActiveModeInfo { + DisplayModeId modeId; + Scheduler::ModeEvent event = Scheduler::ModeEvent::None; - bool operator!=(const ActiveConfigInfo& other) const { - return configId != other.configId || event != other.event; + bool operator!=(const ActiveModeInfo& other) const { + return modeId != other.modeId || event != other.event; } }; @@ -554,8 +554,8 @@ private: status_t getDisplayStats(const sp<IBinder>& displayToken, DisplayStatInfo* stats) override; status_t getDisplayState(const sp<IBinder>& displayToken, ui::DisplayState*) override; status_t getDisplayInfo(const sp<IBinder>& displayToken, DisplayInfo*) override; - status_t getDisplayConfigs(const sp<IBinder>& displayToken, Vector<DisplayConfig>*) override; - int getActiveConfig(const sp<IBinder>& displayToken) override; + status_t getDisplayModes(const sp<IBinder>& displayToken, Vector<ui::DisplayMode>*) override; + int getActiveDisplayModeId(const sp<IBinder>& displayToken) override; status_t getDisplayColorModes(const sp<IBinder>& displayToken, Vector<ui::ColorMode>*) override; status_t getDisplayNativePrimaries(const sp<IBinder>& displayToken, ui::DisplayPrimaries&) override; @@ -594,17 +594,16 @@ private: status_t addRegionSamplingListener(const Rect& samplingArea, const sp<IBinder>& stopLayerHandle, const sp<IRegionSamplingListener>& listener) override; status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) override; - status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, int32_t displayModeId, - bool allowGroupSwitching, float primaryRefreshRateMin, - float primaryRefreshRateMax, - float appRequestRefreshRateMin, - float appRequestRefreshRateMax) override; - status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, - int32_t* outDefaultConfig, bool* outAllowGroupSwitching, - float* outPrimaryRefreshRateMin, - float* outPrimaryRefreshRateMax, - float* outAppRequestRefreshRateMin, - float* outAppRequestRefreshRateMax) override; + status_t setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, size_t displayModeId, + bool allowGroupSwitching, float primaryRefreshRateMin, + float primaryRefreshRateMax, float appRequestRefreshRateMin, + float appRequestRefreshRateMax) override; + status_t getDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, size_t* outDefaultMode, + bool* outAllowGroupSwitching, + float* outPrimaryRefreshRateMin, + float* outPrimaryRefreshRateMax, + float* outAppRequestRefreshRateMin, + float* outAppRequestRefreshRateMax) override; status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken, bool* outSupport) const override; status_t setDisplayBrightness(const sp<IBinder>& displayToken, float brightness) override; @@ -649,7 +648,7 @@ private: // Toggles hardware VSYNC by calling into HWC. void setVsyncEnabled(bool) override; // Initiates a refresh rate change to be applied on invalidate. - void changeRefreshRate(const Scheduler::RefreshRate&, Scheduler::ConfigEvent) override; + void changeRefreshRate(const Scheduler::RefreshRate&, Scheduler::ModeEvent) override; // Forces full composition on all displays without resetting the scheduler idle timer. void repaintEverythingForHWC() override; // Called when kernel idle timer has expired. Used to update the refresh rate overlay. @@ -677,24 +676,24 @@ private: // Called on the main thread in response to initializeDisplays() void onInitializeDisplays() REQUIRES(mStateLock); - // Sets the desired active config bit. It obtains the lock, and sets mDesiredActiveConfig. - void setDesiredActiveConfig(const ActiveConfigInfo& info) REQUIRES(mStateLock); - status_t setActiveConfig(const sp<IBinder>& displayToken, int id); - // Once HWC has returned the present fence, this sets the active config and a new refresh + // Sets the desired active mode bit. It obtains the lock, and sets mDesiredActiveMode. + void setDesiredActiveMode(const ActiveModeInfo& info) REQUIRES(mStateLock); + status_t setActiveMode(const sp<IBinder>& displayToken, int id); + // Once HWC has returned the present fence, this sets the active mode and a new refresh // rate in SF. - void setActiveConfigInternal() REQUIRES(mStateLock); - // Calls to setActiveConfig on the main thread if there is a pending config + void setActiveModeInternal() REQUIRES(mStateLock); + // Calls to setActiveMode on the main thread if there is a pending mode change // that needs to be applied. - void performSetActiveConfig() REQUIRES(mStateLock); - void clearDesiredActiveConfigState() REQUIRES(mStateLock) EXCLUDES(mActiveConfigLock); - // Called when active config is no longer is progress - void desiredActiveConfigChangeDone() REQUIRES(mStateLock); + void performSetActiveMode() REQUIRES(mStateLock); + void clearDesiredActiveModeState() REQUIRES(mStateLock) EXCLUDES(mActiveModeLock); + // Called when active mode is no longer is progress + void desiredActiveModeChangeDone() REQUIRES(mStateLock); // Called on the main thread in response to setPowerMode() void setPowerModeInternal(const sp<DisplayDevice>& display, hal::PowerMode mode) REQUIRES(mStateLock); - // Sets the desired display configs. - status_t setDesiredDisplayConfigSpecsInternal( + // Sets the desired display mode specs. + status_t setDesiredDisplayModeSpecsInternal( const sp<DisplayDevice>& display, const std::optional<scheduler::RefreshRateConfigs::Policy>& policy, bool overridePolicy) EXCLUDES(mStateLock); @@ -927,9 +926,9 @@ private: // Sets the refresh rate by switching active configs, if they are available for // the desired refresh rate. - void changeRefreshRateLocked(const RefreshRate&, Scheduler::ConfigEvent) REQUIRES(mStateLock); + void changeRefreshRateLocked(const RefreshRate&, Scheduler::ModeEvent) REQUIRES(mStateLock); - bool isDisplayConfigAllowed(DisplayModeId configId) const REQUIRES(mStateLock); + bool isDisplayModeAllowed(DisplayModeId) const REQUIRES(mStateLock); // Gets the fence for the previous frame. // Must be called on the main thread. @@ -1045,9 +1044,9 @@ private: * Misc */ - std::optional<ActiveConfigInfo> getDesiredActiveConfig() EXCLUDES(mActiveConfigLock) { - std::lock_guard<std::mutex> lock(mActiveConfigLock); - if (mDesiredActiveConfigChanged) return mDesiredActiveConfig; + std::optional<ActiveModeInfo> getDesiredActiveMode() EXCLUDES(mActiveModeLock) { + std::lock_guard<std::mutex> lock(mActiveModeLock); + if (mDesiredActiveModeChanged) return mDesiredActiveMode; return std::nullopt; } @@ -1244,18 +1243,18 @@ private: nsecs_t mScheduledPresentTime = 0; hal::Vsync mHWCVsyncPendingState = hal::Vsync::DISABLE; - std::mutex mActiveConfigLock; - // This bit is set once we start setting the config. We read from this bit during the - // process. If at the end, this bit is different than mDesiredActiveConfig, we restart + std::mutex mActiveModeLock; + // This bit is set once we start setting the mode. We read from this bit during the + // process. If at the end, this bit is different than mDesiredActiveMode, we restart // the process. - ActiveConfigInfo mUpcomingActiveConfig; // Always read and written on the main thread. - // This bit can be set at any point in time when the system wants the new config. - ActiveConfigInfo mDesiredActiveConfig GUARDED_BY(mActiveConfigLock); + ActiveModeInfo mUpcomingActiveMode; // Always read and written on the main thread. + // This bit can be set at any point in time when the system wants the new mode. + ActiveModeInfo mDesiredActiveMode GUARDED_BY(mActiveModeLock); // below flags are set by main thread only - TracedOrdinal<bool> mDesiredActiveConfigChanged - GUARDED_BY(mActiveConfigLock) = {"DesiredActiveConfigChanged", false}; - bool mSetActiveConfigPending = false; + TracedOrdinal<bool> mDesiredActiveModeChanged + GUARDED_BY(mActiveModeLock) = {"DesiredActiveModeChanged", false}; + bool mSetActiveModePending = false; bool mLumaSampling = true; sp<RegionSamplingThread> mRegionSamplingThread; @@ -1279,8 +1278,8 @@ private: void enableRefreshRateOverlay(bool enable); std::unique_ptr<RefreshRateOverlay> mRefreshRateOverlay GUARDED_BY(mStateLock); - // Flag used to set override allowed display configs from backdoor - bool mDebugDisplayConfigSetByBackdoor = false; + // Flag used to set override desired display mode from backdoor + bool mDebugDisplayModeSetByBackdoor = false; // A set of layers that have no parent so they are not drawn on screen. // Should only be accessed by the main thread. diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp index 9302463190..53e37d874e 100644 --- a/services/surfaceflinger/tests/Credentials_test.cpp +++ b/services/surfaceflinger/tests/Credentials_test.cpp @@ -25,7 +25,7 @@ #include <gui/SurfaceComposerClient.h> #include <private/android_filesystem_config.h> #include <private/gui/ComposerService.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <utils/String8.h> #include <functional> #include "utils/ScreenshotUtils.h" @@ -81,14 +81,13 @@ protected: mDisplay = SurfaceComposerClient::getInternalDisplayToken(); ASSERT_FALSE(mDisplay == nullptr); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(mDisplay, &config)); + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(mDisplay, &mode)); // Background surface - mBGSurfaceControl = - mComposerClient->createSurface(SURFACE_NAME, config.resolution.getWidth(), - config.resolution.getHeight(), - PIXEL_FORMAT_RGBA_8888, 0); + mBGSurfaceControl = mComposerClient->createSurface(SURFACE_NAME, mode.resolution.getWidth(), + mode.resolution.getHeight(), + PIXEL_FORMAT_RGBA_8888, 0); ASSERT_TRUE(mBGSurfaceControl != nullptr); ASSERT_TRUE(mBGSurfaceControl->isValid()); @@ -185,13 +184,13 @@ TEST_F(CredentialsTest, AllowedGetterMethodsTest) { const auto display = SurfaceComposerClient::getInternalDisplayToken(); ASSERT_TRUE(display != nullptr); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); - Vector<DisplayConfig> configs; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayConfigs(display, &configs)); + Vector<ui::DisplayMode> modes; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayModes(display, &modes)); - ASSERT_TRUE(SurfaceComposerClient::getActiveConfig(display) >= 0); + ASSERT_TRUE(SurfaceComposerClient::getActiveDisplayModeId(display) >= 0); ASSERT_NE(static_cast<ui::ColorMode>(BAD_VALUE), SurfaceComposerClient::getActiveColorMode(display)); @@ -217,25 +216,23 @@ TEST_F(CredentialsTest, GetDisplayNativePrimariesTest) { TEST_F(CredentialsTest, SetDesiredDisplayConfigsTest) { const auto display = SurfaceComposerClient::getInternalDisplayToken(); - int32_t defaultConfig; + size_t defaultMode; bool allowGroupSwitching; float primaryFpsMin; float primaryFpsMax; float appRequestFpsMin; float appRequestFpsMax; status_t res = - SurfaceComposerClient::getDesiredDisplayConfigSpecs(display, &defaultConfig, - &allowGroupSwitching, - &primaryFpsMin, &primaryFpsMax, - &appRequestFpsMin, - &appRequestFpsMax); + SurfaceComposerClient::getDesiredDisplayModeSpecs(display, &defaultMode, + &allowGroupSwitching, &primaryFpsMin, + &primaryFpsMax, &appRequestFpsMin, + &appRequestFpsMax); ASSERT_EQ(res, NO_ERROR); std::function<status_t()> condition = [=]() { - return SurfaceComposerClient::setDesiredDisplayConfigSpecs(display, defaultConfig, - allowGroupSwitching, - primaryFpsMin, primaryFpsMax, - appRequestFpsMin, - appRequestFpsMax); + return SurfaceComposerClient::setDesiredDisplayModeSpecs(display, defaultMode, + allowGroupSwitching, primaryFpsMin, + primaryFpsMax, appRequestFpsMin, + appRequestFpsMax); }; ASSERT_NO_FATAL_FAILURE(checkWithPrivileges<status_t>(condition, NO_ERROR, PERMISSION_DENIED)); } diff --git a/services/surfaceflinger/tests/DisplayConfigs_test.cpp b/services/surfaceflinger/tests/DisplayConfigs_test.cpp index 55b317382e..9f025a6aaa 100644 --- a/services/surfaceflinger/tests/DisplayConfigs_test.cpp +++ b/services/surfaceflinger/tests/DisplayConfigs_test.cpp @@ -22,7 +22,7 @@ #include <gui/ISurfaceComposer.h> #include <gui/SurfaceComposerClient.h> #include <private/gui/ComposerService.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <utils/Errors.h> #include <utils/Vector.h> @@ -38,7 +38,7 @@ namespace android { */ class RefreshRateRangeTest : public ::testing::Test { private: - int32_t initialDefaultConfig; + size_t initialDefaultMode; bool initialAllowGroupSwitching; float initialPrimaryMin; float initialPrimaryMax; @@ -49,25 +49,24 @@ protected: void SetUp() override { mDisplayToken = SurfaceComposerClient::getInternalDisplayToken(); status_t res = - SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, - &initialDefaultConfig, - &initialAllowGroupSwitching, - &initialPrimaryMin, - &initialPrimaryMax, - &initialAppRequestMin, - &initialAppRequestMax); + SurfaceComposerClient::getDesiredDisplayModeSpecs(mDisplayToken, + &initialDefaultMode, + &initialAllowGroupSwitching, + &initialPrimaryMin, + &initialPrimaryMax, + &initialAppRequestMin, + &initialAppRequestMax); ASSERT_EQ(res, NO_ERROR); } void TearDown() override { status_t res = - SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, - initialDefaultConfig, - initialAllowGroupSwitching, - initialPrimaryMin, - initialPrimaryMax, - initialAppRequestMin, - initialAppRequestMax); + SurfaceComposerClient::setDesiredDisplayModeSpecs(mDisplayToken, initialDefaultMode, + initialAllowGroupSwitching, + initialPrimaryMin, + initialPrimaryMax, + initialAppRequestMin, + initialAppRequestMax); ASSERT_EQ(res, NO_ERROR); } @@ -77,60 +76,59 @@ protected: }; TEST_F(RefreshRateRangeTest, setAllConfigs) { - Vector<DisplayConfig> configs; - status_t res = SurfaceComposerClient::getDisplayConfigs(mDisplayToken, &configs); + Vector<ui::DisplayMode> modes; + status_t res = SurfaceComposerClient::getDisplayModes(mDisplayToken, &modes); ASSERT_EQ(res, NO_ERROR); - ASSERT_GT(configs.size(), 0); - - for (size_t i = 0; i < configs.size(); i++) { - res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, - static_cast<int32_t>(i), false, - configs[i].refreshRate, - configs[i].refreshRate, - configs[i].refreshRate, - configs[i].refreshRate); + ASSERT_GT(modes.size(), 0); + + for (size_t i = 0; i < modes.size(); i++) { + res = SurfaceComposerClient::setDesiredDisplayModeSpecs(mDisplayToken, i, false, + modes[i].refreshRate, + modes[i].refreshRate, + modes[i].refreshRate, + modes[i].refreshRate); ASSERT_EQ(res, NO_ERROR); - int defaultConfig; + size_t defaultConfig; bool allowGroupSwitching; float primaryRefreshRateMin; float primaryRefreshRateMax; float appRequestRefreshRateMin; float appRequestRefreshRateMax; - res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfig, - &allowGroupSwitching, - &primaryRefreshRateMin, - &primaryRefreshRateMax, - &appRequestRefreshRateMin, - &appRequestRefreshRateMax); + res = SurfaceComposerClient::getDesiredDisplayModeSpecs(mDisplayToken, &defaultConfig, + &allowGroupSwitching, + &primaryRefreshRateMin, + &primaryRefreshRateMax, + &appRequestRefreshRateMin, + &appRequestRefreshRateMax); ASSERT_EQ(res, NO_ERROR); ASSERT_EQ(defaultConfig, i); ASSERT_EQ(allowGroupSwitching, false); - ASSERT_EQ(primaryRefreshRateMin, configs[i].refreshRate); - ASSERT_EQ(primaryRefreshRateMax, configs[i].refreshRate); - ASSERT_EQ(appRequestRefreshRateMin, configs[i].refreshRate); - ASSERT_EQ(appRequestRefreshRateMax, configs[i].refreshRate); + ASSERT_EQ(primaryRefreshRateMin, modes[i].refreshRate); + ASSERT_EQ(primaryRefreshRateMax, modes[i].refreshRate); + ASSERT_EQ(appRequestRefreshRateMin, modes[i].refreshRate); + ASSERT_EQ(appRequestRefreshRateMax, modes[i].refreshRate); } } void RefreshRateRangeTest::testSetAllowGroupSwitching(bool allowGroupSwitching) { - status_t res = SurfaceComposerClient::setDesiredDisplayConfigSpecs(mDisplayToken, 0, - allowGroupSwitching, 0.f, - 90.f, 0.f, 90.f); + status_t res = + SurfaceComposerClient::setDesiredDisplayModeSpecs(mDisplayToken, 0, allowGroupSwitching, + 0.f, 90.f, 0.f, 90.f); ASSERT_EQ(res, NO_ERROR); - int defaultConfig; + size_t defaultConfig; bool newAllowGroupSwitching; float primaryRefreshRateMin; float primaryRefreshRateMax; float appRequestRefreshRateMin; float appRequestRefreshRateMax; - res = SurfaceComposerClient::getDesiredDisplayConfigSpecs(mDisplayToken, &defaultConfig, - &newAllowGroupSwitching, - &primaryRefreshRateMin, - &primaryRefreshRateMax, - &appRequestRefreshRateMin, - &appRequestRefreshRateMax); + res = SurfaceComposerClient::getDesiredDisplayModeSpecs(mDisplayToken, &defaultConfig, + &newAllowGroupSwitching, + &primaryRefreshRateMin, + &primaryRefreshRateMax, + &appRequestRefreshRateMin, + &appRequestRefreshRateMax); ASSERT_EQ(res, NO_ERROR); ASSERT_EQ(defaultConfig, 0); ASSERT_EQ(newAllowGroupSwitching, allowGroupSwitching); diff --git a/services/surfaceflinger/tests/IPC_test.cpp b/services/surfaceflinger/tests/IPC_test.cpp index 4023c66e52..a8647c3e50 100644 --- a/services/surfaceflinger/tests/IPC_test.cpp +++ b/services/surfaceflinger/tests/IPC_test.cpp @@ -23,7 +23,7 @@ #include <gui/LayerState.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <utils/String8.h> #include <limits> @@ -227,10 +227,10 @@ public: ASSERT_EQ(NO_ERROR, mClient->initCheck()); mPrimaryDisplay = mClient->getInternalDisplayToken(); - DisplayConfig config; - mClient->getActiveDisplayConfig(mPrimaryDisplay, &config); - mDisplayWidth = config.resolution.getWidth(); - mDisplayHeight = config.resolution.getHeight(); + ui::DisplayMode mode; + mClient->getActiveDisplayMode(mPrimaryDisplay, &mode); + mDisplayWidth = mode.resolution.getWidth(); + mDisplayHeight = mode.resolution.getHeight(); Transaction setupTransaction; setupTransaction.setDisplayLayerStack(mPrimaryDisplay, 0); diff --git a/services/surfaceflinger/tests/LayerTransactionTest.h b/services/surfaceflinger/tests/LayerTransactionTest.h index 67585185f9..eba2c250a5 100644 --- a/services/surfaceflinger/tests/LayerTransactionTest.h +++ b/services/surfaceflinger/tests/LayerTransactionTest.h @@ -25,7 +25,7 @@ #include <gui/ISurfaceComposer.h> #include <gui/SurfaceComposerClient.h> #include <private/gui/ComposerService.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include "BufferGenerator.h" #include "utils/ScreenshotUtils.h" @@ -265,16 +265,16 @@ private: mDisplay = mClient->getInternalDisplayToken(); ASSERT_FALSE(mDisplay == nullptr) << "failed to get display"; - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(mDisplay, &config)); - mDisplayRect = Rect(config.resolution); + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(mDisplay, &mode)); + mDisplayRect = Rect(mode.resolution); mDisplayWidth = mDisplayRect.getWidth(); mDisplayHeight = mDisplayRect.getHeight(); // After a new buffer is queued, SurfaceFlinger is notified and will // latch the new buffer on next vsync. Let's heuristically wait for 3 // vsyncs. - mBufferPostDelay = static_cast<int32_t>(1e6 / config.refreshRate) * 3; + mBufferPostDelay = static_cast<int32_t>(1e6 / mode.refreshRate) * 3; mDisplayLayerStack = 0; diff --git a/services/surfaceflinger/tests/LayerUpdate_test.cpp b/services/surfaceflinger/tests/LayerUpdate_test.cpp index 6c56d209d4..ec826aed9c 100644 --- a/services/surfaceflinger/tests/LayerUpdate_test.cpp +++ b/services/surfaceflinger/tests/LayerUpdate_test.cpp @@ -36,9 +36,9 @@ protected: const auto display = SurfaceComposerClient::getInternalDisplayToken(); ASSERT_FALSE(display == nullptr); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - const ui::Size& resolution = config.resolution; + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + const ui::Size& resolution = mode.resolution; // Background surface mBGSurfaceControl = createLayer(String8("BG Test Surface"), resolution.getWidth(), diff --git a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp index db0c56f6aa..eaf54e38ec 100644 --- a/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp +++ b/services/surfaceflinger/tests/MultiDisplayLayerBounds_test.cpp @@ -37,13 +37,13 @@ protected: mMainDisplay = SurfaceComposerClient::getInternalDisplayToken(); SurfaceComposerClient::getDisplayState(mMainDisplay, &mMainDisplayState); - SurfaceComposerClient::getActiveDisplayConfig(mMainDisplay, &mMainDisplayConfig); + SurfaceComposerClient::getActiveDisplayMode(mMainDisplay, &mMainDisplayMode); sp<IGraphicBufferConsumer> consumer; BufferQueue::createBufferQueue(&mProducer, &consumer); consumer->setConsumerName(String8("Virtual disp consumer")); - consumer->setDefaultBufferSize(mMainDisplayConfig.resolution.getWidth(), - mMainDisplayConfig.resolution.getHeight()); + consumer->setDefaultBufferSize(mMainDisplayMode.resolution.getWidth(), + mMainDisplayMode.resolution.getHeight()); } virtual void TearDown() { @@ -59,7 +59,7 @@ protected: t.setDisplaySurface(mVirtualDisplay, mProducer); t.setDisplayLayerStack(mVirtualDisplay, layerStack); t.setDisplayProjection(mVirtualDisplay, mMainDisplayState.orientation, - Rect(layerStackSize), Rect(mMainDisplayConfig.resolution)); + Rect(layerStackSize), Rect(mMainDisplayMode.resolution)); }); } @@ -81,7 +81,7 @@ protected: } ui::DisplayState mMainDisplayState; - DisplayConfig mMainDisplayConfig; + ui::DisplayMode mMainDisplayMode; sp<IBinder> mMainDisplay; sp<IBinder> mVirtualDisplay; sp<IGraphicBufferProducer> mProducer; diff --git a/services/surfaceflinger/tests/ScreenCapture_test.cpp b/services/surfaceflinger/tests/ScreenCapture_test.cpp index 51ce1d3ff9..4598f9dc84 100644 --- a/services/surfaceflinger/tests/ScreenCapture_test.cpp +++ b/services/surfaceflinger/tests/ScreenCapture_test.cpp @@ -33,9 +33,9 @@ protected: const auto display = SurfaceComposerClient::getInternalDisplayToken(); ASSERT_FALSE(display == nullptr); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - const ui::Size& resolution = config.resolution; + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + const ui::Size& resolution = mode.resolution; // Background surface mBGSurfaceControl = createLayer(String8("BG Test Surface"), resolution.getWidth(), diff --git a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp index fa88ca5c57..a20d5c62d5 100644 --- a/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp +++ b/services/surfaceflinger/tests/SurfaceInterceptor_test.cpp @@ -27,7 +27,7 @@ #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> #include <private/gui/ComposerService.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <fstream> #include <random> @@ -267,9 +267,9 @@ void SurfaceInterceptorTest::setupBackgroundSurface() { const auto display = SurfaceComposerClient::getInternalDisplayToken(); ASSERT_FALSE(display == nullptr); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - const ui::Size& resolution = config.resolution; + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + const ui::Size& resolution = mode.resolution; // Background surface mBGSurfaceControl = diff --git a/services/surfaceflinger/tests/TransactionTestHarnesses.h b/services/surfaceflinger/tests/TransactionTestHarnesses.h index 33823d7057..89f608645d 100644 --- a/services/surfaceflinger/tests/TransactionTestHarnesses.h +++ b/services/surfaceflinger/tests/TransactionTestHarnesses.h @@ -40,9 +40,9 @@ public: ui::DisplayState displayState; SurfaceComposerClient::getDisplayState(displayToken, &displayState); - DisplayConfig displayConfig; - SurfaceComposerClient::getActiveDisplayConfig(displayToken, &displayConfig); - const ui::Size& resolution = displayConfig.resolution; + ui::DisplayMode displayMode; + SurfaceComposerClient::getActiveDisplayMode(displayToken, &displayMode); + const ui::Size& resolution = displayMode.resolution; sp<IBinder> vDisplay; sp<IGraphicBufferProducer> producer; diff --git a/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp b/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp index efa15f1f73..56e1ae90c3 100644 --- a/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp +++ b/services/surfaceflinger/tests/fakehwc/SFFakeHwc_test.cpp @@ -43,7 +43,7 @@ #include <hwbinder/ProcessState.h> #include <log/log.h> #include <private/gui/ComposerService.h> -#include <ui/DisplayConfig.h> +#include <ui/DisplayMode.h> #include <utils/Looper.h> #include <gmock/gmock.h> @@ -243,9 +243,8 @@ protected: mComposerClient = new SurfaceComposerClient; ASSERT_EQ(NO_ERROR, mComposerClient->initCheck()); - mReceiver.reset( - new DisplayEventReceiver(ISurfaceComposer::eVsyncSourceApp, - ISurfaceComposer::EventRegistration::configChanged)); + mReceiver.reset(new DisplayEventReceiver(ISurfaceComposer::eVsyncSourceApp, + ISurfaceComposer::EventRegistration::modeChanged)); mLooper = new Looper(false); mLooper->addFd(mReceiver->getFd(), 0, ALOOPER_EVENT_INPUT, processDisplayEvents, this); } @@ -305,7 +304,7 @@ protected: return false; } - bool waitForConfigChangedEvent(Display display, int32_t configId) { + bool waitForModeChangedEvent(Display display, int32_t modeId) { PhysicalDisplayId displayId(display); int waitCount = 20; while (waitCount--) { @@ -313,12 +312,12 @@ protected: auto event = mReceivedDisplayEvents.front(); mReceivedDisplayEvents.pop_front(); - ALOGV_IF(event.header.type == DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED, - "event config: displayId %s, configId %d", - to_string(event.header.displayId).c_str(), event.config.configId); + ALOGV_IF(event.header.type == DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE, + "event mode: displayId %s, modeId %d", + to_string(event.header.displayId).c_str(), event.modeChange.modeId); - if (event.header.type == DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED && - event.header.displayId == displayId && event.config.configId == configId) { + if (event.header.type == DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE && + event.header.displayId == displayId && event.modeChange.modeId == modeId) { return true; } } @@ -348,11 +347,11 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kExternalDisplayId); EXPECT_FALSE(display == nullptr); - DisplayConfig config; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - const ui::Size& resolution = config.resolution; + ui::DisplayMode mode; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + const ui::Size& resolution = mode.resolution; EXPECT_EQ(ui::Size(200, 400), resolution); - EXPECT_EQ(1e9f / 16'666'666, config.refreshRate); + EXPECT_EQ(1e9f / 16'666'666, mode.refreshRate); auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), @@ -380,8 +379,8 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kExternalDisplayId); EXPECT_TRUE(display == nullptr); - DisplayConfig config; - EXPECT_NE(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); + ui::DisplayMode mode; + EXPECT_NE(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); } } @@ -409,14 +408,14 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kExternalDisplayId); EXPECT_FALSE(display == nullptr); - DisplayConfig config; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(200, 400), config.resolution); - EXPECT_EQ(1e9f / 16'666'666, config.refreshRate); + ui::DisplayMode mode; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(200, 400), mode.resolution); + EXPECT_EQ(1e9f / 16'666'666, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -433,11 +432,11 @@ protected: } } - Vector<DisplayConfig> configs; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayConfigs(display, &configs)); - EXPECT_EQ(configs.size(), 2); + Vector<ui::DisplayMode> modes; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayModes(display, &modes)); + EXPECT_EQ(modes.size(), 2); - // change active config + // change active mode if (mIs2_4Client) { EXPECT_CALL(*mMockComposer, setActiveConfigWithConstraints(EXTERNAL_DISPLAY, 2, _, _)) @@ -447,28 +446,28 @@ protected: .WillOnce(Return(V2_1::Error::NONE)); } - for (int i = 0; i < configs.size(); i++) { - const auto& config = configs[i]; - if (config.resolution.getWidth() == 800) { + for (int i = 0; i < modes.size(); i++) { + const auto& mode = modes[i]; + if (mode.resolution.getWidth() == 800) { EXPECT_EQ(NO_ERROR, - SurfaceComposerClient::setDesiredDisplayConfigSpecs(display, i, false, - config.refreshRate, - config.refreshRate, - config.refreshRate, - config.refreshRate)); + SurfaceComposerClient::setDesiredDisplayModeSpecs(display, i, false, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate)); waitForDisplayTransaction(EXTERNAL_DISPLAY); - EXPECT_TRUE(waitForConfigChangedEvent(EXTERNAL_DISPLAY, i)); + EXPECT_TRUE(waitForModeChangedEvent(EXTERNAL_DISPLAY, i)); break; } } - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(1e9f / 11'111'111, config.refreshRate); + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(1e9f / 11'111'111, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -516,14 +515,14 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kExternalDisplayId); EXPECT_FALSE(display == nullptr); - DisplayConfig config; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(1e9f / 16'666'666, config.refreshRate); + ui::DisplayMode mode; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(1e9f / 16'666'666, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -540,11 +539,11 @@ protected: } } - Vector<DisplayConfig> configs; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayConfigs(display, &configs)); - EXPECT_EQ(configs.size(), 2); + Vector<ui::DisplayMode> modes; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayModes(display, &modes)); + EXPECT_EQ(modes.size(), 2); - // change active config + // change active mode if (mIs2_4Client) { EXPECT_CALL(*mMockComposer, setActiveConfigWithConstraints(EXTERNAL_DISPLAY, 3, _, _)) .WillOnce(Return(V2_4::Error::NONE)); @@ -553,28 +552,28 @@ protected: .WillOnce(Return(V2_1::Error::NONE)); } - for (int i = 0; i < configs.size(); i++) { - const auto& config = configs[i]; - if (config.refreshRate == 1e9f / 11'111'111) { + for (int i = 0; i < modes.size(); i++) { + const auto& mode = modes[i]; + if (mode.refreshRate == 1e9f / 11'111'111) { EXPECT_EQ(NO_ERROR, - SurfaceComposerClient::setDesiredDisplayConfigSpecs(display, i, false, - config.refreshRate, - config.refreshRate, - config.refreshRate, - config.refreshRate)); + SurfaceComposerClient::setDesiredDisplayModeSpecs(display, i, false, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate)); waitForDisplayTransaction(EXTERNAL_DISPLAY); - EXPECT_TRUE(waitForConfigChangedEvent(EXTERNAL_DISPLAY, i)); + EXPECT_TRUE(waitForModeChangedEvent(EXTERNAL_DISPLAY, i)); break; } } - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(1e9f / 11'111'111, config.refreshRate); + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(1e9f / 11'111'111, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -632,14 +631,14 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kExternalDisplayId); EXPECT_FALSE(display == nullptr); - DisplayConfig config; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(1e9f / 16'666'666, config.refreshRate); + ui::DisplayMode mode; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(1e9f / 16'666'666, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -656,11 +655,11 @@ protected: } } - Vector<DisplayConfig> configs; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayConfigs(display, &configs)); - EXPECT_EQ(configs.size(), 4); + Vector<ui::DisplayMode> modes; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayModes(display, &modes)); + EXPECT_EQ(modes.size(), 4); - // change active config to 800x1600@90Hz + // change active mode to 800x1600@90Hz if (mIs2_4Client) { EXPECT_CALL(*mMockComposer, setActiveConfigWithConstraints(EXTERNAL_DISPLAY, 3, _, _)) .WillOnce(Return(V2_4::Error::NONE)); @@ -669,29 +668,28 @@ protected: .WillOnce(Return(V2_1::Error::NONE)); } - for (size_t i = 0; i < configs.size(); i++) { - const auto& config = configs[i]; - if (config.resolution.getWidth() == 800 && config.refreshRate == 1e9f / 11'111'111) { + for (size_t i = 0; i < modes.size(); i++) { + const auto& mode = modes[i]; + if (mode.resolution.getWidth() == 800 && mode.refreshRate == 1e9f / 11'111'111) { EXPECT_EQ(NO_ERROR, - SurfaceComposerClient:: - setDesiredDisplayConfigSpecs(display, i, false, - configs[i].refreshRate, - configs[i].refreshRate, - configs[i].refreshRate, - configs[i].refreshRate)); + SurfaceComposerClient::setDesiredDisplayModeSpecs(display, i, false, + modes[i].refreshRate, + modes[i].refreshRate, + modes[i].refreshRate, + modes[i].refreshRate)); waitForDisplayTransaction(EXTERNAL_DISPLAY); - EXPECT_TRUE(waitForConfigChangedEvent(EXTERNAL_DISPLAY, i)); + EXPECT_TRUE(waitForModeChangedEvent(EXTERNAL_DISPLAY, i)); break; } } - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(1e9f / 11'111'111, config.refreshRate); + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(1e9f / 11'111'111, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -708,7 +706,7 @@ protected: } } - // change active config to 1600x3200@120Hz + // change active mode to 1600x3200@120Hz if (mIs2_4Client) { EXPECT_CALL(*mMockComposer, setActiveConfigWithConstraints(EXTERNAL_DISPLAY, 4, _, _)) .WillOnce(Return(V2_4::Error::NONE)); @@ -717,28 +715,28 @@ protected: .WillOnce(Return(V2_1::Error::NONE)); } - for (int i = 0; i < configs.size(); i++) { - const auto& config = configs[i]; - if (config.refreshRate == 1e9f / 8'333'333) { + for (int i = 0; i < modes.size(); i++) { + const auto& mode = modes[i]; + if (mode.refreshRate == 1e9f / 8'333'333) { EXPECT_EQ(NO_ERROR, - SurfaceComposerClient::setDesiredDisplayConfigSpecs(display, i, false, - config.refreshRate, - config.refreshRate, - config.refreshRate, - config.refreshRate)); + SurfaceComposerClient::setDesiredDisplayModeSpecs(display, i, false, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate)); waitForDisplayTransaction(EXTERNAL_DISPLAY); - EXPECT_TRUE(waitForConfigChangedEvent(EXTERNAL_DISPLAY, i)); + EXPECT_TRUE(waitForModeChangedEvent(EXTERNAL_DISPLAY, i)); break; } } - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(1600, 3200), config.resolution); - EXPECT_EQ(1e9f / 8'333'333, config.refreshRate); + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(1600, 3200), mode.resolution); + EXPECT_EQ(1e9f / 8'333'333, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -755,7 +753,7 @@ protected: } } - // change active config to 1600x3200@90Hz + // change active mode to 1600x3200@90Hz if (mIs2_4Client) { EXPECT_CALL(*mMockComposer, setActiveConfigWithConstraints(EXTERNAL_DISPLAY, 5, _, _)) .WillOnce(Return(V2_4::Error::NONE)); @@ -764,28 +762,28 @@ protected: .WillOnce(Return(V2_1::Error::NONE)); } - for (int i = 0; i < configs.size(); i++) { - const auto& config = configs[i]; - if (config.resolution.getWidth() == 1600 && config.refreshRate == 1e9f / 11'111'111) { + for (int i = 0; i < modes.size(); i++) { + const auto& mode = modes[i]; + if (mode.resolution.getWidth() == 1600 && mode.refreshRate == 1e9f / 11'111'111) { EXPECT_EQ(NO_ERROR, - SurfaceComposerClient::setDesiredDisplayConfigSpecs(display, i, false, - config.refreshRate, - config.refreshRate, - config.refreshRate, - config.refreshRate)); + SurfaceComposerClient::setDesiredDisplayModeSpecs(display, i, false, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate, + mode.refreshRate)); waitForDisplayTransaction(EXTERNAL_DISPLAY); - EXPECT_TRUE(waitForConfigChangedEvent(EXTERNAL_DISPLAY, i)); + EXPECT_TRUE(waitForModeChangedEvent(EXTERNAL_DISPLAY, i)); break; } } - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(1600, 3200), config.resolution); - EXPECT_EQ(1e9f / 11'111'111, config.refreshRate); + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(1600, 3200), mode.resolution); + EXPECT_EQ(1e9f / 11'111'111, mode.refreshRate); mFakeComposerClient->clearFrames(); { - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; auto surfaceControl = mComposerClient->createSurface(String8("Display Test Surface Foo"), resolution.getWidth(), resolution.getHeight(), @@ -822,8 +820,8 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kPrimaryDisplayId); EXPECT_TRUE(display == nullptr); - DisplayConfig config; - auto result = SurfaceComposerClient::getActiveDisplayConfig(display, &config); + ui::DisplayMode mode; + auto result = SurfaceComposerClient::getActiveDisplayMode(display, &mode); EXPECT_NE(NO_ERROR, result); } @@ -848,11 +846,11 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kPrimaryDisplayId); EXPECT_FALSE(display == nullptr); - DisplayConfig config; - auto result = SurfaceComposerClient::getActiveDisplayConfig(display, &config); + ui::DisplayMode mode; + auto result = SurfaceComposerClient::getActiveDisplayMode(display, &mode); EXPECT_EQ(NO_ERROR, result); - ASSERT_EQ(ui::Size(400, 200), config.resolution); - EXPECT_EQ(1e9f / 16'666'666, config.refreshRate); + ASSERT_EQ(ui::Size(400, 200), mode.resolution); + EXPECT_EQ(1e9f / 16'666'666, mode.refreshRate); } } @@ -881,14 +879,14 @@ protected: // Verify that the active mode and the supported moded are updated { - DisplayConfig config; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(1e9f / 11'111'111, config.refreshRate); + ui::DisplayMode mode; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(1e9f / 11'111'111, mode.refreshRate); - Vector<DisplayConfig> configs; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayConfigs(display, &configs)); - EXPECT_EQ(configs.size(), 1); + Vector<ui::DisplayMode> modes; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayModes(display, &modes)); + EXPECT_EQ(modes.size(), 1); } // Send another hotplug connected event @@ -919,27 +917,27 @@ protected: // Verify that the active mode and the supported moded are updated { - DisplayConfig config; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(1e9f / 16'666'666, config.refreshRate); + ui::DisplayMode mode; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(1e9f / 16'666'666, mode.refreshRate); } - Vector<DisplayConfig> configs; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayConfigs(display, &configs)); - EXPECT_EQ(configs.size(), 3); + Vector<ui::DisplayMode> modes; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getDisplayModes(display, &modes)); + EXPECT_EQ(modes.size(), 3); - EXPECT_EQ(ui::Size(800, 1600), configs[0].resolution); - EXPECT_EQ(1e9f / 16'666'666, configs[0].refreshRate); + EXPECT_EQ(ui::Size(800, 1600), modes[0].resolution); + EXPECT_EQ(1e9f / 16'666'666, modes[0].refreshRate); - EXPECT_EQ(ui::Size(800, 1600), configs[1].resolution); - EXPECT_EQ(1e9f / 11'111'111, configs[1].refreshRate); + EXPECT_EQ(ui::Size(800, 1600), modes[1].resolution); + EXPECT_EQ(1e9f / 11'111'111, modes[1].refreshRate); - EXPECT_EQ(ui::Size(800, 1600), configs[2].resolution); - EXPECT_EQ(1e9f / 8'333'333, configs[2].refreshRate); + EXPECT_EQ(ui::Size(800, 1600), modes[2].resolution); + EXPECT_EQ(1e9f / 8'333'333, modes[2].refreshRate); // Verify that we are able to switch to any of the modes - for (int i = configs.size() - 1; i >= 0; i--) { + for (int i = modes.size() - 1; i >= 0; i--) { const auto hwcId = i + 1; // Set up HWC expectations for the mode change if (mIs2_4Client) { @@ -952,22 +950,22 @@ protected: } EXPECT_EQ(NO_ERROR, - SurfaceComposerClient::setDesiredDisplayConfigSpecs(display, i, false, - configs[i].refreshRate, - configs[i].refreshRate, - configs[i].refreshRate, - configs[i].refreshRate)); + SurfaceComposerClient::setDesiredDisplayModeSpecs(display, i, false, + modes[i].refreshRate, + modes[i].refreshRate, + modes[i].refreshRate, + modes[i].refreshRate)); // We need to refresh twice - once to apply the pending mode change request, // and once to process the change. waitForDisplayTransaction(hwcDisplayId); waitForDisplayTransaction(hwcDisplayId); - EXPECT_TRUE(waitForConfigChangedEvent(hwcDisplayId, i)) + EXPECT_TRUE(waitForModeChangedEvent(hwcDisplayId, i)) << "Failure while switching to mode " << i; - DisplayConfig config; - EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); - EXPECT_EQ(ui::Size(800, 1600), config.resolution); - EXPECT_EQ(configs[i].refreshRate, config.refreshRate); + ui::DisplayMode mode; + EXPECT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); + EXPECT_EQ(ui::Size(800, 1600), mode.resolution); + EXPECT_EQ(modes[i].refreshRate, mode.refreshRate); } } @@ -1168,10 +1166,10 @@ protected: const auto display = SurfaceComposerClient::getPhysicalDisplayToken(kPrimaryDisplayId); ASSERT_FALSE(display == nullptr); - DisplayConfig config; - ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayConfig(display, &config)); + ui::DisplayMode mode; + ASSERT_EQ(NO_ERROR, SurfaceComposerClient::getActiveDisplayMode(display, &mode)); - const ui::Size& resolution = config.resolution; + const ui::Size& resolution = mode.resolution; mDisplayWidth = resolution.getWidth(); mDisplayHeight = resolution.getHeight(); diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp index 45bc29cabb..7cc0032bc8 100644 --- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp +++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp @@ -141,10 +141,10 @@ EventThreadTest::EventThreadTest() { createThread(std::move(vsyncSource)); mConnection = createConnection(mConnectionEventCallRecorder, - ISurfaceComposer::EventRegistration::configChanged | + ISurfaceComposer::EventRegistration::modeChanged | ISurfaceComposer::EventRegistration::frameRateOverride); mThrottledConnection = createConnection(mThrottledConnectionEventCallRecorder, - ISurfaceComposer::EventRegistration::configChanged, + ISurfaceComposer::EventRegistration::modeChanged, mThrottledConnectionUid); // A display must be connected for VSYNC events to be delivered. @@ -257,10 +257,10 @@ void EventThreadTest::expectConfigChangedEventReceivedByConnection( auto args = mConnectionEventCallRecorder.waitForCall(); ASSERT_TRUE(args.has_value()); const auto& event = std::get<0>(args.value()); - EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_CONFIG_CHANGED, event.header.type); + EXPECT_EQ(DisplayEventReceiver::DISPLAY_EVENT_MODE_CHANGE, event.header.type); EXPECT_EQ(expectedDisplayId, event.header.displayId); - EXPECT_EQ(expectedConfigId, event.config.configId); - EXPECT_EQ(expectedVsyncPeriod, event.config.vsyncPeriod); + EXPECT_EQ(expectedConfigId, event.modeChange.modeId); + EXPECT_EQ(expectedVsyncPeriod, event.modeChange.vsyncPeriod); } void EventThreadTest::expectUidFrameRateMappingEventReceivedByConnection( @@ -540,17 +540,17 @@ TEST_F(EventThreadTest, postHotplugExternalConnect) { } TEST_F(EventThreadTest, postConfigChangedPrimary) { - mThread->onConfigChanged(INTERNAL_DISPLAY_ID, DisplayModeId(7), 16666666); + mThread->onModeChanged(INTERNAL_DISPLAY_ID, DisplayModeId(7), 16666666); expectConfigChangedEventReceivedByConnection(INTERNAL_DISPLAY_ID, 7, 16666666); } TEST_F(EventThreadTest, postConfigChangedExternal) { - mThread->onConfigChanged(EXTERNAL_DISPLAY_ID, DisplayModeId(5), 16666666); + mThread->onModeChanged(EXTERNAL_DISPLAY_ID, DisplayModeId(5), 16666666); expectConfigChangedEventReceivedByConnection(EXTERNAL_DISPLAY_ID, 5, 16666666); } TEST_F(EventThreadTest, postConfigChangedPrimary64bit) { - mThread->onConfigChanged(DISPLAY_ID_64BIT, DisplayModeId(7), 16666666); + mThread->onModeChanged(DISPLAY_ID_64BIT, DisplayModeId(7), 16666666); expectConfigChangedEventReceivedByConnection(DISPLAY_ID_64BIT, 7, 16666666); } @@ -559,7 +559,7 @@ TEST_F(EventThreadTest, suppressConfigChanged) { sp<MockEventThreadConnection> suppressConnection = createConnection(suppressConnectionEventRecorder); - mThread->onConfigChanged(INTERNAL_DISPLAY_ID, DisplayModeId(9), 16666666); + mThread->onModeChanged(INTERNAL_DISPLAY_ID, DisplayModeId(9), 16666666); expectConfigChangedEventReceivedByConnection(INTERNAL_DISPLAY_ID, 9, 16666666); auto args = suppressConnectionEventRecorder.waitForCall(); diff --git a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp index 04cafbca72..fec590ee4c 100644 --- a/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp +++ b/services/surfaceflinger/tests/unittests/LayerHistoryTest.cpp @@ -113,12 +113,12 @@ protected: RefreshRateConfigs mConfigs{{DisplayMode::Builder(0) .setId(DisplayModeId(0)) .setVsyncPeriod(int32_t(LO_FPS_PERIOD)) - .setConfigGroup(0) + .setGroup(0) .build(), DisplayMode::Builder(1) .setId(DisplayModeId(1)) .setVsyncPeriod(int32_t(HI_FPS_PERIOD)) - .setConfigGroup(0) + .setGroup(0) .build()}, DisplayModeId(0)}; diff --git a/services/surfaceflinger/tests/unittests/LayerInfoTest.cpp b/services/surfaceflinger/tests/unittests/LayerInfoTest.cpp index d5c9b57c6e..be76e8fd2f 100644 --- a/services/surfaceflinger/tests/unittests/LayerInfoTest.cpp +++ b/services/surfaceflinger/tests/unittests/LayerInfoTest.cpp @@ -53,7 +53,7 @@ TEST_F(LayerInfoTest, prefersPresentTime) { for (int i = 1; i <= kNumFrames; i++) { frameTimes.push_back(FrameTimeData{.presentTime = kPeriod * i, .queueTime = 0, - .pendingConfigChange = false}); + .pendingModeChange = false}); } setFrameTimes(frameTimes); const auto averageFrameTime = calculateAverageFrameTime(); @@ -71,7 +71,7 @@ TEST_F(LayerInfoTest, fallbacksToQueueTimeIfNoPresentTime) { for (int i = 1; i <= kNumFrames; i++) { frameTimes.push_back(FrameTimeData{.presentTime = 0, .queueTime = kPeriod * i, - .pendingConfigChange = false}); + .pendingModeChange = false}); } setFrameTimes(frameTimes); setLastRefreshRate(Fps(20.0f)); // Set to some valid value @@ -89,7 +89,7 @@ TEST_F(LayerInfoTest, returnsNulloptIfThereWasConfigChange) { for (int i = 1; i <= kNumFrames; i++) { frameTimesWithoutConfigChange.push_back(FrameTimeData{.presentTime = period * i, .queueTime = period * i, - .pendingConfigChange = false}); + .pendingModeChange = false}); } setFrameTimes(frameTimesWithoutConfigChange); @@ -98,7 +98,7 @@ TEST_F(LayerInfoTest, returnsNulloptIfThereWasConfigChange) { { // Config change in the first record auto frameTimes = frameTimesWithoutConfigChange; - frameTimes[0].pendingConfigChange = true; + frameTimes[0].pendingModeChange = true; setFrameTimes(frameTimes); ASSERT_FALSE(calculateAverageFrameTime().has_value()); } @@ -106,7 +106,7 @@ TEST_F(LayerInfoTest, returnsNulloptIfThereWasConfigChange) { { // Config change in the last record auto frameTimes = frameTimesWithoutConfigChange; - frameTimes[frameTimes.size() - 1].pendingConfigChange = true; + frameTimes[frameTimes.size() - 1].pendingModeChange = true; setFrameTimes(frameTimes); ASSERT_FALSE(calculateAverageFrameTime().has_value()); } @@ -114,7 +114,7 @@ TEST_F(LayerInfoTest, returnsNulloptIfThereWasConfigChange) { { // Config change in the middle auto frameTimes = frameTimesWithoutConfigChange; - frameTimes[frameTimes.size() / 2].pendingConfigChange = true; + frameTimes[frameTimes.size() / 2].pendingModeChange = true; setFrameTimes(frameTimes); ASSERT_FALSE(calculateAverageFrameTime().has_value()); } @@ -131,12 +131,12 @@ TEST_F(LayerInfoTest, ignoresSmallPeriods) { for (int i = 1; i <= kNumIterations; i++) { frameTimes.push_back(FrameTimeData{.presentTime = kExpectedPeriod * i, .queueTime = 0, - .pendingConfigChange = false}); + .pendingModeChange = false}); // A duplicate frame frameTimes.push_back(FrameTimeData{.presentTime = kExpectedPeriod * i + kSmallPeriod, .queueTime = 0, - .pendingConfigChange = false}); + .pendingModeChange = false}); } setFrameTimes(frameTimes); const auto averageFrameTime = calculateAverageFrameTime(); @@ -156,7 +156,7 @@ TEST_F(LayerInfoTest, ignoresLargePeriods) { auto record = [&](nsecs_t time) { frameTimes.push_back( - FrameTimeData{.presentTime = time, .queueTime = 0, .pendingConfigChange = false}); + FrameTimeData{.presentTime = time, .queueTime = 0, .pendingModeChange = false}); }; auto time = kExpectedPeriod; // Start with non-zero time. diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp index 738ded18ac..376995f79e 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp @@ -81,24 +81,25 @@ protected: static inline const DisplayModeId HWC_CONFIG_ID_50 = DisplayModeId(6); // Test configs - DisplayModePtr mConfig60 = createConfig(HWC_CONFIG_ID_60, 0, Fps(60.0f).getPeriodNsecs()); - DisplayModePtr mConfig90 = createConfig(HWC_CONFIG_ID_90, 0, Fps(90.0f).getPeriodNsecs()); + DisplayModePtr mConfig60 = createDisplayMode(HWC_CONFIG_ID_60, 0, Fps(60.0f).getPeriodNsecs()); + DisplayModePtr mConfig90 = createDisplayMode(HWC_CONFIG_ID_90, 0, Fps(90.0f).getPeriodNsecs()); DisplayModePtr mConfig90DifferentGroup = - createConfig(HWC_CONFIG_ID_90, 1, Fps(90.0f).getPeriodNsecs()); + createDisplayMode(HWC_CONFIG_ID_90, 1, Fps(90.0f).getPeriodNsecs()); DisplayModePtr mConfig90DifferentResolution = - createConfig(HWC_CONFIG_ID_90, 0, Fps(90.0f).getPeriodNsecs(), ui::Size(111, 222)); - DisplayModePtr mConfig72 = createConfig(HWC_CONFIG_ID_72, 0, Fps(72.0f).getPeriodNsecs()); + createDisplayMode(HWC_CONFIG_ID_90, 0, Fps(90.0f).getPeriodNsecs(), ui::Size(111, 222)); + DisplayModePtr mConfig72 = createDisplayMode(HWC_CONFIG_ID_72, 0, Fps(72.0f).getPeriodNsecs()); DisplayModePtr mConfig72DifferentGroup = - createConfig(HWC_CONFIG_ID_72, 1, Fps(72.0f).getPeriodNsecs()); - DisplayModePtr mConfig120 = createConfig(HWC_CONFIG_ID_120, 0, Fps(120.0f).getPeriodNsecs()); + createDisplayMode(HWC_CONFIG_ID_72, 1, Fps(72.0f).getPeriodNsecs()); + DisplayModePtr mConfig120 = + createDisplayMode(HWC_CONFIG_ID_120, 0, Fps(120.0f).getPeriodNsecs()); DisplayModePtr mConfig120DifferentGroup = - createConfig(HWC_CONFIG_ID_120, 1, Fps(120.0f).getPeriodNsecs()); - DisplayModePtr mConfig30 = createConfig(HWC_CONFIG_ID_30, 0, Fps(30.0f).getPeriodNsecs()); + createDisplayMode(HWC_CONFIG_ID_120, 1, Fps(120.0f).getPeriodNsecs()); + DisplayModePtr mConfig30 = createDisplayMode(HWC_CONFIG_ID_30, 0, Fps(30.0f).getPeriodNsecs()); DisplayModePtr mConfig30DifferentGroup = - createConfig(HWC_CONFIG_ID_30, 1, Fps(30.0f).getPeriodNsecs()); + createDisplayMode(HWC_CONFIG_ID_30, 1, Fps(30.0f).getPeriodNsecs()); DisplayModePtr mConfig25DifferentGroup = - createConfig(HWC_CONFIG_ID_25, 1, Fps(25.0f).getPeriodNsecs()); - DisplayModePtr mConfig50 = createConfig(HWC_CONFIG_ID_50, 0, Fps(50.0f).getPeriodNsecs()); + createDisplayMode(HWC_CONFIG_ID_25, 1, Fps(25.0f).getPeriodNsecs()); + DisplayModePtr mConfig50 = createDisplayMode(HWC_CONFIG_ID_50, 0, Fps(50.0f).getPeriodNsecs()); // Test device configurations // The positions of the configs in the arrays below MUST match their IDs. For example, @@ -128,8 +129,8 @@ protected: RefreshRate mExpected60Config = {HWC_CONFIG_ID_60, mConfig60, Fps(60), RefreshRate::ConstructorTag(0)}; RefreshRate mExpectedAlmost60Config = {HWC_CONFIG_ID_60, - createConfig(HWC_CONFIG_ID_60, 0, 16666665), Fps(60), - RefreshRate::ConstructorTag(0)}; + createDisplayMode(HWC_CONFIG_ID_60, 0, 16666665), + Fps(60), RefreshRate::ConstructorTag(0)}; RefreshRate mExpected90Config = {HWC_CONFIG_ID_90, mConfig90, Fps(90), RefreshRate::ConstructorTag(0)}; RefreshRate mExpected90DifferentGroupConfig = {HWC_CONFIG_ID_90, mConfig90DifferentGroup, @@ -144,8 +145,8 @@ protected: RefreshRate mExpected120Config = {HWC_CONFIG_ID_120, mConfig120, Fps(120), RefreshRate::ConstructorTag(0)}; private: - DisplayModePtr createConfig(DisplayModeId configId, int32_t configGroup, int64_t vsyncPeriod, - ui::Size resolution = ui::Size()); + DisplayModePtr createDisplayMode(DisplayModeId modeId, int32_t group, int64_t vsyncPeriod, + ui::Size resolution = ui::Size()); }; using Builder = DisplayMode::Builder; @@ -162,12 +163,12 @@ RefreshRateConfigsTest::~RefreshRateConfigsTest() { ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name()); } -DisplayModePtr RefreshRateConfigsTest::createConfig(DisplayModeId configId, int32_t configGroup, - int64_t vsyncPeriod, ui::Size resolution) { - return DisplayMode::Builder(hal::HWConfigId(configId.value())) - .setId(configId) +DisplayModePtr RefreshRateConfigsTest::createDisplayMode(DisplayModeId modeId, int32_t group, + int64_t vsyncPeriod, ui::Size resolution) { + return DisplayMode::Builder(hal::HWConfigId(modeId.value())) + .setId(modeId) .setVsyncPeriod(int32_t(vsyncPeriod)) - .setConfigGroup(configGroup) + .setGroup(group) .setHeight(resolution.height) .setWidth(resolution.width) .build(); @@ -226,7 +227,7 @@ TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_storesFullRefreshRateMap_differe ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, {Fps(60), Fps(90)}}), 0); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); const auto& minRate90 = getMinRefreshRateByPolicy(*refreshRateConfigs); const auto& performanceRate90 = refreshRateConfigs->getMaxRefreshRateByPolicy(); @@ -252,7 +253,7 @@ TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_storesFullRefreshRateMap_differe ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, {Fps(60), Fps(90)}}), 0); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); const auto& minRate90 = getMinRefreshRateByPolicy(*refreshRateConfigs); const auto& performanceRate90 = refreshRateConfigs->getMaxRefreshRateByPolicy(); @@ -288,20 +289,20 @@ TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_getCurrentRefreshRate) { /*currentConfigId=*/HWC_CONFIG_ID_60); { auto current = refreshRateConfigs->getCurrentRefreshRate(); - EXPECT_EQ(current.getConfigId(), HWC_CONFIG_ID_60); + EXPECT_EQ(current.getModeId(), HWC_CONFIG_ID_60); } - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); { auto current = refreshRateConfigs->getCurrentRefreshRate(); - EXPECT_EQ(current.getConfigId(), HWC_CONFIG_ID_90); + EXPECT_EQ(current.getModeId(), HWC_CONFIG_ID_90); } ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy({HWC_CONFIG_ID_90, {Fps(90), Fps(90)}}), 0); { auto current = refreshRateConfigs->getCurrentRefreshRate(); - EXPECT_EQ(current.getConfigId(), HWC_CONFIG_ID_90); + EXPECT_EQ(current.getModeId(), HWC_CONFIG_ID_90); } } @@ -1196,30 +1197,30 @@ TEST_F(RefreshRateConfigsTest, groupSwitching) { ASSERT_EQ(HWC_CONFIG_ID_60, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); RefreshRateConfigs::Policy policy; - policy.defaultConfig = refreshRateConfigs->getCurrentPolicy().defaultConfig; + policy.defaultMode = refreshRateConfigs->getCurrentPolicy().defaultMode; policy.allowGroupSwitching = true; ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy(policy), 0); ASSERT_EQ(HWC_CONFIG_ID_90, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); // Verify that we won't change the group if seamless switch is required. layer.seamlessness = Seamlessness::OnlySeamless; ASSERT_EQ(HWC_CONFIG_ID_60, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); // Verify that we won't do a seamless switch if we request the same mode as the default - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); layer.desiredRefreshRate = Fps(60.0f); layer.name = "60Hz ExplicitDefault"; layer.seamlessness = Seamlessness::OnlySeamless; ASSERT_EQ(HWC_CONFIG_ID_90, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); // Verify that if the current config is in another group and there are no layers with // seamlessness=SeamedAndSeamless we'll go back to the default group. @@ -1228,11 +1229,11 @@ TEST_F(RefreshRateConfigsTest, groupSwitching) { layer.seamlessness = Seamlessness::Default; ASSERT_EQ(HWC_CONFIG_ID_60, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); // If there's a layer with seamlessness=SeamedAndSeamless, another layer with - // seamlessness=OnlySeamless can't change the config group. - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + // seamlessness=OnlySeamless can't change the mode group. + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); layer.seamlessness = Seamlessness::OnlySeamless; layers.push_back(LayerRequirement{.weight = 0.5f}); @@ -1245,14 +1246,14 @@ TEST_F(RefreshRateConfigsTest, groupSwitching) { ASSERT_EQ(HWC_CONFIG_ID_90, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); // If there's a layer with seamlessness=SeamedAndSeamless, another layer with - // seamlessness=Default can't change the config group. + // seamlessness=Default can't change the mode group. layers[0].seamlessness = Seamlessness::Default; ASSERT_EQ(HWC_CONFIG_ID_90, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); } TEST_F(RefreshRateConfigsTest, nonSeamlessVotePrefersSeamlessSwitches) { @@ -1262,7 +1263,7 @@ TEST_F(RefreshRateConfigsTest, nonSeamlessVotePrefersSeamlessSwitches) { // Allow group switching. RefreshRateConfigs::Policy policy; - policy.defaultConfig = refreshRateConfigs->getCurrentPolicy().defaultConfig; + policy.defaultMode = refreshRateConfigs->getCurrentPolicy().defaultMode; policy.allowGroupSwitching = true; ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy(policy), 0); @@ -1276,12 +1277,12 @@ TEST_F(RefreshRateConfigsTest, nonSeamlessVotePrefersSeamlessSwitches) { ASSERT_EQ(HWC_CONFIG_ID_60, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_120); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_120); ASSERT_EQ(HWC_CONFIG_ID_120, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); } TEST_F(RefreshRateConfigsTest, nonSeamlessExactAndSeamlessMultipleLayers) { @@ -1291,7 +1292,7 @@ TEST_F(RefreshRateConfigsTest, nonSeamlessExactAndSeamlessMultipleLayers) { // Allow group switching. RefreshRateConfigs::Policy policy; - policy.defaultConfig = refreshRateConfigs->getCurrentPolicy().defaultConfig; + policy.defaultMode = refreshRateConfigs->getCurrentPolicy().defaultMode; policy.allowGroupSwitching = true; ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy(policy), 0); @@ -1312,14 +1313,14 @@ TEST_F(RefreshRateConfigsTest, nonSeamlessExactAndSeamlessMultipleLayers) { ASSERT_EQ(HWC_CONFIG_ID_50, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); seamedLayer.name = "30Hz ExplicitDefault", seamedLayer.desiredRefreshRate = Fps(30.0f); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_30); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_30); ASSERT_EQ(HWC_CONFIG_ID_25, refreshRateConfigs->getBestRefreshRate(layers, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); } TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) { @@ -1338,7 +1339,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) { layers[0].desiredRefreshRate = fps; layers[0].focused = focused; return refreshRateConfigs->getBestRefreshRate(layers, {.touch = touchActive, .idle = false}) - .getConfigId(); + .getModeId(); }; ASSERT_GE(refreshRateConfigs->setDisplayManagerPolicy( @@ -1346,7 +1347,7 @@ TEST_F(RefreshRateConfigsTest, primaryVsAppRequestPolicy) { 0); EXPECT_EQ(HWC_CONFIG_ID_60, refreshRateConfigs->getBestRefreshRate({}, {.touch = false, .idle = false}) - .getConfigId()); + .getModeId()); EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::NoVote, Fps(90.f))); EXPECT_EQ(HWC_CONFIG_ID_30, getFrameRate(LayerVoteType::Min, Fps(90.f))); EXPECT_EQ(HWC_CONFIG_ID_60, getFrameRate(LayerVoteType::Max, Fps(90.f))); @@ -1398,7 +1399,7 @@ TEST_F(RefreshRateConfigsTest, idle) { refreshRateConfigs ->getBestRefreshRate(layers, {.touch = touchActive, .idle = true}, &consideredSignals) - .getConfigId(); + .getModeId(); // Refresh rate will be chosen by either touch state or idle state EXPECT_EQ(!touchActive, consideredSignals.idle); return configId; @@ -1421,10 +1422,10 @@ TEST_F(RefreshRateConfigsTest, idle) { // With no layers, idle should still be lower priority than touch boost. EXPECT_EQ(HWC_CONFIG_ID_90, refreshRateConfigs->getBestRefreshRate({}, {.touch = true, .idle = true}) - .getConfigId()); + .getModeId()); // Idle should be higher precedence than other layer frame rate considerations. - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); EXPECT_EQ(HWC_CONFIG_ID_60, getIdleFrameRate(LayerVoteType::NoVote, /*touchActive=*/false)); EXPECT_EQ(HWC_CONFIG_ID_60, getIdleFrameRate(LayerVoteType::Min, /*touchActive=*/false)); EXPECT_EQ(HWC_CONFIG_ID_60, getIdleFrameRate(LayerVoteType::Max, /*touchActive=*/false)); @@ -1437,7 +1438,7 @@ TEST_F(RefreshRateConfigsTest, idle) { // Idle should be applied rather than the current config when there are no layers. EXPECT_EQ(HWC_CONFIG_ID_60, refreshRateConfigs->getBestRefreshRate({}, {.touch = false, .idle = true}) - .getConfigId()); + .getModeId()); } TEST_F(RefreshRateConfigsTest, findClosestKnownFrameRate) { @@ -1628,19 +1629,19 @@ TEST_F(RefreshRateConfigsTest, getRefreshRateDivider) { const auto frameRate = Fps(30.f); EXPECT_EQ(1, refreshRateConfigs->getRefreshRateDivider(frameRate)); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_60); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_60); EXPECT_EQ(2, refreshRateConfigs->getRefreshRateDivider(frameRate)); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_72); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_72); EXPECT_EQ(0, refreshRateConfigs->getRefreshRateDivider(frameRate)); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); EXPECT_EQ(3, refreshRateConfigs->getRefreshRateDivider(frameRate)); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_120); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_120); EXPECT_EQ(4, refreshRateConfigs->getRefreshRateDivider(frameRate)); - refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90); + refreshRateConfigs->setCurrentModeId(HWC_CONFIG_ID_90); EXPECT_EQ(4, refreshRateConfigs->getRefreshRateDivider(Fps(22.5f))); EXPECT_EQ(4, refreshRateConfigs->getRefreshRateDivider(Fps(22.6f))); } diff --git a/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp index ceccd81f7a..bf07106afd 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateStatsTest.cpp @@ -53,7 +53,7 @@ protected: mRefreshRateConfigs = std::make_unique<RefreshRateConfigs>(configs, /*currentConfig=*/CONFIG_ID_0); - const auto currFps = mRefreshRateConfigs->getRefreshRateFromConfigId(CONFIG_ID_0).getFps(); + const auto currFps = mRefreshRateConfigs->getRefreshRateFromModeId(CONFIG_ID_0).getFps(); mRefreshRateStats = std::make_unique<RefreshRateStats>(mTimeStats, currFps, /*currentPowerMode=*/PowerMode::OFF); } @@ -62,7 +62,7 @@ protected: std::unique_ptr<RefreshRateConfigs> mRefreshRateConfigs; std::unique_ptr<RefreshRateStats> mRefreshRateStats; - DisplayModePtr createConfig(DisplayModeId configId, int32_t configGroup, int64_t vsyncPeriod); + DisplayModePtr createDisplayMode(DisplayModeId modeId, int32_t group, int64_t vsyncPeriod); }; RefreshRateStatsTest::RefreshRateStatsTest() { @@ -77,12 +77,12 @@ RefreshRateStatsTest::~RefreshRateStatsTest() { ALOGD("**** Tearing down after %s.%s\n", test_info->test_case_name(), test_info->name()); } -DisplayModePtr RefreshRateStatsTest::createConfig(DisplayModeId configId, int32_t configGroup, - int64_t vsyncPeriod) { - return DisplayMode::Builder(static_cast<hal::HWConfigId>(configId.value())) - .setId(configId) +DisplayModePtr RefreshRateStatsTest::createDisplayMode(DisplayModeId modeId, int32_t group, + int64_t vsyncPeriod) { + return DisplayMode::Builder(static_cast<hal::HWConfigId>(modeId.value())) + .setId(modeId) .setVsyncPeriod(static_cast<int32_t>(vsyncPeriod)) - .setConfigGroup(configGroup) + .setGroup(group) .build(); } @@ -91,7 +91,7 @@ namespace { * Test cases */ TEST_F(RefreshRateStatsTest, oneConfigTest) { - init({createConfig(CONFIG_ID_0, CONFIG_GROUP_0, VSYNC_90)}); + init({createDisplayMode(CONFIG_ID_0, CONFIG_GROUP_0, VSYNC_90)}); EXPECT_CALL(mTimeStats, recordRefreshRate(0, _)).Times(AtLeast(1)); EXPECT_CALL(mTimeStats, recordRefreshRate(90, _)).Times(AtLeast(1)); @@ -110,7 +110,7 @@ TEST_F(RefreshRateStatsTest, oneConfigTest) { EXPECT_LT(screenOff, times["ScreenOff"]); EXPECT_EQ(0u, times.count("90.00fps")); - const auto config0Fps = mRefreshRateConfigs->getRefreshRateFromConfigId(CONFIG_ID_0).getFps(); + const auto config0Fps = mRefreshRateConfigs->getRefreshRateFromModeId(CONFIG_ID_0).getFps(); mRefreshRateStats->setRefreshRate(config0Fps); mRefreshRateStats->setPowerMode(PowerMode::ON); screenOff = mRefreshRateStats->getTotalTimes()["ScreenOff"]; @@ -138,8 +138,8 @@ TEST_F(RefreshRateStatsTest, oneConfigTest) { } TEST_F(RefreshRateStatsTest, twoConfigsTest) { - init({createConfig(CONFIG_ID_0, CONFIG_GROUP_0, VSYNC_90), - createConfig(CONFIG_ID_1, CONFIG_GROUP_0, VSYNC_60)}); + init({createDisplayMode(CONFIG_ID_0, CONFIG_GROUP_0, VSYNC_90), + createDisplayMode(CONFIG_ID_1, CONFIG_GROUP_0, VSYNC_60)}); EXPECT_CALL(mTimeStats, recordRefreshRate(0, _)).Times(AtLeast(1)); EXPECT_CALL(mTimeStats, recordRefreshRate(60, _)).Times(AtLeast(1)); @@ -158,8 +158,8 @@ TEST_F(RefreshRateStatsTest, twoConfigsTest) { times = mRefreshRateStats->getTotalTimes(); EXPECT_LT(screenOff, times["ScreenOff"]); - const auto config0Fps = mRefreshRateConfigs->getRefreshRateFromConfigId(CONFIG_ID_0).getFps(); - const auto config1Fps = mRefreshRateConfigs->getRefreshRateFromConfigId(CONFIG_ID_1).getFps(); + const auto config0Fps = mRefreshRateConfigs->getRefreshRateFromModeId(CONFIG_ID_0).getFps(); + const auto config1Fps = mRefreshRateConfigs->getRefreshRateFromModeId(CONFIG_ID_1).getFps(); mRefreshRateStats->setRefreshRate(config0Fps); mRefreshRateStats->setPowerMode(PowerMode::ON); screenOff = mRefreshRateStats->getTotalTimes()["ScreenOff"]; diff --git a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp index e688e10e14..694790f86a 100644 --- a/services/surfaceflinger/tests/unittests/SchedulerTest.cpp +++ b/services/surfaceflinger/tests/unittests/SchedulerTest.cpp @@ -52,7 +52,7 @@ protected: SchedulerTest(); const scheduler::RefreshRateConfigs - mConfigs{{DisplayMode::Builder(0).setVsyncPeriod(16'666'667).setConfigGroup(0).build()}, + mConfigs{{DisplayMode::Builder(0).setVsyncPeriod(16'666'667).setGroup(0).build()}, DisplayModeId(0)}; mock::SchedulerCallback mSchedulerCallback; @@ -166,25 +166,25 @@ TEST_F(SchedulerTest, noLayerHistory) { mScheduler.chooseRefreshRateForContent(); } -TEST_F(SchedulerTest, testDispatchCachedReportedConfig) { +TEST_F(SchedulerTest, testDispatchCachedReportedMode) { // If the optional fields are cleared, the function should return before - // onConfigChange is called. + // onModeChange is called. mScheduler.clearOptionalFieldsInFeatures(); - EXPECT_NO_FATAL_FAILURE(mScheduler.dispatchCachedReportedConfig()); - EXPECT_CALL(*mEventThread, onConfigChanged(_, _, _)).Times(0); + EXPECT_NO_FATAL_FAILURE(mScheduler.dispatchCachedReportedMode()); + EXPECT_CALL(*mEventThread, onModeChanged(_, _, _)).Times(0); } -TEST_F(SchedulerTest, onNonPrimaryDisplayConfigChanged_invalidParameters) { - DisplayModeId configId = DisplayModeId(111); +TEST_F(SchedulerTest, onNonPrimaryDisplayModeChanged_invalidParameters) { + DisplayModeId modeId = DisplayModeId(111); nsecs_t vsyncPeriod = 111111; // If the handle is incorrect, the function should return before - // onConfigChange is called. + // onModeChange is called. Scheduler::ConnectionHandle invalidHandle = {.id = 123}; - EXPECT_NO_FATAL_FAILURE(mScheduler.onNonPrimaryDisplayConfigChanged(invalidHandle, - PHYSICAL_DISPLAY_ID, - configId, vsyncPeriod)); - EXPECT_CALL(*mEventThread, onConfigChanged(_, _, _)).Times(0); + EXPECT_NO_FATAL_FAILURE(mScheduler.onNonPrimaryDisplayModeChanged(invalidHandle, + PHYSICAL_DISPLAY_ID, modeId, + vsyncPeriod)); + EXPECT_CALL(*mEventThread, onModeChanged(_, _, _)).Times(0); } } // namespace android diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp index 2b5cb77b78..e32c4bf145 100644 --- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp +++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp @@ -246,7 +246,7 @@ void SetupNewDisplayDeviceInternalTest::setupNewDisplayDeviceInternalTest() { .setVsyncPeriod(DEFAULT_VSYNC_PERIOD) .setDpiX(DEFAULT_DPI) .setDpiY(DEFAULT_DPI) - .setConfigGroup(0) + .setGroup(0) .build(); DisplayModes modes{activeMode}; state.physical = {.id = *displayId, diff --git a/services/surfaceflinger/tests/unittests/TestableScheduler.h b/services/surfaceflinger/tests/unittests/TestableScheduler.h index d3e90e39af..3f9dd01588 100644 --- a/services/surfaceflinger/tests/unittests/TestableScheduler.h +++ b/services/surfaceflinger/tests/unittests/TestableScheduler.h @@ -80,20 +80,19 @@ public: return mFeatures.touch == Scheduler::TouchState::Active; } - void dispatchCachedReportedConfig() { + void dispatchCachedReportedMode() { std::lock_guard<std::mutex> lock(mFeatureStateLock); - return Scheduler::dispatchCachedReportedConfig(); + return Scheduler::dispatchCachedReportedMode(); } void clearOptionalFieldsInFeatures() { std::lock_guard<std::mutex> lock(mFeatureStateLock); - mFeatures.cachedConfigChangedParams.reset(); + mFeatures.cachedModeChangedParams.reset(); } - void onNonPrimaryDisplayConfigChanged(ConnectionHandle handle, PhysicalDisplayId displayId, - DisplayModeId configId, nsecs_t vsyncPeriod) { - return Scheduler::onNonPrimaryDisplayConfigChanged(handle, displayId, configId, - vsyncPeriod); + void onNonPrimaryDisplayModeChanged(ConnectionHandle handle, PhysicalDisplayId displayId, + DisplayModeId modeId, nsecs_t vsyncPeriod) { + return Scheduler::onNonPrimaryDisplayModeChanged(handle, displayId, modeId, vsyncPeriod); } ~TestableScheduler() { diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h index 3787c436a0..6aa6d3194d 100644 --- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h +++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h @@ -210,26 +210,26 @@ public: std::unique_ptr<scheduler::VSyncTracker> vsyncTracker, std::unique_ptr<EventThread> appEventThread, std::unique_ptr<EventThread> sfEventThread, - ISchedulerCallback* callback = nullptr, bool hasMultipleConfigs = false) { - DisplayModes configs{DisplayMode::Builder(0) - .setId(DisplayModeId(0)) - .setVsyncPeriod(16'666'667) - .setConfigGroup(0) - .build()}; - - if (hasMultipleConfigs) { - configs.emplace_back(DisplayMode::Builder(1) - .setId(DisplayModeId(1)) - .setVsyncPeriod(11'111'111) - .setConfigGroup(0) - .build()); + ISchedulerCallback* callback = nullptr, bool hasMultipleModes = false) { + DisplayModes modes{DisplayMode::Builder(0) + .setId(DisplayModeId(0)) + .setVsyncPeriod(16'666'667) + .setGroup(0) + .build()}; + + if (hasMultipleModes) { + modes.emplace_back(DisplayMode::Builder(1) + .setId(DisplayModeId(1)) + .setVsyncPeriod(11'111'111) + .setGroup(0) + .build()); } - const auto currConfig = DisplayModeId(0); + const auto currMode = DisplayModeId(0); mFlinger->mRefreshRateConfigs = - std::make_unique<scheduler::RefreshRateConfigs>(configs, currConfig); + std::make_unique<scheduler::RefreshRateConfigs>(modes, currMode); const auto currFps = - mFlinger->mRefreshRateConfigs->getRefreshRateFromConfigId(currConfig).getFps(); + mFlinger->mRefreshRateConfigs->getRefreshRateFromModeId(currMode).getFps(); mFlinger->mRefreshRateStats = std::make_unique<scheduler::RefreshRateStats>(*mFlinger->mTimeStats, currFps, /*powerMode=*/hal::PowerMode::OFF); @@ -643,7 +643,7 @@ public: .setVsyncPeriod(FakeHwcDisplayInjector::DEFAULT_VSYNC_PERIOD) .setDpiX(FakeHwcDisplayInjector::DEFAULT_DPI) .setDpiY(FakeHwcDisplayInjector::DEFAULT_DPI) - .setConfigGroup(0) + .setGroup(0) .build(); DisplayModes modes{activeMode}; @@ -756,7 +756,7 @@ public: private: void setVsyncEnabled(bool) override {} - void changeRefreshRate(const Scheduler::RefreshRate&, Scheduler::ConfigEvent) override {} + void changeRefreshRate(const Scheduler::RefreshRate&, Scheduler::ModeEvent) override {} void repaintEverythingForHWC() override {} void kernelTimerChanged(bool) override {} void triggerOnFrameRateOverridesChanged() {} diff --git a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h index 40437bfe1d..485b4acdce 100644 --- a/services/surfaceflinger/tests/unittests/mock/MockEventThread.h +++ b/services/surfaceflinger/tests/unittests/mock/MockEventThread.h @@ -33,7 +33,7 @@ public: MOCK_METHOD0(onScreenReleased, void()); MOCK_METHOD0(onScreenAcquired, void()); MOCK_METHOD2(onHotplugReceived, void(PhysicalDisplayId, bool)); - MOCK_METHOD3(onConfigChanged, void(PhysicalDisplayId, DisplayModeId, nsecs_t)); + MOCK_METHOD3(onModeChanged, void(PhysicalDisplayId, DisplayModeId, nsecs_t)); MOCK_METHOD2(onFrameRateOverridesChanged, void(PhysicalDisplayId, std::vector<FrameRateOverride>)); MOCK_CONST_METHOD1(dump, void(std::string&)); |