source: trunk/doc/src/platforms/emb-directfb-EmbLinux.qdoc@ 651

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

trunk: Merged in qt 4.6.2 sources.

  • Property svn:eol-style set to native
File size: 13.4 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 documentation 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/*!
43\page qt-embeddedLinux-directfb.html
44
45\title Qt for Embedded Linux and DirectFB
46
47\ingroup qt-embedded-linux
48
49\section1 Introduction
50
51DirectFB is an open source LGPL licensed project founded by Denis Oliver Kropp
52and generally chip vendors start out with the official version and
53implement their own plugins to optimize the operations their hardware
54supports.
55
56We recommend using Qt 4.6 with DirectFB. DirectFB support was introduced
57already into Qt for Embedded Linux as a labs project for Qt 4.3 and folded
58into Qt as a screen driver for Qt 4.4, but not supported fully. In Qt 4.5,
59major changes were made to make it work with the optimized raster paint
60engine. And in Qt 4.6 these have been further improved.
61
62\tableofcontents
63
64\section1 Using DirectFB with Qt
65DirectFB is centered around \l{DirectFB - IDirectFBSurface}{Surfaces}
66which is the equivalent of a QPaintDevice. In the Qt/DirectFB plugin,
67DirectFB maps onto either a QPixmap or a QWindowSurface which essentially
68means that drawing onto QPixmap or a QWidget can be accelerated and drawing
69onto any other paint device (e.g. QImage) cannot.
70
71\section2 Configure
72
73When configuring Qt there are two options, from which you can choose:
74
75\code
76 ./configure -plugin-gfx-directfb
77 ./configure -qt-gfx-directfb
78
79\endcode
80
81With either mode, Qt will try the following to look for the DirectFB
82includes/libs.
83
84\list
85 \o Use pkg-config
86 \o Use directfb-config
87 \o Check in your qmake.conf
88\endlist
89
90Often the values returned from pkg-config/directfb-config indicates the
91locations of the libs/headers on the target rootfs, rather than their
92location on your host. The safest option is usually to explicitly populate
93these variables in your qmake.conf like this:
94
95\code
96QT_CFLAGS_DIRECTFB =
97/opt/toolchain/gcc4.3_mipsel_linux/usr/include/directfb -D_REENTRANT
98QT_LIBS_DIRECTFB = -L/opt/toolchain/gcc4.3_mipsel_linux/usr/lib/-ldirect
99-ldirectfb -lfusion
100\endcode
101
102\note While DirectFB supports a multi-process setup through a
103kernel-extension called Fusion this setup is not well tested with Qt.
104
105\section2 Supported graphics operations
106
107IDirectFBSurface supports blitting, filling, drawing lines rects etc, but
108it does not support everything Qt allows you to do. E.g. painter paths,
109polygons, complex transformations, antialiasing, gradients. Some of these
110things are handled in newer versions of DirectFB and could be supported by
111Qt. They are seemingly optional at the driver level, so you need to have
112fall back code paths for older drivers and drivers on which this is not
113implemented.
114
115The QDirectFBPaintEngine is a subclass of the QRasterPaintEngine, thus
116essentially supporting everything QRasterPaintEngine supports. This means
117that it supports all graphical operations that Qt supports, but certain
118operations will have to fall back to software rendering and that should be
119avoided due to performance issues. Instead, these operations should be
120rendered into a QPixmap once, and then reuse the pixmap.
121
122Note: Fallbacks to software rendering should be avoided. If unsupported
123operations are used, the paint engine must fallback to the
124QRasterPaintEngine engine. A good debugging tip is to make Qt warn you when
125such fall backs occur, and to disable the fall back and only return.
126Debugging options are listed below.
127
128\section2 DirectFB driver
129DirectFB also provides an abstraction for keyboard and mouse drivers. This
130simplifies the process of getting the target hardware up and running. It
131also brings us to a feature fragmentation issue between different versions
132of DirectFB.
133
134The Qt DirectFB driver currently supports DirectFB versions >= 0.9. Still,
135there are large differences in what each actual implementation handles
136correctly. It is relatively common not to properly support
137\l{DirectFB - IDirectFBWindow}{DirectFB windows}, so Qt needs to handle
138this case with a different code path. In addition, certain drivers do not
139properly support DirectFB's cursor handling. This means Qt has to have a
140code path for rendering the cursor itself when this is the case.
141Some drivers do not let us create
142\l{DirectFB - DFBSurfaceDescription}{preallocated surfaces} which means we
143have to have a conditional code path for that case.
144
145\section2 Optimize performance using define options
146
147Qt/DirectFB comes with a number of defines that can be either
148uncommented in directfb.pri or added to the QT_DEFINES_DIRECTFB variable in
149your qmake.conf.
150
151\note The defines have been moved from
152\e{src/plugins/gfxdrivers/directfb/directfb.pro} to
153\e{src/gui/embedded/directfb.pri}
154
155\code
156#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|
157 DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|
158 DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT
159
160 #DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
161 #DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
162\endcode
163
164As demonstrated above, you need to Qt which drawing operations you want to
165warn/disable. Since there are varying implementations of DirectFB from
166manufacturer to manufacture, different operations will be optimized. This
167require you to define the operations you want to warn about or disable.
168These are listed above in the DIRECTFB_DRAWINGOPERATIONS variable.
169
170Following is a table showing which options you have.
171
172\table
173 \header
174 \o Define option
175 \o Description
176 \row
177 \o QT_DIRECTFB_IMAGECACHE
178 \o Defining this means that Qt will cache an IDirectFBSurface per
179QImage you draw based on its \l{QImage::}{cacheKey()}.
180Use this define if your application draws many QImages that
181remain the same. Note that if you in this situation draw an image and then
182change it, by calling bits() or opening a QPainter on it, the cache will
183not benefit you. You can control the cache size with the imageCacheSize
184connect option.
185
186 \row
187 \o QT_NO_DIRECTFB_WM
188 \o If your DirectFB implementation does not support windows, you
189have to define this to make Qt work properly. You can test this by checking
190if the \l{DirectFB - df_window example}{df_window example} runs well.
191This means that all drawing operations onto a QWidget involves
192an extra blitting step since Qt essentially first has to draw into an
193off-screen buffer and then blit this buffer to the back buffer of the
194primary surface. Finally, Qt must flip the back buffer to the front buffer,
195which usually involves another blit. Still, blits are usually very fast
196with DirectFB.
197
198To work around this you can make your widget paint on screen, \l
199Qt::WA_PaintOnScreen but this comes with other limitations. This should be
200avoided if you want more than one full-screen window in your application.
201In addition, it will not work without proper DirectFB mouse support from the
202layer. Also, see QT_NO_DIRECTFB_LAYER for more.
203
204 \row
205 \o QT_NO_DIRECTFB_LAYER
206 \o If your DirectFB display layer cannot be used for e.g. drawing
207mouse cursor, creating windows you have to define this. Defining this also
208requires defining QT_NO_DIRECTFB_WM and involves making Qt render the
209cursor rather than letting DirectFB do it.
210
211 \row
212 \o QT_NO_DIRECTFB_PALETTE
213 \o Define this if your DirectFB driver does not support surfaces
214with \l{DirectFB - IDirectFBPalette}{color tables}.
215The effect of defining this is that Qt will have to convert
216images with \l QImage::Format_Indexed8 format to another format before
217rendering them.
218
219 \row
220 \o QT_NO_DIRECTFB_PREALLOCATED
221 \o Define this if your DirectFB driver does not support creating a
222surface with preallocated data. This will make a more frequent use of
223\l{C++ Reference - memcpy}{memcpy()}
224when drawing images. If you define this, you might want to consider
225defining QT_DIRECTFB_IMAGECACHE for better image rendering performance.
226
227 \row
228 \o QT_NO_DIRECTFB_MOUSE and QT_NO_DIRECTFB_KEYBOARD
229 \o Define this if your driver does not provide keyboard/mouse
230events through \l{DirectFB - CreateInputEventBuffer}{CreateInputEventBuffer}.
231This means that Qt cannot use DirectFB to receive keyboard/mouse events and
232if you want such events in your application, you will have to provide
233another driver. For more info see \l {Qt for Embedded Linux Pointer
234Handling}{Qt for Embedded Linux Pointer Handling} and \l{Qt for Embedded
235Linux Character Input}{Qt for Embedded Linux Character Input}
236
237 \row
238 \o QT_DIRECTFB_TIMING
239 \o Define this when debugging to get output on stderr about the
240frames per second.
241
242 \row
243 \o QT_NO_DIRECTFB_OPAQUE_DETECTION
244 \o When blitting a surface Qt has to decide whether to set the
245\l{DirectFB - DFBSurfaceBlittingFlags}{DSBLIT_BLEND_ALPHACHANNEL}
246flag. If you load an image from file or network data that has a format that
247includes an alpha channel, the image might still be completely opaque.
248Normally Qt runs through every pixel to check if there really is an alpha
249channel there. This involves some overhead but usually pays off in the end
250because blitting is cheaper than blending. If you define this Qt will
251assume that an image with a format that has alpha channel contains at least
252one pixel with an alpha value != 255.
253
254 \row
255 \o QT_DIRECTFB_SUBSURFACE
256 \o Defining this enables a mode that tries to minimize overhead from
257locking/unlocking surfaces. Note that this currently is experimental.
258
259 \row
260 \o QT_DIRECTFB_WINDOW_AS_CURSOR
261 \o Define this if your DirectFB implementation supports windows but
262can not render the cursor properly. This involves creating a small top level
263window and moving it around when the cursor moves. It does not always
264perform well.
265
266 \row
267 \o QT_NO_DIRECTFB_IMAGEPROVIDER
268 \o By default Qt will use DirectFB to load QPixmaps from disk/memory. If
269your DirectFB implementation does not support this it might make sense to
270define this.
271
272 \row
273 \o QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
274 \o Define this to make sure Qt always keeps at least one
275\l{DirectFB - IDirectFBImageProvider}{IDirectFBImageProvider}
276object alive. This is to avoid considerable overhead when the first
277IDirectFBImageProvider is created, the last IDirectFBImageProvider is
278removed.
279
280\endtable
281
282\section2 Unsupported graphics operations
283
284There are a number of unsupported operations causing fallbacks. DirectFB
285does not support the following functions.
286
287
288
289\table
290 \header
291 \o Functions
292 \row
293 \o QPainter::strokePath(const QPainterPath & path, const QPen & pen)
294 \row
295 \o QPainter::drawPath(const QPainterPath & path)
296 \row
297 \o QPainter::fillPath(const QPainterPath & path, const QBrush & brush)
298 \row
299 \o QPainter::drawPoints(const QPointF * points, int pointCount)
300 \row
301 \o QPainter::drawEllipse(const QRectF & rectangle)
302 \row
303 \o QPainter::drawPolygon(const QPointF * points, int pointCount,
304 Qt::FillRule fillRule = Qt::OddEvenFill)
305 \row
306 \o QPainter::drawText(const QPointF & position, const QString & text)
307 \row
308 \o QGradient
309 \endtable
310
311\section2 Avoiding fallbacks
312To avoid fallbacks make sure that the following points are true:
313
314\list
315 \o QPen::isSolid() returns true and uses a color with a one pixel
316width. (QPen::width() returns 1.
317 \o QTransform::TransformationType() <= QTransform::TxScale are not
318supported.
319 \o Clipping must be a simple rectangle or a QRegion.
320\endlist
321
322\section2 When painting images
323\note You should use QPixmap instead of QImage. QImages are drawn by
324the QRasterPaintEngine. To get a warning for every fallback to the
325QRasterPaintEngine, use QT_DIRECTFB_WARN_ON_RASTERFALLBACKS. If
326QT_DIRECTFB_DISABLE_RASTERFALLBACKS is defined, DirectFB will only return
327instead of falling back to QRasterPaintEngine. Please note that these
328defines should only be used when optimizing the application.
329
330*/
Note: See TracBrowser for help on using the repository browser.