OpenVG support in Qt 4.6

Recently we've been working on writing an OpenVG graphics system for Qt 4.6, and now it is all ready to go!

Qt 4.5 added support for pluggable graphics systems, which allow the window drawing surfaces and their associated paint engines to be redirected to a plugin for handling.  There are graphics systems for OpenGL 1.x and 2.x, and now for OpenVG!

The new graphics system supports OpenVG 1.0 and 1.1, and uses the Khronos EGL API's to access VG contexts and low-level window surfaces.  It directly converts QPaintEngine requests into the equivalent OpenVG requests - the two API's are very similar in functionality, so it was relatively easy to do this.  It has been tested using X11/EGL and S60.  There is also a demonstration plugin that uses ShivaVG, which shows how to use a non-EGL VG implementation.

What's supported?

  • Single-context vs multi-context - the default configuration uses a single VG context and multiple window surfaces.  This improves performance by sharing VG paths, images, and paint objects. But you can switch it to one VG context per window if your engine requires that behaviour.
  • All Qt transformations are supported, both affine and projective.  However projective path transformations need to be done client-side, so they won't perform as well as affine transformations.  Images support both affine and projective path transformations server-side.
  • Pen and brush styles except conical gradients, which don't have a VG equivalent.  Opacity is supported for all drawing operations.
  • All the usual Qt primitives: lines, rectangles, points, polygons, ellipses, etc.  For rectangles and other simple objects, path objects are reused to reduce the overhead of recreating them every time.
  • Clipping uses both masking and scissoring, or just scissoring if your engine doesn't support masking. Scissoring will generally be preferred for simple rectangular clipping.
  • Text drawing is very dependent upon the features in your VG engine. For OpenVG 1.0 it uses the default vector path rendering in Qt, which may not give the best result.  For OpenVG 1.1 systems that support VGfont objects, you have a choice of image-based or path-based glyph uploading.  Image-based glyphs are the default.
  • Pixmaps are represented as VGImage objects (in single-context mode only) and so they can be drawn and transformed very quickly. The pixmap filters from Qt 4.5 (convolution, drop shadow, and colorize) are supported using VG functions.

What's left to do?

  • Testing, testing, testing!  Every VG engine has its subtle quirks so help us narrow them down.
  • Rendering into a QPixmap using VG - at present it drops back to the raster paint engine.
  • Text drawing with image glyphs under OpenVG 1.0.
  • Qt/Embedded support - some experimental screen drivers have been written internally but every vendor's EGL is different, which makes Qt/Embedded difficult to support for both OpenVG and OpenGL/ES.

Where to get it?

You can get the engine from the public Qt repository.  To build it, you'll need to edit your mkspecs to specify the include directories and libraries to link against for EGL and OpenVG.  And then configure Qt with the "-openvg" option.  Once it has built, use "app -graphicssystem OpenVG" to run an app using the graphics system plugin (or "app -graphicssystem shivavg" for the ShivaVG version).


Blog Topics:

Comments