]> git.sesse.net Git - kdenlive/blob - src/widgets/videoglwidget.h
Fix jittering issues when sending GL textures cross-thread.
[kdenlive] / src / widgets / videoglwidget.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *               2014 by Jean-Nicolas Artaud (jeannicolasartaud@gmail.com) *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
19  ***************************************************************************/
20
21 #ifndef VIDEOGLWIDGET_H
22 #define VIDEOGLWIDGET_H
23
24 #include <QGLWidget>
25
26 namespace Mlt {
27 class Frame;
28 }
29
30 class VideoGLWidget : public QGLWidget
31 {
32     Q_OBJECT
33
34 public:
35     explicit VideoGLWidget(QWidget *parent = 0, QGLWidget *share = 0);
36     ~VideoGLWidget();
37     void activateMonitor();
38     QSize minimumSizeHint() const;
39     QSize sizeHint() const;
40     void setImageAspectRatio(double ratio);
41     void setBackgroundColor(const QColor &color) {
42         m_backgroundColor = color;
43     }
44
45 public slots:
46     void showImage(const QImage &image);
47     void showImage(Mlt::Frame*, GLuint);
48
49 protected:
50     void initializeGL();
51     void resizeGL(int width, int height);
52     void resizeEvent(QResizeEvent* event);
53     void paintGL();
54     void mouseDoubleClickEvent(QMouseEvent * event);
55
56 private:
57     int x, y, w, h;
58     int m_image_width, m_image_height;
59     GLuint m_texture;
60     Mlt::Frame *m_frame;
61     GLuint m_frame_texture;
62     double m_display_ratio;
63     QColor m_backgroundColor;
64     Qt::WindowFlags m_baseFlags;
65 };
66
67 #endif