Skip to content

Commit

Permalink
bump crengine: count nb of images drawn & others (#4542)
Browse files Browse the repository at this point in the history
Includes:
- Update french hyphenation pattern
- epub.css: update style for 'blockquote'
- DrawBuf: count nb of images and surface drawn

Adds Document:getDrawnImagesStatistics() to help deciding
if refresh with (possibly costly) dithering should be used
(on devices with HW dithering capabilities) with CreDocument:
when a page contains enough images to benefit from it.
  • Loading branch information
poire-z committed Feb 3, 2019
1 parent 895589d commit f2a9ed0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion base
2 changes: 1 addition & 1 deletion frontend/document/credocument.lua
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function CreDocument:drawCurrentView(target, x, y, rect, pos)
-- change has been made, to avoid having crengine redraw the exact
-- same buffer.
-- And it could only change when some other methods from here are called
self._document:drawCurrentPage(self.buffer, self.render_color)
self._drawn_images_count, self._drawn_images_surface_ratio = self._document:drawCurrentPage(self.buffer, self.render_color)
target:blitFrom(self.buffer, x, y, 0, 0, rect.w, rect.h)
end

Expand Down
5 changes: 5 additions & 0 deletions frontend/document/document.lua
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ function Document:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma, re
rect.w, rect.h)
end

function Document:getDrawnImagesStatistics()
-- For now, only set by CreDocument in CreDocument:drawCurrentView()
return self._drawn_images_count, self._drawn_images_surface_ratio
end

function Document:getPageText(pageno)
-- is this worth caching? not done yet.
local page = self._document:openPage(pageno)
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/readerrolling_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ describe("Readerrolling module", function()
it("should show pages for different word gap", function()
readerui.document:setSpaceCondensing(100)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
assert.are.same(266, readerui.document:getPageCount())
assert.are.same(249, readerui.document:getPageCount())
readerui.document:setSpaceCondensing(75)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
assert.are.same(261, readerui.document:getPageCount())
assert.are.same(242, readerui.document:getPageCount())
readerui.document:setSpaceCondensing(50)
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
assert.are.same(247, readerui.document:getPageCount())
assert.are.same(233, readerui.document:getPageCount())
end)
end)

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/readersearch_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe("Readersearch module", function()
end)
it("should find the last occurrence", function()
-- local logger = require("logger")
-- logger.info("nb of pages", doc:getPageCount())
-- 20181208: currently 266 pages
-- logger.warn("nb of pages", doc:getPageCount())
-- 20190202: currently 242 pages
for i = 100, 180, 10 do
rolling:onGotoPage(i)
local words = search:searchFromEnd("Verona")
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/readertoc_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("Readertoc module", function()
title = toc:getTocTitleByPage(60)
DEBUG("toc", toc.toc)
assert(title == "SCENE V. A hall in Capulet's house.")
title = toc:getTocTitleByPage(195)
title = toc:getTocTitleByPage(187)
assert(title == "SCENE I. Friar Laurence's cell.")
end)
describe("getTocTicks API", function()
Expand Down Expand Up @@ -68,7 +68,7 @@ describe("Readertoc module", function()
end)
it("should get page left of chapter", function()
assert.truthy(toc:getChapterPagesLeft(10, 0) > 10)
assert.truthy(toc:getChapterPagesLeft(102, 0) > 10)
assert.truthy(toc:getChapterPagesLeft(97, 0) > 10)
assert.are.same(nil, toc:getChapterPagesLeft(290, 0))
end)
it("should get page done of chapter", function()
Expand Down

0 comments on commit f2a9ed0

Please sign in to comment.