|
1 /* This file is part of the KDE project. |
|
2 |
|
3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
|
5 This library is free software: you can redistribute it and/or modify |
|
6 it under the terms of the GNU Lesser General Public License as published by |
|
7 the Free Software Foundation, either version 2.1 or 3 of the License. |
|
8 |
|
9 This library is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 GNU Lesser General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU Lesser General Public License |
|
15 along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
16 */ |
|
17 |
|
18 #ifndef Phonon_GSTREAMER_GLRENDERER_H |
|
19 #define Phonon_GSTREAMER_GLRENDERER_H |
|
20 |
|
21 #include "videowidget.h" |
|
22 #include "common.h" |
|
23 |
|
24 #ifndef QT_NO_OPENGL |
|
25 |
|
26 #include <QtOpenGL/QGLFormat> |
|
27 #include <QtOpenGL/QGLWidget> |
|
28 |
|
29 #ifndef QT_OPENGL_ES |
|
30 QT_BEGIN_NAMESPACE |
|
31 |
|
32 class QString; |
|
33 |
|
34 namespace Phonon |
|
35 { |
|
36 namespace Gstreamer |
|
37 { |
|
38 class GLRenderWidgetImplementation; |
|
39 |
|
40 class GLRenderer : public AbstractRenderer |
|
41 { |
|
42 public: |
|
43 GLRenderer(VideoWidget *control); |
|
44 ~GLRenderer(); |
|
45 void handleMediaNodeEvent(const MediaNodeEvent *event); |
|
46 bool eventFilter(QEvent * event); |
|
47 bool paintsOnWidget() { return false; } |
|
48 private: |
|
49 GLRenderWidgetImplementation *m_glWindow; |
|
50 }; |
|
51 |
|
52 class GLRenderWidgetImplementation : public QGLWidget |
|
53 { |
|
54 Q_OBJECT |
|
55 |
|
56 // ARB_fragment_program |
|
57 typedef void (*_glProgramStringARB) (GLenum, GLenum, GLsizei, const GLvoid *); |
|
58 typedef void (*_glBindProgramARB) (GLenum, GLuint); |
|
59 typedef void (*_glDeleteProgramsARB) (GLsizei, const GLuint *); |
|
60 typedef void (*_glGenProgramsARB) (GLsizei, GLuint *); |
|
61 typedef void (*_glActiveTexture) (GLenum); |
|
62 public: |
|
63 GLRenderWidgetImplementation(VideoWidget *control, const QGLFormat &format); |
|
64 void paintEvent(QPaintEvent *event); |
|
65 GstElement *createVideoSink(); |
|
66 void updateTexture(const QByteArray &array, int width, int height); |
|
67 bool hasYUVSupport() const; |
|
68 const QImage& currentFrame() const; |
|
69 QRect drawFrameRect() const { return m_drawFrameRect; } |
|
70 bool frameIsSet() const { return !m_array.isNull(); } |
|
71 void setNextFrame(const QByteArray &array, int width, int height); |
|
72 void clearFrame(); |
|
73 private: |
|
74 _glProgramStringARB glProgramStringARB; |
|
75 _glBindProgramARB glBindProgramARB; |
|
76 _glDeleteProgramsARB glDeleteProgramsARB; |
|
77 _glGenProgramsARB glGenProgramsARB; |
|
78 _glActiveTexture glActiveTexture; |
|
79 |
|
80 mutable QImage m_frame; |
|
81 QByteArray m_array; |
|
82 int m_width; |
|
83 int m_height; |
|
84 QRect m_drawFrameRect; |
|
85 GLuint m_texture[3]; |
|
86 |
|
87 bool m_hasPrograms; |
|
88 GLuint m_program; |
|
89 bool m_yuvSupport; |
|
90 VideoWidget *m_videoWidget; |
|
91 }; |
|
92 |
|
93 } |
|
94 } //namespace Phonon::Gstreamer |
|
95 |
|
96 QT_END_NAMESPACE |
|
97 |
|
98 #endif //QT_OPENGL_ES |
|
99 #endif // QT_NO_OPENGL |
|
100 |
|
101 #endif // Phonon_GSTREAMER_GLRENDERER_H |