mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Various blitting related cleanups (#4789)
* Fix the "Enable debug logging" checkbox so that it properly disables "Enable verbose debug logging" when it gets disabled * Avoid asking ImageWidget for alpha-blending when it's not useful * Make ImageWidget's alpha-blending code-path double-check that alpha-blending actually is needed, and avoid it if possible * In the same vein, only do alpha-blending in textboxwidget when absolutely necessary * Prefer color constants over the gray() method, ensuring that they're part of the eInk palette Depends on https://github.com/koreader/koreader-base/pull/853 Fix #4774
This commit is contained in:
@@ -361,20 +361,7 @@ function TextBoxWidget:_renderText(start_row_idx, end_row_idx)
|
||||
if self._bb then self._bb:free() end
|
||||
local bbtype = nil
|
||||
if self.line_num_to_image and self.line_num_to_image[start_row_idx] then
|
||||
-- Whether Screen:isColorEnabled or not, it's best to
|
||||
-- always use BBRGB32 and alphablitFrom() for the best display of
|
||||
-- various images:
|
||||
-- With greyscale screen TYPE_BB8 (the default, and
|
||||
-- what we would have chosen when not Screen:isColorEnabled):
|
||||
-- alphablitFrom: some images are all white (ex: flags on Milan,
|
||||
-- Ilkhanides on wiki.fr)
|
||||
-- blitFrom: some images have a black background (ex: RDA,
|
||||
-- Allemagne on wiki.fr)
|
||||
-- With TYPE_BBRGB32:
|
||||
-- blitFrom: some images have a black background (ex: RDA,
|
||||
-- Allemagne on wiki.fr)
|
||||
-- alphablitFrom: all these images looks good, with a white background
|
||||
bbtype = Blitbuffer.TYPE_BBRGB32
|
||||
bbtype = Screen:isColorEnabled() and Blitbuffer.TYPE_BBRGB32 or Blitbuffer.TYPE_BB8
|
||||
end
|
||||
self._bb = Blitbuffer.new(self.width, h, bbtype)
|
||||
self._bb:fill(Blitbuffer.COLOR_WHITE)
|
||||
@@ -441,14 +428,20 @@ function TextBoxWidget:_renderImage(start_row_idx)
|
||||
-- logger.dbg("display_bb:", display_bb, "display_alt", display_alt, "status_text:", status_text, "do_schedule_update:", do_schedule_update)
|
||||
-- Do what's been decided
|
||||
if display_bb then
|
||||
self._bb:alphablitFrom(image.bb, self.width - image.width, 0)
|
||||
-- With alpha-blending if the image contains an alpha channel
|
||||
local bbtype = image.bb:getType()
|
||||
if bbtype == Blitbuffer.TYPE_BB8A or bbtype == Blitbuffer.TYPE_BBRGB32 then
|
||||
self._bb:alphablitFrom(image.bb, self.width - image.width, 0)
|
||||
else
|
||||
self._bb:blitFrom(image.bb, self.width - image.width, 0)
|
||||
end
|
||||
end
|
||||
local status_height = 0
|
||||
if status_text then
|
||||
local status_widget = TextWidget:new{
|
||||
text = status_text,
|
||||
face = Font:getFace("cfont", 20),
|
||||
fgcolor = Blitbuffer.COLOR_GREY,
|
||||
fgcolor = Blitbuffer.COLOR_DARK_GRAY,
|
||||
bold = true,
|
||||
}
|
||||
status_height = status_widget:getSize().h
|
||||
|
||||
Reference in New Issue
Block a user