X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fjpeg_frame_view.h;h=693ea9b6d0a4c5f58fd3f4afafc7ca1ccf484847;hb=refs%2Fheads%2Fmaster;hp=9af7d2cb7e05f2b30eac4bc9c1841e6239805cd0;hpb=996c5ad2c506048694b32988f7e376a97924c3e9;p=nageru diff --git a/futatabi/jpeg_frame_view.h b/futatabi/jpeg_frame_view.h index 9af7d2c..693ea9b 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; @@ -61,10 +62,11 @@ private: std::unique_ptr ycbcr_converter; movit::EffectChain *current_chain = nullptr; // Owned by ycbcr_converter. - std::shared_ptr current_frame; // So that we hold on to the pixels. + bool displayed_this_frame = false; // Owned by the UI frame. + std::shared_ptr current_frame; // So that we hold on to the textures. std::shared_ptr current_secondary_frame; // Same. - static constexpr int overlay_base_width = 16, overlay_base_height = 16; + int overlay_base_width = 16, overlay_base_height = 16; int overlay_width = overlay_base_width, overlay_height = overlay_base_height; std::unique_ptr overlay_image; // If nullptr, no overlay. std::unique_ptr overlay_chain; // Just to get the overlay on screen in the easiest way possible. @@ -73,7 +75,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)