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

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

trunk: Merged in qt 4.6.1 sources.

  • Property svn:eol-style set to native
File size: 11.1 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
138because OpenVG 1.1 does not have an equivalent in its \c VGBlendMode
139enumeration. Any attempt to set an unsupported mode will result in
140the actual mode being set to QPainter::CompositionMode_SourceOver.
141Client applications should avoid using unsupported modes.
142
143 \row
144 \o Pens and brushes
145 \o All pen styles are supported, including cosmetic pens.
146
147All brush styles are supported except for conical gradients, which are not
148supported by OpenVG 1.1. Conical gradients will be converted into a solid
149color brush corresponding to the first color in the gradient's color ramp.
150
151Affine matrices are supported for brush transforms, but not projective
152matrices.
153
154
155 \row
156 \o Rectangles, lines, and points
157 \o Rectangles, lines, and rounded rectangles use cached VGPath
158objects to try to accelerate drawing operations. vgModifyPathCoords() is
159used to modify the co-ordinates in the cached VGPath object each time
160fillRect(), drawRects(), drawLines(), or drawRoundedRect() is called.
161
162If the engine does not implement vgModifyPathCoords() properly, then the
163QVG_NO_MODIFY_PATH define can be set to disable path caching. This will
164incur a performance penalty.
165
166Points are implemented as lines from the point to itself. The cached line
167drawing VGPath object is used when drawing points.
168
169 \row
170 \o Polygons and Ellipses
171 \o Polygon and ellipse drawing creates a new VGPath object every
172time drawPolygon() or drawEllipse() is called. If the client application
173is making heavy use of these functions, the constant creation and
174destruction of VGPath objects could have an impact on performance.
175
176If a projective transformation is active, ellipses are converted into cubic
177curves prior to transformation, which may further impact performance.
178
179Client applications should avoid polygon and ellipse drawing in performance
180critical code if possible.
181
182 \row
183 \o Other Objects
184 \o Most other objects (arcs, pies, etc) use drawPath(), which takes
185a QPainterPath argument. The default implementation in QPainterEngineEx
186converts the QPainterPath into a QVectorPath and then calls draw(), which
187in turn converts the QVectorPath into a VGPath for drawing.
188
189To reduce the overhead, we have overridden drawPath() in QVGPaintEngine to
190convert QPainterPath's directly into VGPath's. This should help improve
191performance compared to the default implementation.
192
193Client applications should try to avoid these types of objects in
194performance critical code because of the QPainterPath to VGPath conversion
195cost.
196
197 \row
198 \o Clipping
199 \o Clipping with QRect, QRectF, and QRegion objects is supported on
200all OpenVG engines with vgMask() if the transformation matrix is the
201identity or a simple origin translation.
202
203Clipping with an arbitrary QPainterPath, or setting the clip region when
204the transformation matrix is simple, is supported only if the OpenVG engine
205has the vgRenderToMask() function (OpenVG 1.1 and higher).
206
207The QVG_NO_RENDER_TO_MASK define will disable the use of vgRenderToMask().
208
209The QVG_SCISSOR_CLIP define will disable clipping with vgMask() or
210vgRenderToMask() and instead use the scissor rectangle list to perform
211clipping. Clipping with an arbitrary QPainterPath will not be supported.
212
213The QVG_SCISSOR_CLIP define should only be used if the OpenVG engine does
214not support vgMask() or vgRenderToMask().
215
216 \row
217 \o Opacity
218 \o Opacity is supported for all drawing operations. Solid color
219pens, solid color brushes, gradient brushes, and image drawing with
220drawPixmap() and drawImage() will probably have the best performance
221compared to other kinds of pens and brushes.
222
223 \row
224 \o Text Drawing
225 \o If OpenVG 1.1 is used, the paint engine will use VG fonts to
226cache glyphs while drawing. If the engine does not support VG fonts
227correctly, QVG_NO_DRAW_GLYPHS can be defined to disable this mode. Text
228drawing performance will suffer if VG fonts are not used.
229
230By default, image-based glyphs are used. If QVG_NO_IMAGE_GLYPHS is defined,
231then path-based glyphs will be used instead. QVG_NO_IMAGE_GLYPHS is ignored
232if QVG_NO_DRAW_GLYPHS is defined.
233
234If path-based glyphs are used, then the OpenVG engine will need to support
235hinting to render text with good results. Image-based glyphs avoids the
236need for hinting and will usually give better results than path-based
237glyphs.
238
239 \row
240 \o Pixmaps
241 \o In single-context mode, pixmaps will be implemented using
242VGImage unless QVG_NO_PIXMAP_DATA is defined.
243
244QVGPixmapData will convert QImage's into VGImage's when the application
245calls drawPixmap(), and the pixmap will be kept in VGImage form for the
246lifetime of the QVGPixmapData object. When the application tries to paint
247into a QPixmap with QPainter, the data will be converted back into a QImage
248and the raster paint engine will be used to render into the QImage.
249
250This arrangement optimizes for the case of drawing the same static pixmap
251over and over (e.g. for icons), but does not optimize the case of drawing
252into pixmaps.
253
254Bitmaps must use QRasterPixmapData. They are not accelerated with VGImage
255at present.
256
257 \row
258 \o Pixmap filters
259 \o Convolution, colorize, drop shadow, and blur filters are
260accelerated using OpenVG operations.
261
262\endtable
263
264\section2 Known issues
265
266Performance of copying the contents of an OpenVG-rendered window to the
267screen needs platform-specific work in the QVGWindowSurface class.
268
269Clipping with arbitrary non-rectangular paths only works on engines that
270support vgRenderToMask(). Simple rectangular paths are supported on all
271engines that correctly implement vgMask().
272
273The paint engine is not yet thread-safe, so it is not recommended for use
274in threaded Qt applications that draw from multiple threads. Drawing should
275be limited to the main GUI thread.
276
277Performance of projective matrices for non-image drawing is not as good
278as for affine matrices.
279
280QPixmap's are implemented as VGImage objects so that they can be quickly
281rendered with drawPixmap(). Rendering into a QPixmap using QPainter will
282use the default Qt raster paint engine on a QImage copy of the QPixmap, and
283will not be accelerated. This issue may be addressed in a future version
284of the engine.
285
286ShivaVG support is highly experimental and limited to Qt/X11. It is
287provided as an example of how to integrate a non-EGL engine.
288
Note: See TracBrowser for help on using the repository browser.