|
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 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_NO_DIRECTFB_STRETCHBLIT && !defined QT_DIRECTFB_STRETCHBLIT |
|
73 #define QT_DIRECTFB_STRETCHBLIT |
|
74 #endif |
|
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 NoPartialFlip = 0x08 |
|
149 }; |
|
150 |
|
151 Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag); |
|
152 |
|
153 DirectFBFlags directFBFlags() const; |
|
154 |
|
155 bool connect(const QString &displaySpec); |
|
156 void disconnect(); |
|
157 bool initDevice(); |
|
158 void shutdownDevice(); |
|
159 |
|
160 void exposeRegion(QRegion r, int changing); |
|
161 void solidFill(const QColor &color, const QRegion ®ion); |
|
162 |
|
163 void setMode(int width, int height, int depth); |
|
164 void blank(bool on); |
|
165 |
|
166 QWSWindowSurface *createSurface(QWidget *widget) const; |
|
167 QWSWindowSurface *createSurface(const QString &key) const; |
|
168 |
|
169 static QDirectFBScreen *instance(); |
|
170 void waitIdle(); |
|
171 IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const; |
|
172 #ifdef QT_DIRECTFB_SUBSURFACE |
|
173 IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const; |
|
174 #endif |
|
175 IDirectFB *dfb(); |
|
176 #ifdef QT_DIRECTFB_WM |
|
177 IDirectFBWindow *windowForWidget(const QWidget *widget) const; |
|
178 #else |
|
179 IDirectFBSurface *primarySurface(); |
|
180 #endif |
|
181 #ifndef QT_NO_DIRECTFB_LAYER |
|
182 IDirectFBDisplayLayer *dfbDisplayLayer(); |
|
183 #endif |
|
184 |
|
185 // Track surface creation/release so we can release all on exit |
|
186 enum SurfaceCreationOption { |
|
187 DontTrackSurface = 0x1, |
|
188 TrackSurface = 0x2, |
|
189 NoPreallocated = 0x4 |
|
190 }; |
|
191 Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption); |
|
192 IDirectFBSurface *createDFBSurface(const QImage &image, |
|
193 QImage::Format format, |
|
194 SurfaceCreationOptions options, |
|
195 DFBResult *result = 0); |
|
196 IDirectFBSurface *createDFBSurface(const QSize &size, |
|
197 QImage::Format format, |
|
198 SurfaceCreationOptions options, |
|
199 DFBResult *result = 0); |
|
200 IDirectFBSurface *copyDFBSurface(IDirectFBSurface *src, |
|
201 QImage::Format format, |
|
202 SurfaceCreationOptions options, |
|
203 DFBResult *result = 0); |
|
204 IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc, |
|
205 SurfaceCreationOptions options, |
|
206 DFBResult *result); |
|
207 #ifdef QT_DIRECTFB_SUBSURFACE |
|
208 IDirectFBSurface *getSubSurface(IDirectFBSurface *surface, |
|
209 const QRect &rect, |
|
210 SurfaceCreationOptions options, |
|
211 DFBResult *result); |
|
212 #endif |
|
213 |
|
214 void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags, |
|
215 const QRegion ®ion, const QPoint &offset); |
|
216 void releaseDFBSurface(IDirectFBSurface *surface); |
|
217 |
|
218 using QScreen::depth; |
|
219 static int depth(DFBSurfacePixelFormat format); |
|
220 static int depth(QImage::Format format); |
|
221 |
|
222 static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format); |
|
223 static DFBSurfaceDescription getSurfaceDescription(const uint *buffer, |
|
224 int length); |
|
225 static QImage::Format getImageFormat(IDirectFBSurface *surface); |
|
226 static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format); |
|
227 static inline bool isPremultiplied(QImage::Format format); |
|
228 static inline bool hasAlphaChannel(DFBSurfacePixelFormat format); |
|
229 static inline bool hasAlphaChannel(IDirectFBSurface *surface); |
|
230 QImage::Format alphaPixmapFormat() const; |
|
231 |
|
232 #ifndef QT_NO_DIRECTFB_PALETTE |
|
233 static void setSurfaceColorTable(IDirectFBSurface *surface, |
|
234 const QImage &image); |
|
235 #endif |
|
236 |
|
237 static uchar *lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl = 0); |
|
238 #if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE |
|
239 void setDirectFBImageProvider(IDirectFBImageProvider *provider); |
|
240 #endif |
|
241 private: |
|
242 QDirectFBScreenPrivate *d_ptr; |
|
243 }; |
|
244 |
|
245 Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions); |
|
246 Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags); |
|
247 |
|
248 inline bool QDirectFBScreen::isPremultiplied(QImage::Format format) |
|
249 { |
|
250 switch (format) { |
|
251 case QImage::Format_ARGB32_Premultiplied: |
|
252 case QImage::Format_ARGB8565_Premultiplied: |
|
253 case QImage::Format_ARGB6666_Premultiplied: |
|
254 case QImage::Format_ARGB8555_Premultiplied: |
|
255 case QImage::Format_ARGB4444_Premultiplied: |
|
256 return true; |
|
257 default: |
|
258 break; |
|
259 } |
|
260 return false; |
|
261 } |
|
262 |
|
263 inline bool QDirectFBScreen::hasAlphaChannel(DFBSurfacePixelFormat format) |
|
264 { |
|
265 switch (format) { |
|
266 case DSPF_ARGB1555: |
|
267 case DSPF_ARGB: |
|
268 case DSPF_LUT8: |
|
269 case DSPF_AiRGB: |
|
270 case DSPF_A1: |
|
271 case DSPF_ARGB2554: |
|
272 case DSPF_ARGB4444: |
|
273 #if (Q_DIRECTFB_VERSION >= 0x000923) |
|
274 case DSPF_AYUV: |
|
275 #endif |
|
276 #if (Q_DIRECTFB_VERSION >= 0x010000) |
|
277 case DSPF_A4: |
|
278 case DSPF_ARGB1666: |
|
279 case DSPF_ARGB6666: |
|
280 case DSPF_LUT2: |
|
281 #endif |
|
282 return true; |
|
283 default: |
|
284 return false; |
|
285 } |
|
286 } |
|
287 |
|
288 inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface) |
|
289 { |
|
290 Q_ASSERT(surface); |
|
291 DFBSurfacePixelFormat format; |
|
292 surface->GetPixelFormat(surface, &format); |
|
293 return QDirectFBScreen::hasAlphaChannel(format); |
|
294 } |
|
295 |
|
296 QT_END_NAMESPACE |
|
297 |
|
298 QT_END_HEADER |
|
299 |
|
300 #endif // QT_NO_QWS_DIRECTFB |
|
301 #endif // QDIRECTFBSCREEN_H |
|
302 |