1			The X Rendering Extension
2			      Version 0.11
3			       2009-07-15
4			      Keith Packard
5			    keithp@keithp.com
6
71. Introduction
8
9The X Rendering Extension (Render) introduces digital image composition as
10the foundation of a new rendering model within the X Window System.
11Rendering geometric figures is accomplished by client-side tessellation into
12either triangles or trapezoids.  Text is drawn by loading glyphs into the
13server and rendering sets of them.
14
152. Acknowledgments
16
17This extension was the work of many people, in particular:
18
19 +	Thomas Porter and Tom Duff for their formal description
20	of image compositing.
21
22 +	Rob Pike and Russ Cox who designed the Plan 9 window system from
23	which the compositing model was lifted.
24
25 +	Juliusz Chroboczek and Raph Levien whose proposal for client-side
26	glyph management eliminated font handling from the X server.
27
28 +	Jon Leech, Brad Grantham and Allen Akin for patiently explaining
29	how OpenGL works.
30
31 +	Carl Worth for providing the sample implementation of
32 	trapezoid rendering and showing how broken the spec was
33
34 +	Sam Pottle and Jamey Sharp for helping demonstrate the correctness
35 	of the trapezoid specification.
36
37 +	Owen Taylor for helping specify projective transformations
38
393. Rendering Model
40
41Render provides a single rendering operation which can be used in a variety of
42ways to generate images:
43
44	dest = (source IN mask) OP dest
45
46Where 'IN' is the Porter/Duff operator of that name and 'OP' is any of the
47list of compositing operators described below, among which can be found all
48of the Porter/Duff binary operators.
49
50To use this operator several additional values are required:
51
52 +	The destination rectangle.  This is a subset of the destination
53 	within which the rendering is performed.
54
55 +	The source location. This identifies the coordinate in the
56 	source aligned with the upper left corner of the
57	destination rectangle.
58
59 +	The mask location. This identifies the coordinate in the
60 	mask aligned with the upper left corner of the
61	destination rectangle.
62
63 +	A clip list.  This limits the rendering to the intersection of the
64 	destination rectangle with this clip list.
65
66 +	The OP to use
67
68 +	Whether the source should be repeated to cover the destination
69 	rectangle, extended with a constant pixel value or extended by
70	using the nearest available source pixel.
71
72 +	Whether the mask should be repeated to cover the destination
73 	rectangle, extended with a constant pixel value or extended by
74	using the nearest available mask pixel.
75
76 +	Whether the mask has a single alpha value for all four channels or
77 	whether each mask channel should affect the associated source/dest
78	channels.
79
80 +	Whether the source should be reshaped with a projective
81        transformation, and if so, what filter to apply while
82	resampling the data.
83	
84 +	Whether the mask should be reshaped with a projective
85        transformation, and if so, what filter to apply while
86	resampling the data.
87	
88These parameters are variously attached to the operands or included in each
89rendering request.
90
914. Data types
92
93The core protocol rendering system uses a pixel model and applies color only
94in the final generation of the video signal.  A compositing model operates
95on colors, not pixel values so a new datatype is needed to interpret data as
96color instead of just bits.
97
98The "PictFormat" object holds information needed to translate pixel values
99into red, green, blue and alpha channels.  The server has a list of picture
100formats corresponding to the various visuals on the screen.  There are two
101classes of formats, Indexed and Direct.  Indexed PictFormats hold a list of
102pixel values and RGBA values while Direct PictFormats hold bit masks for each
103of R, G, B and A.
104
105The "Picture" object contains a Drawable, a PictFormat and some
106rendering state.  More than one Picture can refer to the same Drawable.
107
1085. Errors
109
110Errors are sent using core X error reports.
111
112PictFormat
113	A value for a PICTFORMAT argument does not name a defined PICTFORMAT.
114
115Picture
116	A value for a PICTURE argument does not name a defined PICTURE.
117
118PictOp
119	A value for a PICTOP argument does not name a defined PICTOP.
120
121GlyphSet
122	A value for a GLYPHSET argument does not name a defined GLYPHSET.
123
124Glyph
125	A value for a GLYPH argument does not name a defined GLYPH in the
126	glyphset.
127
1286. Protocol Types
129
130PICTURE		32-bit value (top three bits guaranteed to be zero)
131PICTFORMAT	32-bit value (top three bits guaranteed to be zero)
132PICTTYPE	{ Indexed, Direct }
133PICTOP		{ Clear, Src, Dst, Over, OverReverse, In, InReverse,
134		  Out, OutReverse, Atop, AtopReverse, Xor, Add, Saturate,
135		  DisjointClear, DisjointSrc, DisjointDst, DisjointOver,
136		  DisjointOverReverse, DisjointIn, DisjointInReverse,
137		  DisjointOut, DisjointOutReverse, DisjointAtop,
138		  DisjointAtopReverse, DisjointXor,
139		  ConjointClear, ConjointSrc, ConjointDst, ConjointOver,
140		  ConjointOverReverse, ConjointIn, ConjointInReverse,
141		  ConjointOut, ConjointOutReverse, ConjointAtop,
142		  ConjointAtopReverse, ConjointXor,
143		  Multiply, Screen, Overlay, Darken, Lighten, ColorDodge,
144		  ColorBurn, HardLight, SoftLight, Difference, Exclusion,
145		  HSLHue, HSLSaturation, HSLColor, HSLLuminosity
146		}
147SUBPIXEL	{ Unknown, HorizontalRGB, HorizontalBGR, 
148		  VerticalRGB, VerticalBGR, None
149		}
150COLOR		[	
151			red, green, blue, alpha: CARD16
152		]
153CHANNELMASK	[
154			shift, mask: CARD16
155		]
156DIRECTFORMAT	[
157			red, green, blue, alpha: CHANNELMASK 
158		]
159INDEXVALUE	[ 
160			pixel: Pixel; 
161			red, green, blue, alpha: CARD16 
162		]
163PICTFORMINFO	[
164			id:		PICTFORMAT
165			type:		PICTTYPE
166			depth:		CARD8
167			direct:		DIRECTFORMAT
168			colormap:	COLORMAP or None
169		]
170
171PICTVISUAL	[
172			visual:		VISUALID or None
173			format:		PICTFORMAT
174		]
175
176PICTDEPTH	[
177			depth:		CARD8
178			visuals:	LISTofPICTVISUAL
179		]
180
181PICTSCREEN	LISTofPICTDEPTH
182
183FIXED		32-bit value (top 16 are integer portion, bottom 16 are fraction)
184TRANSFORM	[
185			p11, p12, p13:	FIXED
186			p21, p22, p23:	FIXED
187			p31, p32, p33:	FIXED
188		]
189POINTFIX	[
190			x, y: FIXED
191		]
192POLYEDGE	{ Sharp, Smooth }
193POLYMODE	{ Precise, Imprecise }
194REPEAT          { None, Regular, Pad, Reflect }
195COLORPOINT	[
196			point:		POINTFIX
197			color:		COLOR
198		]
199SPANFIX		[
200			left, right, y: FIXED
201		]
202COLORSPANFIX	[
203			left, right, y: FIXED
204			left_color:	COLOR
205			right_color:	COLOR
206QUAD		[
207			p1, p2, p3, p4:	POINTFIX
208		]
209TRIANGLE	[
210			p1, p2, p3:	POINTFIX
211		]
212LINEFIX		[
213			p1, p2:		POINTFIX
214		]
215TRAP		[
216			top, bottom:	SPANFIX
217		]
218TRAPEZOID	[
219			top, bottom:	FIXED
220			left, right:	LINEFIX
221		]
222(TRAPEZOID is deprecated)
223GLYPHSET	32-bit value (top three bits guaranteed to be zero)
224GLYPH		32-bit value
225GLYPHINFO	[
226			width, height:	CARD16
227			x, y:		INT16
228			off-x, off-y:	INT16
229		]
230PICTGLYPH	[
231			info:		GLYPHINFO
232			x, y:		INT16
233		]
234GLYPHABLE	GLYPHSET or FONTABLE
235GLYPHELT8	[
236			dx, dy:		INT16
237			glyphs:		LISTofCARD8
238		]
239GLYPHITEM8	GLYPHELT8 or GLYPHABLE
240GLYPHELT16	[
241			dx, dy:		INT16
242			glyphs:		LISTofCARD16
243		]
244GLYPHITEM16	GLYPHELT16 or GLYPHABLE
245GLYPHELT32	[
246			dx, dy:		INT16
247			glyphs:		LISTofCARD32
248		]
249GLYPHITEM32	GLYPHELT32 or GLYPHABLE
250
251ANIMCURSORELT	[
252			cursor:		CURSOR
253			delay:		CARD32
254		]
2557. Standard PictFormats
256
257The server must support a Direct PictFormat with 8 bits each of red, green,
258blue and alpha as well as a Direct PictFormat with 8 bits of red, green and
259blue and 0 bits of alpha.  The server must also support Direct PictFormats
260with 1, 4 and 8 bits of alpha and 0 bits of r, g and b.
261
262Pixel component values lie in the close range [0,1].  These values are
263encoded in a varying number of bits.  Values are encoded in a straight
264forward manner.  For a component encoded in m bits, a binary encoding b
265is equal to a component value of b/(2^m-1).
266
267A Direct PictFormat with zero bits of alpha component is declared to have
268alpha == 1 everywhere.  A Direct PictFormat with zero bits of red, green and
269blue is declared to have red, green, blue == 0 everywhere.  If any of red,
270green or blue components are of zero size, all are of zero size.  Direct
271PictFormats never have colormaps and are therefore screen independent.
272
273Indexed PictFormats never have alpha channels and the direct component is all
274zeros.  Indexed PictFormats always have a colormap in which the specified
275colors are allocated read-only and are therefore screen dependent.  Drawing
276to in Indexed Picture uses only pixel values listed by QueryPictIndexValues.
277Reading from an Indexed Picture uses red, green and blue values from the
278colormap and alpha values from those listed by QueryPictIndexValues.  Pixel
279values not present in QueryPictIndexValues are given alpha values of 1.
280
2818. Compositing Operators
282
283For each pixel, the four channels of the image are computed with:
284
285	C = Ca * Fa + Cb * Fb
286
287where C, Ca, Cb are the values of the respective channels and Fa and Fb
288come from the following table:
289
290	PictOp			Fa			Fb
291	--------------------------------------------------
292	Clear			0			0
293	Src			1			0
294	Dst			0			1
295	Over			1			1-Aa
296	OverReverse		1-Ab			1
297	In			Ab			0
298	InReverse		0			Aa
299	Out			1-Ab			0
300	OutReverse		0			1-Aa
301	Atop			Ab			1-Aa
302	AtopReverse		1-Ab			Aa
303	Xor			1-Ab			1-Aa
304	Add			1			1
305	Saturate		min(1,(1-Ab)/Aa)	1
306	DisjointClear		0			0
307	DisjointSrc		1			0
308	DisjointDst		0			1
309	DisjointOver		1			min(1,(1-Aa)/Ab)
310	DisjointOverReverse	min(1,(1-Ab)/Aa)	1
311	DisjointIn		max(1-(1-Ab)/Aa,0)	0
312	DisjointInReverse	0			max(1-(1-Aa)/Ab,0)
313	DisjointOut		min(1,(1-Ab)/Aa)	0
314	DisjointOutReverse	0			min(1,(1-Aa)/Ab)
315	DisjointAtop		max(1-(1-Ab)/Aa,0)	min(1,(1-Aa)/Ab)
316	DisjointAtopReverse	min(1,(1-Ab)/Aa)	max(1-(1-Aa)/Ab,0)
317	DisjointXor		min(1,(1-Ab)/Aa)	min(1,(1-Aa)/Ab)
318	ConjointClear		0			0
319	ConjointSrc		1			0
320	ConjointDst		0			1
321	ConjointOver		1			max(1-Aa/Ab,0)
322	ConjointOverReverse	max(1-Ab/Aa,0)		1
323	ConjointIn		min(1,Ab/Aa)		0
324	ConjointInReverse	0			min(Aa/Ab,1)
325	ConjointOut		max(1-Ab/Aa,0)		0
326	ConjointOutReverse	0			max(1-Aa/Ab,0)
327	ConjointAtop		min(1,Ab/Aa)		max(1-Aa/Ab,0)
328	ConjointAtopReverse	max(1-Ab/Aa,0)		min(1,Aa/Ab)
329	ConjointXor		max(1-Ab/Aa,0)		max(1-Aa/Ab,0)
330
331Saturate and DisjointOverReverse are the same.  They match OpenGL
332compositing with FUNC_ADD, SRC_ALPHA_SATURATE, ONE, except that Render uses
333premultiplied alpha while Open GL uses non-premultiplied alpha.
334
335The result of any compositing operator is always limited to the range
336[0,1] for each component.  Components whose value would be greater than 1
337are set to 1.
338
339For operations involving division, when the divisor is zero, define the
340quotient to be positive infinity.  The result is always well defined
341because the division is surrounded with a max or min operator which will
342give a finite result.
343
344When the mask contains separate alpha values for each channel, the
345alpha value resulting from the combination of that value with the source
346alpha channel is used in the final image composition.
347
3489. Source and Mask Transformations
349
350When fetching pixels from the source or mask pictures, Render provides four
351options for pixel values which fall outside the drawable (this includes
352pixels within a window geometry obscured by other windows). 
353
354 +	None.  Missing values are replaced with transparent.
355 
356 +	Pad.  Replace missing pixels with the nearest available
357 	pixel.  Where multiple pixels are equidistant, select
358	those with smallest Y and then smallest X coordinates
359
360 +	Normal.  Select the pixel which would appear were the
361 	drawable tiled to enclose the missing coordinate.  If
362	the tiling doesn't cover the coordinate, use the
363	selected Constant or Nearest mode.
364
365 *	Reflect.  Select the pixel which would appear were the
366	drawable tiled to enclose the missing coordinate in such a
367	way that tiles in even numbered columns are reflected in the Y
368	axis, and tiles in even numbered rows are reflected in the X
369	axis. Tiles that in both an even numbered row and an even
370	numbered column are reflected in both axes.
371
372To construct the source and mask operands, the computed pixels values are
373transformed through a homogeneous matrix, filtered and then used in the
374fundamental rendering operator described above.  Each screen provides a list
375of supported filter names. There are a few required filters, and several
376required filter alias which must map to one of the available filters.
377
37810. Polygon Rasterization
379
380Render provides only two kinds of polygons, trapezoids and triangles.  To
381improve efficiency, several different wire encodings exist for each. 
382
383All trapezoids must be convex.  Rendering of concave trapezoids is unspecified
384except that the result must obey the clipping rules.
385
386Composite
387Polygons are rasterized by implicit generating an alpha mask and using that
388in the general compositing operator along with a supplied source image:
389
390	tmp = Rasterize (polygon)
391	Composite (op, dst, src, tmp)
392
393When rasterized with Sharp edges, the mask is computed with a depth of 1 so
394that all of the mask values are either 0 or 1.
395
396When rasterized with Smooth edges, the mask is generated by creating a square
397around each pixel coordinate and computing the amount of that square covered
398by the polygon.  This ignores sampling theory but it provides a precise
399definition which is close to the right answer.  This value is truncated to
400the alpha width in the fallback format before application of the compositing
401operator.
402
403Rasterization
404Alpha values are generated by point sampling the coverage of a square
405surrounding the center of each pixel by the polygon. 
406
407In Precise poly mode, the sample points are located in a regular grid.  When
408alpha depth 'e' is even, the regular grid is 2**(e/2) + 1 samples wide and
4092**(e/2) -1 samples high.  For odd alpha depth 'o', the sample grid is 2**o
410- 1 samples wide and 1 sample high.  Note that odd alpha depth usually
411occurs only at depth 1, so this misshapen sample grid has no ill effects.
412The sample grid is centered within the pixel and then each sample point is
413rounded down to a point on the sub-pixel coordinate grid.
414
415In Imprecise mode, the location of the sample points is not specified, but
416the implementation must conform to the following constraints:
417
418 +	Abutting edges must match precisely.  When specifying two polygons
419	abutting along a common edge, if that edge is specified with the
420	same coordinates in each polygon then the sum of alpha values for
421	pixels inside the union of the two polygons must be precisely one.
422
423 +	Translationally invariant.  The pixelization of the polygon must
424	be the same when either the polygon or the target drawable
425	are translated by any whole number of pixels in any direction.
426
427 +	Sharp edges are honored.  When the polygon is rasterized with Sharp
428	edges, the implicit alpha mask will contain only 1 or 0 for
429	each pixel.
430
431 +	Order independent. Two identical polygons specified with vertices
432	in different orders must generate identical results.
433
43411. Image Filtering
435
436When computing pixels from source and mask images, a filter may be applied
437to the data.  This is usually used with a non-identity transformation
438matrix, but filtering may be applied with an identity transformation.
439
440Each filter is given a unique name encoded as an ISO Latin-1 string.
441Filters may be configured with a list of fixed point values; the number of
442parameters and their interpretation is currently left to conventions passed
443outside of the protocol.  A set of standard filters are required to be
444provided:
445
446	Filter Name	Description
447
448	nearest		Nearest neighbor filtering
449	bilinear	Linear interpolation in two dimensions
450
451Additional names may be provided for any filter as aliases.  A set of
452standard alias names are required to be mapped to a provided filter so that
453applications can use the alias names without checking for availability.
454
455	Alias name	Intended interpretation
456	
457	fast		High performance, quality similar to Nearest
458	good		Reasonable performance, quality similar to Bilinear
459	best		Highest quality available, performance may not
460			be suitable for interactive use
461
462Aliases must map directly to a non-aliased filter name.
463
464There is also a set of standard filters which are not required but may be
465provided.  If they are provided, using the standard name, they must match
466the definition specified here.
467
468	Filter Name	Description
469	
470	convolution	MxN convolution filter.  The values specified
471			in SetPictureFilter are M, N and then M * N
472			filter parameters.  M and N must be integers
473			represented as fixed point numbers.
474	gaussian	Gaussian blur.  The value specified is a radius
475			in pixels (which can be fractional).  A standard
476			Gaussian 2D convolution filter will be applied.
477	binomial	Binomial blur. An approximation of a Gaussian
478			blur using binomial coefficients
479
48012. Glyph Rendering
481
482Glyphs are small alpha masks which can be stored in the X server and
483rendered by referring to them by name.  A set of glyphs can be rendered in a
484single request.  Glyphs are positioned by subtracting the x, y elements of
485the GLYPHINFO from the requested rendering position.  The next glyph
486rendering position is set to the current rendering position plus the off-x
487and off-y elements.
488
489Glyphs are stored in GlyphSets and are named within the GlyphSet with
490client-specified 32-bit numbers.
491
492Glyphs can be stored in any PictFormat supported by the server.  All glyphs
493in a GlyphSet are stored in the same format.
494
49513. Extension Initialization
496
497The client must negotiate the version of the extension before executing
498extension requests.  Behavior of the server is undefined otherwise.
499
500QueryVersion
501
502	client-major-version:		CARD32
503	client-minor-version:		CARD32
504
505	->
506
507	major-version:			CARD32
508	minor-version:			CARD32
509
510	The client sends the highest supported version to the server and
511	the server sends the highest version it supports, but no higher than
512	the requested version.  Major versions changes can introduce
513	incompatibilities in existing functionality, minor version
514	changes introduce only backward compatible changes.  It is
515	the clients responsibility to ensure that the server supports
516	a version which is compatible with its expectations.
517
518QueryPictFormats
519
520	->
521
522	formats:	LISTofPICTFORMINFO
523	screens:	LISTofPICTSCREEN
524	ndepths:	CARD32
525	nvisuals:	CARD32
526	subpixels:	LISTofSUBPIXEL
527
528	Errors:
529		<none>
530
531	The server responds with a list of supported PictFormats and
532	a list of which PictFormat goes with each visual on each screen.
533	Every PictFormat must match a supported depth, but not every
534	PictFormat need have a matching visual.
535
536	The total number of PICTDEPTH and PICTVISUAL objects is this reply
537	is given in 'ndepths' and 'nvisuals'.
538
539	The relationship between the red, green and blue elements making
540	up each pixel indexed by screen is returned in subpixels.
541	This list is not present in servers advertising protocol
542	versions earlier than 0.6.  This list may be shorter than
543	the number of screens, in which case the remaining screens
544	are given sub pixel order Unknown.
545
546QueryPictIndexValues
547
548	format:		PICTFORMAT
549
550	->
551
552	values:		LISTofINDEXVALUE
553
554	Errors:
555		PictFormat, Match
556
557	Returns the mapping from pixel values to RGBA values for the
558	specified Indexed PictFormat.  If 'format' does not refer to
559	an Indexed PictFormat a Match error is generated.
560
561QueryFilters
562
563	drawable:	DRAWABLE
564
565	->
566
567	filters:	LISTofSTRING8
568	aliases:	LISTofCARD16
569
570	This request gets the names of available filters that can be used on the
571	given drawable. Filters are applied using a SetPictureFilter request.
572
573	'aliases' contains a value for each filter name which is the index into
574	'filters' if this name is an alias. Non-aliased filter have this value
575	set to 0xFFFF.
576
57714. Extension Requests
578
579CreatePicture
580
581	pid:		PICTURE
582	drawable:	DRAWABLE
583	format:		PICTFORMAT
584	value-mask:	BITMASK
585	value-list:	LISTofVALUE
586
587	Errors:
588		Alloc, Drawable, IDChoice, Match, Pixmap, Picture,
589		PictFormat, Value
590
591	This request creates a Picture object associated with the specified
592	drawable and assigns the identifier pid to it.  Pixel data in the
593	image are interpreted according to 'format'.  It is a Match error
594	to specify a format with a different depth than the drawable.  If
595	the drawable is a Window then the Red, Green and Blue masks must
596	match those in the visual for the window else a Match error is
597	generated.
598
599	The value-mask and value-list specify attributes of the picture that
600	are to be explicitly initialized.  The possible values are:
601	
602	repeat:			REPEAT
603	alpha-map:		PICTURE or None
604	alpha-x-origin:		INT16
605	alpha-y-origin:		INT16
606	clip-x-origin:		INT16
607	clip-y-origin:		INT16
608	clip-mask:		PIXMAP or None
609	graphics-exposures:	BOOL
610	subwindow-mode:		{ ClipByChildren, IncludeInferiors }
611	poly-edge:		POLYEDGE
612	poly-mode:		POLYMODE
613	dither:			ATOM or None
614	component-alpha:	BOOL
615	
616	When used as a source or mask operand, Repeat indicates how the
617	drawable contents should be extended in both directions.
618	
619	The alpha channel of alpha-map is used in place of any alpha channel
620	contained within the drawable for all rendering operations.  The
621	alpha-mask origin is interpreted relative to the origin of drawable.
622	Rendering is additionally clipped by the geometry and clip mask of
623	alpha-map.  Exposures to the window do not affect the contents of
624	alpha-map.  Alpha-map must refer to a picture containing a Pixmap,
625	not a Window (or a Match error results).  If the alpha-map picture
626	itself already has an alpha-map, the result is undefined.
627
628	The clip-mask restricts reads and writes to drawable.  Only pixels
629	where the clip-mask has bits set to 1 are read or written.  Pixels
630	are not accessed outside the area covered by the clip-mask or where
631	the clip-mask has bits set to 0.  The clip-mask affects all graphics
632	requests, including sources.  The clip-mask origin is interpreted
633	relative to the origin of the picture.  If a pixmap is specified as
634	the clip-mask, it must have depth 1 and have the same root as the
635	drawable (or a Match error results).  If clip-mask is None, then
636	pixels are always drawn, regardless of the clip origin.  The
637	clip-mask can also be set with the SetPictureClipRectangles request.
638	Transformations, filters and repeat modes do not affect the clip
639	mask.
640
641	When a window is used as a destination, the subwindow_mode
642	determines what happens to pixels obscured by inferior
643	windows. For ClipByChildren the window is clipped by inferiors
644	and siblings. For IncludeInferior, the window is clipped by
645	siblings, but not by inferiors.
646
647	When a window is used as source or mask, the subwindow_mode is
648	ignored. Pixels that are obscured by other windows, whether
649	siblings or inferiors, have undefined contents.
650
651	The graphics-exposures flag is ignored. GraphicsExposure events are
652	never generated by this extension.
653
654	Poly-edge and poly-mode control the rasterization of polygons as
655	described above.
656
657	Dither is ignored.
658
659	Component-alpha indicates whether each image component is intended as
660	a separate alpha value when the picture is used as a mask operand.
661
662	The default component values are
663
664		Component		Default
665		-------------------------------
666		repeat			None
667		clip-x-origin        	0
668		clip-y-origin          	0
669		clip-mask		None
670		subwindow-mode		ClipByChildren
671		poly-edge		Smooth
672		poly-mode		Precise
673		component-alpha		False
674
675ChangePicture
676
677	pid:		PICTURE
678	value-mask:     BITMASK
679	value-list:     LISTofVALUE
680
681	Errors:
682		Picture, Alloc, Pixmap, PictOp, Value
683
684	The value-mask and value-list specify which attributes are to be
685	changed.  The values and restrictions are the same as for 
686	CreatePicture.
687
688SetPictureClipRectangles
689
690	picture:	PICTURE
691	clip-x-origin:	INT16
692	clip-y-origin:	INT16
693	rectangles:	LISTofRECTANGLE
694
695	Errors:
696		Alloc, Picture
697
698	This request changes clip-mask in picture to the specified list of
699	rectangles and sets the clip origin.  Input and output will be
700	clipped to remain contained within the rectangles.  The clip origin
701	is interpreted relative to the origin of picture after
702	transformations and repeats have been applied. The rectangle
703	coordinates are interpreted relative to the clip origin.
704
705	The list of rectangles can be empty, which effectively disables
706	output.  This is the opposite of passing None as the clip-mask in
707	CreatePicture and ChangePicture.
708
709	Note that output is clipped to the union of all of the rectangles
710	and that no particular ordering among the rectangles is required.
711
712SetPictureTransform
713
714	picture:	PICTURE
715	transform:	TRANSFORM
716
717	Errors:
718		Alloc, Value, Picture
719
720	This request changes the projective transformation used to
721	map coordinates when 'picture' is used as the source or
722	mask in any compositing operation.  The transform
723	maps from destination pixel geometry back to the source pixel
724	geometry.
725
726	The matrix must be invertable, else a Value error is generated.
727
728SetPictureFilter
729
730	picture:	PICTURE
731	filter:		STRING8
732	values:		LISTofFIXED
733
734	Errors:
735		Value, Match, Picture
736
737	This request sets the current filter used when picture is a source
738	or mask operand.  Filter must be one of the filters supported
739	for the screen associated with picture, else a Match error
740	is generated.  If the filter accepts additional parameters,
741	they can be provided in values, incorrect values generate Value
742	errors, too many values generate Match errors.  Too few values
743	cause the filter to assume default values for the missing
744	parameters.
745
746	When created, Pictures are set to the Nearest filter.
747
748FreePicture
749
750	pid:		PICTURE
751
752	Errors:
753		Picture
754
755	This request deletes the association between the resource ID and the
756	picture.  The picture storage will be freed when no other resource
757	references it.
758
759Composite
760
761	op:		PICTOP
762	src:		PICTURE
763	mask:		PICTURE or None
764	dst:		PICTURE
765	src-x, src-y:	INT16
766	mask-x, mask-y:	INT16
767	dst-x, dst-y:	INT16
768	width, height:	CARD16
769
770	This request combines the specified rectangle of the transformed
771	src and mask operands with the specified rectangle of dst using op
772	as the compositing operator.  The coordinates are relative their
773	respective (transformed) drawable's origin.  Rendering is clipped
774	to the geometry of the dst drawable and then to the dst clip-list.
775
776	Pixels outside the geometry of src or mask needed for this
777	computation are substituted as described in the Source and Mask
778	Transformations section above.
779	
780	If src, mask and dst are not in the same format, and one of their
781	formats can hold all without loss of precision, they are converted
782	to that format.  Alternatively, the server will convert each
783	operand to the fallback format.
784
785	If mask is None, it is replaced by a constant alpha value of 1.
786
787FillRectangles
788
789	op:		PICTOP
790	dst:		PICTURE
791	color:		COLOR
792	rects:		LISTofRECTANGLE
793
794	This request combines color with the destination drawable in the
795	area specified by rects.  Each rectangle is combined separately;
796	overlapping areas will be rendered multiple times.  The effect is
797	equivalent to compositing with a repeating source picture filled with
798	the specified color.
799
800Trapezoids
801
802	op:		PICTOP
803	src:		PICTURE
804	src-x, src-y:   INT16
805	dst:		PICTURE
806	mask-format:	PICTFORMAT or None
807	traps:		LISTofTRAPEZOID
808
809	This request rasterizes the list of trapezoids.
810	
811	For each trap, the area between the left and right edges is filled
812	from the top to the bottom.  src-x and src-y register the pattern to
813	the floor of the top x and y coordinate of the left edge of the
814	first trapezoid, they are adjusted for subsequent trapezoids so that
815	the pattern remains globally aligned within the destination.
816
817	When mask-format is not None, trapezoids are rendered in the
818	following way with the effective mask computed in mask-format:
819
820		tmp = temporary alpha picture (in mask-format)
821		Combine (Zero, tmp, tmp, None)
822		for each trapezoid
823			Combine (Add, tmp, trapezoid, None)
824		Combine (op, dst, source, tmp)
825
826	When mask-format is None, trapezoids are rendered in the order
827	specified directly to the destination:
828
829		for each trapezoid
830			Combine (op, dst, source, trapezoid)
831
832	(The Trapezoids request is deprecated)
833
834Triangles
835
836	op:		PICTOP
837	src:		PICTURE
838	src-x, src-y:   INT16
839	dst:		PICTURE
840	mask-format:	PICTFORMAT or None
841	triangles:	LISTofTRIANGLE
842
843	This request rasterizes the list of triangles in the order they
844	occur in the list.
845
846	When mask-format is not None, triangles are rendered in the
847	following way with the effective mask computed in mask-format:
848
849		tmp = temporary alpha picture (in mask-format)
850		Combine (Zero, tmp, tmp, None)
851		for each triangle
852			Combine (Add, tmp, triangle, None)
853		Combine (op, dst, source, tmp)
854
855	When mask-format is None, triangles are rendered in the order
856	specified directly to the destination:
857
858		for each triangle
859			Combine (op, dst, source, triangle)
860
861TriStrip
862
863	op:		PICTOP
864	src:		PICTURE
865	src-x, src-y:   INT16
866	dst:		PICTURE
867	mask-format:	PICTFORMAT or None
868	points:		LISTofPOINTFIX
869
870	Triangles are formed by initially using the first three points and
871	then by eliminating the first point and appending the next point in
872	the list. If fewer than three points are provided, this request does
873	nothing.
874
875	When mask-format is not None, triangles are rendered in the
876	following way with the effective mask computed in mask-format:
877
878		tmp = temporary alpha picture (in mask-format)
879		Combine (Zero, tmp, tmp, None)
880		for each triangle
881			Combine (Add, tmp, triangle, None)
882		Combine (op, dst, source, tmp)
883
884	When mask-format is None, triangles are rendered in the order
885	specified directly to the destination:
886
887		for each triangle
888			Combine (op, dst, source, triangle)
889
890TriFan
891	op:		PICTOP
892	src:		PICTURE
893	src-x, src-y:   INT16
894	dst:		PICTURE
895	mask-format:	PICTFORMAT or None
896	points:		LISTofPOINTFIX
897
898	Triangles are formed by initially using the first three points and
899	then by eliminating the second point and appending the next point
900	int the list. If fewer than three points are provided, this request
901	does nothing.
902
903	When mask-format is not None, triangles are rendered in the
904	following way with the effective mask computed in mask-format:
905
906		tmp = temporary alpha picture (in mask-format)
907		Combine (Zero, tmp, tmp, None)
908		for each triangle
909			Combine (Add, tmp, triangle, None)
910		Combine (op, dst, source, tmp)
911
912	When mask-format is None, triangles are rendered in the order
913	specified directly to the destination:
914
915		for each triangle
916			Combine (op, dst, source, triangle)
917
918CreateGlyphSet
919
920	gsid:		GLYPHSET
921	format:		PICTFORMAT
922
923	Errors:
924		Alloc, IDChoice, PictFormat, Match
925
926	This request creates a container for glyphs.  The glyphset and
927	all contained glyphs are destroyed when gsid and any other names
928	for the glyphset are freed.  Format must be a Direct format, when
929	it contains RGB values, the glyphs are composited using
930	component-alpha True, otherwise they are composited using
931	component-alpha False.
932
933ReferenceGlyphSet
934
935	gsid:		GLYPHSET
936	existing:	GLYPHSET
937
938	Errors:
939		Alloc, IDChoice, GlyphSet
940
941	This request creates an additional name for the existing glyphset.
942	The glyphset will not be freed until all references to it are
943	destroyed.
944
945FreeGlyphSet
946
947	glyphset:	GLYPHSET
948
949	Errors:
950		GlyphSet
951
952	This request frees the name for the glyphset.  When all names have
953	been freed, the glyphset and all contained glyphs are freed.
954
955AddGlyphs
956	glyphset:	GLYPHSET
957	glyphids:	LISTofCARD32
958	glyphs:		LISTofGLYPHINFO
959	data:		LISTofBYTE
960
961	Errors:
962		GlyphSet, Alloc
963
964	This request adds glyphs to glyphset.  The image for the glyphs
965	are stored with each glyph in a separate Z-format image padded to a
966	32-bit boundary.  Existing glyphs with the same names are replaced.
967
968FreeGlyphs
969
970	glyphset:	GLYPHSET
971	glyphs:		LISTofGLYPH
972
973	Errors:
974		GlyphSet, Match
975
976	This request removes glyphs from glyphset.  Each glyph must exist
977	in glyphset (else a Match error results).
978
979CompositeGlyphs8
980CompositeGlyphs16
981CompositeGlyphs32
982
983	op:		PICTOP
984	src:		PICTURE
985	dst:		PICTURE
986	mask-format:	PICTFORMAT or None
987	glyphset:	GLYPHABLE
988	src-x, src-y:	INT16
989	glyphcmds:	LISTofGLYPHITEM8	CompositeGlyphs8
990	glyphcmds:	LISTofGLYPHITEM16	CompositeGlyphs16
991	glyphcmds:	LISTofGLYPHITEM32	CompositeGlyphs32
992
993	Errors:
994		Picture, PictOp, PictFormat, GlyphSet, Glyph
995
996	The src-x and src-y coordinates are relative to the drawable's
997	origin and specify the baseline starting position (the initial glyph
998	origin).  Each glyph item is processed in turn.  A glyphset item
999	causes the glyphset to be used for subsequent glyphs.  Switching
1000	among glyphsets does not affect the next glyph origin.  A glyph
1001	element delta-x and delta-y specify additional changes in the
1002	position along the x and y axes before the string is drawn; the
1003	deltas are always added to the glyph origin.
1004
1005	All contained GLYPHSETs are always transmitted most significant byte
1006	first.  
1007	
1008	If a GlyphSet error is generated for an item, the previous items may
1009	have been drawn.
1010	
1011	When mask-format is not None, glyphs are rendered in the following
1012	way with the effective mask computed in mask-format:
1013
1014		tmp = temporary alpha picture
1015		Combine (Zero, tmp, tmp, None)
1016		for each glyph
1017			Combine (Add, tmp, glyph, None)
1018		Combine (op, dst, source, tmp)
1019
1020	When mask-format is None, glyphs are rendered in the order specified
1021	directly to the destination:
1022
1023		for each glyph
1024			Combine (op, dst, source, glyph)
1025
1026CreateCursor
1027
1028	cid:		CURSOR
1029	source:		PICTURE
1030	x, y:		CARD16
1031
1032	Errors:		Alloc, IDChoice, Match, Picture
1033
1034	This request creates a cursor and associates identifier cid with it.
1035	The x and y coordinates define the hotspot relative to the source's
1036	origin and must be a point within the source (or a Match error
1037	results).  The resulting picture will nominally be drawn to the
1038	screen with PictOpOver. 
1039	
1040	The components of the cursor may be transformed arbitrarily to meet
1041	display limitations.  In particular, if the display supports only
1042	two colors cursors without translucency, the cursor will be
1043	transformed so that areas less than .5 alpha will be transparent,
1044	else opaque, and areas darker than 50% gray will be black else white.
1045
1046	The source picture can be freed immediately if no further explicit
1047	references to it are to be made.
1048
1049	Subsequent drawing in the source has an undefined effect on the
1050	cursor.  The server might or might not make a copy of the picture.
1051
1052CreateAnimCursor
1053	cid:		CURSOR
1054	cursors:	LISTofANIMCURSORELT
1055
1056	Errors:		Alloc, IDChoice, Cursor
1057
1058	This request creates a cursor and associates identifier cid with it.
1059	When active, the cursor image on the screen will cycle through
1060	'cursors', showing each cursor in the element for the number of
1061	milliseconds indicated by the 'delay' member of that element.
1062
1063AddTraps
1064	picture:	PICTURE
1065	off-x, off-y:	INT16
1066	trapezoids:	LISTofTRAP
1067
1068	Errors:		Match
1069
1070	Each trap is PictOpAdd'ed to 'picture'.  'off-x', 'off-y'
1071	are added to each coordinate.
1072
1073	'picture' must be an alpha-only picture else a 'Match' error is
1074	returned.
1075	
1076CreateSolidFill
1077	pid: 		PICTURE
1078	color:		COLOR	
1079
1080	Creates a Source picture that represents a solid fill with
1081	the specified color. 
1082
1083CreateLinearGradient
1084	pid:		PICTURE
1085	p1, p2:		POINTFIX
1086	nstops:		CARD32
1087	stops:		LISTofFIXED
1088	stop_colors:	LISTofCOLOR
1089
1090	Errors:		Alloc, Value
1091
1092	Creates a source picture representing a linear Gradient. The gradients
1093	bounds are defined by the two end points p1 and p2. 
1094
1095	The gradient has nstops stop points between 0 and 1, each
1096	having a stop color defined in stop_colors.
1097
1098	The array of stops has to contain values between 0 and 1 (inclusive) and
1099	has to be ordered in increasing size or a Value error is generated. If 
1100	p1 == p2 a Value error is generated.
1101
1102	The colors are non premultiplied.
1103
1104CreateRadialGradient
1105	pid:		PICTURE
1106	inner_center:	POINTFIX
1107	outer_center:	POINTFIX
1108	inner_radius:	FIXED
1109	outer_radius:	FIXED
1110	nstops:		CARD32
1111	stops:		LISTofFIXED
1112	stop_colors:	LISTofCOLOR
1113
1114	Errors:		Alloc, Value
1115
1116	Creates a source picture representing a radial Gradient. The
1117	gradients bounds are defined by a center point, a focal point and a
1118	radius around the center.
1119
1120	The gradient has nstops stop points between 0 and 1, each
1121	having a stop color defined in stop_colors.
1122
1123	The array of stops has to contain values between 0 and 1 (inclusive) and
1124	has to be ordered in increasing size or a Value error is generated. The inner
1125	circle has to be completely contained inside the outer one or a Value error is 
1126	generated. 
1127
1128	The colors are non premultiplied.
1129
1130CreateConicalGradient
1131	pid:		PICTURE
1132	center:		POINTFIX
1133	angle:		FIXED
1134	nstops:		CARD32
1135	stops:		LISTofFIXED
1136	stop_colors:	LISTofCOLOR
1137
1138	Errors:		Alloc, Value
1139
1140	Creates a source picture representing a conical Gradient. The
1141	gradient is defined by a center point and an angle (in degrees).
1142
1143	The gradient has nstops stop points between 0 and 1, each
1144	having a stop color defined in stop_colors.
1145
1146	The array of stops has to contain values between 0 and 1 (inclusive) and
1147	has to be ordered in increasing size or a Value error is generated.
1148
1149	The colors are non premultiplied.
1150
1151	
115215. Extension Versioning
1153
1154The Render extension was developed in parallel with the implementation to
1155ensure the feasibility of various portions of the design.  As portions of
1156the extension are implemented, the version number of the extension has
1157changed to reflect the portions of the standard provided.  This document
1158describes the intent for version 1.0 of the specification, the partial
1159implementations have version numbers less than that.  Here's a list of
1160what each version before 1.0 implemented:
1161
1162	0.0:	
1163		No disjoint/conjoint operators
1164		No component alpha
1165		Composite
1166		CreateGlyphSet
1167		FreeGlyphSet
1168		AddGlyphs
1169		CompositeGlyphs
1170
1171	0.1:
1172		Component alpha
1173		FillRectangles
1174
1175	0.2:
1176		Disjoint/Conjoint operators
1177
1178	0.3:
1179		FreeGlyphs
1180
1181	0.4:
1182		Trapezoids
1183		Triangles
1184		TriStrip
1185		TriFan
1186
1187	0.5:
1188		CreateCursor
1189
1190	0.6:
1191		SetPictureTransform
1192		QueryFilters
1193		SetPictureFilter
1194		subpixels member of QueryPictFormats
1195
1196	0.7:
1197		QueryPictIndexValues
1198	0.8:
1199		CreateAnimCursor
1200	0.9:
1201		AddTrapezoids
1202
1203	0.10:	
1204		CreateSolidFill
1205		CreateLinearGradient
1206		CreateRadialGradient
1207		CreateConicalGradient
1208
1209		The repeat picture attribute now supports Pad and
1210		Reflect, older versions only supported None and Normal.
1211
1212	0.11:
1213		Blend mode operators
1214
1215