mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-12-18 03:01:55 +03:00
Improve hardware bitmap threshold option
Also `spotlessApply`
This commit is contained in:
parent
88aff2c77f
commit
d6dfd24548
4 changed files with 26 additions and 16 deletions
|
@ -332,21 +332,26 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||
basePreferences.displayProfile().set(uri.toString())
|
||||
}
|
||||
}
|
||||
val hardwareBitmapThresholdPref = basePreferences.hardwareBitmapThreshold()
|
||||
val hardwareBitmapThreshold by hardwareBitmapThresholdPref.collectAsState()
|
||||
return Preference.PreferenceGroup(
|
||||
title = stringResource(MR.strings.pref_category_reader),
|
||||
preferenceItems = persistentListOf(
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
pref = hardwareBitmapThresholdPref,
|
||||
pref = basePreferences.hardwareBitmapThreshold(),
|
||||
title = stringResource(MR.strings.pref_hardware_bitmap_threshold),
|
||||
subtitle = stringResource(
|
||||
MR.strings.pref_hardware_bitmap_threshold_summary,
|
||||
hardwareBitmapThreshold,
|
||||
),
|
||||
subtitleProvider = { value, options ->
|
||||
stringResource(MR.strings.pref_hardware_bitmap_threshold_summary, options[value].orEmpty())
|
||||
},
|
||||
enabled = GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT,
|
||||
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(),
|
||||
),
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
|
|
|
@ -3,6 +3,7 @@ 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 DEVICE_TEXTURE_LIMIT: Int by lazy {
|
||||
|
@ -38,18 +39,21 @@ object GLUtil {
|
|||
egl.eglTerminate(display)
|
||||
|
||||
// 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
|
||||
}
|
||||
max(maximumTextureSize, 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()
|
||||
val steps = DEVICE_TEXTURE_LIMIT / MULTIPLIER
|
||||
buildList(steps) {
|
||||
add(DEVICE_TEXTURE_LIMIT)
|
||||
for (step in steps downTo 2) {
|
||||
val value = step * MULTIPLIER
|
||||
if (value >= DEVICE_TEXTURE_LIMIT) continue
|
||||
add(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -393,6 +393,7 @@
|
|||
<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_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_crop_borders">Crop borders</string>
|
||||
<string name="pref_custom_brightness">Custom brightness</string>
|
||||
|
|
|
@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
@Composable
|
||||
fun <T: Any> StateFlow<Flow<PagingData<T>>>.collectAsLazyPagingItems(): LazyPagingItems<T> {
|
||||
fun <T : Any> StateFlow<Flow<PagingData<T>>>.collectAsLazyPagingItems(): LazyPagingItems<T> {
|
||||
val flow by collectAsState()
|
||||
return flow.collectAsLazyPagingItems()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue