aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/AsyncImageLoader.hpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp
index 94b225d..7556fbc 100644
--- a/include/AsyncImageLoader.hpp
+++ b/include/AsyncImageLoader.hpp
@@ -15,6 +15,7 @@ namespace QuickMedia {
enum class LoadingState {
NOT_LOADED,
LOADING,
+ READY_TO_LOAD,
FINISHED_LOADING,
APPLIED_TO_TEXTURE
};
@@ -24,6 +25,7 @@ namespace QuickMedia {
sf::Texture texture;
std::unique_ptr<sf::Image> image; // Set in another thread. This should be .reset after loading it into |texture|, to save memory
size_t counter = 0;
+ Path thumbnail_path;
};
struct ThumbnailLoadData {
@@ -70,19 +72,25 @@ namespace QuickMedia {
// set |resize_target_size| to {0, 0} to disable resizing.
// Note: this method is not thread-safe
- void load_thumbnail(const std::string &url, bool local, sf::Vector2i resize_target_size, std::shared_ptr<ThumbnailData> thumbnail_data);
+ bool load_thumbnail(const std::string &url, bool local, sf::Vector2i resize_target_size, std::shared_ptr<ThumbnailData> thumbnail_data, Path &thumbnail_path);
// Returns -1 if all threads are busy
int get_free_load_index() const;
+ void load_create_thumbnail(const Path &thumbnail_path, const Path &thumbnail_path_resized, ThumbnailData *thumbnail_data, sf::Vector2i resize_target_size);
+ void process_thumbnail(ThumbnailLoadData &thumbnail_load_data);
+ private:
void reset_download(Download &download);
private:
std::mutex download_mutex;
// TODO: Use curl single-threaded multi-download feature instead
Download downloads[NUM_IMAGE_LOAD_PARALLEL];
AsyncTask<void> load_thread;
- MessageQueue<ThumbnailLoadData> image_load_queue;
+ MessageQueue<ThumbnailLoadData> image_thumbnail_create_queue;
std::unordered_map<std::string, std::shared_ptr<ThumbnailData>> thumbnails;
size_t counter = 0;
+
+ std::mutex image_load_mutex;
+ ThumbnailLoadData current_loading_image;
};
}