Improve hardware bitmap threshold option

Also `spotlessApply`
This commit is contained in:
AntsyLich 2024-11-21 07:03:21 +06:00
parent 88aff2c77f
commit d6dfd24548
No known key found for this signature in database
4 changed files with 26 additions and 16 deletions

View File

@ -332,21 +332,26 @@ object SettingsAdvancedScreen : SearchableSettings {
basePreferences.displayProfile().set(uri.toString()) basePreferences.displayProfile().set(uri.toString())
} }
} }
val hardwareBitmapThresholdPref = basePreferences.hardwareBitmapThreshold()
val hardwareBitmapThreshold by hardwareBitmapThresholdPref.collectAsState()
return Preference.PreferenceGroup( return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_category_reader), title = stringResource(MR.strings.pref_category_reader),
preferenceItems = persistentListOf( preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference( Preference.PreferenceItem.ListPreference(
pref = hardwareBitmapThresholdPref, pref = basePreferences.hardwareBitmapThreshold(),
title = stringResource(MR.strings.pref_hardware_bitmap_threshold), title = stringResource(MR.strings.pref_hardware_bitmap_threshold),
subtitle = stringResource( subtitleProvider = { value, options ->
MR.strings.pref_hardware_bitmap_threshold_summary, stringResource(MR.strings.pref_hardware_bitmap_threshold_summary, options[value].orEmpty())
hardwareBitmapThreshold, },
),
enabled = GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT, enabled = GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT,
entries = GLUtil.CUSTOM_TEXTURE_LIMIT_OPTIONS entries = GLUtil.CUSTOM_TEXTURE_LIMIT_OPTIONS
.associateWith { it.toString() } .mapIndexed { index, option ->
val display = if (index == 0) {
stringResource(MR.strings.pref_hardware_bitmap_threshold_default, option)
} else {
option.toString()
}
option to display
}
.toMap()
.toImmutableMap(), .toImmutableMap(),
), ),
Preference.PreferenceItem.TextPreference( Preference.PreferenceItem.TextPreference(

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.util.system
import javax.microedition.khronos.egl.EGL10 import javax.microedition.khronos.egl.EGL10
import javax.microedition.khronos.egl.EGLConfig import javax.microedition.khronos.egl.EGLConfig
import javax.microedition.khronos.egl.EGLContext import javax.microedition.khronos.egl.EGLContext
import kotlin.math.max
object GLUtil { object GLUtil {
val DEVICE_TEXTURE_LIMIT: Int by lazy { val DEVICE_TEXTURE_LIMIT: Int by lazy {
@ -38,18 +39,21 @@ object GLUtil {
egl.eglTerminate(display) egl.eglTerminate(display)
// Return largest texture size found (after making it a multiplier of [Multiplier]), or default // Return largest texture size found (after making it a multiplier of [Multiplier]), or default
if (maximumTextureSize > SAFE_TEXTURE_LIMIT) { max(maximumTextureSize, SAFE_TEXTURE_LIMIT)
(maximumTextureSize / MULTIPLIER) * MULTIPLIER
} else {
SAFE_TEXTURE_LIMIT
}
} }
const val SAFE_TEXTURE_LIMIT: Int = 2048 const val SAFE_TEXTURE_LIMIT: Int = 2048
val CUSTOM_TEXTURE_LIMIT_OPTIONS: List<Int> by lazy { val CUSTOM_TEXTURE_LIMIT_OPTIONS: List<Int> by lazy {
val steps = ((DEVICE_TEXTURE_LIMIT / MULTIPLIER) - 1) val steps = DEVICE_TEXTURE_LIMIT / MULTIPLIER
List(steps) { (it + 2) * MULTIPLIER }.asReversed() buildList(steps) {
add(DEVICE_TEXTURE_LIMIT)
for (step in steps downTo 2) {
val value = step * MULTIPLIER
if (value >= DEVICE_TEXTURE_LIMIT) continue
add(value)
}
}
} }
} }

View File

@ -393,6 +393,7 @@
<string name="pref_show_reading_mode_summary">Briefly show current mode when reader is opened</string> <string name="pref_show_reading_mode_summary">Briefly show current mode when reader is opened</string>
<string name="pref_display_profile">Custom display profile</string> <string name="pref_display_profile">Custom display profile</string>
<string name="pref_hardware_bitmap_threshold">Custom hardware bitmap threshold</string> <string name="pref_hardware_bitmap_threshold">Custom hardware bitmap threshold</string>
<string name="pref_hardware_bitmap_threshold_default">Default (%d)</string>
<string name="pref_hardware_bitmap_threshold_summary">If reader loads a blank image incrementally reduce the threshold.\nSelected: %s</string> <string name="pref_hardware_bitmap_threshold_summary">If reader loads a blank image incrementally reduce the threshold.\nSelected: %s</string>
<string name="pref_crop_borders">Crop borders</string> <string name="pref_crop_borders">Crop borders</string>
<string name="pref_custom_brightness">Custom brightness</string> <string name="pref_custom_brightness">Custom brightness</string>