author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
child 7 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the plugins of the Qt Toolkit. |
|
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 QDIRECTFBSCREEN_H |
|
43 |
#define QDIRECTFBSCREEN_H |
|
44 |
||
45 |
#include <qglobal.h> |
|
46 |
#ifndef QT_NO_QWS_DIRECTFB |
|
47 |
#include <QtGui/qscreen_qws.h> |
|
48 |
#include <directfb.h> |
|
49 |
#include <directfb_version.h> |
|
50 |
||
51 |
QT_BEGIN_HEADER |
|
52 |
||
53 |
QT_BEGIN_NAMESPACE |
|
54 |
||
55 |
QT_MODULE(Gui) |
|
56 |
||
57 |
#if !defined QT_DIRECTFB_SUBSURFACE && !defined QT_NO_DIRECTFB_SUBSURFACE |
|
58 |
#define QT_NO_DIRECTFB_SUBSURFACE |
|
59 |
#endif |
|
60 |
#if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER |
|
61 |
#define QT_DIRECTFB_LAYER |
|
62 |
#endif |
|
63 |
#if !defined QT_NO_DIRECTFB_WM && !defined QT_DIRECTFB_WM |
|
64 |
#define QT_DIRECTFB_WM |
|
65 |
#endif |
|
66 |
#if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE |
|
67 |
#define QT_NO_DIRECTFB_IMAGECACHE |
|
68 |
#endif |
|
69 |
#if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER |
|
70 |
#define QT_DIRECTFB_IMAGEPROVIDER |
|
71 |
#endif |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
#if !defined QT_NO_DIRECTFB_STRETCHBLIT && !defined QT_DIRECTFB_STRETCHBLIT |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
#define QT_DIRECTFB_STRETCHBLIT |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
#endif |
0 | 75 |
#if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE |
76 |
#define QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE |
|
77 |
#endif |
|
78 |
#if !defined QT_DIRECTFB_WINDOW_AS_CURSOR && !defined QT_NO_DIRECTFB_WINDOW_AS_CURSOR |
|
79 |
#define QT_NO_DIRECTFB_WINDOW_AS_CURSOR |
|
80 |
#endif |
|
81 |
#if !defined QT_DIRECTFB_PALETTE && !defined QT_NO_DIRECTFB_PALETTE |
|
82 |
#define QT_NO_DIRECTFB_PALETTE |
|
83 |
#endif |
|
84 |
#if !defined QT_NO_DIRECTFB_PREALLOCATED && !defined QT_DIRECTFB_PREALLOCATED |
|
85 |
#define QT_DIRECTFB_PREALLOCATED |
|
86 |
#endif |
|
87 |
#if !defined QT_NO_DIRECTFB_MOUSE && !defined QT_DIRECTFB_MOUSE |
|
88 |
#define QT_DIRECTFB_MOUSE |
|
89 |
#endif |
|
90 |
#if !defined QT_NO_DIRECTFB_KEYBOARD && !defined QT_DIRECTFB_KEYBOARD |
|
91 |
#define QT_DIRECTFB_KEYBOARD |
|
92 |
#endif |
|
93 |
#if !defined QT_NO_DIRECTFB_OPAQUE_DETECTION && !defined QT_DIRECTFB_OPAQUE_DETECTION |
|
94 |
#define QT_DIRECTFB_OPAQUE_DETECTION |
|
95 |
#endif |
|
96 |
#ifndef QT_NO_QWS_CURSOR |
|
97 |
#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR |
|
98 |
#define QT_DIRECTFB_CURSOR |
|
99 |
#elif defined QT_DIRECTFB_LAYER |
|
100 |
#define QT_DIRECTFB_CURSOR |
|
101 |
#endif |
|
102 |
#endif |
|
103 |
#ifndef QT_DIRECTFB_CURSOR |
|
104 |
#define QT_NO_DIRECTFB_CURSOR |
|
105 |
#endif |
|
106 |
#if defined QT_NO_DIRECTFB_LAYER && defined QT_DIRECTFB_WM |
|
107 |
#error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM |
|
108 |
#endif |
|
109 |
#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && defined QT_NO_DIRECTFB_IMAGEPROVIDER |
|
110 |
#error QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE requires QT_DIRECTFB_IMAGEPROVIDER to be defined |
|
111 |
#endif |
|
112 |
#if defined QT_DIRECTFB_WINDOW_AS_CURSOR && defined QT_NO_DIRECTFB_WM |
|
113 |
#error QT_DIRECTFB_WINDOW_AS_CURSOR requires QT_DIRECTFB_WM to be defined |
|
114 |
#endif |
|
115 |
||
116 |
#define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERSION << 8) | DIRECTFB_MICRO_VERSION) |
|
117 |
||
118 |
#define DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(F) \ |
|
119 |
static inline F operator~(F f) { return F(~int(f)); } \ |
|
120 |
static inline F operator&(F left, F right) { return F(int(left) & int(right)); } \ |
|
121 |
static inline F operator|(F left, F right) { return F(int(left) | int(right)); } \ |
|
122 |
static inline F &operator|=(F &left, F right) { left = (left | right); return left; } \ |
|
123 |
static inline F &operator&=(F &left, F right) { left = (left & right); return left; } |
|
124 |
||
125 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBInputDeviceCapabilities); |
|
126 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowDescriptionFlags); |
|
127 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowCapabilities); |
|
128 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowOptions); |
|
129 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDescriptionFlags); |
|
130 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceCapabilities); |
|
131 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceLockFlags); |
|
132 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceBlittingFlags); |
|
133 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDrawingFlags); |
|
134 |
DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceFlipFlags); |
|
135 |
||
136 |
class QDirectFBScreenPrivate; |
|
137 |
class Q_GUI_EXPORT QDirectFBScreen : public QScreen |
|
138 |
{ |
|
139 |
public: |
|
140 |
QDirectFBScreen(int display_id); |
|
141 |
~QDirectFBScreen(); |
|
142 |
||
143 |
enum DirectFBFlag { |
|
144 |
NoFlags = 0x00, |
|
145 |
VideoOnly = 0x01, |
|
146 |
SystemOnly = 0x02, |
|
147 |
BoundingRectFlip = 0x04 |
|
148 |
}; |
|
149 |
||
150 |
Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); |
|
151 |
||
152 |
DirectFBFlags directFBFlags() const; |
|
153 |
||
154 |
bool connect(const QString &displaySpec); |
|
155 |
void disconnect(); |
|
156 |
bool initDevice(); |
|
157 |
void shutdownDevice(); |
|
158 |
||
159 |
void exposeRegion(QRegion r, int changing); |
|
160 |
void solidFill(const QColor &color, const QRegion ®ion); |
|
161 |
||
162 |
void setMode(int width, int height, int depth); |
|
163 |
void blank(bool on); |
|
164 |
||
165 |
QWSWindowSurface *createSurface(QWidget *widget) const; |
|
166 |
QWSWindowSurface *createSurface(const QString &key) const; |
|
167 |
||
168 |
static QDirectFBScreen *instance(); |
|
169 |
void waitIdle(); |
|
170 |
IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; |
|
171 |
#ifdef QT_DIRECTFB_SUBSURFACE |
|
172 |
IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const; |
|
173 |
#endif |
|
174 |
IDirectFB *dfb(); |
|
175 |
#ifdef QT_DIRECTFB_WM |
|
176 |
IDirectFBWindow *windowForWidget(const QWidget *widget) const; |
|
177 |
#else |
|
178 |
IDirectFBSurface *primarySurface(); |
|
179 |
#endif |
|
180 |
#ifndef QT_NO_DIRECTFB_LAYER |
|
181 |
IDirectFBDisplayLayer *dfbDisplayLayer(); |
|
182 |
#endif |
|
183 |
||
184 |
// Track surface creation/release so we can release all on exit |
|
185 |
enum SurfaceCreationOption { |
|
186 |
DontTrackSurface = 0x1, |
|
187 |
TrackSurface = 0x2, |
|
188 |
NoPreallocated = 0x4 |
|
189 |
}; |
|
190 |
Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption); |
|
191 |
IDirectFBSurface *createDFBSurface(const QImage &image, |
|
192 |
QImage::Format format, |
|
193 |
SurfaceCreationOptions options, |
|
194 |
DFBResult *result = 0); |
|
195 |
IDirectFBSurface *createDFBSurface(const QSize &size, |
|
196 |
QImage::Format format, |
|
197 |
SurfaceCreationOptions options, |
|
198 |
DFBResult *result = 0); |
|
199 |
IDirectFBSurface *copyDFBSurface(IDirectFBSurface *src, |
|
200 |
QImage::Format format, |
|
201 |
SurfaceCreationOptions options, |
|
202 |
DFBResult *result = 0); |
|
203 |
IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, |
|
204 |
SurfaceCreationOptions options, |
|
205 |
DFBResult *result); |
|
206 |
#ifdef QT_DIRECTFB_SUBSURFACE |
|
207 |
IDirectFBSurface *getSubSurface(IDirectFBSurface *surface, |
|
208 |
const QRect &rect, |
|
209 |
SurfaceCreationOptions options, |
|
210 |
DFBResult *result); |
|
211 |
#endif |
|
212 |
||
213 |
void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags, |
|
214 |
const QRegion ®ion, const QPoint &offset); |
|
215 |
void releaseDFBSurface(IDirectFBSurface *surface); |
|
216 |
||
217 |
using QScreen::depth; |
|
218 |
static int depth(DFBSurfacePixelFormat format); |
|
219 |
static int depth(QImage::Format format); |
|
220 |
||
221 |
static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format); |
|
222 |
static DFBSurfaceDescription getSurfaceDescription(const uint *buffer, |
|
223 |
int length); |
|
224 |
static QImage::Format getImageFormat(IDirectFBSurface *surface); |
|
225 |
static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format); |
|
226 |
static inline bool isPremultiplied(QImage::Format format); |
|
227 |
static inline bool hasAlphaChannel(DFBSurfacePixelFormat format); |
|
228 |
static inline bool hasAlphaChannel(IDirectFBSurface *surface); |
|
229 |
QImage::Format alphaPixmapFormat() const; |
|
230 |
||
231 |
#ifndef QT_NO_DIRECTFB_PALETTE |
|
232 |
static void setSurfaceColorTable(IDirectFBSurface *surface, |
|
233 |
const QImage &image); |
|
234 |
#endif |
|
235 |
||
236 |
static uchar *lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl = 0); |
|
237 |
#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE |
|
238 |
void setDirectFBImageProvider(IDirectFBImageProvider *provider); |
|
239 |
#endif |
|
240 |
private: |
|
241 |
QDirectFBScreenPrivate *d_ptr; |
|
242 |
}; |
|
243 |
||
244 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions); |
|
245 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags); |
|
246 |
||
247 |
inline bool QDirectFBScreen::isPremultiplied(QImage::Format format) |
|
248 |
{ |
|
249 |
switch (format) { |
|
250 |
case QImage::Format_ARGB32_Premultiplied: |
|
251 |
case QImage::Format_ARGB8565_Premultiplied: |
|
252 |
case QImage::Format_ARGB6666_Premultiplied: |
|
253 |
case QImage::Format_ARGB8555_Premultiplied: |
|
254 |
case QImage::Format_ARGB4444_Premultiplied: |
|
255 |
return true; |
|
256 |
default: |
|
257 |
break; |
|
258 |
} |
|
259 |
return false; |
|
260 |
} |
|
261 |
||
262 |
inline bool QDirectFBScreen::hasAlphaChannel(DFBSurfacePixelFormat format) |
|
263 |
{ |
|
264 |
switch (format) { |
|
265 |
case DSPF_ARGB1555: |
|
266 |
case DSPF_ARGB: |
|
267 |
case DSPF_LUT8: |
|
268 |
case DSPF_AiRGB: |
|
269 |
case DSPF_A1: |
|
270 |
case DSPF_ARGB2554: |
|
271 |
case DSPF_ARGB4444: |
|
272 |
#if (Q_DIRECTFB_VERSION >= 0x000923) |
|
273 |
case DSPF_AYUV: |
|
274 |
#endif |
|
275 |
#if (Q_DIRECTFB_VERSION >= 0x010000) |
|
276 |
case DSPF_A4: |
|
277 |
case DSPF_ARGB1666: |
|
278 |
case DSPF_ARGB6666: |
|
279 |
case DSPF_LUT2: |
|
280 |
#endif |
|
281 |
return true; |
|
282 |
default: |
|
283 |
return false; |
|
284 |
} |
|
285 |
} |
|
286 |
||
287 |
inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface) |
|
288 |
{ |
|
289 |
Q_ASSERT(surface); |
|
290 |
DFBSurfacePixelFormat format; |
|
291 |
surface->GetPixelFormat(surface, &format); |
|
292 |
return QDirectFBScreen::hasAlphaChannel(format); |
|
293 |
} |
|
294 |
||
295 |
QT_END_NAMESPACE |
|
296 |
||
297 |
QT_END_HEADER |
|
298 |
||
299 |
#endif // QT_NO_QWS_DIRECTFB |
|
300 |
#endif // QDIRECTFBSCREEN_H |
|
301 |