render pro to

Upload: caio-loureiro

Post on 03-Jun-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Render Pro To

    1/21

    The X Rendering Extension Version 0.11 2009-07-15 Keith Packard [email protected]

    1. Introduction

    The X Rendering Extension (Render) introduces digital image composition asthe foundation of a new rendering model within the X Window System.Rendering geometric figures is accomplished by client-side tessellation intoeither triangles or trapezoids. Text is drawn by loading glyphs into theserver and rendering sets of them.

    2. Acknowledgments

    This extension was the work of many people, in particular:

    + Thomas Porter and Tom Duff for their formal descriptionof image compositing.

    + Rob Pike and Russ Cox who designed the Plan 9 window system fromwhich the compositing model was lifted.

    + Juliusz Chroboczek and Raph Levien whose proposal for client-sideglyph management eliminated font handling from the X server.

    + Jon Leech, Brad Grantham and Allen Akin for patiently explaininghow OpenGL works.

    + Carl Worth for providing the sample implementation of trapezoid rendering and showing how broken the spec was

    + Sam Pottle and Jamey Sharp for helping demonstrate the correctness of the trapezoid specification.

    + Owen Taylor for helping specify projective transformations

    3. Rendering Model

    Render provides a single rendering operation which can be used in a variety ofways to generate images:

    dest = (source IN mask) OP dest

    Where 'IN' is the Porter/Duff operator of that name and 'OP' is any of thelist of compositing operators described below, among which can be found allof the Porter/Duff binary operators.

    To use this operator several additional values are required:

    + The destination rectangle. This is a subset of the destination within which the rendering is performed.

    + The source location. This identifies the coordinate in the source aligned with the upper left corner of the

    destination rectangle.

    + The mask location. This identifies the coordinate in the mask aligned with the upper left corner of the

  • 8/12/2019 Render Pro To

    2/21

    destination rectangle.

    + A clip list. This limits the rendering to the intersection of the destination rectangle with this clip list.

    + The OP to use

    + Whether the source should be repeated to cover the destination rectangle, extended with a constant pixel value or extended by

    using the nearest available source pixel.

    + Whether the mask should be repeated to cover the destination rectangle, extended with a constant pixel value or extended by

    using the nearest available mask pixel.

    + Whether the mask has a single alpha value for all four channels or whether each mask channel should affect the associated source/dest

    channels.

    + Whether the source should be reshaped with a projective transformation, and if so, what filter to apply while

    resampling the data.

    + Whether the mask should be reshaped with a projective

    transformation, and if so, what filter to apply whileresampling the data.

    These parameters are variously attached to the operands or included in eachrendering request.

    4. Data types

    The core protocol rendering system uses a pixel model and applies color onlyin the final generation of the video signal. A compositing model operateson colors, not pixel values so a new datatype is needed to interpret data ascolor instead of just bits.

    The "PictFormat" object holds information needed to translate pixel valuesinto red, green, blue and alpha channels. The server has a list of pictureformats corresponding to the various visuals on the screen. There are twoclasses of formats, Indexed and Direct. Indexed PictFormats hold a list ofpixel values and RGBA values while Direct PictFormats hold bit masks for eachof R, G, B and A.

    The "Picture" object contains a Drawable, a PictFormat and somerendering state. More than one Picture can refer to the same Drawable.

    5. Errors

    Errors are sent using core X error reports.

    PictFormatA value for a PICTFORMAT argument does not name a defined PICTFORMAT.

    PictureA value for a PICTURE argument does not name a defined PICTURE.

    PictOpA value for a PICTOP argument does not name a defined PICTOP.

  • 8/12/2019 Render Pro To

    3/21

    GlyphSetA value for a GLYPHSET argument does not name a defined GLYPHSET.

    GlyphA value for a GLYPH argument does not name a defined GLYPH in theglyphset.

    6. Protocol Types

    PICTURE 32-bit value (top three bits guaranteed to be zero)PICTFORMAT 32-bit value (top three bits guaranteed to be zero)PICTTYPE { Indexed, Direct }PICTOP { Clear, Src, Dst, Over, OverReverse, In, InReverse,

    Out, OutReverse, Atop, AtopReverse, Xor, Add, Saturate, DisjointClear, DisjointSrc, DisjointDst, DisjointOver, DisjointOverReverse, DisjointIn, DisjointInReverse, DisjointOut, DisjointOutReverse, DisjointAtop, DisjointAtopReverse, DisjointXor, ConjointClear, ConjointSrc, ConjointDst, ConjointOver, ConjointOverReverse, ConjointIn, ConjointInReverse, ConjointOut, ConjointOutReverse, ConjointAtop, ConjointAtopReverse, ConjointXor, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion,

    HSLHue, HSLSaturation, HSLColor, HSLLuminosity}SUBPIXEL { Unknown, HorizontalRGB, HorizontalBGR,

    VerticalRGB, VerticalBGR, None}

    COLOR [red, green, blue, alpha: CARD16

    ]CHANNELMASK [

    shift, mask: CARD16]

    DIRECTFORMAT [red, green, blue, alpha: CHANNELMASK

    ]INDEXVALUE [pixel: Pixel;red, green, blue, alpha: CARD16

    ]PICTFORMINFO [

    id: PICTFORMATtype: PICTTYPEdepth: CARD8direct: DIRECTFORMATcolormap: COLORMAP or None

    ]

    PICTVISUAL [visual: VISUALID or Noneformat: PICTFORMAT

    ]

    PICTDEPTH [depth: CARD8visuals: LISTofPICTVISUAL

    ]

  • 8/12/2019 Render Pro To

    4/21

    PICTSCREEN LISTofPICTDEPTH

    FIXED 32-bit value (top 16 are integer portion, bottom 16 are fraction)TRANSFORM [

    p11, p12, p13: FIXEDp21, p22, p23: FIXEDp31, p32, p33: FIXED

    ]POINTFIX [

    x, y: FIXED]

    POLYEDGE { Sharp, Smooth }POLYMODE { Precise, Imprecise }REPEAT { None, Regular, Pad, Reflect }COLORPOINT [

    point: POINTFIXcolor: COLOR

    ]SPANFIX [

    left, right, y: FIXED]

    COLORSPANFIX [left, right, y: FIXED

    left_color: COLORright_color: COLORQUAD [

    p1, p2, p3, p4: POINTFIX]

    TRIANGLE [p1, p2, p3: POINTFIX

    ]LINEFIX [

    p1, p2: POINTFIX]

    TRAP [top, bottom: SPANFIX

    ]TRAPEZOID [top, bottom: FIXEDleft, right: LINEFIX

    ](TRAPEZOID is deprecated)GLYPHSET 32-bit value (top three bits guaranteed to be zero)GLYPH 32-bit valueGLYPHINFO [

    width, height: CARD16x, y: INT16off-x, off-y: INT16

    ]

    PICTGLYPH [info: GLYPHINFOx, y: INT16

    ]GLYPHABLE GLYPHSET or FONTABLEGLYPHELT8 [

    dx, dy: INT16glyphs: LISTofCARD8

    ]GLYPHITEM8 GLYPHELT8 or GLYPHABLE

  • 8/12/2019 Render Pro To

    5/21

    GLYPHELT16 [dx, dy: INT16glyphs: LISTofCARD16

    ]GLYPHITEM16 GLYPHELT16 or GLYPHABLEGLYPHELT32 [

    dx, dy: INT16glyphs: LISTofCARD32

    ]GLYPHITEM32 GLYPHELT32 or GLYPHABLE

    ANIMCURSORELT [cursor: CURSORdelay: CARD32

    ]7. Standard PictFormats

    The server must support a Direct PictFormat with 8 bits each of red, green,blue and alpha as well as a Direct PictFormat with 8 bits of red, green andblue and 0 bits of alpha. The server must also support Direct PictFormatswith 1, 4 and 8 bits of alpha and 0 bits of r, g and b.

    Pixel component values lie in the close range [0,1]. These values areencoded in a varying number of bits. Values are encoded in a straight

    forward manner. For a component encoded in m bits, a binary encoding bis equal to a component value of b/(2^m-1).

    A Direct PictFormat with zero bits of alpha component is declared to havealpha == 1 everywhere. A Direct PictFormat with zero bits of red, green andblue is declared to have red, green, blue == 0 everywhere. If any of red,green or blue components are of zero size, all are of zero size. DirectPictFormats never have colormaps and are therefore screen independent.

    Indexed PictFormats never have alpha channels and the direct component is allzeros. Indexed PictFormats always have a colormap in which the specifiedcolors are allocated read-only and are therefore screen dependent. Drawingto in Indexed Picture uses only pixel values listed by QueryPictIndexValues.

    Reading from an Indexed Picture uses red, green and blue values from thecolormap and alpha values from those listed by QueryPictIndexValues. Pixelvalues not present in QueryPictIndexValues are given alpha values of 1.

    8. Compositing Operators

    For each pixel, the four channels of the image are computed with:

    C = Ca * Fa + Cb * Fb

    where C, Ca, Cb are the values of the respective channels and Fa and Fbcome from the following table:

    PictOp Fa Fb--------------------------------------------------Clear 0 0Src 1 0Dst 0 1Over 1 1-AaOverReverse 1-Ab 1In Ab 0InReverse 0 AaOut 1-Ab 0

  • 8/12/2019 Render Pro To

    6/21

    OutReverse 0 1-AaAtop Ab 1-AaAtopReverse 1-Ab AaXor 1-Ab 1-AaAdd 1 1Saturate min(1,(1-Ab)/Aa) 1DisjointClear 0 0DisjointSrc 1 0DisjointDst 0 1DisjointOver 1 min(1,(1-Aa)/Ab)DisjointOverReverse min(1,(1-Ab)/Aa) 1DisjointIn max(1-(1-Ab)/Aa,0) 0DisjointInReverse 0 max(1-(1-Aa)/Ab,0)DisjointOut min(1,(1-Ab)/Aa) 0DisjointOutReverse 0 min(1,(1-Aa)/Ab)DisjointAtop max(1-(1-Ab)/Aa,0) min(1,(1-Aa)/Ab)DisjointAtopReverse min(1,(1-Ab)/Aa) max(1-(1-Aa)/Ab,0)DisjointXor min(1,(1-Ab)/Aa) min(1,(1-Aa)/Ab)ConjointClear 0 0ConjointSrc 1 0ConjointDst 0 1ConjointOver 1 max(1-Aa/Ab,0)ConjointOverReverse max(1-Ab/Aa,0) 1ConjointIn min(1,Ab/Aa) 0

    ConjointInReverse 0 min(Aa/Ab,1)ConjointOut max(1-Ab/Aa,0) 0ConjointOutReverse 0 max(1-Aa/Ab,0)ConjointAtop min(1,Ab/Aa) max(1-Aa/Ab,0)ConjointAtopReverse max(1-Ab/Aa,0) min(1,Aa/Ab)ConjointXor max(1-Ab/Aa,0) max(1-Aa/Ab,0)

    Saturate and DisjointOverReverse are the same. They match OpenGLcompositing with FUNC_ADD, SRC_ALPHA_SATURATE, ONE, except that Render usespremultiplied alpha while Open GL uses non-premultiplied alpha.

    The result of any compositing operator is always limited to the range[0,1] for each component. Components whose value would be greater than 1

    are set to 1.

    For operations involving division, when the divisor is zero, define thequotient to be positive infinity. The result is always well definedbecause the division is surrounded with a max or min operator which willgive a finite result.

    When the mask contains separate alpha values for each channel, thealpha value resulting from the combination of that value with the sourcealpha channel is used in the final image composition.

    9. Source and Mask Transformations

    When fetching pixels from the source or mask pictures, Render provides fouroptions for pixel values which fall outside the drawable (this includespixels within a window geometry obscured by other windows).

    + None. Missing values are replaced with transparent.+ Pad. Replace missing pixels with the nearest available pixel. Where multiple pixels are equidistant, select

    those with smallest Y and then smallest X coordinates

  • 8/12/2019 Render Pro To

    7/21

    + Normal. Select the pixel which would appear were the drawable tiled to enclose the missing coordinate. If

    the tiling doesn't cover the coordinate, use theselected Constant or Nearest mode.

    * Reflect. Select the pixel which would appear were thedrawable tiled to enclose the missing coordinate in such away that tiles in even numbered columns are reflected in the Yaxis, and tiles in even numbered rows are reflected in the Xaxis. Tiles that in both an even numbered row and an evennumbered column are reflected in both axes.

    To construct the source and mask operands, the computed pixels values aretransformed through a homogeneous matrix, filtered and then used in thefundamental rendering operator described above. Each screen provides a listof supported filter names. There are a few required filters, and severalrequired filter alias which must map to one of the available filters.

    10. Polygon Rasterization

    Render provides only two kinds of polygons, trapezoids and triangles. Toimprove efficiency, several different wire encodings exist for each.

    All trapezoids must be convex. Rendering of concave trapezoids is unspecified

    except that the result must obey the clipping rules.

    CompositePolygons are rasterized by implicit generating an alpha mask and using thatin the general compositing operator along with a supplied source image:

    tmp = Rasterize (polygon)Composite (op, dst, src, tmp)

    When rasterized with Sharp edges, the mask is computed with a depth of 1 sothat all of the mask values are either 0 or 1.

    When rasterized with Smooth edges, the mask is generated by creating a square

    around each pixel coordinate and computing the amount of that square coveredby the polygon. This ignores sampling theory but it provides a precisedefinition which is close to the right answer. This value is truncated tothe alpha width in the fallback format before application of the compositingoperator.

    RasterizationAlpha values are generated by point sampling the coverage of a squaresurrounding the center of each pixel by the polygon.

    In Precise poly mode, the sample points are located in a regular grid. Whenalpha depth 'e' is even, the regular grid is 2**(e/2) + 1 samples wide and2**(e/2) -1 samples high. For odd alpha depth 'o', the sample grid is 2**o

    - 1 samples wide and 1 sample high. Note that odd alpha depth usuallyoccurs only at depth 1, so this misshapen sample grid has no ill effects.The sample grid is centered within the pixel and then each sample point isrounded down to a point on the sub-pixel coordinate grid.

    In Imprecise mode, the location of the sample points is not specified, butthe implementation must conform to the following constraints:

    + Abutting edges must match precisely. When specifying two polygonsabutting along a common edge, if that edge is specified with the

  • 8/12/2019 Render Pro To

    8/21

    same coordinates in each polygon then the sum of alpha values forpixels inside the union of the two polygons must be precisely one.

    + Translationally invariant. The pixelization of the polygon mustbe the same when either the polygon or the target drawableare translated by any whole number of pixels in any direction.

    + Sharp edges are honored. When the polygon is rasterized with Sharpedges, the implicit alpha mask will contain only 1 or 0 foreach pixel.

    + Order independent. Two identical polygons specified with verticesin different orders must generate identical results.

    11. Image Filtering

    When computing pixels from source and mask images, a filter may be appliedto the data. This is usually used with a non-identity transformationmatrix, but filtering may be applied with an identity transformation.

    Each filter is given a unique name encoded as an ISO Latin-1 string.Filters may be configured with a list of fixed point values; the number ofparameters and their interpretation is currently left to conventions passedoutside of the protocol. A set of standard filters are required to be

    provided:

    Filter Name Description

    nearest Nearest neighbor filteringbilinear Linear interpolation in two dimensions

    Additional names may be provided for any filter as aliases. A set ofstandard alias names are required to be mapped to a provided filter so thatapplications can use the alias names without checking for availability.

    Alias name Intended interpretation

    fast High performance, quality similar to Nearestgood Reasonable performance, quality similar to Bilinearbest Highest quality available, performance may not

    be suitable for interactive use

    Aliases must map directly to a non-aliased filter name.

    There is also a set of standard filters which are not required but may beprovided. If they are provided, using the standard name, they must matchthe definition specified here.

    Filter Name Description

    convolution MxN convolution filter. The values specifiedin SetPictureFilter are M, N and then M * Nfilter parameters. M and N must be integersrepresented as fixed point numbers.

    gaussian Gaussian blur. The value specified is a radiusin pixels (which can be fractional). A standardGaussian 2D convolution filter will be applied.

    binomial Binomial blur. An approximation of a Gaussianblur using binomial coefficients

  • 8/12/2019 Render Pro To

    9/21

    12. Glyph Rendering

    Glyphs are small alpha masks which can be stored in the X server andrendered by referring to them by name. A set of glyphs can be rendered in asingle request. Glyphs are positioned by subtracting the x, y elements ofthe GLYPHINFO from the requested rendering position. The next glyphrendering position is set to the current rendering position plus the off-xand off-y elements.

    Glyphs are stored in GlyphSets and are named within the GlyphSet withclient-specified 32-bit numbers.

    Glyphs can be stored in any PictFormat supported by the server. All glyphsin a GlyphSet are stored in the same format.

    13. Extension Initialization

    The client must negotiate the version of the extension before executingextension requests. Behavior of the server is undefined otherwise.

    QueryVersion

    client-major-version: CARD32client-minor-version: CARD32

    ->

    major-version: CARD32minor-version: CARD32

    The client sends the highest supported version to the server andthe server sends the highest version it supports, but no higher thanthe requested version. Major versions changes can introduceincompatibilities in existing functionality, minor versionchanges introduce only backward compatible changes. It isthe clients responsibility to ensure that the server supportsa version which is compatible with its expectations.

    QueryPictFormats

    ->

    fallback: PICTFORMATformats: LISTofPICTFORMINFOscreens: LISTofPICTSCREENsubpixels: LISTofSUBPIXEL

    Errors:

    The server responds with a list of supported PictFormats anda list of which PictFormat goes with each visual on each screen.Every PictFormat must match a supported depth, but not everyPictFormat need have a matching visual.

    The fallback format is used as an intermediate representationin cases where there is no ideal choice.

    The relationship between the red, green and blue elements makingup each pixel indexed by screen is returned in subpixels.

  • 8/12/2019 Render Pro To

    10/21

    This list is not present in servers advertising protocolversions earlier than 0.6. This list may be shorter thanthe number of screens, in which case the remaining screensare given sub pixel order Unknown.

    QueryPictIndexValues

    format: PICTFORMAT

    ->

    values: LISTofINDEXVALUE

    Errors:PictFormat, Match

    Returns the mapping from pixel values to RGBA values for thespecified Indexed PictFormat. If 'format' does not refer toan Indexed PictFormat a Match error is generated.

    QueryFilters

    drawable: DRAWABLE

    ->

    filters: LISTofSTRING8aliases: LISTofCARD16

    14. Extension Requests

    CreatePicture

    pid: PICTUREdrawable: DRAWABLEformat: PICTFORMAT

    value-mask: BITMASKvalue-list: LISTofVALUE

    Errors:Alloc, Drawable, IDChoice, Match, Pixmap, Picture,PictFormat, Value

    This request creates a Picture object associated with the specifieddrawable and assigns the identifier pid to it. Pixel data in theimage are interpreted according to 'format'. It is a Match errorto specify a format with a different depth than the drawable. Ifthe drawable is a Window then the Red, Green and Blue masks mustmatch those in the visual for the window else a Match error is

    generated.

    The value-mask and value-list specify attributes of the picture thatare to be explicitly initialized. The possible values are:

    repeat: REPEATalpha-map: PICTURE or Nonealpha-x-origin: INT16alpha-y-origin: INT16clip-x-origin: INT16

  • 8/12/2019 Render Pro To

    11/21

    clip-y-origin: INT16clip-mask: PIXMAP or Nonegraphics-exposures: BOOLsubwindow-mode: { ClipByChildren, IncludeInferiors }poly-edge: POLYEDGEpoly-mode: POLYMODEdither: ATOM or Nonecomponent-alpha: BOOL

    When used as a source or mask operand, Repeat indicates how thedrawable contents should be extented in both directions.

    The alpha channel of alpha-map is used in place of any alpha channelcontained within the drawable for all rendering operations. Thealpha-mask origin is interpreted relative to the origin of drawable.Rendering is additionally clipped by the geometry and clip mask ofalpha-map. Exposures to the window do not affect the contents ofalpha-map. Alpha-map must refer to a picture containing a Pixmap,not a Window (or a Match error results). If the alpha-map pictureitself already has an alpha-map, the result is undefined.

    The clip-mask restricts reads and writes to drawable. Only pixelswhere the clip-mask has bits set to 1 are read or written. Pixelsare not accessed outside the area covered by the clip-mask or where

    the clip-mask has bits set to 0. The clip-mask affects all graphicsrequests, including sources. The clip-mask origin is interpretedrelative to the origin of the picture. If a pixmap is specified asthe clip-mask, it must have depth 1 and have the same root as thedrawable (or a Match error results). If clip-mask is None, thenpixels are always drawn, regardless of the clip origin. Theclip-mask can also be set with the SetPictureClipRectangles request.Transformations, filters and repeat modes do not affect the clipmask.

    When a window is used as a destination, the subwindow_modedetermines what happens to pixels obscured by inferiorwindows. For ClipByChildren the window is clipped by inferiors

    and siblings. For IncludeInferior, the window is clipped bysiblings, but not by inferiors.

    When a window is used as source or mask, the subwindow_mode isignored. Pixels that are obscured by other windows, whethersiblings or inferiors, have undefined contents.

    The graphics-exposures flag is ignored. GraphicsExposure events arenever generated by this extension.

    Poly-edge and poly-mode control the rasterization of polygons asdescribed above.

    Dither is ignored.

    Component-alpha indicates whether each image component is intended asa separate alpha value when the picture is used as a mask operand.

    The default component values are

    Component Default-------------------------------repeat None

  • 8/12/2019 Render Pro To

    12/21

    clip-x-origin 0clip-y-origin 0clip-mask Nonesubwindow-mode ClipByChildrenpoly-edge Smoothpoly-mode Precisecomponent-alpha False

    ChangePicture

    pid: PICTUREvalue-mask: BITMASKvalue-list: LISTofVALUE

    Errors:Picture, Alloc, Pixmap, PictOp, Value

    The value-mask and value-list specify which attributes are to bechanged. The values and restrictions are the same as forCreatePicture.

    SetPictureClipRectangles

    picture: PICTURE

    clip-x-origin: INT16clip-y-origin: INT16rectangles: LISTofRECTANGLE

    Errors:Alloc, Picture

    This request changes clip-mask in picture to the specified list ofrectangles and sets the clip origin. Input and output will beclipped to remain contained within the rectangles. The clip originis interpreted relative to the origin of picture aftertransformations and repeats have been applied. The rectanglecoordinates are interpreted relative to the clip origin.

    The list of rectangles can be empty, which effectively disablesoutput. This is the opposite of passing None as the clip-mask inCreatePicture and ChangePicture.

    Note that output is clipped to the union of all of the rectanglesand that no particular ordering among the rectangles is required.

    SetPictureTransform

    picture: PICTUREtransform: TRANSFORM

    Errors:Alloc, Value, Picture

    This request changes the projective transformation used tomap coordinates when 'picture' is used as the source ormask in any compositing operation. The transformmaps from destination pixel geometry back to the source pixelgeometry.

    The matrix must be invertable, else a Value error is generated.

  • 8/12/2019 Render Pro To

    13/21

  • 8/12/2019 Render Pro To

    14/21

    FillRectangles

    op: PICTOPdst: PICTUREcolor: COLORrects: LISTofRECTANGLE

    This request combines color with the destination drawable in thearea specified by rects. Each rectangle is combined separately;overlapping areas will be rendered multiple times. The effect isequivalent to compositing with a repeating source picture filled withthe specified color.

    Trapezoids

    op: PICTOPsrc: PICTUREsrc-x, src-y: INT16dst: PICTUREmask-format: PICTFORMAT or Nonetraps: LISTofTRAPEZOID

    This request rasterizes the list of trapezoids.

    For each trap, the area between the left and right edges is filledfrom the top to the bottom. src-x and src-y register the pattern tothe floor of the top x and y coordinate of the left edge of thefirst trapezoid, they are adjusted for subsequent trapezoids so thatthe pattern remains globally aligned within the destination.

    When mask-format is not None, trapezoids are rendered in thefollowing way with the effective mask computed in mask-format:

    tmp = temporary alpha picture (in mask-format)Combine (Zero, tmp, tmp, None)for each trapezoid

    Combine (Add, tmp, trapezoid, None)

    Combine (op, dst, source, tmp)

    When mask-format is None, trapezoids are rendered in the orderspecified directly to the destination:

    for each trapezoidCombine (op, dst, source, trapezoid)

    (The Trapezoids request is deprecated)

    Triangles

    op: PICTOP

    src: PICTUREsrc-x, src-y: INT16dst: PICTUREmask-format: PICTFORMAT or Nonetriangles: LISTofTRIANGLE

    This request rasterizes the list of triangles in the order theyoccur in the list.

    When mask-format is not None, triangles are rendered in the

  • 8/12/2019 Render Pro To

    15/21

    following way with the effective mask computed in mask-format:

    tmp = temporary alpha picture (in mask-format)Combine (Zero, tmp, tmp, None)for each triangle

    Combine (Add, tmp, triangle, None)Combine (op, dst, source, tmp)

    When mask-format is None, triangles are rendered in the orderspecified directly to the destination:

    for each triangleCombine (op, dst, source, triangle)

    TriStrip

    op: PICTOPsrc: PICTUREsrc-x, src-y: INT16dst: PICTUREmask-format: PICTFORMAT or Nonepoints: LISTofPOINTFIX

    Triangles are formed by initially using the first three points and

    then by eliminating the first point and appending the next point inthe list. If fewer than three points are provided, this request doesnothing.

    When mask-format is not None, triangles are rendered in thefollowing way with the effective mask computed in mask-format:

    tmp = temporary alpha picture (in mask-format)Combine (Zero, tmp, tmp, None)for each triangle

    Combine (Add, tmp, triangle, None)Combine (op, dst, source, tmp)

    When mask-format is None, triangles are rendered in the orderspecified directly to the destination:

    for each triangleCombine (op, dst, source, triangle)

    TriFanop: PICTOPsrc: PICTUREsrc-x, src-y: INT16dst: PICTUREmask-format: PICTFORMAT or Nonepoints: LISTofPOINTFIX

    Triangles are formed by initially using the first three points andthen by eliminating the second point and appending the next pointint the list. If fewer than three points are provided, this requestdoes nothing.

    When mask-format is not None, triangles are rendered in thefollowing way with the effective mask computed in mask-format:

    tmp = temporary alpha picture (in mask-format)

  • 8/12/2019 Render Pro To

    16/21

    Combine (Zero, tmp, tmp, None)for each triangle

    Combine (Add, tmp, triangle, None)Combine (op, dst, source, tmp)

    When mask-format is None, triangles are rendered in the orderspecified directly to the destination:

    for each triangleCombine (op, dst, source, triangle)

    CreateGlyphSet

    gsid: GLYPHSETformat: PICTFORMAT

    Errors:Alloc, IDChoice, PictFormat, Match

    This request creates a container for glyphs. The glyphset andall contained glyphs are destroyed when gsid and any other namesfor the glyphset are freed. Format must be a Direct format, whenit contains RGB values, the glyphs are composited usingcomponent-alpha True, otherwise they are composited using

    component-alpha False.

    ReferenceGlyphSet

    gsid: GLYPHSETexisting: GLYPHSET

    Errors:Alloc, IDChoice, GlyphSet

    This request creates an additional name for the existing glyphset.The glyphset will not be freed until all references to it aredestroyed.

    FreeGlyphSet

    glyphset: GLYPHSET

    Errors:GlyphSet

    This request frees the name for the glyphset. When all names havebeen freed, the glyphset and all contained glyphs are freed.

    AddGlyphsglyphset: GLYPHSET

    glyphids: LISTofCARD32glyphs: LISTofGLYPHINFOdata: LISTofBYTE

    Errors:GlyphSet, Alloc

    This request adds glyphs to glyphset. The image for the glyphsare stored with each glyph in a separate Z-format image padded to a32-bit boundary. Existing glyphs with the same names are replaced.

  • 8/12/2019 Render Pro To

    17/21

    FreeGlyphs

    glyphset: GLYPHSETglyphs: LISTofGLYPH

    Errors:GlyphSet, Match

    This request removes glyphs from glyphset. Each glyph must existin glyphset (else a Match error results).

    CompositeGlyphs8CompositeGlyphs16CompositeGlyphs32

    op: PICTOPsrc: PICTUREdst: PICTUREmask-format: PICTFORMAT or Noneglyphset: GLYPHABLEsrc-x, src-y: INT16dst-x, dst-y: INT16glyphcmds: LISTofGLYPHITEM8 CompositeGlyphs8

    glyphcmds: LISTofGLYPHITEM16 CompositeGlyphs16glyphcmds: LISTofGLYPHITEM32 CompositeGlyphs32

    Errors:Picture, PictOp, PictFormat, GlyphSet, Glyph

    The dst-x and dst-y coordinates are relative to the drawable'sorigin and specify the baseline starting position (the initial glyphorigin). Each glyph item is processed in turn. A glyphset itemcauses the glyphset to be used for subsequent glyphs. Switchingamong glyphsets does not affect the next glyph origin. A glyphelement delta-x and delta-y specify additional changes in theposition along the x and y axes before the string is drawn; the

    deltas are always added to the glyph origin.

    All contained GLYPHSETs are always transmitted most significant bytefirst.

    If a GlyphSet error is generated for an item, the previous items mayhave been drawn.

    When mask-format is not None, glyphs are rendered in the followingway with the effective mask computed in mask-format:

    tmp = temporary alpha pictureCombine (Zero, tmp, tmp, None)

    for each glyphCombine (Add, tmp, glyph, None)

    Combine (op, dst, source, tmp)

    When mask-format is None, glyphs are rendered in the order specifieddirectly to the destination:

    for each glyphCombine (op, dst, source, glyph)

  • 8/12/2019 Render Pro To

    18/21

    CreateCursor

    cid: CURSORsource: PICTUREx, y: CARD16

    Errors: Alloc, IDChoice, Match, Picture

    This request creates a cursor and associates identifier cid with it.The x and y coordinates define the hotspot relative to the source'sorigin and must be a point within the source (or a Match errorresults). The resulting picture will nominally be drawn to thescreen with PictOpOver.

    The components of the cursor may be transformed arbitrarily to meetdisplay limitations. In particular, if the display supports onlytwo colors cursors without translucency, the cursor will betransformed so that areas less than .5 alpha will be transparent,else opaque, and areas darker than 50% gray will be black else white.

    The source picture can be freed immediately if no further explicitreferences to it are to be made.

    Subsequent drawing in the source has an undefined effect on the

    cursor. The server might or might not make a copy of the picture.

    CreateAnimCursorcid: CURSORcursors: LISTofANIMCURSORELT

    Errors: Alloc, IDChoice, Cursor

    This request creates a cursor and associates identifier cid with it.When active, the cursor image on the screen will cycle through'cursors', showing each cursor in the element for the number ofmilliseconds indicated by the 'delay' member of that element.

    AddTrapspicture: PICTUREoff-x, off-y: INT16trapezoids: LISTofTRAP

    Errors: Match

    Each trap is PictOpAdd'ed to 'picture'. 'off-x', 'off-y'are added to each coordinate.

    'picture' must be an alpha-only picture else a 'Match' error isreturned.

    CreateSolidFillpid: PICTUREcolor: COLOR

    Creates a Source picture that represents a solid fill withthe specified color.

    CreateLinearGradientpid: PICTUREp1, p2: POINTFIX

  • 8/12/2019 Render Pro To

    19/21

    nstops: CARD32stops: LISTofFIXEDstop_colors: LISTofCOLOR

    Errors: Alloc, Value

    Creates a source picture representing a linear Gradient. The gradientsbounds are defined by the two end points p1 and p2.

    The gradient has nstops stop points between 0 and 1, eachhaving a stop color defined in stop_colors.

    The array of stops has to contain values between 0 and 1 (inclusive) andhas to be ordered in increasing size or a Value error is generated. Ifp1 == p2 a Value error is generated.

    The colors are non premultiplied.

    CreateRadialGradientpid: PICTUREinner_center: POINTFIXouter_center: POINTFIXinner_radius: FIXEDouter_radius: FIXED

    nstops: CARD32stops: LISTofFIXEDstop_colors: LISTofCOLOR

    Errors: Alloc, Value

    Creates a source picture representing a radial Gradient. Thegradients bounds are defined by a center point, a focal point and aradius around the center.

    The gradient has nstops stop points between 0 and 1, eachhaving a stop color defined in stop_colors.

    The array of stops has to contain values between 0 and 1 (inclusive) andhas to be ordered in increasing size or a Value error is generated. Theinner

    circle has to be completely contained inside the outer one or a Value error is

    generated.

    The colors are non premultiplied.

    CreateConicalGradientpid: PICTUREcenter: POINTFIXangle: FIXED

    nstops: CARD32stops: LISTofFIXEDstop_colors: LISTofCOLOR

    Errors: Alloc, Value

    Creates a source picture representing a conical Gradient. Thegradient is defined by a center point and an angle (in degrees).

    The gradient has nstops stop points between 0 and 1, each

  • 8/12/2019 Render Pro To

    20/21

    having a stop color defined in stop_colors.

    The array of stops has to contain values between 0 and 1 (inclusive) andhas to be ordered in increasing size or a Value error is generated.

    The colors are non premultiplied.

    15. Extension Versioning

    The Render extension was developed in parallel with the implementation toensure the feasibility of various portions of the design. As portions ofthe extension are implemented, the version number of the extension haschanged to reflect the portions of the standard provided. This documentdescribes the intent for version 1.0 of the specification, the partialimplementations have version numbers less than that. Here's a list ofwhat each version before 1.0 implemented:

    0.0:No disjoint/conjoint operatorsNo component alphaCompositeCreateGlyphSetFreeGlyphSet

    AddGlyphsCompositeGlyphs

    0.1:Component alphaFillRectangles

    0.2:Disjoint/Conjoint operators

    0.3:FreeGlyphs

    0.4: TrapezoidsTrianglesTriStripTriFan

    0.5:CreateCursor

    0.6:SetPictureTransformQueryFiltersSetPictureFilter

    subpixels member of QueryPictFormats

    0.7:QueryPictIndexValues

    0.8:CreateAnimCursor

    0.9:AddTrapezoids

    0.10:

  • 8/12/2019 Render Pro To

    21/21

    CreateSolidFillCreateLinearGradientCreateRadialGradientCreateConicalGradient

    The repeat picture attribute now supports Pad andReflect, older versions only supported None and Normal.

    0.11:Blend mode operators