Stash enableCPUCores in CanvasContext

Avoids requring Device direction in Document.

The method needs complete access to the Device object, though, so it's
just another layer of indirection, with an extra reference on the Device
object stashed in CanvasContext...
(much like it already does for Screen)
This commit is contained in:
NiLuJe
2022-01-16 18:36:11 +01:00
committed by poire-z
parent 5e3790677e
commit 7018853940
3 changed files with 13 additions and 10 deletions

View File

@@ -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