Warn if color rendering is enabled on a grayscale device. (#5871)

* Make sure the Color menu is accessible on GrayScale device, in the event
one would have inherited a color-enabled settings from another
device...

* Warn on startup if color rendering is enabled on a grayscale device.

A non-exhaustive lists of things such a setup would break:
* same-to-same blitbuffers for pretty much every rendering engine
* same-to-same blitting codepaths and fast-paths
* software dithering in CRe
reviewable/pr5880/r1
NiLuJe 4 years ago committed by GitHub
parent 687074fa1f
commit aed27a5a16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -198,7 +198,8 @@ if Device:canToggleGSensor() then
common_settings.screen_toggle_gsensor = require("ui/elements/screen_toggle_gsensor")
end
if Screen.isColorScreen() then
-- NOTE: Allow disabling color if it's mistakenly enabled on a Grayscale screen (after a settings import?)
if Screen:isColorEnabled() or Screen:isColorScreen() then
common_settings.color_rendering = require("ui/elements/screen_color_menu_table")
end

@ -4,9 +4,10 @@ local UIManager = require("ui/uimanager")
local CanvasContext = require("document/canvascontext")
local _ = require("gettext")
-- NOTE: Again, make sure this is enabled if for some reason color is enabled on a Grayscale screen...
return {
text = _("Color rendering"),
enabled_func = Screen.isColorScreen,
enabled = Screen:isColorEnabled() or Screen:isColorScreen(),
checked_func = Screen.isColorEnabled,
callback = function()
local new_val = not Screen.isColorEnabled()

@ -182,6 +182,25 @@ if Device:hasColorScreen() and not G_reader_settings:has("color_rendering") then
})
end
-- Conversely, if color is enabled on a Grayscale screen (e.g., after importing settings from a color device), warn that it'll break stuff and adversely affect performance.
if G_reader_settings:isTrue("color_rendering") and not Device:hasColorScreen() then
local ConfirmBox = require("ui/widget/confirmbox")
UIManager:show(ConfirmBox:new{
text = _("Color rendering is mistakenly enabled on your grayscale device.\nThis will subtly break some features, and adversely affect performance."),
cancel_text = _("Ignore"),
cancel_callback = function()
return
end,
ok_text = _("Disable"),
ok_callback = function()
local Event = require("ui/event")
G_reader_settings:delSetting("color_rendering")
CanvasContext:setColorRenderingEnabled(false)
UIManager:broadcastEvent(Event:new("ColorRenderingUpdate"))
end,
})
end
-- Helpers
local lfs = require("libs/libkoreader-lfs")
local function retryLastFile()

Loading…
Cancel
Save