ImageWidget optimisations (#2394)

Avoid multiple renderings.
Don't cache big images (ie: screensaver images)
pull/2400/head
poire-z 8 years ago committed by Qingping Hou
parent 2c01f3add9
commit e1c3448d0e

@ -82,6 +82,9 @@ function ImageWidget:_loadfile()
if cache then
-- hit cache
self._bb = cache.bb
else
if self.height and self.height > 200 then -- don't cache big images
self._bb = Mupdf.renderImageFile(self.file, self.width, self.height)
else
-- cache this image
DEBUG("cache", hash)
@ -92,12 +95,16 @@ function ImageWidget:_loadfile()
ImageCache:insert(hash, cache)
self._bb = cache.bb
end
end
else
error("Image file type not supported.")
end
end
function ImageWidget:_render()
if self._bb then -- already rendered
return
end
if self.image then
self:_loadimage()
elseif self.file then

Loading…
Cancel
Save