Async processing of thumbnails
This commit is contained in:
@@ -132,8 +132,8 @@ void HomeActivity::loadRecentBooks(int maxBooks) {
|
|||||||
void HomeActivity::loadRecentCovers(int coverHeight) {
|
void HomeActivity::loadRecentCovers(int coverHeight) {
|
||||||
recentsLoading = true;
|
recentsLoading = true;
|
||||||
|
|
||||||
int progress = 0;
|
for (; nextRecentCoverIndex < recentBooks.size(); nextRecentCoverIndex++) {
|
||||||
for (RecentBook& book : recentBooks) {
|
RecentBook& book = recentBooks[nextRecentCoverIndex];
|
||||||
if (!book.coverBmpPath.empty()) {
|
if (!book.coverBmpPath.empty()) {
|
||||||
std::string coverPath = UITheme::getCoverThumbPath(book.coverBmpPath, coverHeight);
|
std::string coverPath = UITheme::getCoverThumbPath(book.coverBmpPath, coverHeight);
|
||||||
if (!Storage.exists(coverPath.c_str())) {
|
if (!Storage.exists(coverPath.c_str())) {
|
||||||
@@ -150,7 +150,10 @@ void HomeActivity::loadRecentCovers(int coverHeight) {
|
|||||||
book.coverBmpPath = "";
|
book.coverBmpPath = "";
|
||||||
}
|
}
|
||||||
coverRendered = false;
|
coverRendered = false;
|
||||||
|
nextRecentCoverIndex++;
|
||||||
|
recentsLoading = false;
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
|
return;
|
||||||
} else if (FsHelpers::hasXtcExtension(book.path)) {
|
} else if (FsHelpers::hasXtcExtension(book.path)) {
|
||||||
// Handle XTC file
|
// Handle XTC file
|
||||||
Xtc xtc(book.path, "/.crosspoint");
|
Xtc xtc(book.path, "/.crosspoint");
|
||||||
@@ -162,12 +165,14 @@ void HomeActivity::loadRecentCovers(int coverHeight) {
|
|||||||
book.coverBmpPath = "";
|
book.coverBmpPath = "";
|
||||||
}
|
}
|
||||||
coverRendered = false;
|
coverRendered = false;
|
||||||
|
nextRecentCoverIndex++;
|
||||||
|
recentsLoading = false;
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
progress++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recentsLoaded = true;
|
recentsLoaded = true;
|
||||||
@@ -181,9 +186,18 @@ void HomeActivity::onEnter() {
|
|||||||
hasOpdsUrl = strlen(SETTINGS.opdsServerUrl) > 0;
|
hasOpdsUrl = strlen(SETTINGS.opdsServerUrl) > 0;
|
||||||
|
|
||||||
selectorIndex = 0;
|
selectorIndex = 0;
|
||||||
|
recentsLoading = false;
|
||||||
|
recentsLoaded = false;
|
||||||
|
firstRenderDone = false;
|
||||||
|
nextRecentCoverIndex = 0;
|
||||||
|
coverRendered = false;
|
||||||
|
freeCoverBuffer();
|
||||||
|
|
||||||
const auto& metrics = UITheme::getInstance().getMetrics();
|
const auto& metrics = UITheme::getInstance().getMetrics();
|
||||||
loadRecentBooks(metrics.homeRecentBooksCount);
|
loadRecentBooks(metrics.homeRecentBooksCount);
|
||||||
|
if (recentBooks.empty()) {
|
||||||
|
recentsLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Trigger first update
|
// Trigger first update
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <cstddef>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ class HomeActivity final : public Activity {
|
|||||||
bool hasOpdsUrl = false;
|
bool hasOpdsUrl = false;
|
||||||
bool coverRendered = false; // Track if cover has been rendered once
|
bool coverRendered = false; // Track if cover has been rendered once
|
||||||
bool coverBufferStored = false; // Track if cover buffer is stored
|
bool coverBufferStored = false; // Track if cover buffer is stored
|
||||||
|
size_t nextRecentCoverIndex = 0;
|
||||||
uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image
|
uint8_t* coverBuffer = nullptr; // HomeActivity's own buffer for cover image
|
||||||
std::vector<RecentBook> recentBooks;
|
std::vector<RecentBook> recentBooks;
|
||||||
void onSelectBook(const std::string& path);
|
void onSelectBook(const std::string& path);
|
||||||
|
|||||||
Reference in New Issue
Block a user