mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Separate isHardwareThresholdExceeded from isMaxTextureSizeExceeded
This commit is contained in:
parent
23db3244ce
commit
332f3f7ee6
3 changed files with 23 additions and 9 deletions
|
@ -50,7 +50,7 @@ class TachiyomiImageDecoder(private val resources: ImageSource, private val opti
|
|||
if (
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||
options.bitmapConfig == Bitmap.Config.HARDWARE &&
|
||||
!ImageUtil.isMaxTextureSizeExceeded(bitmap)
|
||||
!ImageUtil.isHardwareThresholdExceeded(bitmap)
|
||||
) {
|
||||
val hwBitmap = bitmap.copy(Bitmap.Config.HARDWARE, false)
|
||||
if (hwBitmap != null) {
|
||||
|
|
|
@ -234,7 +234,7 @@ open class ReaderPageImageView @JvmOverloads constructor(
|
|||
is BufferedSource -> {
|
||||
// SSIV doesn't tile bitmaps, so if the image exceeded max texture size it won't load regardless.
|
||||
if (!isWebtoon || ImageUtil.isMaxTextureSizeExceeded(data)) {
|
||||
setHardwareConfig(!ImageUtil.isMaxTextureSizeExceeded(data))
|
||||
setHardwareConfig(!ImageUtil.isHardwareThresholdExceeded(data))
|
||||
setImage(ImageSource.inputStream(data.inputStream()))
|
||||
isVisible = true
|
||||
return@apply
|
||||
|
|
|
@ -776,20 +776,34 @@ object ImageUtil {
|
|||
return options
|
||||
}
|
||||
|
||||
fun isMaxTextureSizeExceeded(source: BufferedSource): Boolean =
|
||||
extractImageOptions(source).let { opts -> isMaxTextureSizeExceeded(opts.outWidth, opts.outHeight) }
|
||||
fun isHardwareThresholdExceeded(source: BufferedSource): Boolean = extractImageOptions(source).let { opts ->
|
||||
isHardwareThresholdExceeded(opts.outWidth, opts.outHeight)
|
||||
}
|
||||
|
||||
fun isMaxTextureSizeExceeded(drawable: BitmapDrawable): Boolean =
|
||||
isMaxTextureSizeExceeded(drawable.bitmap)
|
||||
fun isHardwareThresholdExceeded(drawable: BitmapDrawable): Boolean =
|
||||
isHardwareThresholdExceeded(drawable.bitmap)
|
||||
|
||||
fun isMaxTextureSizeExceeded(bitmap: Bitmap): Boolean =
|
||||
isMaxTextureSizeExceeded(bitmap.width, bitmap.height)
|
||||
fun isHardwareThresholdExceeded(bitmap: Bitmap): Boolean =
|
||||
isHardwareThresholdExceeded(bitmap.width, bitmap.height)
|
||||
|
||||
var hardwareBitmapThreshold: Int = GLUtil.SAFE_TEXTURE_LIMIT
|
||||
|
||||
private fun isMaxTextureSizeExceeded(width: Int, height: Int): Boolean {
|
||||
private fun isHardwareThresholdExceeded(width: Int, height: Int): Boolean {
|
||||
if (minOf(width, height) <= 0) return false
|
||||
|
||||
return maxOf(width, height) > hardwareBitmapThreshold
|
||||
}
|
||||
|
||||
fun isMaxTextureSizeExceeded(source: BufferedSource): Boolean = extractImageOptions(source).let { opts ->
|
||||
isMaxTextureSizeExceeded(opts.outWidth, opts.outHeight)
|
||||
}
|
||||
|
||||
fun isMaxTextureSizeExceeded(bitmap: Bitmap): Boolean =
|
||||
isMaxTextureSizeExceeded(bitmap.width, bitmap.height)
|
||||
|
||||
private fun isMaxTextureSizeExceeded(width: Int, height: Int): Boolean {
|
||||
if (minOf(width, height) <= 0) return false
|
||||
|
||||
return maxOf(width, height) > GLUtil.DEVICE_TEXTURE_LIMIT
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue