]> git.sesse.net Git - nageru/blob - jpeg_frame_view.h
Make the JPEG decoding run asynchronously, in a separate thread with a bit of queue...
[nageru] / jpeg_frame_view.h
1 #ifndef _JPEG_FRAME_VIEW_H
2 #define _JPEG_FRAME_VIEW_H 1
3
4 #include <QGraphicsView>
5 #include <QGraphicsPixmapItem>
6 #include <QGraphicsScene>
7
8 #include <stdint.h>
9
10 #include <memory>
11
12 class JPEGFrameView : public QGraphicsView {
13         Q_OBJECT
14
15 public:
16         JPEGFrameView(QWidget *parent);
17
18         void setFrame(unsigned stream_idx, int64_t pts)
19         {
20                 this->stream_idx = stream_idx;
21                 this->pts = pts;
22                 update_frame();
23         }
24
25         void setPixmap(std::shared_ptr<QPixmap> pixmap);
26
27 protected:
28         void resizeEvent(QResizeEvent *event) override;
29
30 private:
31         void update_frame();
32
33         QGraphicsPixmapItem item;
34         QGraphicsScene scene;
35
36         unsigned stream_idx;
37         int64_t pts;
38         bool dirty = false;
39 };
40
41 #endif  // !defined(_JPEG_FRAME_VIEW_H)