|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QPAINTERVIDEOSURFACE_P_H |
|
43 #define QPAINTERVIDEOSURFACE_P_H |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 |
|
56 #include <qmobilityglobal.h> |
|
57 #include <QtCore/qsize.h> |
|
58 #include <QtGui/qimage.h> |
|
59 #include <QtGui/qmatrix4x4.h> |
|
60 #include <QtGui/qpaintengine.h> |
|
61 #include <qabstractvideosurface.h> |
|
62 #include <qvideoframe.h> |
|
63 |
|
64 QT_BEGIN_NAMESPACE |
|
65 class QGLContext; |
|
66 QT_END_NAMESPACE |
|
67 |
|
68 QT_USE_NAMESPACE |
|
69 |
|
70 QT_BEGIN_NAMESPACE |
|
71 |
|
72 class QVideoSurfacePainter |
|
73 { |
|
74 public: |
|
75 virtual ~QVideoSurfacePainter(); |
|
76 |
|
77 virtual QList<QVideoFrame::PixelFormat> supportedPixelFormats( |
|
78 QAbstractVideoBuffer::HandleType handleType) const = 0; |
|
79 |
|
80 virtual bool isFormatSupported( |
|
81 const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar) const = 0; |
|
82 |
|
83 virtual QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) = 0; |
|
84 virtual void stop() = 0; |
|
85 |
|
86 virtual QAbstractVideoSurface::Error setCurrentFrame(const QVideoFrame &frame) = 0; |
|
87 |
|
88 virtual QAbstractVideoSurface::Error paint( |
|
89 const QRectF &target, QPainter *painter, const QRectF &source) = 0; |
|
90 |
|
91 virtual void updateColors(int brightness, int contrast, int hue, int saturation) = 0; |
|
92 virtual void viewportDestroyed() {} |
|
93 }; |
|
94 |
|
95 |
|
96 class Q_AUTOTEST_EXPORT QPainterVideoSurface : public QAbstractVideoSurface |
|
97 { |
|
98 Q_OBJECT |
|
99 public: |
|
100 explicit QPainterVideoSurface(QObject *parent = 0); |
|
101 ~QPainterVideoSurface(); |
|
102 |
|
103 QList<QVideoFrame::PixelFormat> supportedPixelFormats( |
|
104 QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; |
|
105 |
|
106 bool isFormatSupported( |
|
107 const QVideoSurfaceFormat &format, QVideoSurfaceFormat *similar = 0) const; |
|
108 |
|
109 bool start(const QVideoSurfaceFormat &format); |
|
110 void stop(); |
|
111 |
|
112 bool present(const QVideoFrame &frame); |
|
113 |
|
114 int brightness() const; |
|
115 void setBrightness(int brightness); |
|
116 |
|
117 int contrast() const; |
|
118 void setContrast(int contrast); |
|
119 |
|
120 int hue() const; |
|
121 void setHue(int hue); |
|
122 |
|
123 int saturation() const; |
|
124 void setSaturation(int saturation); |
|
125 |
|
126 bool isReady() const; |
|
127 void setReady(bool ready); |
|
128 |
|
129 void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1)); |
|
130 |
|
131 #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) |
|
132 const QGLContext *glContext() const; |
|
133 void setGLContext(QGLContext *context); |
|
134 |
|
135 enum ShaderType |
|
136 { |
|
137 NoShaders = 0x00, |
|
138 FragmentProgramShader = 0x01, |
|
139 GlslShader = 0x02 |
|
140 }; |
|
141 |
|
142 Q_DECLARE_FLAGS(ShaderTypes, ShaderType) |
|
143 |
|
144 ShaderTypes supportedShaderTypes() const; |
|
145 |
|
146 ShaderType shaderType() const; |
|
147 void setShaderType(ShaderType type); |
|
148 #endif |
|
149 |
|
150 public Q_SLOTS: |
|
151 void viewportDestroyed(); |
|
152 |
|
153 Q_SIGNALS: |
|
154 void frameChanged(); |
|
155 |
|
156 private: |
|
157 void createPainter(); |
|
158 |
|
159 QVideoSurfacePainter *m_painter; |
|
160 #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) |
|
161 QGLContext *m_glContext; |
|
162 ShaderTypes m_shaderTypes; |
|
163 ShaderType m_shaderType; |
|
164 #endif |
|
165 int m_brightness; |
|
166 int m_contrast; |
|
167 int m_hue; |
|
168 int m_saturation; |
|
169 |
|
170 QVideoFrame::PixelFormat m_pixelFormat; |
|
171 QSize m_frameSize; |
|
172 QRect m_sourceRect; |
|
173 bool m_colorsDirty; |
|
174 bool m_ready; |
|
175 }; |
|
176 |
|
177 #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) |
|
178 Q_DECLARE_OPERATORS_FOR_FLAGS(QPainterVideoSurface::ShaderTypes) |
|
179 #endif |
|
180 |
|
181 QT_END_NAMESPACE |
|
182 |
|
183 #endif |