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