mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
Nit: Make some cache keys prettier (#12354)
Completely pointless commit because I got triggered by a missing pipe in a log ;).
This commit is contained in:
parent
3450aaba99
commit
a51bd7a7fd
@ -81,7 +81,8 @@ function RenderText:getGlyph(face, charcode, bold)
|
|||||||
if face.is_real_bold then
|
if face.is_real_bold then
|
||||||
bold = false -- don't embolden glyphs already bold
|
bold = false -- don't embolden glyphs already bold
|
||||||
end
|
end
|
||||||
local hash = "glyph|"..face.hash.."|"..charcode.."|"..(bold and 1 or 0)
|
-- nil is falsy, cache it as such (i.e., we don't want to use tostring here, as that would make it tristate: true/false/nil)
|
||||||
|
local hash = "glyph|"..face.hash.."|"..charcode.."|"..(bold and "1" or "0")
|
||||||
local glyph = GlyphCache:check(hash)
|
local glyph = GlyphCache:check(hash)
|
||||||
if glyph then
|
if glyph then
|
||||||
-- cache hit
|
-- cache hit
|
||||||
@ -288,12 +289,13 @@ end
|
|||||||
-- @tparam ui.font.FontFaceObj face font face for the text
|
-- @tparam ui.font.FontFaceObj face font face for the text
|
||||||
-- @int glyph index
|
-- @int glyph index
|
||||||
-- @bool[opt=false] bold whether the glyph should be artificially boldened
|
-- @bool[opt=false] bold whether the glyph should be artificially boldened
|
||||||
|
-- @bool[opt=false] bolder whether the glyph should be *even more* artificially boldened (*can* stack with bold, but can also be used solo)
|
||||||
-- @treturn glyph
|
-- @treturn glyph
|
||||||
function RenderText:getGlyphByIndex(face, glyphindex, bold, bolder)
|
function RenderText:getGlyphByIndex(face, glyphindex, bold, bolder)
|
||||||
if face.is_real_bold then
|
if face.is_real_bold then
|
||||||
bold = false -- don't embolden glyphs already bold
|
bold = false -- don't embolden glyphs already bold
|
||||||
end
|
end
|
||||||
local hash = "xglyph|"..face.hash.."|"..glyphindex.."|"..(bold and 1 or 0)..(bolder and "x" or "")
|
local hash = "xglyph|"..face.hash.."|"..glyphindex.."|"..(bold and "1" or "0")..(bolder and "x" or "")
|
||||||
local glyph = GlyphCache:check(hash)
|
local glyph = GlyphCache:check(hash)
|
||||||
if glyph then
|
if glyph then
|
||||||
-- cache hit
|
-- cache hit
|
||||||
|
@ -144,7 +144,7 @@ function ImageWidget:_loadfile()
|
|||||||
width = self.width
|
width = self.width
|
||||||
height = self.height
|
height = self.height
|
||||||
end
|
end
|
||||||
local hash = "image|"..self.file.."|"..(width or "").."|"..(height or "")..tostring(self.alpha)
|
local hash = "image|"..self.file.."|"..tostring(width).."|"..tostring(height).."|"..(self.alpha and "alpha" or "flat")
|
||||||
-- Do the scaling for DPI here, so it can be cached and not re-done
|
-- Do the scaling for DPI here, so it can be cached and not re-done
|
||||||
-- each time in _render() (but not if scale_factor, to avoid double scaling)
|
-- each time in _render() (but not if scale_factor, to avoid double scaling)
|
||||||
local scale_for_dpi_here = false
|
local scale_for_dpi_here = false
|
||||||
|
Loading…
Reference in New Issue
Block a user