117ca54c3Smrg			The X Rendering Extension
217ca54c3Smrg			      Version 0.11
317ca54c3Smrg			       2009-07-15
417ca54c3Smrg			      Keith Packard
517ca54c3Smrg			    keithp@keithp.com
617ca54c3Smrg
717ca54c3Smrg1. Introduction
817ca54c3Smrg
917ca54c3SmrgThe X Rendering Extension (Render) introduces digital image composition as
1017ca54c3Smrgthe foundation of a new rendering model within the X Window System.
1117ca54c3SmrgRendering geometric figures is accomplished by client-side tessellation into
1217ca54c3Smrgeither triangles or trapezoids.  Text is drawn by loading glyphs into the
1317ca54c3Smrgserver and rendering sets of them.
1417ca54c3Smrg
1517ca54c3Smrg2. Acknowledgments
1617ca54c3Smrg
1717ca54c3SmrgThis extension was the work of many people, in particular:
1817ca54c3Smrg
1917ca54c3Smrg +	Thomas Porter and Tom Duff for their formal description
2017ca54c3Smrg	of image compositing.
2117ca54c3Smrg
2217ca54c3Smrg +	Rob Pike and Russ Cox who designed the Plan 9 window system from
2317ca54c3Smrg	which the compositing model was lifted.
2417ca54c3Smrg
2517ca54c3Smrg +	Juliusz Chroboczek and Raph Levien whose proposal for client-side
2617ca54c3Smrg	glyph management eliminated font handling from the X server.
2717ca54c3Smrg
2817ca54c3Smrg +	Jon Leech, Brad Grantham and Allen Akin for patiently explaining
2917ca54c3Smrg	how OpenGL works.
3017ca54c3Smrg
3117ca54c3Smrg +	Carl Worth for providing the sample implementation of
3217ca54c3Smrg 	trapezoid rendering and showing how broken the spec was
3317ca54c3Smrg
3417ca54c3Smrg +	Sam Pottle and Jamey Sharp for helping demonstrate the correctness
3517ca54c3Smrg 	of the trapezoid specification.
3617ca54c3Smrg
3717ca54c3Smrg +	Owen Taylor for helping specify projective transformations
3817ca54c3Smrg
3917ca54c3Smrg3. Rendering Model
4017ca54c3Smrg
4117ca54c3SmrgRender provides a single rendering operation which can be used in a variety of
4217ca54c3Smrgways to generate images:
4317ca54c3Smrg
4417ca54c3Smrg	dest = (source IN mask) OP dest
4517ca54c3Smrg
4617ca54c3SmrgWhere 'IN' is the Porter/Duff operator of that name and 'OP' is any of the
4717ca54c3Smrglist of compositing operators described below, among which can be found all
4817ca54c3Smrgof the Porter/Duff binary operators.
4917ca54c3Smrg
5017ca54c3SmrgTo use this operator several additional values are required:
5117ca54c3Smrg
5217ca54c3Smrg +	The destination rectangle.  This is a subset of the destination
5317ca54c3Smrg 	within which the rendering is performed.
5417ca54c3Smrg
5517ca54c3Smrg +	The source location. This identifies the coordinate in the
5617ca54c3Smrg 	source aligned with the upper left corner of the
5717ca54c3Smrg	destination rectangle.
5817ca54c3Smrg
5917ca54c3Smrg +	The mask location. This identifies the coordinate in the
6017ca54c3Smrg 	mask aligned with the upper left corner of the
6117ca54c3Smrg	destination rectangle.
6217ca54c3Smrg
6317ca54c3Smrg +	A clip list.  This limits the rendering to the intersection of the
6417ca54c3Smrg 	destination rectangle with this clip list.
6517ca54c3Smrg
6617ca54c3Smrg +	The OP to use
6717ca54c3Smrg
6817ca54c3Smrg +	Whether the source should be repeated to cover the destination
6917ca54c3Smrg 	rectangle, extended with a constant pixel value or extended by
7017ca54c3Smrg	using the nearest available source pixel.
7117ca54c3Smrg
7217ca54c3Smrg +	Whether the mask should be repeated to cover the destination
7317ca54c3Smrg 	rectangle, extended with a constant pixel value or extended by
7417ca54c3Smrg	using the nearest available mask pixel.
7517ca54c3Smrg
7617ca54c3Smrg +	Whether the mask has a single alpha value for all four channels or
7717ca54c3Smrg 	whether each mask channel should affect the associated source/dest
7817ca54c3Smrg	channels.
7917ca54c3Smrg
8017ca54c3Smrg +	Whether the source should be reshaped with a projective
8117ca54c3Smrg        transformation, and if so, what filter to apply while
8217ca54c3Smrg	resampling the data.
8317ca54c3Smrg	
8417ca54c3Smrg +	Whether the mask should be reshaped with a projective
8517ca54c3Smrg        transformation, and if so, what filter to apply while
8617ca54c3Smrg	resampling the data.
8717ca54c3Smrg	
8817ca54c3SmrgThese parameters are variously attached to the operands or included in each
8917ca54c3Smrgrendering request.
9017ca54c3Smrg
9117ca54c3Smrg4. Data types
9217ca54c3Smrg
9317ca54c3SmrgThe core protocol rendering system uses a pixel model and applies color only
9417ca54c3Smrgin the final generation of the video signal.  A compositing model operates
9517ca54c3Smrgon colors, not pixel values so a new datatype is needed to interpret data as
9617ca54c3Smrgcolor instead of just bits.
9717ca54c3Smrg
9817ca54c3SmrgThe "PictFormat" object holds information needed to translate pixel values
9917ca54c3Smrginto red, green, blue and alpha channels.  The server has a list of picture
10017ca54c3Smrgformats corresponding to the various visuals on the screen.  There are two
10117ca54c3Smrgclasses of formats, Indexed and Direct.  Indexed PictFormats hold a list of
10217ca54c3Smrgpixel values and RGBA values while Direct PictFormats hold bit masks for each
10317ca54c3Smrgof R, G, B and A.
10417ca54c3Smrg
10517ca54c3SmrgThe "Picture" object contains a Drawable, a PictFormat and some
10617ca54c3Smrgrendering state.  More than one Picture can refer to the same Drawable.
10717ca54c3Smrg
10817ca54c3Smrg5. Errors
10917ca54c3Smrg
11017ca54c3SmrgErrors are sent using core X error reports.
11117ca54c3Smrg
11217ca54c3SmrgPictFormat
11317ca54c3Smrg	A value for a PICTFORMAT argument does not name a defined PICTFORMAT.
11417ca54c3Smrg
11517ca54c3SmrgPicture
11617ca54c3Smrg	A value for a PICTURE argument does not name a defined PICTURE.
11717ca54c3Smrg
11817ca54c3SmrgPictOp
11917ca54c3Smrg	A value for a PICTOP argument does not name a defined PICTOP.
12017ca54c3Smrg
12117ca54c3SmrgGlyphSet
12217ca54c3Smrg	A value for a GLYPHSET argument does not name a defined GLYPHSET.
12317ca54c3Smrg
12417ca54c3SmrgGlyph
12517ca54c3Smrg	A value for a GLYPH argument does not name a defined GLYPH in the
12617ca54c3Smrg	glyphset.
12717ca54c3Smrg
12817ca54c3Smrg6. Protocol Types
12917ca54c3Smrg
13017ca54c3SmrgPICTURE		32-bit value (top three bits guaranteed to be zero)
13117ca54c3SmrgPICTFORMAT	32-bit value (top three bits guaranteed to be zero)
13217ca54c3SmrgPICTTYPE	{ Indexed, Direct }
13317ca54c3SmrgPICTOP		{ Clear, Src, Dst, Over, OverReverse, In, InReverse,
13417ca54c3Smrg		  Out, OutReverse, Atop, AtopReverse, Xor, Add, Saturate,
13517ca54c3Smrg		  DisjointClear, DisjointSrc, DisjointDst, DisjointOver,
13617ca54c3Smrg		  DisjointOverReverse, DisjointIn, DisjointInReverse,
13717ca54c3Smrg		  DisjointOut, DisjointOutReverse, DisjointAtop,
13817ca54c3Smrg		  DisjointAtopReverse, DisjointXor,
13917ca54c3Smrg		  ConjointClear, ConjointSrc, ConjointDst, ConjointOver,
14017ca54c3Smrg		  ConjointOverReverse, ConjointIn, ConjointInReverse,
14117ca54c3Smrg		  ConjointOut, ConjointOutReverse, ConjointAtop,
14217ca54c3Smrg		  ConjointAtopReverse, ConjointXor,
14317ca54c3Smrg		  Multiply, Screen, Overlay, Darken, Lighten, ColorDodge,
14417ca54c3Smrg		  ColorBurn, HardLight, SoftLight, Difference, Exclusion,
14517ca54c3Smrg		  HSLHue, HSLSaturation, HSLColor, HSLLuminosity
14617ca54c3Smrg		}
14717ca54c3SmrgSUBPIXEL	{ Unknown, HorizontalRGB, HorizontalBGR, 
14817ca54c3Smrg		  VerticalRGB, VerticalBGR, None
14917ca54c3Smrg		}
15017ca54c3SmrgCOLOR		[	
15117ca54c3Smrg			red, green, blue, alpha: CARD16
15217ca54c3Smrg		]
15317ca54c3SmrgCHANNELMASK	[
15417ca54c3Smrg			shift, mask: CARD16
15517ca54c3Smrg		]
15617ca54c3SmrgDIRECTFORMAT	[
15717ca54c3Smrg			red, green, blue, alpha: CHANNELMASK 
15817ca54c3Smrg		]
15917ca54c3SmrgINDEXVALUE	[ 
16017ca54c3Smrg			pixel: Pixel; 
16117ca54c3Smrg			red, green, blue, alpha: CARD16 
16217ca54c3Smrg		]
16317ca54c3SmrgPICTFORMINFO	[
16417ca54c3Smrg			id:		PICTFORMAT
16517ca54c3Smrg			type:		PICTTYPE
16617ca54c3Smrg			depth:		CARD8
16717ca54c3Smrg			direct:		DIRECTFORMAT
16817ca54c3Smrg			colormap:	COLORMAP or None
16917ca54c3Smrg		]
17017ca54c3Smrg
17117ca54c3SmrgPICTVISUAL	[
17217ca54c3Smrg			visual:		VISUALID or None
17317ca54c3Smrg			format:		PICTFORMAT
17417ca54c3Smrg		]
17517ca54c3Smrg
17617ca54c3SmrgPICTDEPTH	[
17717ca54c3Smrg			depth:		CARD8
17817ca54c3Smrg			visuals:	LISTofPICTVISUAL
17917ca54c3Smrg		]
18017ca54c3Smrg
18117ca54c3SmrgPICTSCREEN	LISTofPICTDEPTH
18217ca54c3Smrg
18317ca54c3SmrgFIXED		32-bit value (top 16 are integer portion, bottom 16 are fraction)
18417ca54c3SmrgTRANSFORM	[
18517ca54c3Smrg			p11, p12, p13:	FIXED
18617ca54c3Smrg			p21, p22, p23:	FIXED
18717ca54c3Smrg			p31, p32, p33:	FIXED
18817ca54c3Smrg		]
18917ca54c3SmrgPOINTFIX	[
19017ca54c3Smrg			x, y: FIXED
19117ca54c3Smrg		]
19217ca54c3SmrgPOLYEDGE	{ Sharp, Smooth }
19317ca54c3SmrgPOLYMODE	{ Precise, Imprecise }
19417ca54c3SmrgREPEAT          { None, Regular, Pad, Reflect }
19517ca54c3SmrgCOLORPOINT	[
19617ca54c3Smrg			point:		POINTFIX
19717ca54c3Smrg			color:		COLOR
19817ca54c3Smrg		]
19917ca54c3SmrgSPANFIX		[
20017ca54c3Smrg			left, right, y: FIXED
20117ca54c3Smrg		]
20217ca54c3SmrgCOLORSPANFIX	[
20317ca54c3Smrg			left, right, y: FIXED
20417ca54c3Smrg			left_color:	COLOR
20517ca54c3Smrg			right_color:	COLOR
20617ca54c3SmrgQUAD		[
20717ca54c3Smrg			p1, p2, p3, p4:	POINTFIX
20817ca54c3Smrg		]
20917ca54c3SmrgTRIANGLE	[
21017ca54c3Smrg			p1, p2, p3:	POINTFIX
21117ca54c3Smrg		]
21217ca54c3SmrgLINEFIX		[
21317ca54c3Smrg			p1, p2:		POINTFIX
21417ca54c3Smrg		]
21517ca54c3SmrgTRAP		[
21617ca54c3Smrg			top, bottom:	SPANFIX
21717ca54c3Smrg		]
21817ca54c3SmrgTRAPEZOID	[
21917ca54c3Smrg			top, bottom:	FIXED
22017ca54c3Smrg			left, right:	LINEFIX
22117ca54c3Smrg		]
22217ca54c3Smrg(TRAPEZOID is deprecated)
22317ca54c3SmrgGLYPHSET	32-bit value (top three bits guaranteed to be zero)
22417ca54c3SmrgGLYPH		32-bit value
22517ca54c3SmrgGLYPHINFO	[
22617ca54c3Smrg			width, height:	CARD16
22717ca54c3Smrg			x, y:		INT16
22817ca54c3Smrg			off-x, off-y:	INT16
22917ca54c3Smrg		]
23017ca54c3SmrgPICTGLYPH	[
23117ca54c3Smrg			info:		GLYPHINFO
23217ca54c3Smrg			x, y:		INT16
23317ca54c3Smrg		]
23417ca54c3SmrgGLYPHABLE	GLYPHSET or FONTABLE
23517ca54c3SmrgGLYPHELT8	[
23617ca54c3Smrg			dx, dy:		INT16
23717ca54c3Smrg			glyphs:		LISTofCARD8
23817ca54c3Smrg		]
23917ca54c3SmrgGLYPHITEM8	GLYPHELT8 or GLYPHABLE
24017ca54c3SmrgGLYPHELT16	[
24117ca54c3Smrg			dx, dy:		INT16
24217ca54c3Smrg			glyphs:		LISTofCARD16
24317ca54c3Smrg		]
24417ca54c3SmrgGLYPHITEM16	GLYPHELT16 or GLYPHABLE
24517ca54c3SmrgGLYPHELT32	[
24617ca54c3Smrg			dx, dy:		INT16
24717ca54c3Smrg			glyphs:		LISTofCARD32
24817ca54c3Smrg		]
24917ca54c3SmrgGLYPHITEM32	GLYPHELT32 or GLYPHABLE
25017ca54c3Smrg
25117ca54c3SmrgANIMCURSORELT	[
25217ca54c3Smrg			cursor:		CURSOR
25317ca54c3Smrg			delay:		CARD32
25417ca54c3Smrg		]
25517ca54c3Smrg7. Standard PictFormats
25617ca54c3Smrg
25717ca54c3SmrgThe server must support a Direct PictFormat with 8 bits each of red, green,
25817ca54c3Smrgblue and alpha as well as a Direct PictFormat with 8 bits of red, green and
25917ca54c3Smrgblue and 0 bits of alpha.  The server must also support Direct PictFormats
26017ca54c3Smrgwith 1, 4 and 8 bits of alpha and 0 bits of r, g and b.
26117ca54c3Smrg
26217ca54c3SmrgPixel component values lie in the close range [0,1].  These values are
26317ca54c3Smrgencoded in a varying number of bits.  Values are encoded in a straight
26417ca54c3Smrgforward manner.  For a component encoded in m bits, a binary encoding b
26517ca54c3Smrgis equal to a component value of b/(2^m-1).
26617ca54c3Smrg
26717ca54c3SmrgA Direct PictFormat with zero bits of alpha component is declared to have
26817ca54c3Smrgalpha == 1 everywhere.  A Direct PictFormat with zero bits of red, green and
26917ca54c3Smrgblue is declared to have red, green, blue == 0 everywhere.  If any of red,
27017ca54c3Smrggreen or blue components are of zero size, all are of zero size.  Direct
27117ca54c3SmrgPictFormats never have colormaps and are therefore screen independent.
27217ca54c3Smrg
27317ca54c3SmrgIndexed PictFormats never have alpha channels and the direct component is all
27417ca54c3Smrgzeros.  Indexed PictFormats always have a colormap in which the specified
27517ca54c3Smrgcolors are allocated read-only and are therefore screen dependent.  Drawing
27617ca54c3Smrgto in Indexed Picture uses only pixel values listed by QueryPictIndexValues.
27717ca54c3SmrgReading from an Indexed Picture uses red, green and blue values from the
27817ca54c3Smrgcolormap and alpha values from those listed by QueryPictIndexValues.  Pixel
27917ca54c3Smrgvalues not present in QueryPictIndexValues are given alpha values of 1.
28017ca54c3Smrg
28117ca54c3Smrg8. Compositing Operators
28217ca54c3Smrg
28317ca54c3SmrgFor each pixel, the four channels of the image are computed with:
28417ca54c3Smrg
28517ca54c3Smrg	C = Ca * Fa + Cb * Fb
28617ca54c3Smrg
28717ca54c3Smrgwhere C, Ca, Cb are the values of the respective channels and Fa and Fb
28817ca54c3Smrgcome from the following table:
28917ca54c3Smrg
29017ca54c3Smrg	PictOp			Fa			Fb
29117ca54c3Smrg	--------------------------------------------------
29217ca54c3Smrg	Clear			0			0
29317ca54c3Smrg	Src			1			0
29417ca54c3Smrg	Dst			0			1
29517ca54c3Smrg	Over			1			1-Aa
29617ca54c3Smrg	OverReverse		1-Ab			1
29717ca54c3Smrg	In			Ab			0
29817ca54c3Smrg	InReverse		0			Aa
29917ca54c3Smrg	Out			1-Ab			0
30017ca54c3Smrg	OutReverse		0			1-Aa
30117ca54c3Smrg	Atop			Ab			1-Aa
30217ca54c3Smrg	AtopReverse		1-Ab			Aa
30317ca54c3Smrg	Xor			1-Ab			1-Aa
30417ca54c3Smrg	Add			1			1
30517ca54c3Smrg	Saturate		min(1,(1-Ab)/Aa)	1
30617ca54c3Smrg	DisjointClear		0			0
30717ca54c3Smrg	DisjointSrc		1			0
30817ca54c3Smrg	DisjointDst		0			1
30917ca54c3Smrg	DisjointOver		1			min(1,(1-Aa)/Ab)
31017ca54c3Smrg	DisjointOverReverse	min(1,(1-Ab)/Aa)	1
31117ca54c3Smrg	DisjointIn		max(1-(1-Ab)/Aa,0)	0
31217ca54c3Smrg	DisjointInReverse	0			max(1-(1-Aa)/Ab,0)
31317ca54c3Smrg	DisjointOut		min(1,(1-Ab)/Aa)	0
31417ca54c3Smrg	DisjointOutReverse	0			min(1,(1-Aa)/Ab)
31517ca54c3Smrg	DisjointAtop		max(1-(1-Ab)/Aa,0)	min(1,(1-Aa)/Ab)
31617ca54c3Smrg	DisjointAtopReverse	min(1,(1-Ab)/Aa)	max(1-(1-Aa)/Ab,0)
31717ca54c3Smrg	DisjointXor		min(1,(1-Ab)/Aa)	min(1,(1-Aa)/Ab)
31817ca54c3Smrg	ConjointClear		0			0
31917ca54c3Smrg	ConjointSrc		1			0
32017ca54c3Smrg	ConjointDst		0			1
32117ca54c3Smrg	ConjointOver		1			max(1-Aa/Ab,0)
32217ca54c3Smrg	ConjointOverReverse	max(1-Ab/Aa,0)		1
32317ca54c3Smrg	ConjointIn		min(1,Ab/Aa)		0
32417ca54c3Smrg	ConjointInReverse	0			min(Aa/Ab,1)
32517ca54c3Smrg	ConjointOut		max(1-Ab/Aa,0)		0
32617ca54c3Smrg	ConjointOutReverse	0			max(1-Aa/Ab,0)
32717ca54c3Smrg	ConjointAtop		min(1,Ab/Aa)		max(1-Aa/Ab,0)
32817ca54c3Smrg	ConjointAtopReverse	max(1-Ab/Aa,0)		min(1,Aa/Ab)
32917ca54c3Smrg	ConjointXor		max(1-Ab/Aa,0)		max(1-Aa/Ab,0)
33017ca54c3Smrg
33117ca54c3SmrgSaturate and DisjointOverReverse are the same.  They match OpenGL
33217ca54c3Smrgcompositing with FUNC_ADD, SRC_ALPHA_SATURATE, ONE, except that Render uses
33317ca54c3Smrgpremultiplied alpha while Open GL uses non-premultiplied alpha.
33417ca54c3Smrg
33517ca54c3SmrgThe result of any compositing operator is always limited to the range
33617ca54c3Smrg[0,1] for each component.  Components whose value would be greater than 1
33717ca54c3Smrgare set to 1.
33817ca54c3Smrg
33917ca54c3SmrgFor operations involving division, when the divisor is zero, define the
34017ca54c3Smrgquotient to be positive infinity.  The result is always well defined
34117ca54c3Smrgbecause the division is surrounded with a max or min operator which will
34217ca54c3Smrggive a finite result.
34317ca54c3Smrg
34417ca54c3SmrgWhen the mask contains separate alpha values for each channel, the
34517ca54c3Smrgalpha value resulting from the combination of that value with the source
34617ca54c3Smrgalpha channel is used in the final image composition.
34717ca54c3Smrg
34817ca54c3Smrg9. Source and Mask Transformations
34917ca54c3Smrg
35017ca54c3SmrgWhen fetching pixels from the source or mask pictures, Render provides four
35117ca54c3Smrgoptions for pixel values which fall outside the drawable (this includes
35217ca54c3Smrgpixels within a window geometry obscured by other windows). 
35317ca54c3Smrg
35417ca54c3Smrg +	None.  Missing values are replaced with transparent.
35517ca54c3Smrg 
35617ca54c3Smrg +	Pad.  Replace missing pixels with the nearest available
35717ca54c3Smrg 	pixel.  Where multiple pixels are equidistant, select
35817ca54c3Smrg	those with smallest Y and then smallest X coordinates
35917ca54c3Smrg
36017ca54c3Smrg +	Normal.  Select the pixel which would appear were the
36117ca54c3Smrg 	drawable tiled to enclose the missing coordinate.  If
36217ca54c3Smrg	the tiling doesn't cover the coordinate, use the
36317ca54c3Smrg	selected Constant or Nearest mode.
36417ca54c3Smrg
36517ca54c3Smrg *	Reflect.  Select the pixel which would appear were the
36617ca54c3Smrg	drawable tiled to enclose the missing coordinate in such a
36717ca54c3Smrg	way that tiles in even numbered columns are reflected in the Y
36817ca54c3Smrg	axis, and tiles in even numbered rows are reflected in the X
36917ca54c3Smrg	axis. Tiles that in both an even numbered row and an even
37017ca54c3Smrg	numbered column are reflected in both axes.
37117ca54c3Smrg
37217ca54c3SmrgTo construct the source and mask operands, the computed pixels values are
37317ca54c3Smrgtransformed through a homogeneous matrix, filtered and then used in the
37417ca54c3Smrgfundamental rendering operator described above.  Each screen provides a list
37517ca54c3Smrgof supported filter names. There are a few required filters, and several
37617ca54c3Smrgrequired filter alias which must map to one of the available filters.
37717ca54c3Smrg
37817ca54c3Smrg10. Polygon Rasterization
37917ca54c3Smrg
38017ca54c3SmrgRender provides only two kinds of polygons, trapezoids and triangles.  To
38117ca54c3Smrgimprove efficiency, several different wire encodings exist for each. 
38217ca54c3Smrg
38317ca54c3SmrgAll trapezoids must be convex.  Rendering of concave trapezoids is unspecified
38417ca54c3Smrgexcept that the result must obey the clipping rules.
38517ca54c3Smrg
38617ca54c3SmrgComposite
38717ca54c3SmrgPolygons are rasterized by implicit generating an alpha mask and using that
38817ca54c3Smrgin the general compositing operator along with a supplied source image:
38917ca54c3Smrg
39017ca54c3Smrg	tmp = Rasterize (polygon)
39117ca54c3Smrg	Composite (op, dst, src, tmp)
39217ca54c3Smrg
39317ca54c3SmrgWhen rasterized with Sharp edges, the mask is computed with a depth of 1 so
39417ca54c3Smrgthat all of the mask values are either 0 or 1.
39517ca54c3Smrg
39617ca54c3SmrgWhen rasterized with Smooth edges, the mask is generated by creating a square
39717ca54c3Smrgaround each pixel coordinate and computing the amount of that square covered
39817ca54c3Smrgby the polygon.  This ignores sampling theory but it provides a precise
39917ca54c3Smrgdefinition which is close to the right answer.  This value is truncated to
40017ca54c3Smrgthe alpha width in the fallback format before application of the compositing
40117ca54c3Smrgoperator.
40217ca54c3Smrg
40317ca54c3SmrgRasterization
40417ca54c3SmrgAlpha values are generated by point sampling the coverage of a square
40517ca54c3Smrgsurrounding the center of each pixel by the polygon. 
40617ca54c3Smrg
40717ca54c3SmrgIn Precise poly mode, the sample points are located in a regular grid.  When
40817ca54c3Smrgalpha depth 'e' is even, the regular grid is 2**(e/2) + 1 samples wide and
40917ca54c3Smrg2**(e/2) -1 samples high.  For odd alpha depth 'o', the sample grid is 2**o
41017ca54c3Smrg- 1 samples wide and 1 sample high.  Note that odd alpha depth usually
41117ca54c3Smrgoccurs only at depth 1, so this misshapen sample grid has no ill effects.
41217ca54c3SmrgThe sample grid is centered within the pixel and then each sample point is
41317ca54c3Smrgrounded down to a point on the sub-pixel coordinate grid.
41417ca54c3Smrg
41517ca54c3SmrgIn Imprecise mode, the location of the sample points is not specified, but
41617ca54c3Smrgthe implementation must conform to the following constraints:
41717ca54c3Smrg
41817ca54c3Smrg +	Abutting edges must match precisely.  When specifying two polygons
41917ca54c3Smrg	abutting along a common edge, if that edge is specified with the
42017ca54c3Smrg	same coordinates in each polygon then the sum of alpha values for
42117ca54c3Smrg	pixels inside the union of the two polygons must be precisely one.
42217ca54c3Smrg
42317ca54c3Smrg +	Translationally invariant.  The pixelization of the polygon must
42417ca54c3Smrg	be the same when either the polygon or the target drawable
42517ca54c3Smrg	are translated by any whole number of pixels in any direction.
42617ca54c3Smrg
42717ca54c3Smrg +	Sharp edges are honored.  When the polygon is rasterized with Sharp
42817ca54c3Smrg	edges, the implicit alpha mask will contain only 1 or 0 for
42917ca54c3Smrg	each pixel.
43017ca54c3Smrg
43117ca54c3Smrg +	Order independent. Two identical polygons specified with vertices
43217ca54c3Smrg	in different orders must generate identical results.
43317ca54c3Smrg
43417ca54c3Smrg11. Image Filtering
43517ca54c3Smrg
43617ca54c3SmrgWhen computing pixels from source and mask images, a filter may be applied
43717ca54c3Smrgto the data.  This is usually used with a non-identity transformation
43817ca54c3Smrgmatrix, but filtering may be applied with an identity transformation.
43917ca54c3Smrg
44017ca54c3SmrgEach filter is given a unique name encoded as an ISO Latin-1 string.
44117ca54c3SmrgFilters may be configured with a list of fixed point values; the number of
44217ca54c3Smrgparameters and their interpretation is currently left to conventions passed
44317ca54c3Smrgoutside of the protocol.  A set of standard filters are required to be
44417ca54c3Smrgprovided:
44517ca54c3Smrg
44617ca54c3Smrg	Filter Name	Description
44717ca54c3Smrg
44817ca54c3Smrg	nearest		Nearest neighbor filtering
44917ca54c3Smrg	bilinear	Linear interpolation in two dimensions
45017ca54c3Smrg
45117ca54c3SmrgAdditional names may be provided for any filter as aliases.  A set of
45217ca54c3Smrgstandard alias names are required to be mapped to a provided filter so that
45317ca54c3Smrgapplications can use the alias names without checking for availability.
45417ca54c3Smrg
45517ca54c3Smrg	Alias name	Intended interpretation
45617ca54c3Smrg	
45717ca54c3Smrg	fast		High performance, quality similar to Nearest
45817ca54c3Smrg	good		Reasonable performance, quality similar to Bilinear
45917ca54c3Smrg	best		Highest quality available, performance may not
46017ca54c3Smrg			be suitable for interactive use
46117ca54c3Smrg
46217ca54c3SmrgAliases must map directly to a non-aliased filter name.
46317ca54c3Smrg
46417ca54c3SmrgThere is also a set of standard filters which are not required but may be
46517ca54c3Smrgprovided.  If they are provided, using the standard name, they must match
46617ca54c3Smrgthe definition specified here.
46717ca54c3Smrg
46817ca54c3Smrg	Filter Name	Description
46917ca54c3Smrg	
47017ca54c3Smrg	convolution	MxN convolution filter.  The values specified
47117ca54c3Smrg			in SetPictureFilter are M, N and then M * N
47217ca54c3Smrg			filter parameters.  M and N must be integers
47317ca54c3Smrg			represented as fixed point numbers.
47417ca54c3Smrg	gaussian	Gaussian blur.  The value specified is a radius
47517ca54c3Smrg			in pixels (which can be fractional).  A standard
47617ca54c3Smrg			Gaussian 2D convolution filter will be applied.
47717ca54c3Smrg	binomial	Binomial blur. An approximation of a Gaussian
47817ca54c3Smrg			blur using binomial coefficients
47917ca54c3Smrg
48017ca54c3Smrg12. Glyph Rendering
48117ca54c3Smrg
48217ca54c3SmrgGlyphs are small alpha masks which can be stored in the X server and
48317ca54c3Smrgrendered by referring to them by name.  A set of glyphs can be rendered in a
48417ca54c3Smrgsingle request.  Glyphs are positioned by subtracting the x, y elements of
48517ca54c3Smrgthe GLYPHINFO from the requested rendering position.  The next glyph
48617ca54c3Smrgrendering position is set to the current rendering position plus the off-x
48717ca54c3Smrgand off-y elements.
48817ca54c3Smrg
48917ca54c3SmrgGlyphs are stored in GlyphSets and are named within the GlyphSet with
49017ca54c3Smrgclient-specified 32-bit numbers.
49117ca54c3Smrg
49217ca54c3SmrgGlyphs can be stored in any PictFormat supported by the server.  All glyphs
49317ca54c3Smrgin a GlyphSet are stored in the same format.
49417ca54c3Smrg
49517ca54c3Smrg13. Extension Initialization
49617ca54c3Smrg
49717ca54c3SmrgThe client must negotiate the version of the extension before executing
49817ca54c3Smrgextension requests.  Behavior of the server is undefined otherwise.
49917ca54c3Smrg
50017ca54c3SmrgQueryVersion
50117ca54c3Smrg
50217ca54c3Smrg	client-major-version:		CARD32
50317ca54c3Smrg	client-minor-version:		CARD32
50417ca54c3Smrg
50517ca54c3Smrg	->
50617ca54c3Smrg
50717ca54c3Smrg	major-version:			CARD32
50817ca54c3Smrg	minor-version:			CARD32
50917ca54c3Smrg
51017ca54c3Smrg	The client sends the highest supported version to the server and
51117ca54c3Smrg	the server sends the highest version it supports, but no higher than
51217ca54c3Smrg	the requested version.  Major versions changes can introduce
51317ca54c3Smrg	incompatibilities in existing functionality, minor version
51417ca54c3Smrg	changes introduce only backward compatible changes.  It is
51517ca54c3Smrg	the clients responsibility to ensure that the server supports
51617ca54c3Smrg	a version which is compatible with its expectations.
51717ca54c3Smrg
51817ca54c3SmrgQueryPictFormats
51917ca54c3Smrg
52017ca54c3Smrg	->
52117ca54c3Smrg
52217ca54c3Smrg	formats:	LISTofPICTFORMINFO
52317ca54c3Smrg	screens:	LISTofPICTSCREEN
52417ca54c3Smrg	ndepths:	CARD32
52517ca54c3Smrg	nvisuals:	CARD32
52617ca54c3Smrg	subpixels:	LISTofSUBPIXEL
52717ca54c3Smrg
52817ca54c3Smrg	Errors:
52917ca54c3Smrg		<none>
53017ca54c3Smrg
53117ca54c3Smrg	The server responds with a list of supported PictFormats and
53217ca54c3Smrg	a list of which PictFormat goes with each visual on each screen.
53317ca54c3Smrg	Every PictFormat must match a supported depth, but not every
53417ca54c3Smrg	PictFormat need have a matching visual.
53517ca54c3Smrg
53617ca54c3Smrg	The total number of PICTDEPTH and PICTVISUAL objects is this reply
53717ca54c3Smrg	is given in 'ndepths' and 'nvisuals'.
53817ca54c3Smrg
53917ca54c3Smrg	The relationship between the red, green and blue elements making
54017ca54c3Smrg	up each pixel indexed by screen is returned in subpixels.
54117ca54c3Smrg	This list is not present in servers advertising protocol
54217ca54c3Smrg	versions earlier than 0.6.  This list may be shorter than
54317ca54c3Smrg	the number of screens, in which case the remaining screens
54417ca54c3Smrg	are given sub pixel order Unknown.
54517ca54c3Smrg
54617ca54c3SmrgQueryPictIndexValues
54717ca54c3Smrg
54817ca54c3Smrg	format:		PICTFORMAT
54917ca54c3Smrg
55017ca54c3Smrg	->
55117ca54c3Smrg
55217ca54c3Smrg	values:		LISTofINDEXVALUE
55317ca54c3Smrg
55417ca54c3Smrg	Errors:
55517ca54c3Smrg		PictFormat, Match
55617ca54c3Smrg
55717ca54c3Smrg	Returns the mapping from pixel values to RGBA values for the
55817ca54c3Smrg	specified Indexed PictFormat.  If 'format' does not refer to
55917ca54c3Smrg	an Indexed PictFormat a Match error is generated.
56017ca54c3Smrg
56117ca54c3SmrgQueryFilters
56217ca54c3Smrg
56317ca54c3Smrg	drawable:	DRAWABLE
56417ca54c3Smrg
56517ca54c3Smrg	->
56617ca54c3Smrg
56717ca54c3Smrg	filters:	LISTofSTRING8
56817ca54c3Smrg	aliases:	LISTofCARD16
56917ca54c3Smrg
57017ca54c3Smrg	This request gets the names of available filters that can be used on the
57117ca54c3Smrg	given drawable. Filters are applied using a SetPictureFilter request.
57217ca54c3Smrg
57317ca54c3Smrg	'aliases' contains a value for each filter name which is the index into
57417ca54c3Smrg	'filters' if this name is an alias. Non-aliased filter have this value
57517ca54c3Smrg	set to 0xFFFF.
57617ca54c3Smrg
57717ca54c3Smrg14. Extension Requests
57817ca54c3Smrg
57917ca54c3SmrgCreatePicture
58017ca54c3Smrg
58117ca54c3Smrg	pid:		PICTURE
58217ca54c3Smrg	drawable:	DRAWABLE
58317ca54c3Smrg	format:		PICTFORMAT
58417ca54c3Smrg	value-mask:	BITMASK
58517ca54c3Smrg	value-list:	LISTofVALUE
58617ca54c3Smrg
58717ca54c3Smrg	Errors:
58817ca54c3Smrg		Alloc, Drawable, IDChoice, Match, Pixmap, Picture,
58917ca54c3Smrg		PictFormat, Value
59017ca54c3Smrg
59117ca54c3Smrg	This request creates a Picture object associated with the specified
59217ca54c3Smrg	drawable and assigns the identifier pid to it.  Pixel data in the
59317ca54c3Smrg	image are interpreted according to 'format'.  It is a Match error
59417ca54c3Smrg	to specify a format with a different depth than the drawable.  If
59517ca54c3Smrg	the drawable is a Window then the Red, Green and Blue masks must
59617ca54c3Smrg	match those in the visual for the window else a Match error is
59717ca54c3Smrg	generated.
59817ca54c3Smrg
59917ca54c3Smrg	The value-mask and value-list specify attributes of the picture that
60017ca54c3Smrg	are to be explicitly initialized.  The possible values are:
60117ca54c3Smrg	
60217ca54c3Smrg	repeat:			REPEAT
60317ca54c3Smrg	alpha-map:		PICTURE or None
60417ca54c3Smrg	alpha-x-origin:		INT16
60517ca54c3Smrg	alpha-y-origin:		INT16
60617ca54c3Smrg	clip-x-origin:		INT16
60717ca54c3Smrg	clip-y-origin:		INT16
60817ca54c3Smrg	clip-mask:		PIXMAP or None
60917ca54c3Smrg	graphics-exposures:	BOOL
61017ca54c3Smrg	subwindow-mode:		{ ClipByChildren, IncludeInferiors }
61117ca54c3Smrg	poly-edge:		POLYEDGE
61217ca54c3Smrg	poly-mode:		POLYMODE
61317ca54c3Smrg	dither:			ATOM or None
61417ca54c3Smrg	component-alpha:	BOOL
61517ca54c3Smrg	
61617ca54c3Smrg	When used as a source or mask operand, Repeat indicates how the
61717ca54c3Smrg	drawable contents should be extended in both directions.
61817ca54c3Smrg	
61917ca54c3Smrg	The alpha channel of alpha-map is used in place of any alpha channel
62017ca54c3Smrg	contained within the drawable for all rendering operations.  The
62117ca54c3Smrg	alpha-mask origin is interpreted relative to the origin of drawable.
62217ca54c3Smrg	Rendering is additionally clipped by the geometry and clip mask of
62317ca54c3Smrg	alpha-map.  Exposures to the window do not affect the contents of
62417ca54c3Smrg	alpha-map.  Alpha-map must refer to a picture containing a Pixmap,
62517ca54c3Smrg	not a Window (or a Match error results).  If the alpha-map picture
62617ca54c3Smrg	itself already has an alpha-map, the result is undefined.
62717ca54c3Smrg
62817ca54c3Smrg	The clip-mask restricts reads and writes to drawable.  Only pixels
62917ca54c3Smrg	where the clip-mask has bits set to 1 are read or written.  Pixels
63017ca54c3Smrg	are not accessed outside the area covered by the clip-mask or where
63117ca54c3Smrg	the clip-mask has bits set to 0.  The clip-mask affects all graphics
63217ca54c3Smrg	requests, including sources.  The clip-mask origin is interpreted
63317ca54c3Smrg	relative to the origin of the picture.  If a pixmap is specified as
63417ca54c3Smrg	the clip-mask, it must have depth 1 and have the same root as the
63517ca54c3Smrg	drawable (or a Match error results).  If clip-mask is None, then
63617ca54c3Smrg	pixels are always drawn, regardless of the clip origin.  The
63717ca54c3Smrg	clip-mask can also be set with the SetPictureClipRectangles request.
63817ca54c3Smrg	Transformations, filters and repeat modes do not affect the clip
63917ca54c3Smrg	mask.
64017ca54c3Smrg
64117ca54c3Smrg	When a window is used as a destination, the subwindow_mode
64217ca54c3Smrg	determines what happens to pixels obscured by inferior
64317ca54c3Smrg	windows. For ClipByChildren the window is clipped by inferiors
64417ca54c3Smrg	and siblings. For IncludeInferior, the window is clipped by
64517ca54c3Smrg	siblings, but not by inferiors.
64617ca54c3Smrg
64717ca54c3Smrg	When a window is used as source or mask, the subwindow_mode is
64817ca54c3Smrg	ignored. Pixels that are obscured by other windows, whether
64917ca54c3Smrg	siblings or inferiors, have undefined contents.
65017ca54c3Smrg
65117ca54c3Smrg	The graphics-exposures flag is ignored. GraphicsExposure events are
65217ca54c3Smrg	never generated by this extension.
65317ca54c3Smrg
65417ca54c3Smrg	Poly-edge and poly-mode control the rasterization of polygons as
65517ca54c3Smrg	described above.
65617ca54c3Smrg
65717ca54c3Smrg	Dither is ignored.
65817ca54c3Smrg
65917ca54c3Smrg	Component-alpha indicates whether each image component is intended as
66017ca54c3Smrg	a separate alpha value when the picture is used as a mask operand.
66117ca54c3Smrg
66217ca54c3Smrg	The default component values are
66317ca54c3Smrg
66417ca54c3Smrg		Component		Default
66517ca54c3Smrg		-------------------------------
66617ca54c3Smrg		repeat			None
66717ca54c3Smrg		clip-x-origin        	0
66817ca54c3Smrg		clip-y-origin          	0
66917ca54c3Smrg		clip-mask		None
67017ca54c3Smrg		subwindow-mode		ClipByChildren
67117ca54c3Smrg		poly-edge		Smooth
67217ca54c3Smrg		poly-mode		Precise
67317ca54c3Smrg		component-alpha		False
67417ca54c3Smrg
67517ca54c3SmrgChangePicture
67617ca54c3Smrg
67717ca54c3Smrg	pid:		PICTURE
67817ca54c3Smrg	value-mask:     BITMASK
67917ca54c3Smrg	value-list:     LISTofVALUE
68017ca54c3Smrg
68117ca54c3Smrg	Errors:
68217ca54c3Smrg		Picture, Alloc, Pixmap, PictOp, Value
68317ca54c3Smrg
68417ca54c3Smrg	The value-mask and value-list specify which attributes are to be
68517ca54c3Smrg	changed.  The values and restrictions are the same as for 
68617ca54c3Smrg	CreatePicture.
68717ca54c3Smrg
68817ca54c3SmrgSetPictureClipRectangles
68917ca54c3Smrg
69017ca54c3Smrg	picture:	PICTURE
69117ca54c3Smrg	clip-x-origin:	INT16
69217ca54c3Smrg	clip-y-origin:	INT16
69317ca54c3Smrg	rectangles:	LISTofRECTANGLE
69417ca54c3Smrg
69517ca54c3Smrg	Errors:
69617ca54c3Smrg		Alloc, Picture
69717ca54c3Smrg
69817ca54c3Smrg	This request changes clip-mask in picture to the specified list of
69917ca54c3Smrg	rectangles and sets the clip origin.  Input and output will be
70017ca54c3Smrg	clipped to remain contained within the rectangles.  The clip origin
70117ca54c3Smrg	is interpreted relative to the origin of picture after
70217ca54c3Smrg	transformations and repeats have been applied. The rectangle
70317ca54c3Smrg	coordinates are interpreted relative to the clip origin.
70417ca54c3Smrg
70517ca54c3Smrg	The list of rectangles can be empty, which effectively disables
70617ca54c3Smrg	output.  This is the opposite of passing None as the clip-mask in
70717ca54c3Smrg	CreatePicture and ChangePicture.
70817ca54c3Smrg
70917ca54c3Smrg	Note that output is clipped to the union of all of the rectangles
71017ca54c3Smrg	and that no particular ordering among the rectangles is required.
71117ca54c3Smrg
71217ca54c3SmrgSetPictureTransform
71317ca54c3Smrg
71417ca54c3Smrg	picture:	PICTURE
71517ca54c3Smrg	transform:	TRANSFORM
71617ca54c3Smrg
71717ca54c3Smrg	Errors:
71817ca54c3Smrg		Alloc, Value, Picture
71917ca54c3Smrg
72017ca54c3Smrg	This request changes the projective transformation used to
72117ca54c3Smrg	map coordinates when 'picture' is used as the source or
72217ca54c3Smrg	mask in any compositing operation.  The transform
72317ca54c3Smrg	maps from destination pixel geometry back to the source pixel
72417ca54c3Smrg	geometry.
72517ca54c3Smrg
72617ca54c3Smrg	The matrix must be invertable, else a Value error is generated.
72717ca54c3Smrg
72817ca54c3SmrgSetPictureFilter
72917ca54c3Smrg
73017ca54c3Smrg	picture:	PICTURE
73117ca54c3Smrg	filter:		STRING8
73217ca54c3Smrg	values:		LISTofFIXED
73317ca54c3Smrg
73417ca54c3Smrg	Errors:
73517ca54c3Smrg		Value, Match, Picture
73617ca54c3Smrg
73717ca54c3Smrg	This request sets the current filter used when picture is a source
73817ca54c3Smrg	or mask operand.  Filter must be one of the filters supported
73917ca54c3Smrg	for the screen associated with picture, else a Match error
74017ca54c3Smrg	is generated.  If the filter accepts additional parameters,
74117ca54c3Smrg	they can be provided in values, incorrect values generate Value
74217ca54c3Smrg	errors, too many values generate Match errors.  Too few values
74317ca54c3Smrg	cause the filter to assume default values for the missing
74417ca54c3Smrg	parameters.
74517ca54c3Smrg
74617ca54c3Smrg	When created, Pictures are set to the Nearest filter.
74717ca54c3Smrg
74817ca54c3SmrgFreePicture
74917ca54c3Smrg
75017ca54c3Smrg	pid:		PICTURE
75117ca54c3Smrg
75217ca54c3Smrg	Errors:
75317ca54c3Smrg		Picture
75417ca54c3Smrg
75517ca54c3Smrg	This request deletes the association between the resource ID and the
75617ca54c3Smrg	picture.  The picture storage will be freed when no other resource
75717ca54c3Smrg	references it.
75817ca54c3Smrg
75917ca54c3SmrgComposite
76017ca54c3Smrg
76117ca54c3Smrg	op:		PICTOP
76217ca54c3Smrg	src:		PICTURE
76317ca54c3Smrg	mask:		PICTURE or None
76417ca54c3Smrg	dst:		PICTURE
76517ca54c3Smrg	src-x, src-y:	INT16
76617ca54c3Smrg	mask-x, mask-y:	INT16
76717ca54c3Smrg	dst-x, dst-y:	INT16
76817ca54c3Smrg	width, height:	CARD16
76917ca54c3Smrg
77017ca54c3Smrg	This request combines the specified rectangle of the transformed
77117ca54c3Smrg	src and mask operands with the specified rectangle of dst using op
77217ca54c3Smrg	as the compositing operator.  The coordinates are relative their
77317ca54c3Smrg	respective (transformed) drawable's origin.  Rendering is clipped
77417ca54c3Smrg	to the geometry of the dst drawable and then to the dst clip-list.
77517ca54c3Smrg
77617ca54c3Smrg	Pixels outside the geometry of src or mask needed for this
77717ca54c3Smrg	computation are substituted as described in the Source and Mask
77817ca54c3Smrg	Transformations section above.
77917ca54c3Smrg	
78017ca54c3Smrg	If src, mask and dst are not in the same format, and one of their
78117ca54c3Smrg	formats can hold all without loss of precision, they are converted
78217ca54c3Smrg	to that format.  Alternatively, the server will convert each
78317ca54c3Smrg	operand to the fallback format.
78417ca54c3Smrg
78517ca54c3Smrg	If mask is None, it is replaced by a constant alpha value of 1.
78617ca54c3Smrg
78717ca54c3SmrgFillRectangles
78817ca54c3Smrg
78917ca54c3Smrg	op:		PICTOP
79017ca54c3Smrg	dst:		PICTURE
79117ca54c3Smrg	color:		COLOR
79217ca54c3Smrg	rects:		LISTofRECTANGLE
79317ca54c3Smrg
79417ca54c3Smrg	This request combines color with the destination drawable in the
79517ca54c3Smrg	area specified by rects.  Each rectangle is combined separately;
79617ca54c3Smrg	overlapping areas will be rendered multiple times.  The effect is
79717ca54c3Smrg	equivalent to compositing with a repeating source picture filled with
79817ca54c3Smrg	the specified color.
79917ca54c3Smrg
80017ca54c3SmrgTrapezoids
80117ca54c3Smrg
80217ca54c3Smrg	op:		PICTOP
80317ca54c3Smrg	src:		PICTURE
80417ca54c3Smrg	src-x, src-y:   INT16
80517ca54c3Smrg	dst:		PICTURE
80617ca54c3Smrg	mask-format:	PICTFORMAT or None
80717ca54c3Smrg	traps:		LISTofTRAPEZOID
80817ca54c3Smrg
80917ca54c3Smrg	This request rasterizes the list of trapezoids.
81017ca54c3Smrg	
81117ca54c3Smrg	For each trap, the area between the left and right edges is filled
81217ca54c3Smrg	from the top to the bottom.  src-x and src-y register the pattern to
81317ca54c3Smrg	the floor of the top x and y coordinate of the left edge of the
81417ca54c3Smrg	first trapezoid, they are adjusted for subsequent trapezoids so that
81517ca54c3Smrg	the pattern remains globally aligned within the destination.
81617ca54c3Smrg
81717ca54c3Smrg	When mask-format is not None, trapezoids are rendered in the
81817ca54c3Smrg	following way with the effective mask computed in mask-format:
81917ca54c3Smrg
82017ca54c3Smrg		tmp = temporary alpha picture (in mask-format)
82117ca54c3Smrg		Combine (Zero, tmp, tmp, None)
82217ca54c3Smrg		for each trapezoid
82317ca54c3Smrg			Combine (Add, tmp, trapezoid, None)
82417ca54c3Smrg		Combine (op, dst, source, tmp)
82517ca54c3Smrg
82617ca54c3Smrg	When mask-format is None, trapezoids are rendered in the order
82717ca54c3Smrg	specified directly to the destination:
82817ca54c3Smrg
82917ca54c3Smrg		for each trapezoid
83017ca54c3Smrg			Combine (op, dst, source, trapezoid)
83117ca54c3Smrg
83217ca54c3Smrg	(The Trapezoids request is deprecated)
83317ca54c3Smrg
83417ca54c3SmrgTriangles
83517ca54c3Smrg
83617ca54c3Smrg	op:		PICTOP
83717ca54c3Smrg	src:		PICTURE
83817ca54c3Smrg	src-x, src-y:   INT16
83917ca54c3Smrg	dst:		PICTURE
84017ca54c3Smrg	mask-format:	PICTFORMAT or None
84117ca54c3Smrg	triangles:	LISTofTRIANGLE
84217ca54c3Smrg
84317ca54c3Smrg	This request rasterizes the list of triangles in the order they
84417ca54c3Smrg	occur in the list.
84517ca54c3Smrg
84617ca54c3Smrg	When mask-format is not None, triangles are rendered in the
84717ca54c3Smrg	following way with the effective mask computed in mask-format:
84817ca54c3Smrg
84917ca54c3Smrg		tmp = temporary alpha picture (in mask-format)
85017ca54c3Smrg		Combine (Zero, tmp, tmp, None)
85117ca54c3Smrg		for each triangle
85217ca54c3Smrg			Combine (Add, tmp, triangle, None)
85317ca54c3Smrg		Combine (op, dst, source, tmp)
85417ca54c3Smrg
85517ca54c3Smrg	When mask-format is None, triangles are rendered in the order
85617ca54c3Smrg	specified directly to the destination:
85717ca54c3Smrg
85817ca54c3Smrg		for each triangle
85917ca54c3Smrg			Combine (op, dst, source, triangle)
86017ca54c3Smrg
86117ca54c3SmrgTriStrip
86217ca54c3Smrg
86317ca54c3Smrg	op:		PICTOP
86417ca54c3Smrg	src:		PICTURE
86517ca54c3Smrg	src-x, src-y:   INT16
86617ca54c3Smrg	dst:		PICTURE
86717ca54c3Smrg	mask-format:	PICTFORMAT or None
86817ca54c3Smrg	points:		LISTofPOINTFIX
86917ca54c3Smrg
87017ca54c3Smrg	Triangles are formed by initially using the first three points and
87117ca54c3Smrg	then by eliminating the first point and appending the next point in
87217ca54c3Smrg	the list. If fewer than three points are provided, this request does
87317ca54c3Smrg	nothing.
87417ca54c3Smrg
87517ca54c3Smrg	When mask-format is not None, triangles are rendered in the
87617ca54c3Smrg	following way with the effective mask computed in mask-format:
87717ca54c3Smrg
87817ca54c3Smrg		tmp = temporary alpha picture (in mask-format)
87917ca54c3Smrg		Combine (Zero, tmp, tmp, None)
88017ca54c3Smrg		for each triangle
88117ca54c3Smrg			Combine (Add, tmp, triangle, None)
88217ca54c3Smrg		Combine (op, dst, source, tmp)
88317ca54c3Smrg
88417ca54c3Smrg	When mask-format is None, triangles are rendered in the order
88517ca54c3Smrg	specified directly to the destination:
88617ca54c3Smrg
88717ca54c3Smrg		for each triangle
88817ca54c3Smrg			Combine (op, dst, source, triangle)
88917ca54c3Smrg
89017ca54c3SmrgTriFan
89117ca54c3Smrg	op:		PICTOP
89217ca54c3Smrg	src:		PICTURE
89317ca54c3Smrg	src-x, src-y:   INT16
89417ca54c3Smrg	dst:		PICTURE
89517ca54c3Smrg	mask-format:	PICTFORMAT or None
89617ca54c3Smrg	points:		LISTofPOINTFIX
89717ca54c3Smrg
89817ca54c3Smrg	Triangles are formed by initially using the first three points and
89917ca54c3Smrg	then by eliminating the second point and appending the next point
90017ca54c3Smrg	int the list. If fewer than three points are provided, this request
90117ca54c3Smrg	does nothing.
90217ca54c3Smrg
90317ca54c3Smrg	When mask-format is not None, triangles are rendered in the
90417ca54c3Smrg	following way with the effective mask computed in mask-format:
90517ca54c3Smrg
90617ca54c3Smrg		tmp = temporary alpha picture (in mask-format)
90717ca54c3Smrg		Combine (Zero, tmp, tmp, None)
90817ca54c3Smrg		for each triangle
90917ca54c3Smrg			Combine (Add, tmp, triangle, None)
91017ca54c3Smrg		Combine (op, dst, source, tmp)
91117ca54c3Smrg
91217ca54c3Smrg	When mask-format is None, triangles are rendered in the order
91317ca54c3Smrg	specified directly to the destination:
91417ca54c3Smrg
91517ca54c3Smrg		for each triangle
91617ca54c3Smrg			Combine (op, dst, source, triangle)
91717ca54c3Smrg
91817ca54c3SmrgCreateGlyphSet
91917ca54c3Smrg
92017ca54c3Smrg	gsid:		GLYPHSET
92117ca54c3Smrg	format:		PICTFORMAT
92217ca54c3Smrg
92317ca54c3Smrg	Errors:
92417ca54c3Smrg		Alloc, IDChoice, PictFormat, Match
92517ca54c3Smrg
92617ca54c3Smrg	This request creates a container for glyphs.  The glyphset and
92717ca54c3Smrg	all contained glyphs are destroyed when gsid and any other names
92817ca54c3Smrg	for the glyphset are freed.  Format must be a Direct format, when
92917ca54c3Smrg	it contains RGB values, the glyphs are composited using
93017ca54c3Smrg	component-alpha True, otherwise they are composited using
93117ca54c3Smrg	component-alpha False.
93217ca54c3Smrg
93317ca54c3SmrgReferenceGlyphSet
93417ca54c3Smrg
93517ca54c3Smrg	gsid:		GLYPHSET
93617ca54c3Smrg	existing:	GLYPHSET
93717ca54c3Smrg
93817ca54c3Smrg	Errors:
93917ca54c3Smrg		Alloc, IDChoice, GlyphSet
94017ca54c3Smrg
94117ca54c3Smrg	This request creates an additional name for the existing glyphset.
94217ca54c3Smrg	The glyphset will not be freed until all references to it are
94317ca54c3Smrg	destroyed.
94417ca54c3Smrg
94517ca54c3SmrgFreeGlyphSet
94617ca54c3Smrg
94717ca54c3Smrg	glyphset:	GLYPHSET
94817ca54c3Smrg
94917ca54c3Smrg	Errors:
95017ca54c3Smrg		GlyphSet
95117ca54c3Smrg
95217ca54c3Smrg	This request frees the name for the glyphset.  When all names have
95317ca54c3Smrg	been freed, the glyphset and all contained glyphs are freed.
95417ca54c3Smrg
95517ca54c3SmrgAddGlyphs
95617ca54c3Smrg	glyphset:	GLYPHSET
95717ca54c3Smrg	glyphids:	LISTofCARD32
95817ca54c3Smrg	glyphs:		LISTofGLYPHINFO
95917ca54c3Smrg	data:		LISTofBYTE
96017ca54c3Smrg
96117ca54c3Smrg	Errors:
96217ca54c3Smrg		GlyphSet, Alloc
96317ca54c3Smrg
96417ca54c3Smrg	This request adds glyphs to glyphset.  The image for the glyphs
96517ca54c3Smrg	are stored with each glyph in a separate Z-format image padded to a
96617ca54c3Smrg	32-bit boundary.  Existing glyphs with the same names are replaced.
96717ca54c3Smrg
96817ca54c3SmrgFreeGlyphs
96917ca54c3Smrg
97017ca54c3Smrg	glyphset:	GLYPHSET
97117ca54c3Smrg	glyphs:		LISTofGLYPH
97217ca54c3Smrg
97317ca54c3Smrg	Errors:
97417ca54c3Smrg		GlyphSet, Match
97517ca54c3Smrg
97617ca54c3Smrg	This request removes glyphs from glyphset.  Each glyph must exist
97717ca54c3Smrg	in glyphset (else a Match error results).
97817ca54c3Smrg
97917ca54c3SmrgCompositeGlyphs8
98017ca54c3SmrgCompositeGlyphs16
98117ca54c3SmrgCompositeGlyphs32
98217ca54c3Smrg
98317ca54c3Smrg	op:		PICTOP
98417ca54c3Smrg	src:		PICTURE
98517ca54c3Smrg	dst:		PICTURE
98617ca54c3Smrg	mask-format:	PICTFORMAT or None
98717ca54c3Smrg	glyphset:	GLYPHABLE
98817ca54c3Smrg	src-x, src-y:	INT16
98917ca54c3Smrg	glyphcmds:	LISTofGLYPHITEM8	CompositeGlyphs8
99017ca54c3Smrg	glyphcmds:	LISTofGLYPHITEM16	CompositeGlyphs16
99117ca54c3Smrg	glyphcmds:	LISTofGLYPHITEM32	CompositeGlyphs32
99217ca54c3Smrg
99317ca54c3Smrg	Errors:
99417ca54c3Smrg		Picture, PictOp, PictFormat, GlyphSet, Glyph
99517ca54c3Smrg
99617ca54c3Smrg	The src-x and src-y coordinates are relative to the drawable's
99717ca54c3Smrg	origin and specify the baseline starting position (the initial glyph
99817ca54c3Smrg	origin).  Each glyph item is processed in turn.  A glyphset item
99917ca54c3Smrg	causes the glyphset to be used for subsequent glyphs.  Switching
100017ca54c3Smrg	among glyphsets does not affect the next glyph origin.  A glyph
100117ca54c3Smrg	element delta-x and delta-y specify additional changes in the
100217ca54c3Smrg	position along the x and y axes before the string is drawn; the
100317ca54c3Smrg	deltas are always added to the glyph origin.
100417ca54c3Smrg
100517ca54c3Smrg	All contained GLYPHSETs are always transmitted most significant byte
100617ca54c3Smrg	first.  
100717ca54c3Smrg	
100817ca54c3Smrg	If a GlyphSet error is generated for an item, the previous items may
100917ca54c3Smrg	have been drawn.
101017ca54c3Smrg	
101117ca54c3Smrg	When mask-format is not None, glyphs are rendered in the following
101217ca54c3Smrg	way with the effective mask computed in mask-format:
101317ca54c3Smrg
101417ca54c3Smrg		tmp = temporary alpha picture
101517ca54c3Smrg		Combine (Zero, tmp, tmp, None)
101617ca54c3Smrg		for each glyph
101717ca54c3Smrg			Combine (Add, tmp, glyph, None)
101817ca54c3Smrg		Combine (op, dst, source, tmp)
101917ca54c3Smrg
102017ca54c3Smrg	When mask-format is None, glyphs are rendered in the order specified
102117ca54c3Smrg	directly to the destination:
102217ca54c3Smrg
102317ca54c3Smrg		for each glyph
102417ca54c3Smrg			Combine (op, dst, source, glyph)
102517ca54c3Smrg
102617ca54c3SmrgCreateCursor
102717ca54c3Smrg
102817ca54c3Smrg	cid:		CURSOR
102917ca54c3Smrg	source:		PICTURE
103017ca54c3Smrg	x, y:		CARD16
103117ca54c3Smrg
103217ca54c3Smrg	Errors:		Alloc, IDChoice, Match, Picture
103317ca54c3Smrg
103417ca54c3Smrg	This request creates a cursor and associates identifier cid with it.
103517ca54c3Smrg	The x and y coordinates define the hotspot relative to the source's
103617ca54c3Smrg	origin and must be a point within the source (or a Match error
103717ca54c3Smrg	results).  The resulting picture will nominally be drawn to the
103817ca54c3Smrg	screen with PictOpOver. 
103917ca54c3Smrg	
104017ca54c3Smrg	The components of the cursor may be transformed arbitrarily to meet
104117ca54c3Smrg	display limitations.  In particular, if the display supports only
104217ca54c3Smrg	two colors cursors without translucency, the cursor will be
104317ca54c3Smrg	transformed so that areas less than .5 alpha will be transparent,
104417ca54c3Smrg	else opaque, and areas darker than 50% gray will be black else white.
104517ca54c3Smrg
104617ca54c3Smrg	The source picture can be freed immediately if no further explicit
104717ca54c3Smrg	references to it are to be made.
104817ca54c3Smrg
104917ca54c3Smrg	Subsequent drawing in the source has an undefined effect on the
105017ca54c3Smrg	cursor.  The server might or might not make a copy of the picture.
105117ca54c3Smrg
105217ca54c3SmrgCreateAnimCursor
105317ca54c3Smrg	cid:		CURSOR
105417ca54c3Smrg	cursors:	LISTofANIMCURSORELT
105517ca54c3Smrg
105617ca54c3Smrg	Errors:		Alloc, IDChoice, Cursor
105717ca54c3Smrg
105817ca54c3Smrg	This request creates a cursor and associates identifier cid with it.
105917ca54c3Smrg	When active, the cursor image on the screen will cycle through
106017ca54c3Smrg	'cursors', showing each cursor in the element for the number of
106117ca54c3Smrg	milliseconds indicated by the 'delay' member of that element.
106217ca54c3Smrg
106317ca54c3SmrgAddTraps
106417ca54c3Smrg	picture:	PICTURE
106517ca54c3Smrg	off-x, off-y:	INT16
106617ca54c3Smrg	trapezoids:	LISTofTRAP
106717ca54c3Smrg
106817ca54c3Smrg	Errors:		Match
106917ca54c3Smrg
107017ca54c3Smrg	Each trap is PictOpAdd'ed to 'picture'.  'off-x', 'off-y'
107117ca54c3Smrg	are added to each coordinate.
107217ca54c3Smrg
107317ca54c3Smrg	'picture' must be an alpha-only picture else a 'Match' error is
107417ca54c3Smrg	returned.
107517ca54c3Smrg	
107617ca54c3SmrgCreateSolidFill
107717ca54c3Smrg	pid: 		PICTURE
107817ca54c3Smrg	color:		COLOR	
107917ca54c3Smrg
108017ca54c3Smrg	Creates a Source picture that represents a solid fill with
108117ca54c3Smrg	the specified color. 
108217ca54c3Smrg
108317ca54c3SmrgCreateLinearGradient
108417ca54c3Smrg	pid:		PICTURE
108517ca54c3Smrg	p1, p2:		POINTFIX
108617ca54c3Smrg	nstops:		CARD32
108717ca54c3Smrg	stops:		LISTofFIXED
108817ca54c3Smrg	stop_colors:	LISTofCOLOR
108917ca54c3Smrg
109017ca54c3Smrg	Errors:		Alloc, Value
109117ca54c3Smrg
109217ca54c3Smrg	Creates a source picture representing a linear Gradient. The gradients
109317ca54c3Smrg	bounds are defined by the two end points p1 and p2. 
109417ca54c3Smrg
109517ca54c3Smrg	The gradient has nstops stop points between 0 and 1, each
109617ca54c3Smrg	having a stop color defined in stop_colors.
109717ca54c3Smrg
109817ca54c3Smrg	The array of stops has to contain values between 0 and 1 (inclusive) and
109917ca54c3Smrg	has to be ordered in increasing size or a Value error is generated. If 
110017ca54c3Smrg	p1 == p2 a Value error is generated.
110117ca54c3Smrg
110217ca54c3Smrg	The colors are non premultiplied.
110317ca54c3Smrg
110417ca54c3SmrgCreateRadialGradient
110517ca54c3Smrg	pid:		PICTURE
110617ca54c3Smrg	inner_center:	POINTFIX
110717ca54c3Smrg	outer_center:	POINTFIX
110817ca54c3Smrg	inner_radius:	FIXED
110917ca54c3Smrg	outer_radius:	FIXED
111017ca54c3Smrg	nstops:		CARD32
111117ca54c3Smrg	stops:		LISTofFIXED
111217ca54c3Smrg	stop_colors:	LISTofCOLOR
111317ca54c3Smrg
111417ca54c3Smrg	Errors:		Alloc, Value
111517ca54c3Smrg
111617ca54c3Smrg	Creates a source picture representing a radial Gradient. The
111717ca54c3Smrg	gradients bounds are defined by a center point, a focal point and a
111817ca54c3Smrg	radius around the center.
111917ca54c3Smrg
112017ca54c3Smrg	The gradient has nstops stop points between 0 and 1, each
112117ca54c3Smrg	having a stop color defined in stop_colors.
112217ca54c3Smrg
112317ca54c3Smrg	The array of stops has to contain values between 0 and 1 (inclusive) and
112417ca54c3Smrg	has to be ordered in increasing size or a Value error is generated. The inner
112517ca54c3Smrg	circle has to be completely contained inside the outer one or a Value error is 
112617ca54c3Smrg	generated. 
112717ca54c3Smrg
112817ca54c3Smrg	The colors are non premultiplied.
112917ca54c3Smrg
113017ca54c3SmrgCreateConicalGradient
113117ca54c3Smrg	pid:		PICTURE
113217ca54c3Smrg	center:		POINTFIX
113317ca54c3Smrg	angle:		FIXED
113417ca54c3Smrg	nstops:		CARD32
113517ca54c3Smrg	stops:		LISTofFIXED
113617ca54c3Smrg	stop_colors:	LISTofCOLOR
113717ca54c3Smrg
113817ca54c3Smrg	Errors:		Alloc, Value
113917ca54c3Smrg
114017ca54c3Smrg	Creates a source picture representing a conical Gradient. The
114117ca54c3Smrg	gradient is defined by a center point and an angle (in degrees).
114217ca54c3Smrg
114317ca54c3Smrg	The gradient has nstops stop points between 0 and 1, each
114417ca54c3Smrg	having a stop color defined in stop_colors.
114517ca54c3Smrg
114617ca54c3Smrg	The array of stops has to contain values between 0 and 1 (inclusive) and
114717ca54c3Smrg	has to be ordered in increasing size or a Value error is generated.
114817ca54c3Smrg
114917ca54c3Smrg	The colors are non premultiplied.
115017ca54c3Smrg
115117ca54c3Smrg	
115217ca54c3Smrg15. Extension Versioning
115317ca54c3Smrg
115417ca54c3SmrgThe Render extension was developed in parallel with the implementation to
115517ca54c3Smrgensure the feasibility of various portions of the design.  As portions of
115617ca54c3Smrgthe extension are implemented, the version number of the extension has
115717ca54c3Smrgchanged to reflect the portions of the standard provided.  This document
115817ca54c3Smrgdescribes the intent for version 1.0 of the specification, the partial
115917ca54c3Smrgimplementations have version numbers less than that.  Here's a list of
116017ca54c3Smrgwhat each version before 1.0 implemented:
116117ca54c3Smrg
116217ca54c3Smrg	0.0:	
116317ca54c3Smrg		No disjoint/conjoint operators
116417ca54c3Smrg		No component alpha
116517ca54c3Smrg		Composite
116617ca54c3Smrg		CreateGlyphSet
116717ca54c3Smrg		FreeGlyphSet
116817ca54c3Smrg		AddGlyphs
116917ca54c3Smrg		CompositeGlyphs
117017ca54c3Smrg
117117ca54c3Smrg	0.1:
117217ca54c3Smrg		Component alpha
117317ca54c3Smrg		FillRectangles
117417ca54c3Smrg
117517ca54c3Smrg	0.2:
117617ca54c3Smrg		Disjoint/Conjoint operators
117717ca54c3Smrg
117817ca54c3Smrg	0.3:
117917ca54c3Smrg		FreeGlyphs
118017ca54c3Smrg
118117ca54c3Smrg	0.4:
118217ca54c3Smrg		Trapezoids
118317ca54c3Smrg		Triangles
118417ca54c3Smrg		TriStrip
118517ca54c3Smrg		TriFan
118617ca54c3Smrg
118717ca54c3Smrg	0.5:
118817ca54c3Smrg		CreateCursor
118917ca54c3Smrg
119017ca54c3Smrg	0.6:
119117ca54c3Smrg		SetPictureTransform
119217ca54c3Smrg		QueryFilters
119317ca54c3Smrg		SetPictureFilter
119417ca54c3Smrg		subpixels member of QueryPictFormats
119517ca54c3Smrg
119617ca54c3Smrg	0.7:
119717ca54c3Smrg		QueryPictIndexValues
119817ca54c3Smrg	0.8:
119917ca54c3Smrg		CreateAnimCursor
120017ca54c3Smrg	0.9:
120117ca54c3Smrg		AddTrapezoids
120217ca54c3Smrg
120317ca54c3Smrg	0.10:	
120417ca54c3Smrg		CreateSolidFill
120517ca54c3Smrg		CreateLinearGradient
120617ca54c3Smrg		CreateRadialGradient
120717ca54c3Smrg		CreateConicalGradient
120817ca54c3Smrg
120917ca54c3Smrg		The repeat picture attribute now supports Pad and
121017ca54c3Smrg		Reflect, older versions only supported None and Normal.
121117ca54c3Smrg
121217ca54c3Smrg	0.11:
121317ca54c3Smrg		Blend mode operators
121417ca54c3Smrg
1215