aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ImageUtils.hpp8
-rw-r--r--include/ImageViewer.hpp16
-rw-r--r--include/QuickMedia.hpp15
3 files changed, 37 insertions, 2 deletions
diff --git a/include/ImageUtils.hpp b/include/ImageUtils.hpp
new file mode 100644
index 0000000..f0670d6
--- /dev/null
+++ b/include/ImageUtils.hpp
@@ -0,0 +1,8 @@
+#pragma once
+
+#include "Path.hpp"
+
+namespace QuickMedia {
+ // Works with jpg, png and gif files
+ bool image_get_resolution(const Path &path, int *width, int *height);
+} \ No newline at end of file
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp
index 7fe4921..93e7d7c 100644
--- a/include/ImageViewer.hpp
+++ b/include/ImageViewer.hpp
@@ -9,14 +9,22 @@
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/System/Clock.hpp>
+#include <thread>
namespace QuickMedia {
class Manga;
+ enum class ImageStatus {
+ WAITING,
+ LOADING,
+ FAILED_TO_LOAD,
+ LOADED
+ };
+
struct ImageData {
sf::Texture texture;
sf::Sprite sprite;
- bool failed_to_load_image;
+ ImageStatus image_status;
bool visible_on_screen;
};
@@ -39,6 +47,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);
bool render_page(sf::RenderWindow &window, int page, double offset_y);
sf::Vector2<double> get_page_size(int page);
private:
@@ -61,7 +70,7 @@ namespace QuickMedia {
sf::Clock frame_timer;
sf::Text page_text;
- std::vector<std::unique_ptr<ImageData>> image_data;
+ std::vector<std::shared_ptr<ImageData>> image_data;
std::vector<PageSize> page_size;
sf::Vector2<double> window_size;
@@ -77,5 +86,8 @@ namespace QuickMedia {
bool up_pressed = false;
bool down_pressed = false;
+
+ std::thread image_loader_thread;
+ bool loading_image = false;
};
} \ No newline at end of file
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index b2c499c..d3bff47 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -11,7 +11,11 @@
#include <json/value.h>
#include <unordered_set>
#include <future>
+#include <thread>
+#include <mutex>
+#include <condition_variable>
#include <stack>
+#include <deque>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
@@ -23,6 +27,11 @@ namespace QuickMedia {
SINGLE,
SCROLL
};
+
+ struct CopyOp {
+ Path source;
+ Path destination;
+ };
class Program {
public:
@@ -94,12 +103,18 @@ namespace QuickMedia {
std::future<BodyItems> search_suggestion_future;
std::future<std::string> autocomplete_future;
std::future<void> image_download_future;
+ std::thread image_upscale_thead;
+ std::mutex image_upscale_mutex;
+ std::deque<CopyOp> images_to_upscale;
+ std::condition_variable image_upscale_cv;
std::string downloading_chapter_url;
bool image_download_cancel = false;
int exit_code = 0;
std::string resources_root;
bool use_tor = false;
bool use_system_mpv_config = false;
+ bool upscale_images = false;
+ bool running = false;
// TODO: Save this to config file when switching modes
ImageViewMode image_view_mode = ImageViewMode::SINGLE;
Body *related_media_body;