qt: Only include qtgui-config.h on qt >= 5.9.0
[platform/upstream/gst-plugins-good.git] / ext / qt / qtitem.h
1 /*
2  * GStreamer
3  * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef __QT_ITEM_H__
22 #define __QT_ITEM_H__
23
24 #include <gst/gst.h>
25 #include <gst/gl/gl.h>
26
27 #include "gstqtgl.h"
28 #include <QtCore/QMutex>
29 #include <QtQuick/QQuickItem>
30 #include <QtGui/QOpenGLContext>
31 #include <QtGui/QOpenGLFunctions>
32
33 typedef struct _QtGLVideoItemPrivate QtGLVideoItemPrivate;
34
35 class QtGLVideoItem;
36
37 class QtGLVideoItemInterface : public QObject
38 {
39     Q_OBJECT
40 public:
41     QtGLVideoItemInterface (QtGLVideoItem *w) : qt_item (w), lock() {};
42
43     void invalidateRef();
44
45     void setBuffer (GstBuffer * buffer);
46     gboolean setCaps (GstCaps *caps);
47     gboolean initWinSys ();
48     GstGLContext *getQtContext();
49     GstGLContext *getContext();
50     GstGLDisplay *getDisplay();
51     QtGLVideoItem *videoItem () { return qt_item; };
52
53     void setDAR(gint, gint);
54     void getDAR(gint *, gint *);
55     void setForceAspectRatio(bool);
56     bool getForceAspectRatio();
57 private:
58     QtGLVideoItem *qt_item;
59     QMutex lock;
60 };
61
62 class InitializeSceneGraph;
63
64 class QtGLVideoItem : public QQuickItem, protected QOpenGLFunctions
65 {
66     Q_OBJECT
67 public:
68     QtGLVideoItem();
69     ~QtGLVideoItem();
70
71     void setDAR(gint, gint);
72     void getDAR(gint *, gint *);
73     void setForceAspectRatio(bool);
74     bool getForceAspectRatio();
75
76     QSharedPointer<QtGLVideoItemInterface> getInterface() { return proxy; };
77     /* private for C interface ... */
78     QtGLVideoItemPrivate *priv;
79
80 Q_SIGNALS:
81     void itemInitialized();
82
83 private Q_SLOTS:
84     void handleWindowChanged(QQuickWindow * win);
85     void onSceneGraphInitialized();
86     void onSceneGraphInvalidated();
87
88 protected:
89     QSGNode * updatePaintNode (QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData);
90
91 private:
92
93     friend class InitializeSceneGraph;
94     void setViewportSize(const QSize &size);
95     void shareContext();
96
97     QSize m_viewportSize;
98     bool m_openGlContextInitialized;
99
100     QSharedPointer<QtGLVideoItemInterface> proxy;
101 };
102
103 #endif /* __QT_ITEM_H__ */