Switch to hardware bitmap in reader only if device can handle it

Closes #1460
This commit is contained in:
AntsyLich
2024-11-17 03:04:38 +06:00
parent 1909126921
commit e6d96bd348
4 changed files with 39 additions and 32 deletions

View File

@ -310,9 +310,18 @@ object ImageUtil {
val bottomOffset = topOffset + splitHeight
}
fun canUseCoilToDecode(imageSource: BufferedSource): Boolean {
val options = extractImageOptions(imageSource)
return maxOf(options.outWidth, options.outHeight) <= GLUtil.maxTextureSize
fun canUseHardwareBitmap(bitmap: Bitmap): Boolean {
return canUseHardwareBitmap(bitmap.width, bitmap.height)
}
fun canUseHardwareBitmap(imageSource: BufferedSource): Boolean {
return with(extractImageOptions(imageSource)) {
canUseHardwareBitmap(outWidth, outHeight)
}
}
private fun canUseHardwareBitmap(width: Int, height: Int): Boolean {
return maxOf(width, height) <= GLUtil.maxTextureSize
}
/**