From 1605409c602358f8fd2c71cbd0616a4d16c3d500 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 18 Feb 2019 08:01:00 -0800 Subject: [PATCH] rename runtimectl to document/canvascontext --- frontend/cache.lua | 4 +- frontend/device/android/device.lua | 12 +++ frontend/device/generic/device.lua | 1 + frontend/document/canvascontext.lua | 61 +++++++++++++ frontend/document/credocument.lua | 10 +-- frontend/document/document.lua | 4 +- frontend/document/koptinterface.lua | 25 +++--- frontend/document/pdfdocument.lua | 8 +- frontend/document/picdocument.lua | 4 +- frontend/runtimectl.lua | 85 ------------------- .../ui/elements/screen_color_menu_table.lua | 4 +- frontend/ui/font.lua | 16 +++- frontend/ui/rendertext.lua | 4 +- .../ui/widget/container/inputcontainer.lua | 4 +- .../ui/widget/container/widgetcontainer.lua | 4 +- reader.lua | 18 ++-- spec/unit/autofrontlight_spec.lua | 4 +- spec/unit/autosuspend_spec.lua | 2 +- spec/unit/background_runner_spec.lua | 4 +- spec/unit/background_task_plugin_spec.lua | 2 +- spec/unit/batterystat_spec.lua | 4 +- spec/unit/commonrequire.lua | 4 +- spec/unit/device_spec.lua | 2 +- spec/unit/filemanager_spec.lua | 2 +- spec/unit/readerfooter_spec.lua | 2 +- spec/unit/readerhighlight_spec.lua | 2 +- spec/unit/readerlink_spec.lua | 2 +- spec/unit/readerview_spec.lua | 2 +- 28 files changed, 146 insertions(+), 150 deletions(-) create mode 100644 frontend/document/canvascontext.lua delete mode 100644 frontend/runtimectl.lua diff --git a/frontend/cache.lua b/frontend/cache.lua index 7bc4a42dc..129c82be5 100644 --- a/frontend/cache.lua +++ b/frontend/cache.lua @@ -7,8 +7,8 @@ local lfs = require("libs/libkoreader-lfs") local logger = require("logger") local md5 = require("ffi/MD5") -local runtimectl = require("runtimectl") -if runtimectl.should_restrict_JIT then +local CanvasContext = require("document/canvascontext") +if CanvasContext.should_restrict_JIT then require("jit").off(true, true) end diff --git a/frontend/device/android/device.lua b/frontend/device/android/device.lua index 2526fb962..039f582f1 100644 --- a/frontend/device/android/device.lua +++ b/frontend/device/android/device.lua @@ -27,6 +27,18 @@ local Device = Generic:new{ hasClipboard = yes, hasColorScreen = yes, hasOTAUpdates = canUpdateApk, + --[[ + Disable jit on some modules on android to make koreader on Android more stable. + + The strategy here is that we only use precious mcode memory (jitting) + on deep loops like the several blitting methods in blitbuffer.lua and + the pixel-copying methods in mupdf.lua. So that a small amount of mcode + memory (64KB) allocated when koreader is launched in the android.lua + is enough for the program and it won't need to jit other parts of lua + code and thus won't allocate mcode memory any more which by our + observation will be harder and harder as we run koreader. + ]]-- + should_restrict_JIT = true, } function Device:init() diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index 0496783f9..2bf18c760 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -9,6 +9,7 @@ local Device = { charging_mode = false, survive_screen_saver = false, is_cover_closed = false, + should_restrict_JIT = false, model = nil, powerd = nil, screen = nil, diff --git a/frontend/document/canvascontext.lua b/frontend/document/canvascontext.lua new file mode 100644 index 000000000..92b164835 --- /dev/null +++ b/frontend/document/canvascontext.lua @@ -0,0 +1,61 @@ +local Mupdf = require("ffi/mupdf") + +local CanvasContext = { + should_restrict_JIT = false, + is_color_rendering_enabled = false, + is_bgr = false, +} + +--[[ +Initialize CanvasContext with settings from device. + +The following key is required for a device object: + +* should_restrict_JIT: bool +* hasBGRFrameBuffer: function() -> boolean +* screen: object with following methods: + * getWidth() -> int + * getHeight() -> int + * getDPI() -> int + * getSize() -> Rect + * scaleBySize(int) -> int +]]-- +function CanvasContext:init(device) + self.screen = device.screen + self.isAndroid = device.isAndroid + self.isKindle = device.isKindle + self.should_restrict_JIT = device.should_restrict_JIT + + -- NOTE: Kobo's fb is BGR, not RGB. Handle the conversion in MuPDF if needed. + if device:hasBGRFrameBuffer() then + self.is_bgr = true + Mupdf.bgr = true + end +end + + +function CanvasContext:setColorRenderingEnabled(val) + self.is_color_rendering_enabled = val +end + +function CanvasContext:getWidth() + return self.screen:getWidth() +end + +function CanvasContext:getHeight() + return self.screen:getHeight() +end + +function CanvasContext:getDPI() + return self.screen:getDPI() +end + +function CanvasContext:getSize() + return self.screen:getSize() +end + +function CanvasContext:scaleBySize(px) + return self.screen:scaleBySize(px) +end + +return CanvasContext diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index c80cc4cf7..299d23b81 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -4,7 +4,7 @@ local Document = require("document/document") local Font = require("ui/font") local Geom = require("ui/geometry") local RenderImage = require("ui/renderimage") -local Runtimectl = require("runtimectl") +local CanvasContext = require("document/canvascontext") local ffi = require("ffi") local C = ffi.C local lfs = require("libs/libkoreader-lfs") @@ -116,7 +116,7 @@ function CreDocument:init() self._view_mode = DCREREADER_VIEW_MODE == "scroll" and self.SCROLL_VIEW_MODE or self.PAGE_VIEW_MODE local ok - ok, self._document = pcall(cre.newDocView, Runtimectl:getRenderWidth(), Runtimectl:getRenderHeight(), self._view_mode) + ok, self._document = pcall(cre.newDocView, CanvasContext:getWidth(), CanvasContext:getHeight(), self._view_mode) if not ok then error(self._document) -- will contain error message end @@ -163,8 +163,8 @@ function CreDocument:setupDefaultView() self._document:setStringProperty("crengine.font.fallback.face", G_reader_settings:readSetting("fallback_font") or self.fallback_font) - -- adjust font sizes according to dpi set in runtime - self._document:adjustFontSizes(Runtimectl:getRenderDPI()) + -- adjust font sizes according to dpi set in canvas context + self._document:adjustFontSizes(CanvasContext:getDPI()) -- set top status bar font size if G_reader_settings:readSetting("cre_header_status_font_size") then @@ -191,7 +191,7 @@ function CreDocument:render() -- load document before rendering self:loadDocument() -- set visible page count in landscape - if math.max(Runtimectl:getRenderWidth(), Runtimectl:getRenderHeight()) / Runtimectl:getRenderDPI() + if math.max(CanvasContext:getWidth(), CanvasContext:getHeight()) / CanvasContext:getDPI() < DCREREADER_TWO_PAGE_THRESHOLD then self:setVisiblePageCount(1) end diff --git a/frontend/document/document.lua b/frontend/document/document.lua index 7de98ccfd..83bb7dad1 100644 --- a/frontend/document/document.lua +++ b/frontend/document/document.lua @@ -3,7 +3,7 @@ local Cache = require("cache") local CacheItem = require("cacheitem") local Configurable = require("configurable") local DrawContext = require("ffi/drawcontext") -local Runtimectl = require("runtimectl") +local CanvasContext = require("document/canvascontext") local Geom = require("ui/geometry") local Math = require("optmath") local TileCacheItem = require("document/tilecacheitem") @@ -291,7 +291,7 @@ function Document:findText() end function Document:updateColorRendering() - if self.is_color_capable and Runtimectl.is_color_rendering_enabled then + if self.is_color_capable and CanvasContext.is_color_rendering_enabled then self.render_color = true else self.render_color = false diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index 7941e609d..37b4f1314 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -9,7 +9,7 @@ local TileCacheItem = require("document/tilecacheitem") local logger = require("logger") local serial = require("serialize") local util = require("ffi/util") -local Runtimectl = require("runtimectl") +local CanvasContext = require("document/canvascontext") local KoptInterface = { ocrengine = "ocrengine", @@ -88,7 +88,7 @@ function KoptInterface:createContext(doc, pageno, bbox) -- Now koptcontext keeps track of its dst bitmap reflowed by libk2pdfopt. -- So there is no need to check background context when creating new context. local kc = KOPTContext.new() - local screen_size = Runtimectl:getRenderSize() + local canvas_size = CanvasContext:getSize() local lang = doc.configurable.doc_language if lang == "chi_sim" or lang == "chi_tra" or lang == "jpn" or lang == "kor" then @@ -99,8 +99,8 @@ function KoptInterface:createContext(doc, pageno, bbox) kc:setWrap(doc.configurable.text_wrap) kc:setIndent(doc.configurable.detect_indent) kc:setColumns(doc.configurable.max_columns) - kc:setDeviceDim(screen_size.w, screen_size.h) - kc:setDeviceDPI(Runtimectl:getRenderDPI()) + kc:setDeviceDim(canvas_size.w, canvas_size.h) + kc:setDeviceDPI(CanvasContext:getDPI()) kc:setStraighten(doc.configurable.auto_straighten) kc:setJustification(doc.configurable.justification) kc:setWritingDirection(doc.configurable.writing_direction) @@ -124,11 +124,11 @@ function KoptInterface:createContext(doc, pageno, bbox) end function KoptInterface:getContextHash(doc, pageno, bbox) - local screen_size = Runtimectl:getRenderSize() - local screen_size_hash = screen_size.w.."|"..screen_size.h + local canvas_size = CanvasContext:getSize() + local canvas_size_hash = canvas_size.w.."|"..canvas_size.h local bbox_hash = bbox.x0.."|"..bbox.y0.."|"..bbox.x1.."|"..bbox.y1 return doc.file.."|"..doc.mod_time.."|"..pageno.."|" - ..doc.configurable:hash("|").."|"..bbox_hash.."|"..screen_size_hash + ..doc.configurable:hash("|").."|"..bbox_hash.."|"..canvas_size_hash end function KoptInterface:getPageBBox(doc, pageno) @@ -276,8 +276,8 @@ get first page image --]] function KoptInterface:getCoverPageImage(doc) local native_size = Document.getNativePageDimensions(doc, 1) - local screen_size = Runtimectl:getRenderSize() - local zoom = math.min(screen_size.w / native_size.w, screen_size.h / native_size.h) + local canvas_size = CanvasContext:getSize() + local zoom = math.min(canvas_size.w / native_size.w, canvas_size.h / native_size.h) local tile = Document.renderPage(doc, 1, nil, zoom, 0, 1, 0) if tile then return tile.bb:copy() @@ -571,9 +571,8 @@ function KoptInterface:getPageBlock(doc, pageno, x, y) y1 = page_size.h, } local kc = self:createContext(doc, pageno, full_page_bbox) - local screen_size = Runtimectl:getRenderSize() -- leptonica needs a source image of at least 300dpi - kc:setZoom(screen_size.w / page_size.w * 300 / Runtimectl:getRenderDPI()) + kc:setZoom(CanvasContext:getWidth() / page_size.w * 300 / CanvasContext:getDPI()) local page = doc._document:openPage(pageno) page:getPagePix(kc) kc:findPageBlocks() @@ -938,8 +937,8 @@ function KoptInterface:getLinkFromPosition(doc, pageno, pos) pos = self:reflowToNativePosTransform(doc, pageno, pos, {x=0.5, y=0.5}) end - local offset = Runtimectl:scaleByRenderSize(5) - local len = Runtimectl:scaleByRenderSize(10) + local offset = CanvasContext:scaleBySize(5) + local len = CanvasContext:scaleBySize(10) for i = 1, #page_links do local link = page_links[i] -- enlarge tappable link box diff --git a/frontend/document/pdfdocument.lua b/frontend/document/pdfdocument.lua index 2169e82d2..ba2d65823 100644 --- a/frontend/document/pdfdocument.lua +++ b/frontend/document/pdfdocument.lua @@ -7,7 +7,7 @@ local util = require("util") local ffi = require("ffi") local C = ffi.C local pdf = nil -local Runtimectl = require("runtimectl") +local CanvasContext = require("document/canvascontext") local PdfDocument = Document:new{ @@ -37,8 +37,10 @@ function PdfDocument:init() error(self._document) -- will contain error message end -- no-op on PDF - self._document:layoutDocument(Runtimectl:getRenderWidth(), Runtimectl:getRenderHeight(), - Runtimectl:scaleByRenderSize(self.epub_font_size)) + self._document:layoutDocument( + CanvasContext:getWidth(), + CanvasContext:getHeight(), + CanvasContext:scaleBySize(self.epub_font_size)) self.is_open = true self.info.has_pages = true self.info.configurable = true diff --git a/frontend/document/picdocument.lua b/frontend/document/picdocument.lua index 8fee410e0..b566db9b4 100644 --- a/frontend/document/picdocument.lua +++ b/frontend/document/picdocument.lua @@ -1,6 +1,6 @@ local Document = require("document/document") local DrawContext = require("ffi/drawcontext") -local Runtimectl = require("runtimectl") +local CanvasContext = require("document/canvascontext") local pic = nil local PicDocument = Document:new{ @@ -15,7 +15,7 @@ function PicDocument:init() self:updateColorRendering() if not pic then pic = require("ffi/pic") end -- pic.color needs to be true before opening document to allow toggling color - pic.color = Runtimectl.is_color_rendering_enabled + pic.color = CanvasContext.is_color_rendering_enabled local ok ok, self._document = pcall(pic.openDocument, self.file) if not ok then diff --git a/frontend/runtimectl.lua b/frontend/runtimectl.lua deleted file mode 100644 index 088d2927a..000000000 --- a/frontend/runtimectl.lua +++ /dev/null @@ -1,85 +0,0 @@ -local Mupdf = require("ffi/mupdf") - -local Runtimectl = { - should_restrict_JIT = false, - is_color_rendering_enabled = false, - is_bgr = false, -} - ---[[ -Initialize runtimectl with settings from device. - -The following key is required for a device object: - -* hasBGRFrameBuffer: function() -> boolean -* screen: object with following methods: - * getWidth() -> int - * getHeight() -> int - * getDPI() -> int - * getSize() -> Rect - * scaleBySize(int) -> int -]]-- -function Runtimectl:init(device) - self.screen = device.screen - self.isAndroid = device.isAndroid - self.isKindle = device.isKindle - - if self.isAndroid() then - self:restrictJIT() - end - - -- NOTE: Kobo's fb is BGR, not RGB. Handle the conversion in MuPDF if needed. - if device:hasBGRFrameBuffer() then - self.is_bgr = true - Mupdf.bgr = true - end -end - ---[[ -Disable jit on some modules on android to make koreader on Android more stable. - -The strategy here is that we only use precious mcode memory (jitting) -on deep loops like the several blitting methods in blitbuffer.lua and -the pixel-copying methods in mupdf.lua. So that a small amount of mcode -memory (64KB) allocated when koreader is launched in the android.lua -is enough for the program and it won't need to jit other parts of lua -code and thus won't allocate mcode memory any more which by our -observation will be harder and harder as we run koreader. -]]-- -function Runtimectl:restrictJIT() - self.should_restrict_JIT = true -end - -function Runtimectl:setColorRenderingEnabled(val) - self.is_color_rendering_enabled = val -end - -function Runtimectl:getExternalFontDir() - if self.isAndroid() then - return ANDROID_FONT_DIR - else - return os.getenv("EXT_FONT_DIR") - end -end - -function Runtimectl:getRenderWidth() - return self.screen:getWidth() -end - -function Runtimectl:getRenderHeight() - return self.screen:getHeight() -end - -function Runtimectl:getRenderDPI() - return self.screen:getDPI() -end - -function Runtimectl:getRenderSize() - return self.screen:getSize() -end - -function Runtimectl:scaleByRenderSize(px) - return self.screen:scaleBySize(px) -end - -return Runtimectl diff --git a/frontend/ui/elements/screen_color_menu_table.lua b/frontend/ui/elements/screen_color_menu_table.lua index 290c2c24e..8c9363d25 100644 --- a/frontend/ui/elements/screen_color_menu_table.lua +++ b/frontend/ui/elements/screen_color_menu_table.lua @@ -1,7 +1,7 @@ local Event = require("ui/event") local Screen = require("device").screen local UIManager = require("ui/uimanager") -local Runtimectl = require("runtimectl") +local CanvasContext = require("document/canvascontext") local _ = require("gettext") return { @@ -10,7 +10,7 @@ return { checked_func = Screen.isColorEnabled, callback = function() local new_val = Screen.isColorEnabled() - Runtimectl:setColorRenderingEnabled(new_val) + CanvasContext:setColorRenderingEnabled(new_val) G_reader_settings:saveSetting("color_rendering", new_val) UIManager:broadcastEvent(Event:new("ColorRenderingUpdate")) end diff --git a/frontend/ui/font.lua b/frontend/ui/font.lua index 38922febe..c6e7e9037 100644 --- a/frontend/ui/font.lua +++ b/frontend/ui/font.lua @@ -5,7 +5,7 @@ Font module. local Freetype = require("ffi/freetype") local lfs = require("libs/libkoreader-lfs") local logger = require("logger") -local Runtimectl = require("runtimectl") +local CanvasContext = require("document/canvascontext") local Font = { fontmap = { @@ -98,7 +98,7 @@ function Font:getFace(font, size) if not size then size = self.sizemap[font] end -- original size before scaling by screen DPI local orig_size = size - size = Runtimectl:scaleByRenderSize(size) + size = CanvasContext:scaleBySize(size) local hash = font..size local face_obj = self.faces[hash] @@ -188,7 +188,7 @@ local kindle_fonts_blacklist = { local function isInFontsBlacklist(f) -- write test for this - return Runtimectl.isKindle() and kindle_fonts_blacklist[f] + return CanvasContext.isKindle() and kindle_fonts_blacklist[f] end function Font:_readList(target, dir) @@ -212,11 +212,19 @@ function Font:_readList(target, dir) end end +local function getExternalFontDir() + if CanvasContext.isAndroid() then + return ANDROID_FONT_DIR + else + return os.getenv("EXT_FONT_DIR") + end +end + function Font:getFontList() local fontlist = {} self:_readList(fontlist, self.fontdir) -- multiple paths should be joined with semicolon - for dir in string.gmatch(Runtimectl:getExternalFontDir() or "", "([^;]+)") do + for dir in string.gmatch(getExternalFontDir() or "", "([^;]+)") do self:_readList(fontlist, dir) end table.sort(fontlist) diff --git a/frontend/ui/rendertext.lua b/frontend/ui/rendertext.lua index 17ca6d049..47f8c8bb5 100644 --- a/frontend/ui/rendertext.lua +++ b/frontend/ui/rendertext.lua @@ -8,8 +8,8 @@ local CacheItem = require("cacheitem") local BlitBuffer = require("ffi/blitbuffer") local logger = require("logger") -local runtimectl = require("runtimectl") -if runtimectl.should_restrict_JIT then +local CanvasContext = require("document/canvascontext") +if CanvasContext.should_restrict_JIT then require("jit").off(true, true) end diff --git a/frontend/ui/widget/container/inputcontainer.lua b/frontend/ui/widget/container/inputcontainer.lua index 25f9532d9..fdbb74cea 100644 --- a/frontend/ui/widget/container/inputcontainer.lua +++ b/frontend/ui/widget/container/inputcontainer.lua @@ -33,8 +33,8 @@ local WidgetContainer = require("ui/widget/container/widgetcontainer") local _ = require("gettext") local Screen = require("device").screen -local runtimectl = require("runtimectl") -if runtimectl.should_restrict_JIT then +local CanvasContext = require("document/canvascontext") +if CanvasContext.should_restrict_JIT then require("jit").off(true, true) end diff --git a/frontend/ui/widget/container/widgetcontainer.lua b/frontend/ui/widget/container/widgetcontainer.lua index dec6fa682..257a796a9 100644 --- a/frontend/ui/widget/container/widgetcontainer.lua +++ b/frontend/ui/widget/container/widgetcontainer.lua @@ -16,8 +16,8 @@ It handles event propagation and painting (with different alignments) for its ch local Geom = require("ui/geometry") local Widget = require("ui/widget/widget") -local runtimectl = require("runtimectl") -if runtimectl.should_restrict_JIT then +local CanvasContext = require("document/canvascontext") +if CanvasContext.should_restrict_JIT then require("jit").off(true, true) end diff --git a/reader.lua b/reader.lua index be70e99f2..1ae51dcee 100755 --- a/reader.lua +++ b/reader.lua @@ -34,22 +34,20 @@ if lang_locale then _.changeLang(lang_locale) end --- setup various runtime control -local Runtimectl = require("runtimectl") local Device = require("device") -Runtimectl:init(Device) - -if G_reader_settings:has("color_rendering") then - Runtimectl:setColorRenderingEnabled(G_reader_settings:isTrue("color_rendering")) -else - Runtimectl:setColorRenderingEnabled(Device.screen.isColorScreen()) -end - local dpi_override = G_reader_settings:readSetting("screen_dpi") if dpi_override ~= nil then Device.screen:setDPI(dpi_override) end +local CanvasContext = require("document/canvascontext") +CanvasContext:init(Device) +if G_reader_settings:has("color_rendering") then + CanvasContext:setColorRenderingEnabled(G_reader_settings:isTrue("color_rendering")) +else + CanvasContext:setColorRenderingEnabled(Device.screen.isColorScreen()) +end + -- option parsing: local longopts = { debug = "d", diff --git a/spec/unit/autofrontlight_spec.lua b/spec/unit/autofrontlight_spec.lua index 118577f09..a346eb627 100644 --- a/spec/unit/autofrontlight_spec.lua +++ b/spec/unit/autofrontlight_spec.lua @@ -4,7 +4,7 @@ describe("AutoFrontlight widget tests", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) MockTime = require("mock_time") MockTime:install() @@ -23,7 +23,7 @@ describe("AutoFrontlight widget tests", function() teardown(function() MockTime:uninstall() package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) end) before_each(function() diff --git a/spec/unit/autosuspend_spec.lua b/spec/unit/autosuspend_spec.lua index 7a535c47d..be62d164d 100644 --- a/spec/unit/autosuspend_spec.lua +++ b/spec/unit/autosuspend_spec.lua @@ -2,7 +2,7 @@ describe("AutoSuspend widget tests", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) end) before_each(function() diff --git a/spec/unit/background_runner_spec.lua b/spec/unit/background_runner_spec.lua index 27a5e2f84..3a87f5553 100644 --- a/spec/unit/background_runner_spec.lua +++ b/spec/unit/background_runner_spec.lua @@ -4,7 +4,7 @@ describe("BackgroundRunner widget tests", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) -- Device needs to be loaded before UIManager. Device = require("device") Device.input.waitEvent = function() end @@ -19,7 +19,7 @@ describe("BackgroundRunner widget tests", function() teardown(function() MockTime:uninstall() package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) stopBackgroundRunner() end) diff --git a/spec/unit/background_task_plugin_spec.lua b/spec/unit/background_task_plugin_spec.lua index 5bc64243b..61f795231 100644 --- a/spec/unit/background_task_plugin_spec.lua +++ b/spec/unit/background_task_plugin_spec.lua @@ -15,7 +15,7 @@ describe("BackgroundTaskPlugin", function() teardown(function() MockTime:uninstall() package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) stopBackgroundRunner() end) diff --git a/spec/unit/batterystat_spec.lua b/spec/unit/batterystat_spec.lua index 4740f60f1..058ad0bfe 100644 --- a/spec/unit/batterystat_spec.lua +++ b/spec/unit/batterystat_spec.lua @@ -8,7 +8,7 @@ describe("BatteryState plugin tests #nocov", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) MockTime = require("mock_time") MockTime:install() end) @@ -16,7 +16,7 @@ describe("BatteryState plugin tests #nocov", function() teardown(function() MockTime:uninstall() package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) end) before_each(function() diff --git a/spec/unit/commonrequire.lua b/spec/unit/commonrequire.lua index bc3e6794f..020c270c7 100644 --- a/spec/unit/commonrequire.lua +++ b/spec/unit/commonrequire.lua @@ -18,8 +18,8 @@ einkfb.dummy = true --luacheck: ignore local Device = require("device") -local Runtimectl = require("runtimectl") -Runtimectl:init(Device) +local CanvasContext = require("document/canvascontext") +CanvasContext:init(Device) -- init output device local Screen = Device.screen diff --git a/spec/unit/device_spec.lua b/spec/unit/device_spec.lua index 9bf9cb8e0..cd2449f5a 100644 --- a/spec/unit/device_spec.lua +++ b/spec/unit/device_spec.lua @@ -20,7 +20,7 @@ describe("device module", function() } require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) end) before_each(function() diff --git a/spec/unit/filemanager_spec.lua b/spec/unit/filemanager_spec.lua index ff9049350..e9e962dea 100644 --- a/spec/unit/filemanager_spec.lua +++ b/spec/unit/filemanager_spec.lua @@ -3,7 +3,7 @@ describe("FileManager module", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) FileManager = require("apps/filemanager/filemanager") Screen = require("device").screen UIManager = require("ui/uimanager") diff --git a/spec/unit/readerfooter_spec.lua b/spec/unit/readerfooter_spec.lua index d05b7c760..5e1ffb1db 100644 --- a/spec/unit/readerfooter_spec.lua +++ b/spec/unit/readerfooter_spec.lua @@ -6,7 +6,7 @@ describe("Readerfooter module", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) DocumentRegistry = require("document/documentregistry") DocSettings = require("docsettings") ReaderUI = require("apps/reader/readerui") diff --git a/spec/unit/readerhighlight_spec.lua b/spec/unit/readerhighlight_spec.lua index 09d79cc32..4bb91be38 100644 --- a/spec/unit/readerhighlight_spec.lua +++ b/spec/unit/readerhighlight_spec.lua @@ -3,7 +3,7 @@ describe("Readerhighlight module", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) DocumentRegistry = require("document/documentregistry") Event = require("ui/event") Geom = require("ui/geometry") diff --git a/spec/unit/readerlink_spec.lua b/spec/unit/readerlink_spec.lua index 6537df40d..565b77514 100644 --- a/spec/unit/readerlink_spec.lua +++ b/spec/unit/readerlink_spec.lua @@ -4,7 +4,7 @@ describe("ReaderLink module", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) DocumentRegistry = require("document/documentregistry") Event = require("ui/event") ReaderUI = require("apps/reader/readerui") diff --git a/spec/unit/readerview_spec.lua b/spec/unit/readerview_spec.lua index e29f9ad10..761b79761 100644 --- a/spec/unit/readerview_spec.lua +++ b/spec/unit/readerview_spec.lua @@ -4,7 +4,7 @@ describe("Readerview module", function() setup(function() require("commonrequire") package.unloadAll() - require("runtimectl"):init(require("device")) + require("document/canvascontext"):init(require("device")) DocumentRegistry = require("document/documentregistry") Blitbuffer = require("ffi/blitbuffer") ReaderUI = require("apps/reader/readerui")