feat: port upstream PRs #852, #965, #972, #971, #977, #975

Port 6 upstream PRs (PR #939 was already ported):

- #852: Complete HalPowerManager with RAII Lock class, WiFi check in
  setPowerSaving, skipLoopDelay overrides for ClearCache/OtaUpdate,
  and power lock in Activity render task loops
- #965: Fix paragraph formatting inside list items by tracking
  listItemUntilDepth to prevent unwanted line breaks
- #972: Micro-optimizations: std::move in insertFont, const ref for
  getDataFromBook parameter
- #971: Remove redundant hasPrintableChars pre-rendering pass from
  EpdFont, EpdFontFamily, and GfxRenderer
- #977: Skip unsupported image formats before extraction, add
  PARSE_BUFFER_SIZE constant and chapter parse timing
- #975: Fix UITheme memory leak by replacing raw pointer with
  std::unique_ptr for currentTheme

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cottongin
2026-02-18 15:45:06 -05:00
parent 7819cf0f77
commit a1ac11ab51
17 changed files with 100 additions and 45 deletions

View File

@@ -85,7 +85,7 @@ bool RecentBooksStore::saveToFile() const {
return true;
}
RecentBook RecentBooksStore::getDataFromBook(std::string path) const {
RecentBook RecentBooksStore::getDataFromBook(const std::string& path) const {
std::string lastBookFileName = "";
const size_t lastSlash = path.find_last_of('/');
if (lastSlash != std::string::npos) {

View File

@@ -42,7 +42,7 @@ class RecentBooksStore {
bool saveToFile() const;
bool loadFromFile();
RecentBook getDataFromBook(std::string path) const;
RecentBook getDataFromBook(const std::string& path) const;
};
// Helper macro to access recent books store

View File

@@ -1,5 +1,7 @@
#include "Activity.h"
#include <HalPowerManager.h>
void Activity::renderTaskTrampoline(void* param) {
auto* self = static_cast<Activity*>(param);
self->renderTaskLoop();
@@ -9,6 +11,7 @@ void Activity::renderTaskLoop() {
while (true) {
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
{
HalPowerManager::Lock powerLock;
RenderLock lock(*this);
render(std::move(lock));
}

View File

@@ -1,9 +1,12 @@
#include "ActivityWithSubactivity.h"
#include <HalPowerManager.h>
void ActivityWithSubactivity::renderTaskLoop() {
while (true) {
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
{
HalPowerManager::Lock powerLock;
RenderLock lock(*this);
if (!subActivity) {
render(std::move(lock));

View File

@@ -14,6 +14,7 @@ class ClearCacheActivity final : public ActivityWithSubactivity {
void onExit() override;
void loop() override;
void render(Activity::RenderLock&&) override;
bool skipLoopDelay() override { return true; }
private:
enum State { WARNING, CLEARING, SUCCESS, FAILED };

View File

@@ -33,5 +33,6 @@ class OtaUpdateActivity : public ActivityWithSubactivity {
void onExit() override;
void loop() override;
void render(Activity::RenderLock&&) override;
bool skipLoopDelay() override { return true; }
bool preventAutoSleep() override { return state == CHECKING_FOR_UPDATE || state == UPDATE_IN_PROGRESS; }
};

View File

@@ -25,12 +25,12 @@ void UITheme::setTheme(CrossPointSettings::UI_THEME type) {
switch (type) {
case CrossPointSettings::UI_THEME::CLASSIC:
LOG_DBG("UI", "Using Classic theme");
currentTheme = new BaseTheme();
currentTheme = std::make_unique<BaseTheme>();
currentMetrics = &BaseMetrics::values;
break;
case CrossPointSettings::UI_THEME::LYRA:
LOG_DBG("UI", "Using Lyra theme");
currentTheme = new LyraTheme();
currentTheme = std::make_unique<LyraTheme>();
currentMetrics = &LyraMetrics::values;
break;
}

View File

@@ -1,6 +1,7 @@
#pragma once
#include <functional>
#include <memory>
#include <vector>
#include "CrossPointSettings.h"
@@ -24,7 +25,7 @@ class UITheme {
private:
const ThemeMetrics* currentMetrics;
const BaseTheme* currentTheme;
std::unique_ptr<const BaseTheme> currentTheme;
};
// Known theme thumbnail heights to prerender when opening a book for the first time.