diff --git a/android/app/src/main/kotlin/com/edde746/plezy/shared/GlCapabilities.kt b/android/app/src/main/kotlin/com/edde746/plezy/shared/GlCapabilities.kt index c468a7f54..8ce28be89 100644 --- a/android/app/src/main/kotlin/com/edde746/plezy/shared/GlCapabilities.kt +++ b/android/app/src/main/kotlin/com/edde746/plezy/shared/GlCapabilities.kt @@ -71,11 +71,18 @@ internal object GlCapabilities { if (!EGL14.eglChooseConfig(display, configAttributes, 0, configs, 0, 1, count, 0) || count[0] < 1) return null val config = configs[0] ?: return null surface = EGL14.eglCreatePbufferSurface( - display, config, intArrayOf(EGL14.EGL_WIDTH, 1, EGL14.EGL_HEIGHT, 1, EGL14.EGL_NONE), 0 + display, + config, + intArrayOf(EGL14.EGL_WIDTH, 1, EGL14.EGL_HEIGHT, 1, EGL14.EGL_NONE), + 0 ) if (surface == EGL14.EGL_NO_SURFACE) return null context = EGL14.eglCreateContext( - display, config, EGL14.EGL_NO_CONTEXT, intArrayOf(EGL14.EGL_CONTEXT_CLIENT_VERSION, 3, EGL14.EGL_NONE), 0 + display, + config, + EGL14.EGL_NO_CONTEXT, + intArrayOf(EGL14.EGL_CONTEXT_CLIENT_VERSION, 3, EGL14.EGL_NONE), + 0 ) if (context == EGL14.EGL_NO_CONTEXT) return null if (!EGL14.eglMakeCurrent(display, surface, surface, context)) return null diff --git a/android/app/src/main/kotlin/com/edde746/plezy/shared/PlayerSurfaceHost.kt b/android/app/src/main/kotlin/com/edde746/plezy/shared/PlayerSurfaceHost.kt index 499c78e65..e3f404f5e 100644 --- a/android/app/src/main/kotlin/com/edde746/plezy/shared/PlayerSurfaceHost.kt +++ b/android/app/src/main/kotlin/com/edde746/plezy/shared/PlayerSurfaceHost.kt @@ -70,25 +70,24 @@ internal object PlayerSurfaceHost { * compositor scales the plane to the view. Re-applied on every layout so a * container resize keeps the ratio. */ - fun createOsdSurface(activity: Activity, callback: SurfaceHolder.Callback, renderScale: Float = 1f): SurfaceView = - SurfaceView(activity).apply { - layoutParams = FrameLayout.LayoutParams( - FrameLayout.LayoutParams.MATCH_PARENT, - FrameLayout.LayoutParams.MATCH_PARENT - ) - holder.addCallback(callback) - holder.setFormat(PixelFormat.TRANSLUCENT) - setZOrderOnTop(false) - setZOrderMediaOverlay(true) - FlutterOverlayHelper.applyCompositionOrder(this, -1) - if (renderScale < 1f) { - addOnLayoutChangeListener { view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> - if (right - left == oldRight - oldLeft && bottom - top == oldBottom - oldTop) return@addOnLayoutChangeListener - val size = OsdPlanePolicy.fixedSizeFor(right - left, bottom - top, renderScale) ?: return@addOnLayoutChangeListener - (view as SurfaceView).holder.setFixedSize(size.width, size.height) - } + fun createOsdSurface(activity: Activity, callback: SurfaceHolder.Callback, renderScale: Float = 1f): SurfaceView = SurfaceView(activity).apply { + layoutParams = FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT + ) + holder.addCallback(callback) + holder.setFormat(PixelFormat.TRANSLUCENT) + setZOrderOnTop(false) + setZOrderMediaOverlay(true) + FlutterOverlayHelper.applyCompositionOrder(this, -1) + if (renderScale < 1f) { + addOnLayoutChangeListener { view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom -> + if (right - left == oldRight - oldLeft && bottom - top == oldBottom - oldTop) return@addOnLayoutChangeListener + val size = OsdPlanePolicy.fixedSizeFor(right - left, bottom - top, renderScale) ?: return@addOnLayoutChangeListener + (view as SurfaceView).holder.setFixedSize(size.width, size.height) } } + } fun attachToContent(activity: Activity, container: FrameLayout): ViewGroup { val contentView = activity.findViewById(android.R.id.content)