mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Allow toggling CRe's new dithering & scaling (#4922)
Smooth scaling toggle is per document, in the gear tab. Dithering is in the Dev top menu ;).
This commit is contained in:
@@ -5,6 +5,7 @@ local Document = require("document/document")
|
||||
local FontList = require("fontlist")
|
||||
local Geom = require("ui/geometry")
|
||||
local RenderImage = require("ui/renderimage")
|
||||
local Screen = require("device").screen
|
||||
local ffi = require("ffi")
|
||||
local C = ffi.C
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
@@ -21,6 +22,7 @@ local CreDocument = Document:new{
|
||||
_document = false,
|
||||
_loaded = false,
|
||||
_view_mode = nil,
|
||||
_smooth_scaling = false,
|
||||
|
||||
line_space_percent = 100,
|
||||
default_font = "Noto Serif",
|
||||
@@ -368,14 +370,15 @@ function CreDocument:drawCurrentView(target, x, y, rect, pos)
|
||||
-- same buffer. And it could only change when some other methods
|
||||
-- from here are called
|
||||
|
||||
-- If in night mode, ask crengine to invert all images, so they
|
||||
-- If in night mode, we ask crengine to invert all images, so they
|
||||
-- get displayed in their original colors when the whole screen
|
||||
-- is inverted by night mode
|
||||
local invert_images = G_reader_settings:isTrue("night_mode")
|
||||
-- We also honor the current smooth scaling setting,
|
||||
-- as well as the global SW dithering setting.
|
||||
|
||||
-- local start_clock = os.clock()
|
||||
self._drawn_images_count, self._drawn_images_surface_ratio =
|
||||
self._document:drawCurrentPage(self.buffer, self.render_color, invert_images)
|
||||
self._document:drawCurrentPage(self.buffer, self.render_color, Screen.night_mode, self._smooth_scaling, Screen.sw_dithering)
|
||||
-- print(string.format("CreDocument:drawCurrentView: Rendering took %9.3f ms", (os.clock() - start_clock) * 1000))
|
||||
|
||||
-- start_clock = os.clock()
|
||||
@@ -728,6 +731,11 @@ function CreDocument:setPageMargins(left, top, right, bottom)
|
||||
self._document:setIntProperty("crengine.page.margin.bottom", bottom)
|
||||
end
|
||||
|
||||
function CreDocument:setImageScaling(toggle)
|
||||
logger.dbg("CreDocument: set smooth scaling", toggle)
|
||||
self._smooth_scaling = toggle
|
||||
end
|
||||
|
||||
function CreDocument:setFloatingPunctuation(enabled)
|
||||
-- FIXME: occasional segmentation fault when toggling floating punctuation
|
||||
logger.dbg("CreDocument: set floating punctuation", enabled)
|
||||
|
||||
Reference in New Issue
Block a user