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

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