source: trunk/doc/src/platforms/emb-openvg.qdocinc@ 846

Last change on this file since 846 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: 12.0 KB
Line 
1\section1 Introduction
2
3\l {http://www.khronos.org/openvg}{OpenVG} is a standard API from the
4\l{http://www.khronos.org/openvg}{Khronos Group} for accelerated 2D vector
5graphics and raster graphics. It is a dedicated API for 2D graphics on
6mobile devices. It is therefore more likely to be a better alternative for
72D acceleration than OpenGL/ES.
8
9\tableofcontents
10
11\section1 Using OpenVG with Qt
12The QtOpenVG plugin provides support for OpenVG painting. OpenVG is
13optimized for 2D vector operations, and closely matches the functionality
14in QPainter. To translate QPainter operations into OpenVG calls, Qt uses a
15subclass of QPaintEngine. Unlike with OpenGL ES, OpenVG can be used for
16acceleration of regular widgets. It can therefore be an excellent substitute
17for the default raster-based QPaintEngine on hardware that supports the
18OpenVG API.
19
20\section2 Configure
21OpenVG support can be enabled by passing the \c{-openvg} option to
22configure. It is assumed that the following qmake variables are set to
23appropriate values in the qmake.conf file for your platform:
24
25 \list
26 \o QMAKE_INCDIR_OPENVG
27 \o QMAKE_LIBDIR_OPENVG
28 \o QMAKE_LIBS_OPENVG
29 \endlist
30
31Most OpenVG implementations are based on EGL, so the following variables
32may also need to be set:
33
34 \list
35 \o QMAKE_INCDIR_EGL
36 \o QMAKE_LIBDIR_EGL
37 \o QMAKE_LIBS_EGL
38 \endlist
39
40See \l{qmake Variable Reference} for more information on these variables.
41
42\section2 Supported OpenVG Engines
43
44Two kinds of OpenVG engines are currently supported: EGL based, and engines
45built on top of OpenGL such as
46\l{http://sourceforge.net/projects/shivavg}{ShivaVG}. EGL based engines are
47preferred.
48
49It is assumed that the EGL implementation has some way to turn a
50QWidget::winId() into an EGL rendering surface with
51\c{eglCreateWindowSurface()}. If this is not the case, then modifications
52may be needed to the code under \c{src/gui/egl} and
53\c{src/plugins/graphicssystems/openvg} to accomodate the EGL
54implementation.
55
56The ShivaVG graphics system under \c{src/plugins/graphicssystems/shivavg}
57is an example of how to integrate a non-EGL implementation of OpenVG into
58Qt. It is currently only supported with Qt/X11 and being an example only,
59the resulting screen output may not be as good as with other OpenVG
60engines.
61
62\section1 Using the OpenVG graphics system
63
64Once the graphics system plugin has been built and installed, applications
65can be run as follows to use the plugin:
66
67 \code
68 app -graphicssystem OpenVG
69 \endcode
70
71If ShivaVG is being used, then substitute \c ShivaVG instead of \c OpenVG
72in the line above.
73
74If the plugin fails to load, try setting the \c QT_DEBUG_PLUGINS
75environment variable to 1 and try again. Usually the plugin cannot be
76loaded because Qt cannot locate it in the directory
77\c{plugins/graphicssystems} within the Qt installation, or the dynamic
78library path does not include the directory containing the system's \c
79libOpenVG.so library.
80
81\section2 Supported features
82
83\table
84 \header
85 \o Feature
86 \o Description
87
88 \row
89 \o Context modes
90 \o The default configuration is "single-context" mode, where a single
91EGLContext object is used for all drawing, regardless of the surface.
92Multiple EGLSurfaces are created, one for each window surface or pixmap.
93eglMakeCurrent() is called with the same EGLContext every time, but a
94different EGLSurface.
95
96Single-context mode is necessary for QPixmapData to be implemented in terms
97of a VGImage. If single-context mode is not enabled, then QPixmapData will
98use the fallback QRasterPixmapData implementation, which is less efficient
99performance-wise.
100
101Single-context mode can be disabled with the QVG_NO_SINGLE_CONTEXT
102define if the OpenVG engine does not support one context with multiple
103surfaces.
104
105 \row
106 \o Transformation matrices
107 \o All affine and projective transformation matrices are supported.
108
109QVGPaintEngine will use the engine to accelerate affine transformation
110matrices only. When a projective transformation matrix is used,
111QVGPaintEngine will transform the coordinates before passing them to the
112engine. This will probably incur a performance penalty.
113
114Pixmaps and images are always transformed by the engine, because OpenVG
115specifies that projective transformations must work for images.
116
117It is recommended that client applications should avoid using projective
118transformations for non-image elements in performance critical code.
119
120 \row
121 \o Composition modes
122 \o The following composition modes are supported:
123
124\list
125\o QPainter::CompositionMode_SourceOver
126\o QPainter::CompositionMode_DestinationOver
127\o QPainter::CompositionMode_Source
128\o QPainter::CompositionMode_SourceIn
129\o QPainter::CompositionMode_DestinationIn
130\o QPainter::CompositionMode_Plus
131\o QPainter::CompositionMode_Multiply
132\o QPainter::CompositionMode_Screen
133\o QPainter::CompositionMode_Darken
134\o QPainter::CompositionMode_Lighten
135\endlist
136
137The other members of QPainter::CompositionMode are not supported
138unless the \c{VG_KHR_advanced_blending} extension is present,
139in which case the following additional modes are supported:
140
141\list
142\o QPainter::CompositionMode_Overlay
143\o QPainter::CompositionMode_ColorDodge
144\o QPainter::CompositionMode_ColorBurn
145\o QPainter::CompositionMode_HardLight
146\o QPainter::CompositionMode_SoftLight
147\o QPainter::CompositionMode_Difference
148\o QPainter::CompositionMode_Exclusion
149\o QPainter::CompositionMode_SourceOut
150\o QPainter::CompositionMode_DestinationOut
151\o QPainter::CompositionMode_SourceAtop
152\o QPainter::CompositionMode_DestinationAtop
153\o QPainter::CompositionMode_Xor
154\endlist
155
156Any attempt to set an unsupported mode will result in
157the actual mode being set to QPainter::CompositionMode_SourceOver.
158Client applications should avoid using unsupported modes.
159
160 \row
161 \o Pens and brushes
162 \o All pen styles are supported, including cosmetic pens.
163
164All brush styles are supported except for conical gradients, which are not
165supported by OpenVG 1.1. Conical gradients will be converted into a solid
166color brush corresponding to the first color in the gradient's color ramp.
167
168Affine matrices are supported for brush transforms, but not projective
169matrices.
170
171
172 \row
173 \o Rectangles, lines, and points
174 \o Rectangles, lines, and rounded rectangles use cached VGPath
175objects to try to accelerate drawing operations. vgModifyPathCoords() is
176used to modify the co-ordinates in the cached VGPath object each time
177fillRect(), drawRects(), drawLines(), or drawRoundedRect() is called.
178
179If the engine does not implement vgModifyPathCoords() properly, then the
180QVG_NO_MODIFY_PATH define can be set to disable path caching. This will
181incur a performance penalty.
182
183Points are implemented as lines from the point to itself. The cached line
184drawing VGPath object is used when drawing points.
185
186 \row
187 \o Polygons and Ellipses
188 \o Polygon and ellipse drawing creates a new VGPath object every
189time drawPolygon() or drawEllipse() is called. If the client application
190is making heavy use of these functions, the constant creation and
191destruction of VGPath objects could have an impact on performance.
192
193If a projective transformation is active, ellipses are converted into cubic
194curves prior to transformation, which may further impact performance.
195
196Client applications should avoid polygon and ellipse drawing in performance
197critical code if possible.
198
199 \row
200 \o Other Objects
201 \o Most other objects (arcs, pies, etc) use drawPath(), which takes
202a QPainterPath argument. The default implementation in QPainterEngineEx
203converts the QPainterPath into a QVectorPath and then calls draw(), which
204in turn converts the QVectorPath into a VGPath for drawing.
205
206To reduce the overhead, we have overridden drawPath() in QVGPaintEngine to
207convert QPainterPath's directly into VGPath's. This should help improve
208performance compared to the default implementation.
209
210Client applications should try to avoid these types of objects in
211performance critical code because of the QPainterPath to VGPath conversion
212cost.
213
214 \row
215 \o Clipping
216 \o Clipping with QRect, QRectF, and QRegion objects is supported on
217all OpenVG engines with vgMask() if the transformation matrix is the
218identity or a simple origin translation.
219
220Clipping with an arbitrary QPainterPath, or setting the clip region when
221the transformation matrix is simple, is supported only if the OpenVG engine
222has the vgRenderToMask() function (OpenVG 1.1 and higher).
223
224The QVG_NO_RENDER_TO_MASK define will disable the use of vgRenderToMask().
225
226The QVG_SCISSOR_CLIP define will disable clipping with vgMask() or
227vgRenderToMask() and instead use the scissor rectangle list to perform
228clipping. Clipping with an arbitrary QPainterPath will need to convert
229the path into a series of rectangles. If the number of rectangles
230exceeds VG_MAX_SCISSOR_RECTS, then the results will not be exact.
231
232The QVG_SCISSOR_CLIP define should only be used if the OpenVG engine does
233not support vgMask() or vgRenderToMask().
234
235 \row
236 \o Opacity
237 \o Opacity is supported for all drawing operations. Solid color
238pens, solid color brushes, gradient brushes, and image drawing with
239drawPixmap() and drawImage() will probably have the best performance
240compared to other kinds of pens and brushes.
241
242 \row
243 \o Text Drawing
244 \o If OpenVG 1.1 is used, the paint engine will use VG fonts to
245cache glyphs while drawing. If the engine does not support VG fonts
246correctly, QVG_NO_DRAW_GLYPHS can be defined to disable this mode. Text
247drawing performance will suffer if VG fonts are not used.
248
249By default, image-based glyphs are used. If QVG_NO_IMAGE_GLYPHS is defined,
250then path-based glyphs will be used instead. QVG_NO_IMAGE_GLYPHS is ignored
251if QVG_NO_DRAW_GLYPHS is defined.
252
253If path-based glyphs are used, then the OpenVG engine will need to support
254hinting to render text with good results. Image-based glyphs avoids the
255need for hinting and will usually give better results than path-based
256glyphs.
257
258 \row
259 \o Pixmaps
260 \o In single-context mode, pixmaps will be implemented using
261VGImage unless QVG_NO_PIXMAP_DATA is defined.
262
263QVGPixmapData will convert QImage's into VGImage's when the application
264calls drawPixmap(), and the pixmap will be kept in VGImage form for the
265lifetime of the QVGPixmapData object. When the application tries to paint
266into a QPixmap with QPainter, the data will be converted back into a QImage
267and the raster paint engine will be used to render into the QImage.
268
269This arrangement optimizes for the case of drawing the same static pixmap
270over and over (e.g. for icons), but does not optimize the case of drawing
271into pixmaps.
272
273Bitmaps must use QRasterPixmapData. They are not accelerated with VGImage
274at present.
275
276 \row
277 \o Pixmap filters
278 \o Convolution, colorize, drop shadow, and blur filters are
279accelerated using OpenVG operations.
280
281 \row
282 \o Scrolling
283 \o Accelerated scrolling is implemented but disabled by default
284unless QVG_BUFFER_SCROLLING is defined. This should only be enabled on
285OpenVG engines where vgCopyPixels() is known to be efficient.
286
287\endtable
288
289\section2 Known issues
290
291Performance of copying the contents of an OpenVG-rendered window to the
292screen needs platform-specific work in the QVGWindowSurface class.
293
294Clipping with arbitrary non-rectangular paths only works on engines that
295support vgRenderToMask(). Simple rectangular paths are supported on all
296engines that correctly implement vgMask().
297
298The paint engine is not yet thread-safe, so it is not recommended for use
299in threaded Qt applications that draw from multiple threads. Drawing should
300be limited to the main GUI thread.
301
302Performance of projective matrices for non-image drawing is not as good
303as for affine matrices.
304
305QPixmap's are implemented as VGImage objects so that they can be quickly
306rendered with drawPixmap(). Rendering into a QPixmap using QPainter will
307use the default Qt raster paint engine on a QImage copy of the QPixmap, and
308will not be accelerated. This issue may be addressed in a future version
309of the engine.
310
311ShivaVG support is highly experimental and limited to Qt/X11. It is