fix: Make it so bitmap also use coil pipeline if possible

This commit is contained in:
Ahmad Ansori Palembani 2024-05-31 05:41:04 +07:00
parent 70230fa16d
commit b4317f8f3b
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 13 additions and 1 deletions

View file

@ -224,7 +224,15 @@ open class ReaderPageImageView @JvmOverloads constructor(
},
)
val useCoilPipeline = if (isWebtoon && data is BufferedSource) !ImageUtil.isMaxTextureSizeExceeded(data) else false
val useCoilPipeline = if (isWebtoon) {
when (data) {
is BitmapDrawable -> !ImageUtil.isMaxTextureSizeExceeded(data.bitmap)
is BufferedSource -> !ImageUtil.isMaxTextureSizeExceeded(data)
else -> false
}
} else {
false
}
if (useCoilPipeline) {
val request = ImageRequest.Builder(context)

View file

@ -783,6 +783,10 @@ object ImageUtil {
"image/jxl" to "jxl",
)
fun isMaxTextureSizeExceeded(bitmap: Bitmap): Boolean {
return maxOf(bitmap.width, bitmap.height) > GLUtil.maxTextureSize
}
fun isMaxTextureSizeExceeded(imageSource: BufferedSource): Boolean {
val opts = extractImageOptions(imageSource)
return maxOf(opts.outWidth, opts.outHeight) > GLUtil.maxTextureSize