mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 07:37:37 +03:00
## Summary
* Consolidate chapter page data into single file
* Header structure of the file stays the same, following the page count,
we now put a LUT offset
* The page data is all then appended to this file
* Finally the LUT is appended to the end of the file, and the page count
is updated
* This will also significantly improve the duration of cache cleanup
which takes a while to scan the directory and cleanup content
* Remove page file version as it's all tied up into the section file now
* Bumped section file version to 7
* Moved section content into sub directory
* Updated docs
## Additional Context
* Benchmarks:
* Generating 74 pages of content from a chapter in Jade Legacy took:
* master: 6,229ms
* this PR: 1,305ms
* Speedup of 79%
* Generating 207 pages of content from Livesuit book:
* With progress bar UI updates:
* master: 24,250ms
* this PR: 8,063ms
* Speedup of 67%
* Without progress bar UI updates:
* master: 13,055ms
* this PR: 3,600ms
* Speedup of 72%
42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#pragma once
|
|
#include <EpdFontFamily.h>
|
|
#include <FS.h>
|
|
|
|
#include <list>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "Block.h"
|
|
|
|
// represents a block of words in the html document
|
|
class TextBlock final : public Block {
|
|
public:
|
|
enum BLOCK_STYLE : uint8_t {
|
|
JUSTIFIED = 0,
|
|
LEFT_ALIGN = 1,
|
|
CENTER_ALIGN = 2,
|
|
RIGHT_ALIGN = 3,
|
|
};
|
|
|
|
private:
|
|
std::list<std::string> words;
|
|
std::list<uint16_t> wordXpos;
|
|
std::list<EpdFontStyle> wordStyles;
|
|
BLOCK_STYLE style;
|
|
|
|
public:
|
|
explicit TextBlock(std::list<std::string> words, std::list<uint16_t> word_xpos, std::list<EpdFontStyle> word_styles,
|
|
const BLOCK_STYLE style)
|
|
: words(std::move(words)), wordXpos(std::move(word_xpos)), wordStyles(std::move(word_styles)), style(style) {}
|
|
~TextBlock() override = default;
|
|
void setStyle(const BLOCK_STYLE style) { this->style = style; }
|
|
BLOCK_STYLE getStyle() const { return style; }
|
|
bool isEmpty() override { return words.empty(); }
|
|
void layout(GfxRenderer& renderer) override {};
|
|
// given a renderer works out where to break the words into lines
|
|
void render(const GfxRenderer& renderer, int fontId, int x, int y) const;
|
|
BlockType getType() override { return TEXT_BLOCK; }
|
|
bool serialize(File& file) const;
|
|
static std::unique_ptr<TextBlock> deserialize(File& file);
|
|
};
|