X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fjpeg_frame_view.h;h=b66e2656d437cedc7d6407c45f5f11afe59ff5bf;hb=6fe0ba86faca3769c57bf30cbf526959b418fc9a;hp=3ecfa0d2f4568254a4e41fa64798523860755c13;hpb=5e85184e5e35367d2bbcd41970c0a4f7fde8c9c5;p=nageru diff --git a/futatabi/jpeg_frame_view.h b/futatabi/jpeg_frame_view.h index 3ecfa0d..b66e265 100644 --- a/futatabi/jpeg_frame_view.h +++ b/futatabi/jpeg_frame_view.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include enum CacheMissBehavior { @@ -22,12 +24,14 @@ enum CacheMissBehavior { std::shared_ptr decode_jpeg(const std::string &jpeg); std::shared_ptr decode_jpeg_with_cache(FrameOnDisk id, CacheMissBehavior cache_miss_behavior, FrameReader *frame_reader, bool *did_decode); +std::shared_ptr get_black_frame(); class JPEGFrameView : public QGLWidget { Q_OBJECT public: JPEGFrameView(QWidget *parent); + ~JPEGFrameView(); void setFrame(unsigned stream_idx, FrameOnDisk frame, FrameOnDisk secondary_frame = {}, float fade_alpha = 0.0f); void setFrame(std::shared_ptr frame); @@ -39,8 +43,6 @@ public: void setDecodedFrame(std::shared_ptr frame, std::shared_ptr secondary_frame, float fade_alpha); void set_overlay(const std::string &text); // Blank for none. - static void shutdown(); - signals: void clicked(); @@ -50,7 +52,7 @@ protected: void paintGL() override; private: - static void jpeg_decoder_thread_func(); + void jpeg_decoder_thread_func(); FrameReader frame_reader; @@ -72,7 +74,22 @@ private: int gl_width, gl_height; - static std::thread jpeg_decoder_thread; + std::thread jpeg_decoder_thread; + movit::ResourcePool *resource_pool = nullptr; + + struct PendingDecode { + // For actual decodes (only if frame below is nullptr). + FrameOnDisk primary, secondary; + float fade_alpha; // Irrelevant if secondary.stream_idx == -1. + + // Already-decoded frames are also sent through PendingDecode, + // so that they get drawn in the right order. If frame is nullptr, + // it's a real decode. + std::shared_ptr frame; + }; + + std::condition_variable any_pending_decodes; + std::deque pending_decodes; // Under cache_mu. }; #endif // !defined(_JPEG_FRAME_VIEW_H)