X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fimage_input.h;h=32fd52913a6cf2b930e6866772c0592ab004e89f;hb=021fa9fa5ce103ae5843647fee3d5d1d7038d32f;hp=ac3c519147d6d4d6f66ad4e2baffaffaabdf7a69;hpb=c660c05323237bf118e6844c71703bf96be70d32;p=nageru diff --git a/nageru/image_input.h b/nageru/image_input.h index ac3c519..32fd529 100644 --- a/nageru/image_input.h +++ b/nageru/image_input.h @@ -13,21 +13,29 @@ #include #include +#include "ref_counted_texture.h" +#include "tweaked_inputs.h" + +class QSurface; + // An output that takes its input from a static image, loaded with ffmpeg. // comes from a single 2D array with chunky pixels. The image is refreshed // from disk about every second. -class ImageInput : public movit::FlatInput { +class ImageInput : public sRGBSwitchingFlatInput { public: + // NOTE: You will need to call start_update_thread() yourself, once per program. ImageInput(const std::string &filename); std::string effect_type_id() const override { return "ImageInput"; } void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) override; - static void shutdown_updaters(); + + static void start_update_thread(QSurface *surface); + static void end_update_thread(); private: struct Image { unsigned width, height; - std::unique_ptr pixels; + RefCountedTexture tex; timespec last_modified; }; @@ -36,15 +44,14 @@ private: static std::shared_ptr load_image(const std::string &filename, const std::string &pathname); static std::shared_ptr load_image_raw(const std::string &pathname); - static void update_thread_func(); + static void update_thread_func(QSurface *surface); static std::mutex all_images_lock; static std::map> all_images; // Under all_images_lock. - static bool update_thread_started; // Under all_images_lock. - static std::thread update_thread; // Under all_images_lock. - static std::mutex threads_should_quit_mu; - static bool threads_should_quit; // Under threads_should_quit_mu. - static std::condition_variable threads_should_quit_modified; // Signals when threads_should_quit is set. + static std::thread update_thread; + static std::mutex update_thread_should_quit_mu; + static bool update_thread_should_quit; // Under thread_should_quit_mu. + static std::condition_variable update_thread_should_quit_modified; // Signals when threads_should_quit is set. }; #endif // !defined(_IMAGE_INPUT_H)