Clients of the X Window System specify the visual attributes of graphical output primitives by using graphics contexts. A graphics context is a set of graphical attribute values such as foreground color, font, line style, and so forth. Like a window, a graphics context is another kind of X server resource which is created and maintained at the request of a client program. The client program, which may use several different graphics contexts at different times, is responsible for specifying a graphics context to use with each graphical output function.
CLX represents a graphics context by an object of type gcontext and defines functions to create, modify, and manipulate gcontext objects. By default, CLX also records the contents of graphics contexts in a cache associated with each display. This local caching of graphics contexts has two important advantages:
Caching graphics contexts can result in a synchronization problem if more than one client program modifies a graphics context. However, this problem is unusual. Sharing a graphics context among several clients, while possible, is not expected to be useful and is not very easy to do. At any rate, a client program can choose to not cache a gcontext when it is created.
Each client program must determine its own policy for creating and using graphics contexts. Depending on the display hardware and the server implementation, creating a new graphics context can be more or less expensive than modifying an existing one. In general, some amount of graphics context information can be cached in the display hardware, in which case modifying the hardware cache is faster than replacing it. Typical display hardware can cache only a small number of graphics contexts. Graphics output is fastest when only a few graphics contexts are used without heavy modifications.
This section explains the CLX functions used to:
|• Creating Graphics Contexts:|
|• Graphics Context Attributes:|
|• Copying Graphics Contexts:|
|• Destroying Graphics Contexts:|
|• Graphics Context Cache:|