source: trunk/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h@ 1050

Last change on this file since 1050 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 11.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the plugins of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
51QT_BEGIN_HEADER
52
53QT_BEGIN_NAMESPACE
54
55QT_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
125DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBInputDeviceCapabilities);
126DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowDescriptionFlags);
127DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowCapabilities);
128DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowOptions);
129DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDescriptionFlags);
130DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceCapabilities);
131DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceLockFlags);
132DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceBlittingFlags);
133DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDrawingFlags);
134DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceFlipFlags);
135
136class QDirectFBScreenPrivate;
137class Q_GUI_EXPORT QDirectFBScreen : public QScreen
138{
139public:
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 &region);
162 static void solidFill(IDirectFBSurface *surface, const QColor &color, const QRegion &region);
163
164 void setMode(int width, int height, int depth);
165 void blank(bool on);
166
167 QWSWindowSurface *createSurface(QWidget *widget) const;
168 QWSWindowSurface *createSurface(const QString &key) const;
169
170 static QDirectFBScreen *instance();
171 void waitIdle();
172 IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const;
173#ifdef QT_DIRECTFB_SUBSURFACE
174 IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const;
175#endif
176 IDirectFB *dfb();
177#ifdef QT_DIRECTFB_WM
178 IDirectFBWindow *windowForWidget(const QWidget *widget) const;
179#else
180 IDirectFBSurface *primarySurface();
181#endif
182#ifndef QT_NO_DIRECTFB_LAYER
183 IDirectFBDisplayLayer *dfbDisplayLayer();
184#endif
185
186 // Track surface creation/release so we can release all on exit
187 enum SurfaceCreationOption {
188 DontTrackSurface = 0x1,
189 TrackSurface = 0x2,
190 NoPreallocated = 0x4
191 };
192 Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption);
193 IDirectFBSurface *createDFBSurface(const QImage &image,
194 QImage::Format format,
195 SurfaceCreationOptions options,
196 DFBResult *result = 0);
197 IDirectFBSurface *createDFBSurface(const QSize &size,
198 QImage::Format format,
199 SurfaceCreationOptions options,
200 DFBResult *result = 0);
201 IDirectFBSurface *copyDFBSurface(IDirectFBSurface *src,
202 QImage::Format format,
203 SurfaceCreationOptions options,
204 DFBResult *result = 0);
205 IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc,
206 SurfaceCreationOptions options,
207 DFBResult *result);
208#ifdef QT_DIRECTFB_SUBSURFACE
209 IDirectFBSurface *getSubSurface(IDirectFBSurface *surface,
210 const QRect &rect,
211 SurfaceCreationOptions options,
212 DFBResult *result);
213#endif
214
215 void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags,
216 const QRegion &region, const QPoint &offset);
217 void releaseDFBSurface(IDirectFBSurface *surface);
218
219 using QScreen::depth;
220 static int depth(DFBSurfacePixelFormat format);
221 static int depth(QImage::Format format);
222
223 static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format);
224 static DFBSurfaceDescription getSurfaceDescription(const uint *buffer,
225 int length);
226 static QImage::Format getImageFormat(IDirectFBSurface *surface);
227 static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format);
228 static inline bool isPremultiplied(QImage::Format format);
229 static inline bool hasAlphaChannel(DFBSurfacePixelFormat format);
230 static inline bool hasAlphaChannel(IDirectFBSurface *surface);
231 QImage::Format alphaPixmapFormat() const;
232
233#ifndef QT_NO_DIRECTFB_PALETTE
234 static void setSurfaceColorTable(IDirectFBSurface *surface,
235 const QImage &image);
236#endif
237
238 static uchar *lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl = 0);
239#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
240 void setDirectFBImageProvider(IDirectFBImageProvider *provider);
241#endif
242private:
243 QDirectFBScreenPrivate *d_ptr;
244};
245
246Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions);
247Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags);
248
249inline bool QDirectFBScreen::isPremultiplied(QImage::Format format)
250{
251 switch (format) {
252 case QImage::Format_ARGB32_Premultiplied:
253 case QImage::Format_ARGB8565_Premultiplied:
254 case QImage::Format_ARGB6666_Premultiplied:
255 case QImage::Format_ARGB8555_Premultiplied:
256 case QImage::Format_ARGB4444_Premultiplied:
257 return true;
258 default:
259 break;
260 }
261 return false;
262}
263
264inline bool QDirectFBScreen::hasAlphaChannel(DFBSurfacePixelFormat format)
265{
266 switch (format) {
267 case DSPF_ARGB1555:
268 case DSPF_ARGB:
269 case DSPF_LUT8:
270 case DSPF_AiRGB:
271 case DSPF_A1:
272 case DSPF_ARGB2554:
273 case DSPF_ARGB4444:
274#if (Q_DIRECTFB_VERSION >= 0x000923)
275 case DSPF_AYUV:
276#endif
277#if (Q_DIRECTFB_VERSION >= 0x010000)
278 case DSPF_A4:
279 case DSPF_ARGB1666:
280 case DSPF_ARGB6666:
281 case DSPF_LUT2:
282#endif
283 return true;
284 default:
285 return false;
286 }
287}
288
289inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface)
290{
291 Q_ASSERT(surface);
292 DFBSurfacePixelFormat format;
293 surface->GetPixelFormat(surface, &format);
294 return QDirectFBScreen::hasAlphaChannel(format);
295}
296
297QT_END_NAMESPACE
298
299QT_END_HEADER
300
301#endif // QT_NO_QWS_DIRECTFB
302#endif // QDIRECTFBSCREEN_H
303
Note: See TracBrowser for help on using the repository browser.