Last active
February 3, 2020 21:26
-
-
Save courville/854ad922f14d9a19c0afb83e2607f49a to your computer and use it in GitHub Desktop.
find display modeId that matches currentMode resolution and desired refreshRate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Build.VERSION.SDK_INT >= 23) { | |
Display.Mode[] supportedModes = d.getSupportedModes(); | |
Display.Mode currentMode = d.getMode(); | |
// calculate wantedFps | |
float wantedFps = (float) ((double) video.fpsRate / (double) video.fpsScale); | |
int wantedModeId = 0; | |
// find corresponding wantedModeId for wantedFps | |
for (int i = 0; i < supportedModes.length; i++) { | |
if (supportedModes[i].matches(currentMode.getPhysicalWidth(), currentMode.getPhysicalHeight(), wantedFps)) { | |
wantedModeId = supportedModes[i].getModeId(); | |
} | |
} | |
if (wantedModeId != 0) { | |
lp.preferredDisplayModeId = wantedModeId; | |
mWindow.setAttributes(lp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment