diff --git a/frontend/document/canvascontext.lua b/frontend/document/canvascontext.lua index 5de8d452b..6e2a88b58 100644 --- a/frontend/document/canvascontext.lua +++ b/frontend/document/canvascontext.lua @@ -35,6 +35,7 @@ The following key is required for a device object: * isColorEnabled() -> boolean ]]-- function CanvasContext:init(device) + self.device = device self.screen = device.screen self.isAndroid = device.isAndroid self.isDesktop = device.isDesktop @@ -45,7 +46,7 @@ function CanvasContext:init(device) self.hasSystemFonts = device.hasSystemFonts self:setColorRenderingEnabled(device.screen.isColorEnabled()) - -- NOTE: Kobo's fb is BGR, not RGB. Handle the conversion in MuPDF if needed. + -- NOTE: At 32bpp, 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 @@ -77,4 +78,8 @@ function CanvasContext:scaleBySize(px) return self.screen:scaleBySize(px) end +function CanvasContext:enableCPUCores(amount) + return self.device:enableCPUCores(amount) +end + return CanvasContext diff --git a/frontend/document/document.lua b/frontend/document/document.lua index 57f206a47..6e4fa4d31 100644 --- a/frontend/document/document.lua +++ b/frontend/document/document.lua @@ -1,7 +1,6 @@ local Blitbuffer = require("ffi/blitbuffer") local CacheItem = require("cacheitem") local Configurable = require("configurable") -local Device = require("device") local DocCache = require("document/doccache") local DrawContext = require("ffi/drawcontext") local CanvasContext = require("document/canvascontext") @@ -413,7 +412,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode, h end if hinting then - Device:enableCPUCores(2) + CanvasContext:enableCPUCores(2) end self:preRenderPage() @@ -429,7 +428,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode, h logger.warn("aborting, since we do not have a specification for that part") -- required part not given, so abort if hinting then - Device:enableCPUCores(1) + CanvasContext:enableCPUCores(1) end return end @@ -474,7 +473,7 @@ function Document:renderPage(pageno, rect, zoom, rotation, gamma, render_mode, h self:postRenderPage() if hinting then - Device:enableCPUCores(1) + CanvasContext:enableCPUCores(1) end return tile end diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index 078893ade..c43457fd0 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -6,7 +6,6 @@ local CacheItem = require("cacheitem") local CanvasContext = require("document/canvascontext") local DataStorage = require("datastorage") local DEBUG = require("dbg") -local Device = require("device") local DocCache = require("document/doccache") local Document = require("document/document") local FFIUtil = require("ffi/util") @@ -111,7 +110,7 @@ function KoptInterface:waitForContext(kc) if waited or self.bg_thread then -- Background thread is done, go back to a single CPU core. - Device:enableCPUCores(1) + CanvasContext:enableCPUCores(1) self.bg_thread = nil end @@ -392,7 +391,7 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, re local cached = DocCache:check(hash, TileCacheItem) if not cached then if hinting then - Device:enableCPUCores(2) + CanvasContext:enableCPUCores(2) end local page_size = Document.getNativePageDimensions(doc, pageno) @@ -425,7 +424,7 @@ function KoptInterface:renderOptimizedPage(doc, pageno, rect, zoom, rotation, re DocCache:insert(hash, tile) if hinting then - Device:enableCPUCores(1) + CanvasContext:enableCPUCores(1) end return tile @@ -464,7 +463,7 @@ function KoptInterface:hintReflowedPage(doc, pageno, zoom, rotation, gamma, rend local cached = DocCache:check(hash) if not cached then if hinting then - Device:enableCPUCores(2) + CanvasContext:enableCPUCores(2) end local kc = self:createContext(doc, pageno, bbox)