small state cleanup

This commit is contained in:
Chloe committed 2025-01-21 22:28:23 -07:00
1 parent dacabda792
commit c029fed37d
3 files changed
+17 -21

No files matched your search

@@ -119,12 +119,8 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
}
@RequiresApi(Build.VERSION_CODES.R)
fun updateRefreshRate() {
val maxRefreshRate = display.supportedModes.maxBy { it.refreshRate }.refreshRate
holder.surface.setFrameRate(
maxRefreshRate,
Surface.FRAME_RATE_COMPATIBILITY_DEFAULT
)
fun updateRefreshRate(refreshRate: Float) {
holder.surface.setFrameRate(refreshRate, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT)
}
override fun onPause() {
@@ -64,7 +64,7 @@ class Cocos2dxRenderer(private var handler: Cocos2dxGLSurfaceView) : GLSurfaceVi
private var screenWidth = 0
private var screenHeight = 0
var sendResizeEvents = false
var setFrameRate = false
var setFrameRate: Float? = null
private var mAnimationInterval: Long? = null
fun limitFrameRate(rate: Int) {
@@ -82,8 +82,9 @@ class Cocos2dxRenderer(private var handler: Cocos2dxGLSurfaceView) : GLSurfaceVi
}
override fun onSurfaceChanged(gl10: GL10?, width: Int, height: Int) {
if (setFrameRate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
handler.updateRefreshRate()
val chosenRefreshRate = setFrameRate
if (chosenRefreshRate != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
handler.updateRefreshRate(chosenRefreshRate)
}
}