From 003de939b09e83622cf8bce671aa40f3471896e4 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Mon, 18 Mar 2019 09:35:27 +0100 Subject: [PATCH] [fix] Properly account for MuPDF feeding us premultiplied alpha (#4807) * Properly account for MuPDF feeding us premultiplied alpha * Bump base to pickup necessary backend changes Also includes a bunch of CMake refactoring (https://github.com/koreader/koreader-base/pull/865 https://github.com/koreader/koreader-base/pull/867 https://github.com/koreader/koreader-base/pull/868) --- base | 2 +- frontend/ui/widget/imagewidget.lua | 3 ++- frontend/ui/widget/textboxwidget.lua | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/base b/base index 6bd23e9dc..9dd733331 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 6bd23e9dc0887211487804f6d7622889a4c2e042 +Subproject commit 9dd73333120a146746f1d2d363dacefeadf7627d diff --git a/frontend/ui/widget/imagewidget.lua b/frontend/ui/widget/imagewidget.lua index f6d4c6763..199d30dec 100644 --- a/frontend/ui/widget/imagewidget.lua +++ b/frontend/ui/widget/imagewidget.lua @@ -359,7 +359,8 @@ function ImageWidget:paintTo(bb, x, y) -- Only actually try to alpha-blend if the image really has an alpha channel... local bbtype = self._bb:getType() if bbtype == Blitbuffer.TYPE_BB8A or bbtype == Blitbuffer.TYPE_BBRGB32 then - bb:alphablitFrom(self._bb, x, y, self._offset_x, self._offset_y, size.w, size.h) + -- NOTE: MuPDF feeds us premultiplied alpha (and we don't care w/ GifLib, as alpha is all or nothing). + bb:pmulalphablitFrom(self._bb, x, y, self._offset_x, self._offset_y, size.w, size.h) else bb:blitFrom(self._bb, x, y, self._offset_x, self._offset_y, size.w, size.h) end diff --git a/frontend/ui/widget/textboxwidget.lua b/frontend/ui/widget/textboxwidget.lua index 1deabb623..381613dac 100644 --- a/frontend/ui/widget/textboxwidget.lua +++ b/frontend/ui/widget/textboxwidget.lua @@ -431,7 +431,8 @@ function TextBoxWidget:_renderImage(start_row_idx) -- 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) + -- NOTE: MuPDF feeds us premultiplied alpha (and we don't care w/ GifLib, as alpha is all or nothing). + self._bb:pmulalphablitFrom(image.bb, self.width - image.width, 0) else self._bb:blitFrom(image.bb, self.width - image.width, 0) end