From 9866713ba916f9768edca02c61ed5ec580bd9557 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 27 Sep 2020 01:08:34 +0200 Subject: Reduce scroll cpu usage from 10% to 1-2% by load image files in another thread but load the texture in the main thread --- include/ImageViewer.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/ImageViewer.hpp') 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 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 image_data, int page); + void load_image_async(const Path &path, std::shared_ptr image_data); bool render_page(sf::RenderWindow &window, int page, double offset_y); sf::Vector2 get_page_size(int page); private: -- cgit v1.2.3