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

Last change on this file since 769 was 769, checked in by Dmitry A. Kuminov, 15 years ago

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

  • Property svn:eol-style set to native
File size: 11.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 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
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 &region, 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
241private:
242 QDirectFBScreenPrivate *d_ptr;
243};
244
245Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions);
246Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags);
247
248inline 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
263inline 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
288inline 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
296QT_END_NAMESPACE
297
298QT_END_HEADER
299
300#endif // QT_NO_QWS_DIRECTFB
301#endif // QDIRECTFBSCREEN_H
302
Note: See TracBrowser for help on using the repository browser.