X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fjpeg_frame_view.h;h=b66e2656d437cedc7d6407c45f5f11afe59ff5bf;hb=36ae902913f91a6e4d3d6a1f5d16a0ab1b92c3ae;hp=9af7d2cb7e05f2b30eac4bc9c1841e6239805cd0;hpb=9f90c49a50f30b13ed6638515d17cac7e6712d19;p=nageru diff --git a/futatabi/jpeg_frame_view.h b/futatabi/jpeg_frame_view.h index 9af7d2c..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 { @@ -29,6 +31,7 @@ class JPEGFrameView : public QGLWidget { 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); @@ -40,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(); @@ -51,7 +52,7 @@ protected: void paintGL() override; private: - static void jpeg_decoder_thread_func(); + void jpeg_decoder_thread_func(); FrameReader frame_reader; @@ -73,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)