Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Graphics

Window server applications exist mainly to draw graphics to the screen. They may draw to any RDrawableWindow — either an RWindow or an RBackedUpWindow — via a graphics device, of type CWsScreenDevice, and a graphics context, of type CWindowGc. These classes are derived from the CGraphicsDevice and CGraphicsContext classes defined by the GDI, so that general drawing functions may be used for drawing to windows, as well as to other graphics devices. The window server itself does not provide the facilities to draw graphics to a physical device. CWindowGc functions are not passed to the window server directly. Rather, they are stored in a buffer maintained by the Window Server Client API. This buffer is flushed to the window server only rarely. By this means the context switching involved in drawing is minimised, and system performance significantly enhanced.

CWsScreenDevice encapsulates the device-dependent aspects of graphics operations. Graphics functions are not carried out directly via a CWsScreenDevice, however, but via a graphics context with which it is associated. The graphics context class, CWindowGC, provides a rich set of drawing functions, including functions to draw lines, arcs, polygons, text and bitmaps, etc.

A graphics context contains a collection of configurable parameters concerned with graphics, such as pen width, pen colour, brush colour, etc. It is stored in the server, thus reducing the amount of information that has to be sent with each graphics call: the graphics call simply specifies the graphics context it wishes to use, and a single graphics context can be shared between multiple windows.

To draw to a graphics context it must be associated with a window. Typically a graphics context is created when a session is constructed, and that graphics context is shared between several windows in the application. When the window needs to use the graphics context it calls CWindowGc::Activate(). If necessary it can change the graphics context's settings. CWindowGc::Deactivate() should be called if the graphics context is currently active upon a window.

Several optimisations are used by the window server to obtain high-performance graphics