mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 18:47:51 +02:00
Add option to lower the threshold for hardware bitmaps
Closes #1436 Closes #1486
This commit is contained in:
@ -3,10 +3,9 @@ package eu.kanade.tachiyomi.util.system
|
||||
import javax.microedition.khronos.egl.EGL10
|
||||
import javax.microedition.khronos.egl.EGLConfig
|
||||
import javax.microedition.khronos.egl.EGLContext
|
||||
import kotlin.math.max
|
||||
|
||||
object GLUtil {
|
||||
val maxTextureSize: Int by lazy {
|
||||
val DEVICE_TEXTURE_LIMIT: Int by lazy {
|
||||
// Get EGL Display
|
||||
val egl = EGLContext.getEGL() as EGL10
|
||||
val display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY)
|
||||
@ -38,10 +37,20 @@ object GLUtil {
|
||||
// Release
|
||||
egl.eglTerminate(display)
|
||||
|
||||
// Return largest texture size found, or default
|
||||
max(maximumTextureSize, IMAGE_MAX_BITMAP_DIMENSION)
|
||||
// Return largest texture size found (after making it a multiplier of [Multiplier]), or default
|
||||
if (maximumTextureSize > SAFE_TEXTURE_LIMIT) {
|
||||
(maximumTextureSize / MULTIPLIER) * MULTIPLIER
|
||||
} else {
|
||||
SAFE_TEXTURE_LIMIT
|
||||
}
|
||||
}
|
||||
|
||||
const val SAFE_TEXTURE_LIMIT: Int = 2048
|
||||
|
||||
val CUSTOM_TEXTURE_LIMIT_OPTIONS: List<Int> by lazy {
|
||||
val steps = ((DEVICE_TEXTURE_LIMIT / MULTIPLIER) - 1)
|
||||
List(steps) { (it + 2) * MULTIPLIER }.asReversed()
|
||||
}
|
||||
}
|
||||
|
||||
// Safe minimum default size
|
||||
private const val IMAGE_MAX_BITMAP_DIMENSION = 2048
|
||||
private const val MULTIPLIER: Int = 1024
|
||||
|
@ -320,8 +320,10 @@ object ImageUtil {
|
||||
}
|
||||
}
|
||||
|
||||
var hardwareBitmapThreshold: Int = GLUtil.SAFE_TEXTURE_LIMIT
|
||||
|
||||
private fun canUseHardwareBitmap(width: Int, height: Int): Boolean {
|
||||
return maxOf(width, height) <= GLUtil.maxTextureSize
|
||||
return maxOf(width, height) <= hardwareBitmapThreshold
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user