aboutsummaryrefslogtreecommitdiff
path: root/include/ImageViewer.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-27 01:08:34 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-27 01:13:49 +0200
commit9866713ba916f9768edca02c61ed5ec580bd9557 (patch)
treee3f31e47f45c50656ce7fdb609c62d9df66583cd /include/ImageViewer.hpp
parenta00bdf3c76cd2d813533788b83abac87d6449b18 (diff)
Reduce scroll cpu usage from 10% to 1-2% by load image files in another thread but load the texture in the main thread
Diffstat (limited to 'include/ImageViewer.hpp')
-rw-r--r--include/ImageViewer.hpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp
index 93e7d7c..0ca64e9 100644
--- a/include/ImageViewer.hpp
+++ b/include/ImageViewer.hpp
@@ -18,13 +18,15 @@ namespace QuickMedia {
WAITING,
LOADING,
FAILED_TO_LOAD,
- LOADED
+ LOADED,
+ APPLIED_TO_TEXTURE
};
struct ImageData {
sf::Texture texture;
sf::Sprite sprite;
ImageStatus image_status;
+ std::unique_ptr<std::string> image_data_str;
bool visible_on_screen;
};
@@ -47,7 +49,7 @@ namespace QuickMedia {
int get_focused_page() const;
int get_num_pages() const { return num_pages; }
private:
- void load_image_async(const Path &path, std::shared_ptr<ImageData> image_data, int page);
+ void load_image_async(const Path &path, std::shared_ptr<ImageData> image_data);
bool render_page(sf::RenderWindow &window, int page, double offset_y);
sf::Vector2<double> get_page_size(int page);
private: