aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-24 15:12:49 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-24 15:12:49 +0100
commit97e9fcb00af17d0fd1220ce2a5b4f264bf83e8cf (patch)
tree36434fc08fd1c790dd3fdae2a4b16617b32d3251 /include
parentba97f72453b76942b6eba9c6f2134b64cb1304c5 (diff)
Make async image loader static to reduce number of process threads when using multiple instances
Diffstat (limited to 'include')
-rw-r--r--include/AsyncImageLoader.hpp8
-rw-r--r--include/Body.hpp1
2 files changed, 6 insertions, 3 deletions
diff --git a/include/AsyncImageLoader.hpp b/include/AsyncImageLoader.hpp
index c1c2e11..5de9215 100644
--- a/include/AsyncImageLoader.hpp
+++ b/include/AsyncImageLoader.hpp
@@ -29,14 +29,18 @@ namespace QuickMedia {
class AsyncImageLoader {
public:
- AsyncImageLoader();
- ~AsyncImageLoader();
+ static AsyncImageLoader& get_instance();
// Returns false if the image loader is already loading an image. In that case, this function should be called again later.
// set |resize_target_size| to {0, 0} to disable resizing.
// |thumbnail_data.loading_state| has to be LoadingState::NOT_LOADED when calling this!
// Note: this method is not thread-safe
void load_thumbnail(const std::string &url, bool local, sf::Vector2i resize_target_size, bool use_tor, std::shared_ptr<ThumbnailData> thumbnail_data);
private:
+ AsyncImageLoader();
+ ~AsyncImageLoader();
+ AsyncImageLoader(AsyncImageLoader &other) = delete;
+ AsyncImageLoader& operator=(AsyncImageLoader &other) = delete;
+
struct ThumbnailLoadData {
Path path;
Path thumbnail_path;
diff --git a/include/Body.hpp b/include/Body.hpp
index 56ef262..4bfd36f 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -258,7 +258,6 @@ namespace QuickMedia {
private:
Program *program;
std::unordered_map<std::string, std::shared_ptr<ThumbnailData>> item_thumbnail_textures;
- AsyncImageLoader async_image_loader;
int selected_item;
int prev_selected_item;
float page_scroll;