1706f2543Smrg 2706f2543Smrg 3706f2543Smrg XAA.HOWTO 4706f2543Smrg 5706f2543Smrg This file describes how to add basic XAA support to a chipset driver. 6706f2543Smrg 7706f2543Smrg0) What is XAA 8706f2543Smrg1) XAA Initialization and Shutdown 9706f2543Smrg2) The Primitives 10706f2543Smrg 2.0 Generic Flags 11706f2543Smrg 2.1 Screen to Screen Copies 12706f2543Smrg 2.2 Solid Fills 13706f2543Smrg 2.3 Solid Lines 14706f2543Smrg 2.4 Dashed Lines 15706f2543Smrg 2.5 Color Expand Fills 16706f2543Smrg 2.5.1 Screen to Screen Color Expansion 17706f2543Smrg 2.5.2 CPU to Screen Color Expansion 18706f2543Smrg 2.5.2.1 The Direct Method 19706f2543Smrg 2.5.2.2 The Indirect Method 20706f2543Smrg 2.6 8x8 Mono Pattern Fills 21706f2543Smrg 2.7 8x8 Color Pattern Fills 22706f2543Smrg 2.8 Image Writes 23706f2543Smrg 2.8.1 The Direct Method 24706f2543Smrg 2.8.2 The Indirect Method 25706f2543Smrg 2.9 Clipping 26706f2543Smrg3) The Pixmap Cache 27706f2543Smrg4) Offscreen Pixmaps 28706f2543Smrg 29706f2543Smrg/********************************************************************/ 30706f2543Smrg 31706f2543Smrg0) WHAT IS XAA 32706f2543Smrg 33706f2543Smrg XAA (the XFree86 Acceleration Architecture) is a device dependent 34706f2543Smrglayer that encapsulates the unaccelerated framebuffer rendering layer, 35706f2543Smrgintercepting rendering commands sent to it from higher levels of the 36706f2543Smrgserver. For rendering tasks where hardware acceleration is not 37706f2543Smrgpossible, XAA allows the requests to proceed to the software rendering 38706f2543Smrgcode. Otherwise, XAA breaks the sometimes complicated X primitives 39706f2543Smrginto simpler primitives more suitable for hardware acceleration and 40706f2543Smrgwill use accelerated functions exported by the chipset driver to 41706f2543Smrgrender these. 42706f2543Smrg 43706f2543Smrg XAA provides a simple, easy to use driver interface that allows 44706f2543Smrgthe driver to communicate its acceleration capabilities and restrictions 45706f2543Smrgback to XAA. XAA will use the information provided by the driver 46706f2543Smrgto determine whether or not acceleration will be possible for a 47706f2543Smrgparticular X primitive. 48706f2543Smrg 49706f2543Smrg 50706f2543Smrg 51706f2543Smrg1) XAA INITIALIZATION AND SHUTDOWN 52706f2543Smrg 53706f2543Smrg All relevant prototypes and defines are in xaa.h. 54706f2543Smrg 55706f2543Smrg To Initialize the XAA layer, the driver should allocate an XAAInfoRec 56706f2543Smrgvia XAACreateInfoRec(), fill it out as described in this document 57706f2543Smrgand pass it to XAAInit(). XAAInit() must be called _after_ the 58706f2543Smrgframebuffer initialization (usually cfb?ScreenInit or similar) since 59706f2543Smrgit is "wrapping" that layer. XAAInit() should be called _before_ the 60706f2543Smrgcursor initialization (usually miDCInitialize) since the cursor 61706f2543Smrglayer needs to "wrap" all the rendering code including XAA. 62706f2543Smrg 63706f2543Smrg When shutting down, the driver should free the XAAInfoRec 64706f2543Smrgstructure in its CloseScreen function via XAADestroyInfoRec(). 65706f2543SmrgThe prototypes for the functions mentioned above are as follows: 66706f2543Smrg 67706f2543Smrg XAAInfoRecPtr XAACreateInfoRec(void); 68706f2543Smrg Bool XAAInit(ScreenPtr, XAAInfoRecPtr); 69706f2543Smrg void XAADestroyInfoRec(XAAInfoRec); 70706f2543Smrg 71706f2543Smrg The driver informs XAA of it's acceleration capablities by 72706f2543Smrgfilling out an XAAInfoRec structure and passing it to XAAInit(). 73706f2543SmrgThe XAAInfoRec structure contains many fields, most of which are 74706f2543Smrgfunction pointers and flags. Each primitive will typically have 75706f2543Smrgtwo functions and a set of flags associated with it, but it may 76706f2543Smrghave more. These two functions are the "SetupFor" and "Subsequent" 77706f2543Smrgfunctions. The "SetupFor" function tells the driver that the 78706f2543Smrghardware should be initialized for a particular type of graphics 79706f2543Smrgoperation. After the "SetupFor" function, one or more calls to the 80706f2543Smrg"Subsequent" function will be made to indicate that an instance 81706f2543Smrgof the particular primitive should be rendered by the hardware. 82706f2543SmrgThe details of each instance (width, height, etc...) are given 83706f2543Smrgwith each "Subsequent" function. The set of flags associated 84706f2543Smrgwith each primitive lets the driver tell XAA what its hardware 85706f2543Smrglimitations are (eg. It doesn't support a planemask, it can only 86706f2543Smrgdo one of the raster-ops, etc...). 87706f2543Smrg 88706f2543Smrg Of the XAAInfoRec fields, one is required. This is the 89706f2543SmrgSync function. XAA initialization will fail if this function 90706f2543Smrgis not provided. 91706f2543Smrg 92706f2543Smrgvoid Sync(ScrnInfoPtr pScrn) /* Required */ 93706f2543Smrg 94706f2543Smrg Sync will be called when XAA needs to be certain that all 95706f2543Smrg graphics coprocessor operations are finished, such as when 96706f2543Smrg the framebuffer must be written to or read from directly 97706f2543Smrg and it must be certain that the accelerator will not be 98706f2543Smrg overwriting the area of interest. 99706f2543Smrg 100706f2543Smrg One needs to make certain that the Sync function not only 101706f2543Smrg waits for the accelerator fifo to empty, but that it waits for 102706f2543Smrg the rendering of that last operation to complete. 103706f2543Smrg 104706f2543Smrg It is guaranteed that no direct framebuffer access will 105706f2543Smrg occur after a "SetupFor" or "Subsequent" function without 106706f2543Smrg the Sync function being called first. 107706f2543Smrg 108706f2543Smrg 109706f2543Smrg 110706f2543Smrg2) THE PRIMITIVES 111706f2543Smrg 112706f2543Smrg2.0 Generic Flags 113706f2543Smrg 114706f2543Smrg Each primitive type has a set of flags associated with it which 115706f2543Smrgallow the driver to tell XAA what the hardware limitations are. 116706f2543SmrgThe common ones are as follows: 117706f2543Smrg 118706f2543Smrg/* Foreground, Background, rop and planemask restrictions */ 119706f2543Smrg 120706f2543Smrg GXCOPY_ONLY 121706f2543Smrg 122706f2543Smrg This indicates that the accelerator only supports GXcopy 123706f2543Smrg for the particular primitive. 124706f2543Smrg 125706f2543Smrg ROP_NEEDS_SOURCE 126706f2543Smrg 127706f2543Smrg This indicates that the accelerator doesn't supports a 128706f2543Smrg particular primitive with rops that don't involve the source. 129706f2543Smrg These rops are GXclear, GXnoop, GXinvert and GXset. If neither 130706f2543Smrg this flag nor GXCOPY_ONLY is defined, it is assumed that the 131706f2543Smrg accelerator supports all 16 raster operations (rops) for that 132706f2543Smrg primitive. 133706f2543Smrg 134706f2543Smrg NO_PLANEMASK 135706f2543Smrg 136706f2543Smrg This indicates that the accelerator does not support a hardware 137706f2543Smrg write planemask for the particular primitive. 138706f2543Smrg 139706f2543Smrg RGB_EQUAL 140706f2543Smrg 141706f2543Smrg This indicates that the particular primitive requires the red, 142706f2543Smrg green and blue bytes of the foreground color (and background color, 143706f2543Smrg if applicable) to be equal. This is useful for 24bpp when a graphics 144706f2543Smrg coprocessor is used in 8bpp mode, which is not uncommon in older 145706f2543Smrg hardware since some have no support for or only limited support for 146706f2543Smrg acceleration at 24bpp. This way, many operations will be accelerated 147706f2543Smrg for the common case of "grayscale" colors. This flag should only 148706f2543Smrg be used in 24bpp. 149706f2543Smrg 150706f2543Smrg In addition to the common ones listed above which are possible for 151706f2543Smrgnearly all primitives, each primitive may have its own flags specific 152706f2543Smrgto that primitive. If such flags exist they are documented in the 153706f2543Smrgdescriptions of those primitives below. 154706f2543Smrg 155706f2543Smrg 156706f2543Smrg 157706f2543Smrg 158706f2543Smrg2.1 Screen to Screen Copies 159706f2543Smrg 160706f2543Smrg The SetupFor and Subsequent ScreenToScreenCopy functions provide 161706f2543Smrg an interface for copying rectangular areas from video memory to 162706f2543Smrg video memory. To accelerate this primitive the driver should 163706f2543Smrg provide both the SetupFor and Subsequent functions and indicate 164706f2543Smrg the hardware restrictions via the ScreenToScreenCopyFlags. The 165706f2543Smrg NO_PLANEMASK, GXCOPY_ONLY and ROP_NEEDS_SOURCE flags as described 166706f2543Smrg in Section 2.0 are valid as well as the following: 167706f2543Smrg 168706f2543Smrg NO_TRANSPARENCY 169706f2543Smrg 170706f2543Smrg This indicates that the accelerator does not support skipping 171706f2543Smrg of color keyed pixels when copying from the source to the destination. 172706f2543Smrg 173706f2543Smrg TRANSPARENCY_GXCOPY_ONLY 174706f2543Smrg 175706f2543Smrg This indicates that the accelerator supports skipping of color keyed 176706f2543Smrg pixels only when the rop is GXcopy. 177706f2543Smrg 178706f2543Smrg ONLY_LEFT_TO_RIGHT_BITBLT 179706f2543Smrg 180706f2543Smrg This indicates that the hardware only accepts blitting when the 181706f2543Smrg x direction is positive. 182706f2543Smrg 183706f2543Smrg ONLY_TWO_BITBLT_DIRECTIONS 184706f2543Smrg 185706f2543Smrg This indicates that the hardware can only cope with blitting when 186706f2543Smrg the direction of x is the same as the direction in y. 187706f2543Smrg 188706f2543Smrg 189706f2543Smrgvoid SetupForScreenToScreenCopy( ScrnInfoPtr pScrn, 190706f2543Smrg int xdir, int ydir, 191706f2543Smrg int rop, 192706f2543Smrg unsigned int planemask, 193706f2543Smrg int trans_color ) 194706f2543Smrg 195706f2543Smrg When this is called, SubsequentScreenToScreenCopy will be called 196706f2543Smrg one or more times directly after. If ydir is 1, then the accelerator 197706f2543Smrg should copy starting from the top (minimum y) of the source and 198706f2543Smrg proceed downward. If ydir is -1, then the accelerator should copy 199706f2543Smrg starting from the bottom of the source (maximum y) and proceed 200706f2543Smrg upward. If xdir is 1, then the accelerator should copy each 201706f2543Smrg y scanline starting from the leftmost pixel of the source. If 202706f2543Smrg xdir is -1, it should start from the rightmost pixel. 203706f2543Smrg If trans_color is not -1 then trans_color indicates that the 204706f2543Smrg accelerator should not copy pixels with the color trans_color 205706f2543Smrg from the source to the destination, but should skip them. 206706f2543Smrg Trans_color is always -1 if the NO_TRANSPARENCY flag is set. 207706f2543Smrg 208706f2543Smrg 209706f2543Smrgvoid SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, 210706f2543Smrg int x1, int y1, 211706f2543Smrg int x2, int y2, 212706f2543Smrg int width, int height) 213706f2543Smrg 214706f2543Smrg Copy a rectangle "width" x "height" from the source (x1,y1) to the 215706f2543Smrg destination (x2,y2) using the parameters passed by the last 216706f2543Smrg SetupForScreenToScreenCopy call. (x1,y1) and (x2,y2) always denote 217706f2543Smrg the upper left hand corners of the source and destination regardless 218706f2543Smrg of which xdir and ydir values are given by SetupForScreenToScreenCopy. 219706f2543Smrg 220706f2543Smrg 221706f2543Smrg 222706f2543Smrg2.2 Solid Fills 223706f2543Smrg 224706f2543Smrg The SetupFor and Subsequent SolidFill(Rect/Trap) functions provide 225706f2543Smrg an interface for filling rectangular areas of the screen with a 226706f2543Smrg foreground color. To accelerate this primitive the driver should 227706f2543Smrg provide both the SetupForSolidFill and SubsequentSolidFillRect 228706f2543Smrg functions and indicate the hardware restrictions via the SolidFillFlags. 229706f2543Smrg The driver may optionally provide a SubsequentSolidFillTrap if 230706f2543Smrg it is capable of rendering the primitive correctly. 231706f2543Smrg The GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags 232706f2543Smrg as described in Section 2.0 are valid. 233706f2543Smrg 234706f2543Smrg 235706f2543Smrgvoid SetupForSolidFill(ScrnInfoPtr pScrn, 236706f2543Smrg int color, int rop, unsigned int planemask) 237706f2543Smrg 238706f2543Smrg SetupForSolidFill indicates that any combination of the following 239706f2543Smrg may follow it. 240706f2543Smrg 241706f2543Smrg SubsequentSolidFillRect 242706f2543Smrg SubsequentSolidFillTrap 243706f2543Smrg 244706f2543Smrg 245706f2543Smrg 246706f2543Smrgvoid SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h) 247706f2543Smrg 248706f2543Smrg Fill a rectangle of dimensions "w" by "h" with origin at (x,y) 249706f2543Smrg using the color, rop and planemask given by the last 250706f2543Smrg SetupForSolidFill call. 251706f2543Smrg 252706f2543Smrgvoid SubsequentSolidFillTrap(ScrnInfoPtr pScrn, int y, int h, 253706f2543Smrg int left, int dxL, int dyL, int eL, 254706f2543Smrg int right, int dxR, int dyR, int eR) 255706f2543Smrg 256706f2543Smrg These parameters describe a trapezoid via a version of 257706f2543Smrg Bresenham's parameters. "y" is the top line. "h" is the 258706f2543Smrg number of spans to be filled in the positive Y direction. 259706f2543Smrg "left" and "right" indicate the starting X values of the 260706f2543Smrg left and right edges. dy/dx describes the edge slope. 261706f2543Smrg These are not the deltas between the beginning and ending 262706f2543Smrg points on an edge. They merely describe the slope. "e" is 263706f2543Smrg the initial error term. It's the relationships between dx, 264706f2543Smrg dy and e that define the edge. 265706f2543Smrg If your engine does not do bresenham trapezoids or does 266706f2543Smrg not allow the programmer to specify the error term then 267706f2543Smrg you are not expected to be able to accelerate them. 268706f2543Smrg 269706f2543Smrg 270706f2543Smrg2.3 Solid Lines 271706f2543Smrg 272706f2543Smrg XAA provides an interface for drawing thin lines. In order to 273706f2543Smrg draw X lines correctly a high degree of accuracy is required. 274706f2543Smrg This usually limits line acceleration to hardware which has a 275706f2543Smrg Bresenham line engine, though depending on the algorithm used, 276706f2543Smrg other line engines may come close if they accept 16 bit line 277706f2543Smrg deltas. XAA has both a Bresenham line interface and a two-point 278706f2543Smrg line interface for drawing lines of arbitrary orientation. 279706f2543Smrg Additionally there is a SubsequentSolidHorVertLine which will 280706f2543Smrg be used for all horizontal and vertical lines. Horizontal and 281706f2543Smrg vertical lines are handled separately since hardware that doesn't 282706f2543Smrg have a line engine (or has one that is unusable due to precision 283706f2543Smrg problems) can usually draw these lines by some other method such 284706f2543Smrg as drawing them as thin rectangles. Even for hardware that can 285706f2543Smrg draw arbitrary lines via the Bresenham or two-point interfaces, 286706f2543Smrg the SubsequentSolidHorVertLine is used for horizontal and vertical 287706f2543Smrg lines since most hardware is able to render the horizontal lines 288706f2543Smrg and sometimes the vertical lines faster by other methods (Hint: 289706f2543Smrg try rendering horizontal lines as flattened rectangles). If you have 290706f2543Smrg not provided a SubsequentSolidHorVertLine but you have provided 291706f2543Smrg Bresenham or two-point lines, a SubsequentSolidHorVertLine function 292706f2543Smrg will be supplied for you. 293706f2543Smrg 294706f2543Smrg The flags field associated with Solid Lines is SolidLineFlags and 295706f2543Smrg the GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags as 296706f2543Smrg described in Section 2.0 are valid restrictions. 297706f2543Smrg 298706f2543Smrg Some line engines have line biases hardcoded to comply with 299706f2543Smrg Microsoft line biasing rules. A tell-tale sign of this is the 300706f2543Smrg hardware lines not matching the software lines in the zeroth and 301706f2543Smrg fourth octants. The driver can set the flag: 302706f2543Smrg 303706f2543Smrg MICROSOFT_ZERO_LINE_BIAS 304706f2543Smrg 305706f2543Smrg in the AccelInfoRec.Flags field to adjust the software lines to 306706f2543Smrg match the hardware lines. This is in the generic flags field 307706f2543Smrg rather than the SolidLineFlags since this flag applies to all 308706f2543Smrg software zero-width lines on the screen and not just the solid ones. 309706f2543Smrg 310706f2543Smrg 311706f2543Smrgvoid SetupForSolidLine(ScrnInfoPtr pScrn, 312706f2543Smrg int color, int rop, unsigned int planemask) 313706f2543Smrg 314706f2543Smrg SetupForSolidLine indicates that any combination of the following 315706f2543Smrg may follow it. 316706f2543Smrg 317706f2543Smrg SubsequentSolidBresenhamLine 318706f2543Smrg SubsequentSolidTwoPointLine 319706f2543Smrg SubsequentSolidHorVertLine 320706f2543Smrg 321706f2543Smrg 322706f2543Smrgvoid SubsequentSolidHorVertLine( ScrnInfoPtr pScrn, 323706f2543Smrg int x, int y, int len, int dir ) 324706f2543Smrg 325706f2543Smrg All vertical and horizontal solid thin lines are rendered with 326706f2543Smrg this function. The line starts at coordinate (x,y) and extends 327706f2543Smrg "len" pixels inclusive. In the direction indicated by "dir." 328706f2543Smrg The direction is either DEGREES_O or DEGREES_270. That is, it 329706f2543Smrg always extends to the right or down. 330706f2543Smrg 331706f2543Smrg 332706f2543Smrg 333706f2543Smrgvoid SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, 334706f2543Smrg int x1, int y1, int x2, int y2, int flags) 335706f2543Smrg 336706f2543Smrg Draw a line from (x1,y1) to (x2,y2). If the flags field contains 337706f2543Smrg the flag OMIT_LAST, the last pixel should not be drawn. Otherwise, 338706f2543Smrg the pixel at (x2,y2) should be drawn. 339706f2543Smrg 340706f2543Smrg If you use the TwoPoint line interface there is a good possibility 341706f2543Smrg that your line engine has hard-coded line biases that do not match 342706f2543Smrg the default X zero-width lines. If so, you may need to set the 343706f2543Smrg MICROSOFT_ZERO_LINE_BIAS flag described above. Note that since 344706f2543Smrg any vertex in the 16-bit signed coordinate system is valid, your 345706f2543Smrg line engine is expected to handle 16-bit values if you have hardware 346706f2543Smrg line clipping enabled. If your engine cannot handle 16-bit values, 347706f2543Smrg you should not use hardware line clipping. 348706f2543Smrg 349706f2543Smrg 350706f2543Smrgvoid SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, 351706f2543Smrg int x, int y, int major, int minor, int err, int len, int octant) 352706f2543Smrg 353706f2543Smrg "X" and "y" are the starting point of the line. "Major" and "minor" 354706f2543Smrg are the major and minor step constants. "Err" is the initial error 355706f2543Smrg term. "Len" is the number of pixels to be drawn (inclusive). "Octant" 356706f2543Smrg can be any combination of the following flags OR'd together: 357706f2543Smrg 358706f2543Smrg Y_MAJOR Y is the major axis (X otherwise) 359706f2543Smrg X_DECREASING The line is drawn from right to left 360706f2543Smrg Y_DECREASING The line is drawn from bottom to top 361706f2543Smrg 362706f2543Smrg The major, minor and err terms are the "raw" Bresenham parameters 363706f2543Smrg consistent with a line engine that does: 364706f2543Smrg 365706f2543Smrg e = err; 366706f2543Smrg while(len--) { 367706f2543Smrg DRAW_POINT(x,y); 368706f2543Smrg e += minor; 369706f2543Smrg if(e >= 0) { 370706f2543Smrg e -= major; 371706f2543Smrg TAKE_ONE_STEP_ALONG_MINOR_AXIS; 372706f2543Smrg } 373706f2543Smrg TAKE_ONE_STEP_ALONG_MAJOR_AXIS; 374706f2543Smrg } 375706f2543Smrg 376706f2543Smrg IBM 8514 style Bresenham line interfaces require their parameters 377706f2543Smrg modified in the following way: 378706f2543Smrg 379706f2543Smrg Axial = minor; 380706f2543Smrg Diagonal = minor - major; 381706f2543Smrg Error = minor + err; 382706f2543Smrg 383706f2543SmrgSolidBresenhamLineErrorTermBits 384706f2543Smrg 385706f2543Smrg This field allows the driver to tell XAA how many bits large its 386706f2543Smrg Bresenham parameter registers are. Many engines have registers that 387706f2543Smrg only accept 12 or 13 bit Bresenham parameters, and the parameters 388706f2543Smrg for clipped lines may overflow these if they are not scaled down. 389706f2543Smrg If this field is not set, XAA will assume the engine can accomodate 390706f2543Smrg 16 bit parameters, otherwise, it will scale the parameters to the 391706f2543Smrg size specified. 392706f2543Smrg 393706f2543Smrg 394706f2543Smrg2.4 Dashed Lines 395706f2543Smrg 396706f2543Smrg The same degree of accuracy required by the solid lines is required 397706f2543Smrg for drawing dashed lines as well. The dash pattern itself is a 398706f2543Smrg buffer of binary data where ones are expanded into the foreground 399706f2543Smrg color and zeros either correspond to the background color or 400706f2543Smrg indicate transparency depending on whether or not DoubleDash or 401706f2543Smrg OnOffDashes are being drawn. 402706f2543Smrg 403706f2543Smrg The flags field associated with dashed Lines is DashedLineFlags and 404706f2543Smrg the GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags as 405706f2543Smrg described in Section 2.0 are valid restrictions. Additionally, the 406706f2543Smrg following flags are valid: 407706f2543Smrg 408706f2543Smrg NO_TRANSPARENCY 409706f2543Smrg 410706f2543Smrg This indicates that the driver cannot support dashed lines 411706f2543Smrg with transparent backgrounds (OnOffDashes). 412706f2543Smrg 413706f2543Smrg TRANSPARENCY_ONLY 414706f2543Smrg 415706f2543Smrg This indicates that the driver cannot support dashes with 416706f2543Smrg both a foreground and background color (DoubleDashes). 417706f2543Smrg 418706f2543Smrg LINE_PATTERN_POWER_OF_2_ONLY 419706f2543Smrg 420706f2543Smrg This indicates that only patterns with a power of 2 length 421706f2543Smrg can be accelerated. 422706f2543Smrg 423706f2543Smrg LINE_PATTERN_LSBFIRST_MSBJUSTIFIED 424706f2543Smrg LINE_PATTERN_LSBFIRST_LSBJUSTIFIED 425706f2543Smrg LINE_PATTERN_MSBFIRST_MSBJUSTIFIED 426706f2543Smrg LINE_PATTERN_MSBFIRST_LSBJUSTIFIED 427706f2543Smrg 428706f2543Smrg These describe how the line pattern should be packed. 429706f2543Smrg The pattern buffer is DWORD padded. LSBFIRST indicates 430706f2543Smrg that the pattern runs from the LSB end to the MSB end. 431706f2543Smrg MSBFIRST indicates that the pattern runs from the MSB end 432706f2543Smrg to the LSB end. When the pattern does not completely fill 433706f2543Smrg the DWORD padded buffer, the pattern will be justified 434706f2543Smrg towards the MSB or LSB end based on the flags above. 435706f2543Smrg 436706f2543Smrg 437706f2543Smrg The following field indicates the maximum length dash pattern that 438706f2543Smrg should be accelerated. 439706f2543Smrg 440706f2543Smrg int DashPatternMaxLength 441706f2543Smrg 442706f2543Smrg 443706f2543Smrgvoid SetupForDashedLine(ScrnInfoPtr pScrn, 444706f2543Smrg int fg, int bg, int rop, unsigned int planemask, 445706f2543Smrg int length, unsigned char *pattern) 446706f2543Smrg 447706f2543Smrg 448706f2543Smrg SetupForDashedLine indicates that any combination of the following 449706f2543Smrg may follow it. 450706f2543Smrg 451706f2543Smrg SubsequentDashedBresenhamLine 452706f2543Smrg SubsequentDashedTwoPointLine 453706f2543Smrg 454706f2543Smrg If "bg" is -1, then the background (pixels corresponding to clear 455706f2543Smrg bits in the pattern) should remain unmodified. "Bg" indicates the 456706f2543Smrg background color otherwise. "Length" indicates the length of 457706f2543Smrg the pattern in bits and "pattern" points to the DWORD padded buffer 458706f2543Smrg holding the pattern which has been packed according to the flags 459706f2543Smrg set above. 460706f2543Smrg 461706f2543Smrg 462706f2543Smrgvoid SubsequentDashedTwoPointLine( ScrnInfoPtr pScrn, 463706f2543Smrg int x1, int y1, int x2, int y2, int flags, int phase) 464706f2543Smrg 465706f2543Smrgvoid SubsequentDashedBresenhamLine(ScrnInfoPtr pScrn, 466706f2543Smrg int x1, int y1, int major, int minor, int err, int len, int octant, 467706f2543Smrg int phase) 468706f2543Smrg 469706f2543Smrg These are the same as the SubsequentSolidTwoPointLine and 470706f2543Smrg SubsequentBresenhamLine functions except for the addition 471706f2543Smrg of the "phase" field which indicates the offset into the dash 472706f2543Smrg pattern that the pixel at (x1,y1) corresponds to. 473706f2543Smrg 474706f2543Smrg As with the SubsequentBresenhamLine, there is an 475706f2543Smrg 476706f2543Smrg int DashedBresenhamLineErrorTermBits 477706f2543Smrg 478706f2543Smrg field which indicates the size of the error term registers 479706f2543Smrg used with dashed lines. This is usually the same value as 480706f2543Smrg the field for the solid lines (because it's usually the same 481706f2543Smrg register). 482706f2543Smrg 483706f2543Smrg 484706f2543Smrg 485706f2543Smrg2.5 Color Expansion Fills 486706f2543Smrg 487706f2543Smrg When filling a color expansion rectangle, the accelerator 488706f2543Smrg paints each pixel depending on whether or not a bit in a 489706f2543Smrg corresponding bitmap is set or clear. Opaque expansions are 490706f2543Smrg when a set bit corresponds to the foreground color and a clear 491706f2543Smrg bit corresponds to the background color. A transparent expansion 492706f2543Smrg is when a set bit corresponds to the foreground color and a 493706f2543Smrg clear bit indicates that the pixel should remain unmodified. 494706f2543Smrg 495706f2543Smrg The graphics accelerator usually has access to the source 496706f2543Smrg bitmap in one of two ways: 1) the bitmap data is sent serially 497706f2543Smrg to the accelerator by the CPU through some memory mapped aperture 498706f2543Smrg or 2) the accelerator reads the source bitmap out of offscreen 499706f2543Smrg video memory. Some types of primitives are better suited towards 500706f2543Smrg one method or the other. Type 2 is useful for reusable patterns 501706f2543Smrg such as stipples which can be cached in offscreen memory. The 502706f2543Smrg aperature method can be used for stippling but the CPU must pass 503706f2543Smrg the data across the bus each time a stippled fill is to be performed. 504706f2543Smrg For expanding 1bpp client pixmaps or text strings to the screen, 505706f2543Smrg the aperature method is usually superior because the intermediate 506706f2543Smrg copy in offscreen memory needed by the second method would only be 507706f2543Smrg used once. Unfortunately, many accelerators can only do one of these 508706f2543Smrg methods and not both. 509706f2543Smrg 510706f2543Smrg XAA provides both ScreenToScreen and CPUToScreen color expansion 511706f2543Smrg interfaces for doing color expansion fills. The ScreenToScreen 512706f2543Smrg functions can only be used with hardware that supports reading 513706f2543Smrg of source bitmaps from offscreen video memory, and these are only 514706f2543Smrg used for cacheable patterns such as stipples. There are two 515706f2543Smrg variants of the CPUToScreen routines - a direct method intended 516706f2543Smrg for hardware that has a transfer aperature, and an indirect method 517706f2543Smrg intended for hardware without transfer aperatures or hardware 518706f2543Smrg with unusual transfer requirements. Hardware that can only expand 519706f2543Smrg bitmaps from video memory should supply ScreenToScreen routines 520706f2543Smrg but also ScanlineCPUToScreen (indirect) routines to optimize transfers 521706f2543Smrg of non-cacheable data. Hardware that can only accept source bitmaps 522706f2543Smrg through an aperature should supply CPUToScreen (or ScanlineCPUToScreen) 523706f2543Smrg routines. Hardware that can do both should provide both ScreenToScreen 524706f2543Smrg and CPUToScreen routines. 525706f2543Smrg 526706f2543Smrg For both ScreenToScreen and CPUToScreen interfaces, the GXCOPY_ONLY, 527706f2543Smrg ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags described in 528706f2543Smrg Section 2.0 are valid as well as the following: 529706f2543Smrg 530706f2543Smrg /* bit order requirements (one of these must be set) */ 531706f2543Smrg 532706f2543Smrg BIT_ORDER_IN_BYTE_LSBFIRST 533706f2543Smrg 534706f2543Smrg This indicates that least significant bit in each byte of the source 535706f2543Smrg data corresponds to the leftmost of that block of 8 pixels. This 536706f2543Smrg is the prefered format. 537706f2543Smrg 538706f2543Smrg BIT_ORDER_IN_BYTE_MSBFIRST 539706f2543Smrg 540706f2543Smrg This indicates that most significant bit in each byte of the source 541706f2543Smrg data corresponds to the leftmost of that block of 8 pixels. 542706f2543Smrg 543706f2543Smrg /* transparency restrictions */ 544706f2543Smrg 545706f2543Smrg NO_TRANSPARENCY 546706f2543Smrg 547706f2543Smrg This indicates that the accelerator cannot do a transparent expansion. 548706f2543Smrg 549706f2543Smrg TRANSPARENCY_ONLY 550706f2543Smrg 551706f2543Smrg This indicates that the accelerator cannot do an opaque expansion. 552706f2543Smrg In cases where where the background needs to be filled, XAA will 553706f2543Smrg render the primitive in two passes when using the CPUToScreen 554706f2543Smrg interface, but will not do so with the ScreenToScreen interface 555706f2543Smrg since that would require caching of two patterns. Some 556706f2543Smrg ScreenToScreen hardware may be able to render two passes at the 557706f2543Smrg driver level and remove the TRANSPARENCY_ONLY restriction if 558706f2543Smrg it can render pixels corresponding to the zero bits. 559706f2543Smrg 560706f2543Smrg 561706f2543Smrg 562706f2543Smrg2.5.1 Screen To Screen Color Expansion 563706f2543Smrg 564706f2543Smrg The ScreenToScreenColorExpandFill routines provide an interface 565706f2543Smrg for doing expansion blits from source patterns stored in offscreen 566706f2543Smrg video memory. 567706f2543Smrg 568706f2543Smrg void SetupForScreenToScreenColorExpandFill (ScrnInfoPtr pScrn, 569706f2543Smrg int fg, int bg, 570706f2543Smrg int rop, unsigned int planemask) 571706f2543Smrg 572706f2543Smrg 573706f2543Smrg Ones in the source bitmap will correspond to the fg color. 574706f2543Smrg Zeros in the source bitmap will correspond to the bg color 575706f2543Smrg unless bg = -1. In that case the pixels corresponding to the 576706f2543Smrg zeros in the bitmap shall be left unmodified by the accelerator. 577706f2543Smrg 578706f2543Smrg For hardware that doesn't allow an easy implementation of skipleft, the 579706f2543Smrg driver can replace CacheMonoStipple function with one that stores multiple 580706f2543Smrg rotated copies of the stipple and select between them. In this case the 581706f2543Smrg driver should set CacheColorExpandDensity to tell XAA how many copies of 582706f2543Smrg the pattern are stored in the width of a cache slot. For instance if the 583706f2543Smrg hardware can specify the starting address in bytes, then 8 rotated copies 584706f2543Smrg of the stipple are needed and CacheColorExpandDensity should be set to 8. 585706f2543Smrg 586706f2543Smrg void SubsequentScreenToScreenColorExpandFill( ScrnInfoPtr pScrn, 587706f2543Smrg int x, int y, int w, int h, 588706f2543Smrg int srcx, int srcy, int offset ) 589706f2543Smrg 590706f2543Smrg 591706f2543Smrg Fill a rectangle "w" x "h" at location (x,y). The source pitch 592706f2543Smrg between scanlines is the framebuffer pitch (pScrn->displayWidth 593706f2543Smrg pixels) and srcx and srcy indicate the start of the source pattern 594706f2543Smrg in units of framebuffer pixels. "Offset" indicates the bit offset 595706f2543Smrg into the pattern that corresponds to the pixel being painted at 596706f2543Smrg "x" on the screen. Some hardware accepts source coordinates in 597706f2543Smrg units of bits which makes implementation of the offset trivial. 598706f2543Smrg In that case, the bit address of the source bit corresponding to 599706f2543Smrg the pixel painted at (x,y) would be: 600706f2543Smrg 601706f2543Smrg (srcy * pScrn->displayWidth + srcx) * pScrn->bitsPerPixel + offset 602706f2543Smrg 603706f2543Smrg It should be noted that the offset assumes LSBFIRST hardware. 604706f2543Smrg For MSBFIRST hardware, the driver may need to implement the 605706f2543Smrg offset by bliting only from byte boundaries and hardware clipping. 606706f2543Smrg 607706f2543Smrg 608706f2543Smrg 609706f2543Smrg2.5.2 CPU To Screen Color Expansion 610706f2543Smrg 611706f2543Smrg 612706f2543Smrg The CPUToScreenColorExpandFill routines provide an interface for 613706f2543Smrg doing expansion blits from source patterns stored in system memory. 614706f2543Smrg There are two varieties of this primitive, a CPUToScreenColorExpandFill 615706f2543Smrg and a ScanlineCPUToScreenColorExpandFill. With the 616706f2543Smrg CPUToScreenColorExpandFill method, the source data is sent serially 617706f2543Smrg through a memory mapped aperature. With the Scanline version, the 618706f2543Smrg data is rendered scanline at a time into intermediate buffers with 619706f2543Smrg a call to SubsequentColorExpandScanline following each scanline. 620706f2543Smrg 621706f2543Smrg These two methods have separate flags fields, the 622706f2543Smrg CPUToScreenColorExpandFillFlags and ScanlineCPUToScreenColorExpandFillFlags 623706f2543Smrg respectively. Flags specific to one method or the other are described 624706f2543Smrg in sections 2.5.2.1 and 2.5.2.2 but for both cases the bit order and 625706f2543Smrg transparency restrictions listed at the beginning of section 2.5 are 626706f2543Smrg valid as well as the following: 627706f2543Smrg 628706f2543Smrg /* clipping (optional) */ 629706f2543Smrg 630706f2543Smrg LEFT_EDGE_CLIPPING 631706f2543Smrg 632706f2543Smrg This indicates that the accelerator supports omission of up to 633706f2543Smrg 31 pixels on the left edge of the rectangle to be filled. This 634706f2543Smrg is beneficial since it allows transfer of the source bitmap to 635706f2543Smrg always occur from DWORD boundaries. 636706f2543Smrg 637706f2543Smrg LEFT_EDGE_CLIPPING_NEGATIVE_X 638706f2543Smrg 639706f2543Smrg This flag indicates that the accelerator can render color expansion 640706f2543Smrg rectangles even if the value of x origin is negative (off of 641706f2543Smrg the screen on the left edge). 642706f2543Smrg 643706f2543Smrg /* misc */ 644706f2543Smrg 645706f2543Smrg TRIPLE_BITS_24BPP 646706f2543Smrg 647706f2543Smrg When enabled (must be in 24bpp mode), color expansion functions 648706f2543Smrg are expected to require three times the amount of bits to be 649706f2543Smrg transferred so that 24bpp grayscale colors can be used with color 650706f2543Smrg expansion in 8bpp coprocessor mode. Each bit is expanded to 3 651706f2543Smrg bits when writing the monochrome data. 652706f2543Smrg 653706f2543Smrg 654706f2543Smrg 2.5.1 The Direct Method 655706f2543Smrg 656706f2543Smrg 657706f2543Smrg Using the direct method of color expansion XAA will send all 658706f2543Smrg bitmap data to the accelerator serially through an memory mapped 659706f2543Smrg transfer window defined by the following two fields: 660706f2543Smrg 661706f2543Smrg unsigned char *ColorExpandBase 662706f2543Smrg 663706f2543Smrg This indicates the memory address of the beginning of the aperture. 664706f2543Smrg 665706f2543Smrg int ColorExpandRange 666706f2543Smrg 667706f2543Smrg This indicates the size in bytes of the aperture. 668706f2543Smrg 669706f2543Smrg The driver should specify how the transfered data should be padded. 670706f2543Smrg There are options for both the padding of each Y scanline and for the 671706f2543Smrg total transfer to the aperature. 672706f2543Smrg One of the following two flags must be set: 673706f2543Smrg 674706f2543Smrg CPU_TRANSFER_PAD_DWORD 675706f2543Smrg 676706f2543Smrg This indicates that the total transfer (sum of all scanlines) sent 677706f2543Smrg to the aperature must be DWORD padded. This is the default behavior. 678706f2543Smrg 679706f2543Smrg CPU_TRANSFER_PAD_QWORD 680706f2543Smrg 681706f2543Smrg This indicates that the total transfer (sum of all scanlines) sent 682706f2543Smrg to the aperature must be QWORD padded. With this set, XAA will send 683706f2543Smrg an extra DWORD to the aperature when needed to ensure that only 684706f2543Smrg an even number of DWORDs are sent. 685706f2543Smrg 686706f2543Smrg And then there are the flags for padding of each scanline: 687706f2543Smrg 688706f2543Smrg SCANLINE_PAD_DWORD 689706f2543Smrg 690706f2543Smrg This indicates that each Y scanline should be DWORD padded. 691706f2543Smrg This is the only option available and is the default. 692706f2543Smrg 693706f2543Smrg Finally, there is the CPU_TRANSFER_BASE_FIXED flag which indicates 694706f2543Smrg that the aperture is a single register rather than a range of 695706f2543Smrg registers, and XAA should write all of the data to the first DWORD. 696706f2543Smrg If the ColorExpandRange is not large enough to accomodate scanlines 697706f2543Smrg the width of the screen, this option will be forced. That is, the 698706f2543Smrg ColorExpandRange must be: 699706f2543Smrg 700706f2543Smrg ((virtualX + 31)/32) * 4 bytes or more. 701706f2543Smrg 702706f2543Smrg ((virtualX + 62)/32 * 4) if LEFT_EDGE_CLIPPING_NEGATIVE_X is set. 703706f2543Smrg 704706f2543Smrg If the TRIPLE_BITS_24BPP flag is set, the required area should be 705706f2543Smrg multiplied by three. 706706f2543Smrg 707706f2543Smrg 708706f2543Smrgvoid SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, 709706f2543Smrg int fg, int bg, 710706f2543Smrg int rop, 711706f2543Smrg unsigned int planemask) 712706f2543Smrg 713706f2543Smrg 714706f2543Smrg 715706f2543Smrg Ones in the source bitmap will correspond to the fg color. 716706f2543Smrg Zeros in the source bitmap will correspond to the bg color 717706f2543Smrg unless bg = -1. In that case the pixels corresponding to the 718706f2543Smrg zeros in the bitmap shall be left unmodified by the accelerator. 719706f2543Smrg 720706f2543Smrg 721706f2543Smrgvoid SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, 722706f2543Smrg int x, int y, int w, int h, 723706f2543Smrg int skipleft ) 724706f2543Smrg 725706f2543Smrg When this function is called, the accelerator should be setup 726706f2543Smrg to fill a rectangle of dimension "w" by "h" with origin at (x,y) 727706f2543Smrg in the fill style prescribed by the last call to 728706f2543Smrg SetupForCPUToScreenColorExpandFill. XAA will pass the data to 729706f2543Smrg the aperture immediately after this function is called. If the 730706f2543Smrg skipleft is non-zero (and LEFT_EDGE_CLIPPING has been enabled), then 731706f2543Smrg the accelerator _should_not_ render skipleft pixels on the leftmost 732706f2543Smrg edge of the rectangle. Some engines have an alignment feature 733706f2543Smrg like this built in, some others can do this using a clipping 734706f2543Smrg window. 735706f2543Smrg 736706f2543Smrg It can be arranged for XAA to call Sync() after it is through 737706f2543Smrg calling the Subsequent function by setting SYNC_AFTER_COLOR_EXPAND 738706f2543Smrg in the CPUToScreenColorExpandFillFlags. This can provide the driver 739706f2543Smrg with an oportunity to reset a clipping window if needed. 740706f2543Smrg 741706f2543Smrg 742706f2543Smrg2.5.2 The Indirect Method 743706f2543Smrg 744706f2543Smrg Using the indirect method, XAA will render the bitmap data scanline 745706f2543Smrg at a time to one or more buffers. These buffers may be memory 746706f2543Smrg mapped apertures or just intermediate storage. 747706f2543Smrg 748706f2543Smrg int NumScanlineColorExpandBuffers 749706f2543Smrg 750706f2543Smrg This indicates the number of buffers available. 751706f2543Smrg 752706f2543Smrg unsigned char **ScanlineColorExpandBuffers 753706f2543Smrg 754706f2543Smrg This is an array of pointers to the memory locations of each buffer. 755706f2543Smrg Each buffer is expected to be large enough to accommodate scanlines 756706f2543Smrg the width of the screen. That is: 757706f2543Smrg 758706f2543Smrg ((virtualX + 31)/32) * 4 bytes or more. 759706f2543Smrg 760706f2543Smrg ((virtualX + 62)/32 * 4) if LEFT_EDGE_CLIPPING_NEGATIVE_X is set. 761706f2543Smrg 762706f2543Smrg Scanlines are always DWORD padded. 763706f2543Smrg If the TRIPLE_BITS_24BPP flag is set, the required area should be 764706f2543Smrg multiplied by three. 765706f2543Smrg 766706f2543Smrg 767706f2543Smrgvoid SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, 768706f2543Smrg int fg, int bg, 769706f2543Smrg int rop, 770706f2543Smrg unsigned int planemask) 771706f2543Smrg 772706f2543Smrg Ones in the source bitmap will correspond to the fg color. 773706f2543Smrg Zeros in the source bitmap will correspond to the bg color 774706f2543Smrg unless bg = -1. In that case the pixels corresponding to the 775706f2543Smrg zeros in the bitmap shall be left unmodified by the accelerator. 776706f2543Smrg 777706f2543Smrg 778706f2543Smrgvoid SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, 779706f2543Smrg int x, int y, int w, int h, 780706f2543Smrg int skipleft ) 781706f2543Smrg 782706f2543Smrgvoid SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) 783706f2543Smrg 784706f2543Smrg 785706f2543Smrg When SubsequentScanlineCPUToScreenColorExpandFill is called, XAA 786706f2543Smrg will begin transfering the source data scanline at a time, calling 787706f2543Smrg SubsequentColorExpandScanline after each scanline. If more than 788706f2543Smrg one buffer is available, XAA will cycle through the buffers. 789706f2543Smrg Subsequent scanlines will use the next buffer and go back to the 790706f2543Smrg buffer 0 again when the last buffer is reached. The index into 791706f2543Smrg the ScanlineColorExpandBuffers array is presented as "bufno" 792706f2543Smrg with each SubsequentColorExpandScanline call. 793706f2543Smrg 794706f2543Smrg The skipleft field is the same as for the direct method. 795706f2543Smrg 796706f2543Smrg The indirect method can be use to send the source data directly 797706f2543Smrg to a memory mapped aperture represented by a single color expand 798706f2543Smrg buffer, scanline at a time, but more commonly it is used to place 799706f2543Smrg the data into offscreen video memory so that the accelerator can 800706f2543Smrg blit it to the visible screen from there. In the case where the 801706f2543Smrg accelerator permits rendering into offscreen video memory while 802706f2543Smrg the accelerator is active, several buffers can be used so that 803706f2543Smrg XAA can be placing source data into the next buffer while the 804706f2543Smrg accelerator is blitting the current buffer. For cases where 805706f2543Smrg the accelerator requires some special manipulation of the source 806706f2543Smrg data first, the buffers can be in system memory. The CPU can 807706f2543Smrg manipulate these buffers and then send the data to the accelerator. 808706f2543Smrg 809706f2543Smrg 810706f2543Smrg 811706f2543Smrg2.6 8x8 Mono Pattern Fills 812706f2543Smrg 813706f2543Smrg XAA provides support for two types of 8x8 hardware patterns - 814706f2543Smrg "Mono" patterns and "Color" patterns. Mono pattern data is 815706f2543Smrg 64 bits of color expansion data with ones indicating the 816706f2543Smrg foreground color and zeros indicating the background color. 817706f2543Smrg The source bitmaps for the 8x8 mono patterns can be presented 818706f2543Smrg to the graphics accelerator in one of two ways. They can be 819706f2543Smrg passed as two DWORDS to the 8x8 mono pattern functions or 820706f2543Smrg they can be cached in offscreen memory and their locations 821706f2543Smrg passed to the 8x8 mono pattern functions. In addition to the 822706f2543Smrg GXCOPY_ONLY, ROP_NEEDS_SOURCE, NO_PLANEMASK and RGB_EQUAL flags 823706f2543Smrg defined in Section 2.0, the following are defined for the 824706f2543Smrg Mono8x8PatternFillFlags: 825706f2543Smrg 826706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_BITS 827706f2543Smrg 828706f2543Smrg This indicates that the 8x8 patterns should be packed into two 829706f2543Smrg DWORDS and passed to the 8x8 mono pattern functions. The default 830706f2543Smrg behavior is to cache the patterns in offscreen video memory and 831706f2543Smrg pass the locations of these patterns to the functions instead. 832706f2543Smrg The pixmap cache must be enabled for the default behavior (8x8 833706f2543Smrg pattern caching) to work. See Section 3 for how to enable the 834706f2543Smrg pixmap cache. The pixmap cache is not necessary for 835706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_BITS. 836706f2543Smrg 837706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_ORIGIN 838706f2543Smrg 839706f2543Smrg If the hardware supports programmable pattern offsets then 840706f2543Smrg this option should be set. See the table below for further 841706f2543Smrg infomation. 842706f2543Smrg 843706f2543Smrg HARDWARE_PATTERN_SCREEN_ORIGIN 844706f2543Smrg 845706f2543Smrg Some hardware wants the pattern offset specified with respect to the 846706f2543Smrg upper left-hand corner of the primitive being drawn. Other hardware 847706f2543Smrg needs the option HARDWARE_PATTERN_SCREEN_ORIGIN set to indicate that 848706f2543Smrg all pattern offsets should be referenced to the upper left-hand 849706f2543Smrg corner of the screen. HARDWARE_PATTERN_SCREEN_ORIGIN is preferable 850706f2543Smrg since this is more natural for the X-Window system and offsets will 851706f2543Smrg have to be recalculated for each Subsequent function otherwise. 852706f2543Smrg 853706f2543Smrg BIT_ORDER_IN_BYTE_MSBFIRST 854706f2543Smrg BIT_ORDER_IN_BYTE_LSBFIRST 855706f2543Smrg 856706f2543Smrg As with other color expansion routines this indicates whether the 857706f2543Smrg most or the least significant bit in each byte from the pattern is 858706f2543Smrg the leftmost on the screen. 859706f2543Smrg 860706f2543Smrg TRANSPARENCY_ONLY 861706f2543Smrg NO_TRANSPARENCY 862706f2543Smrg 863706f2543Smrg This means the same thing as for the color expansion rect routines 864706f2543Smrg except that for TRANSPARENCY_ONLY XAA will not render the primitive 865706f2543Smrg in two passes since this is more easily handled by the driver. 866706f2543Smrg It is recommended that TRANSPARENCY_ONLY hardware handle rendering 867706f2543Smrg of opaque patterns in two passes (the background can be filled as 868706f2543Smrg a rectangle in GXcopy) in the Subsequent function so that the 869706f2543Smrg TRANSPARENCY_ONLY restriction can be removed. 870706f2543Smrg 871706f2543Smrg 872706f2543Smrg 873706f2543Smrg Additional information about cached patterns... 874706f2543Smrg For the case where HARDWARE_PATTERN_PROGRAMMED_BITS is not set and 875706f2543Smrg the pattern must be cached in offscreen memory, the first pattern 876706f2543Smrg starts at the cache slot boundary which is set by the 877706f2543Smrg CachePixelGranularity field used to configure the pixmap cache. 878706f2543Smrg One should ensure that the CachePixelGranularity reflects any 879706f2543Smrg alignment restrictions that the accelerator may put on 8x8 pattern 880706f2543Smrg storage locations. When HARDWARE_PATTERN_PROGRAMMED_ORIGIN is set 881706f2543Smrg there is only one pattern stored. When this flag is not set, 882706f2543Smrg all 64 pre-rotated copies of the pattern are cached in offscreen memory. 883706f2543Smrg The MonoPatternPitch field can be used to specify the X position pixel 884706f2543Smrg granularity that each of these patterns must align on. If the 885706f2543Smrg MonoPatternPitch is not supplied, the patterns will be densely packed 886706f2543Smrg within the cache slot. The behavior of the default XAA 8x8 pattern 887706f2543Smrg caching mechanism to store all 8x8 patterns linearly in video memory. 888706f2543Smrg If the accelerator needs the patterns stored in a more unusual fashion, 889706f2543Smrg the driver will need to provide its own 8x8 mono pattern caching 890706f2543Smrg routines for XAA to use. 891706f2543Smrg 892706f2543Smrg The following table describes the meanings of the "patx" and "paty" 893706f2543Smrg fields in both the SetupFor and Subsequent functions. 894706f2543Smrg 895706f2543Smrg With HARDWARE_PATTERN_SCREEN_ORIGIN 896706f2543Smrg ----------------------------------- 897706f2543Smrg 898706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_BITS and HARDWARE_PATTERN_PROGRAMMED_ORIGIN 899706f2543Smrg 900706f2543Smrg SetupFor: patx and paty are the first and second DWORDS of the 901706f2543Smrg 8x8 mono pattern. 902706f2543Smrg 903706f2543Smrg Subsequent: patx and paty are the x,y offset into that pattern. 904706f2543Smrg All Subsequent calls will have the same offset in 905706f2543Smrg the case of HARDWARE_PATTERN_SCREEN_ORIGIN so only 906706f2543Smrg the offset specified by the first Subsequent call 907706f2543Smrg after a SetupFor call will need to be observed. 908706f2543Smrg 909706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_BITS only 910706f2543Smrg 911706f2543Smrg SetupFor: patx and paty hold the first and second DWORDS of 912706f2543Smrg the 8x8 mono pattern pre-rotated to match the desired 913706f2543Smrg offset. 914706f2543Smrg 915706f2543Smrg Subsequent: These just hold the same patterns and can be ignored. 916706f2543Smrg 917706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_ORIGIN only 918706f2543Smrg 919706f2543Smrg SetupFor: patx and paty hold the x,y coordinates of the offscreen 920706f2543Smrg memory location where the 8x8 pattern is stored. The 921706f2543Smrg bits are stored linearly in memory at that location. 922706f2543Smrg 923706f2543Smrg Subsequent: patx and paty hold the offset into the pattern. 924706f2543Smrg All Subsequent calls will have the same offset in 925706f2543Smrg the case of HARDWARE_PATTERN_SCREEN_ORIGIN so only 926706f2543Smrg the offset specified by the first Subsequent call 927706f2543Smrg after a SetupFor call will need to be observed. 928706f2543Smrg 929706f2543Smrg Neither programmed bits or origin 930706f2543Smrg 931706f2543Smrg SetupFor: patx and paty hold the x,y coordinates of the offscreen 932706f2543Smrg memory location where the pre-rotated 8x8 pattern is 933706f2543Smrg stored. 934706f2543Smrg 935706f2543Smrg Subsequent: patx and paty are the same as in the SetupFor function 936706f2543Smrg and can be ignored. 937706f2543Smrg 938706f2543Smrg 939706f2543Smrg Without HARDWARE_PATTERN_SCREEN_ORIGIN 940706f2543Smrg -------------------------------------- 941706f2543Smrg 942706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_BITS and HARDWARE_PATTERN_PROGRAMMED_ORIGIN 943706f2543Smrg 944706f2543Smrg SetupFor: patx and paty are the first and second DWORDS of the 945706f2543Smrg 8x8 mono pattern. 946706f2543Smrg 947706f2543Smrg Subsequent: patx and paty are the x,y offset into that pattern. 948706f2543Smrg 949706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_BITS only 950706f2543Smrg 951706f2543Smrg SetupFor: patx and paty holds the first and second DWORDS of 952706f2543Smrg the unrotated 8x8 mono pattern. This can be ignored. 953706f2543Smrg 954706f2543Smrg Subsequent: patx and paty hold the rotated 8x8 pattern to be 955706f2543Smrg rendered. 956706f2543Smrg 957706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_ORIGIN only 958706f2543Smrg 959706f2543Smrg SetupFor: patx and paty hold the x,y coordinates of the offscreen 960706f2543Smrg memory location where the 8x8 pattern is stored. The 961706f2543Smrg bits are stored linearly in memory at that location. 962706f2543Smrg 963706f2543Smrg Subsequent: patx and paty hold the offset into the pattern. 964706f2543Smrg 965706f2543Smrg Neither programmed bits or origin 966706f2543Smrg 967706f2543Smrg SetupFor: patx and paty hold the x,y coordinates of the offscreen 968706f2543Smrg memory location where the unrotated 8x8 pattern is 969706f2543Smrg stored. This can be ignored. 970706f2543Smrg 971706f2543Smrg Subsequent: patx and paty hold the x,y coordinates of the 972706f2543Smrg rotated 8x8 pattern to be rendered. 973706f2543Smrg 974706f2543Smrg 975706f2543Smrg 976706f2543Smrgvoid SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, 977706f2543Smrg int fg, int bg, int rop, unsigned int planemask) 978706f2543Smrg 979706f2543Smrg SetupForMono8x8PatternFill indicates that any combination of the 980706f2543Smrg following may follow it. 981706f2543Smrg 982706f2543Smrg SubsequentMono8x8PatternFillRect 983706f2543Smrg SubsequentMono8x8PatternFillTrap 984706f2543Smrg 985706f2543Smrg The fg, bg, rop and planemask fields have the same meaning as the 986706f2543Smrg ones used for the other color expansion routines. Patx's and paty's 987706f2543Smrg meaning can be determined from the table above. 988706f2543Smrg 989706f2543Smrg 990706f2543Smrgvoid SubsequentMono8x8PatternFillRect( ScrnInfoPtr pScrn, 991706f2543Smrg int patx, int paty, int x, int y, int w, int h) 992706f2543Smrg 993706f2543Smrg Fill a rectangle of dimensions "w" by "h" with origin at (x,y) 994706f2543Smrg using the parameters give by the last SetupForMono8x8PatternFill 995706f2543Smrg call. The meanings of patx and paty can be determined by the 996706f2543Smrg table above. 997706f2543Smrg 998706f2543Smrgvoid SubsequentMono8x8PatternFillTrap( ScrnInfoPtr pScrn, 999706f2543Smrg int patx, int paty, int y, int h, 1000706f2543Smrg int left, int dxL, int dyL, int eL, 1001706f2543Smrg int right, int dxR, int dyR, int eR ) 1002706f2543Smrg 1003706f2543Smrg The meanings of patx and paty can be determined by the table above. 1004706f2543Smrg The rest of the fields have the same meanings as those in the 1005706f2543Smrg SubsequentSolidFillTrap function. 1006706f2543Smrg 1007706f2543Smrg 1008706f2543Smrg 1009706f2543Smrg2.7 8x8 Color Pattern Fills 1010706f2543Smrg 1011706f2543Smrg 8x8 color pattern data is 64 pixels of full color data that 1012706f2543Smrg is stored linearly in offscreen video memory. 8x8 color patterns 1013706f2543Smrg are useful as a substitute for 8x8 mono patterns when tiling, 1014706f2543Smrg doing opaque stipples, or in the case where transperency is 1015706f2543Smrg supported, regular stipples. 8x8 color pattern fills also have 1016706f2543Smrg the additional benefit of being able to tile full color 8x8 1017706f2543Smrg patterns instead of just 2 color ones like the mono patterns. 1018706f2543Smrg However, full color 8x8 patterns aren't used very often in the 1019706f2543Smrg X Window system so you might consider passing this primitive 1020706f2543Smrg by if you already can do mono patterns, especially if they 1021706f2543Smrg require alot of cache area. Color8x8PatternFillFlags is 1022706f2543Smrg the flags field for this primitive and the GXCOPY_ONLY, 1023706f2543Smrg ROP_NEEDS_SOURCE and NO_PLANEMASK flags as described in 1024706f2543Smrg Section 2.0 are valid as well as the following: 1025706f2543Smrg 1026706f2543Smrg 1027706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_ORIGIN 1028706f2543Smrg 1029706f2543Smrg If the hardware supports programmable pattern offsets then 1030706f2543Smrg this option should be set. 1031706f2543Smrg 1032706f2543Smrg HARDWARE_PATTERN_SCREEN_ORIGIN 1033706f2543Smrg 1034706f2543Smrg Some hardware wants the pattern offset specified with respect to the 1035706f2543Smrg upper left-hand corner of the primitive being drawn. Other hardware 1036706f2543Smrg needs the option HARDWARE_PATTERN_SCREEN_ORIGIN set to indicate that 1037706f2543Smrg all pattern offsets should be referenced to the upper left-hand 1038706f2543Smrg corner of the screen. HARDWARE_PATTERN_SCREEN_ORIGIN is preferable 1039706f2543Smrg since this is more natural for the X-Window system and offsets will 1040706f2543Smrg have to be recalculated for each Subsequent function otherwise. 1041706f2543Smrg 1042706f2543Smrg NO_TRANSPARENCY 1043706f2543Smrg TRANSPARENCY_GXCOPY_ONLY 1044706f2543Smrg 1045706f2543Smrg These mean the same as for the ScreenToScreenCopy functions. 1046706f2543Smrg 1047706f2543Smrg 1048706f2543Smrg The following table describes the meanings of patx and paty passed 1049706f2543Smrg to the SetupFor and Subsequent fields: 1050706f2543Smrg 1051706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_ORIGIN && HARDWARE_PATTERN_SCREEN_ORIGIN 1052706f2543Smrg 1053706f2543Smrg SetupFor: patx and paty hold the x,y location of the unrotated 1054706f2543Smrg pattern. 1055706f2543Smrg 1056706f2543Smrg Subsequent: patx and paty hold the pattern offset. For the case 1057706f2543Smrg of HARDWARE_PATTERN_SCREEN_ORIGIN all Subsequent calls 1058706f2543Smrg have the same offset so only the first call will need 1059706f2543Smrg to be observed. 1060706f2543Smrg 1061706f2543Smrg 1062706f2543Smrg HARDWARE_PATTERN_PROGRAMMED_ORIGIN only 1063706f2543Smrg 1064706f2543Smrg SetupFor: patx and paty hold the x,y location of the unrotated 1065706f2543Smrg pattern. 1066706f2543Smrg 1067706f2543Smrg Subsequent: patx and paty hold the pattern offset. 1068706f2543Smrg 1069706f2543Smrg HARDWARE_PATTERN_SCREEN_ORIGIN 1070706f2543Smrg 1071706f2543Smrg SetupFor: patx and paty hold the x,y location of the rotated pattern. 1072706f2543Smrg 1073706f2543Smrg Subsequent: patx and paty hold the same location as the SetupFor 1074706f2543Smrg function so these can be ignored. 1075706f2543Smrg 1076706f2543Smrg neither flag 1077706f2543Smrg 1078706f2543Smrg SetupFor: patx and paty hold the x,y location of the unrotated 1079706f2543Smrg pattern. This can be ignored. 1080706f2543Smrg 1081706f2543Smrg Subsequent: patx and paty hold the x,y location of the rotated 1082706f2543Smrg pattern. 1083706f2543Smrg 1084706f2543Smrg Additional information about cached patterns... 1085706f2543Smrg All 8x8 color patterns are cached in offscreen video memory so 1086706f2543Smrg the pixmap cache must be enabled to use them. The first pattern 1087706f2543Smrg starts at the cache slot boundary which is set by the 1088706f2543Smrg CachePixelGranularity field used to configure the pixmap cache. 1089706f2543Smrg One should ensure that the CachePixelGranularity reflects any 1090706f2543Smrg alignment restrictions that the accelerator may put on 8x8 pattern 1091706f2543Smrg storage locations. When HARDWARE_PATTERN_PROGRAMMED_ORIGIN is set 1092706f2543Smrg there is only one pattern stored. When this flag is not set, 1093706f2543Smrg all 64 rotations off the pattern are accessible but it is assumed 1094706f2543Smrg that the accelerator is capable of accessing data stored on 8 1095706f2543Smrg pixel boundaries. If the accelerator has stricter alignment 1096706f2543Smrg requirements than this the dirver will need to provide its own 1097706f2543Smrg 8x8 color pattern caching routines. 1098706f2543Smrg 1099706f2543Smrg 1100706f2543Smrgvoid SetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty, 1101706f2543Smrg int rop, unsigned int planemask, int trans_color) 1102706f2543Smrg 1103706f2543Smrg SetupForColor8x8PatternFill indicates that any combination of the 1104706f2543Smrg following may follow it. 1105706f2543Smrg 1106706f2543Smrg SubsequentColor8x8PatternFillRect 1107706f2543Smrg SubsequentColor8x8PatternFillTrap (not implemented yet) 1108706f2543Smrg 1109706f2543Smrg For the meanings of patx and paty, see the table above. Trans_color 1110706f2543Smrg means the same as for the ScreenToScreenCopy functions. 1111706f2543Smrg 1112706f2543Smrg 1113706f2543Smrg 1114706f2543Smrgvoid SubsequentColor8x8PatternFillRect( ScrnInfoPtr pScrn, 1115706f2543Smrg int patx, int paty, int x, int y, int w, int h) 1116706f2543Smrg 1117706f2543Smrg Fill a rectangle of dimensions "w" by "h" with origin at (x,y) 1118706f2543Smrg using the parameters give by the last SetupForColor8x8PatternFill 1119706f2543Smrg call. The meanings of patx and paty can be determined by the 1120706f2543Smrg table above. 1121706f2543Smrg 1122706f2543Smrgvoid SubsequentColor8x8PatternFillTrap( ScrnInfoPtr pScrn, 1123706f2543Smrg int patx, int paty, int y, int h, 1124706f2543Smrg int left, int dxL, int dyL, int eL, 1125706f2543Smrg int right, int dxR, int dyR, int eR ) 1126706f2543Smrg 1127706f2543Smrg For the meanings of patx and paty, see the table above. 1128706f2543Smrg The rest of the fields have the same meanings as those in the 1129706f2543Smrg SubsequentSolidFillTrap function. 1130706f2543Smrg 1131706f2543Smrg 1132706f2543Smrg 1133706f2543Smrg2.8 Image Writes 1134706f2543Smrg 1135706f2543Smrg XAA provides a mechanism for transfering full color pixel data from 1136706f2543Smrg system memory to video memory through the accelerator. This is 1137706f2543Smrg useful for dealing with alignment issues and performing raster ops 1138706f2543Smrg on the data when writing it to the framebuffer. As with color 1139706f2543Smrg expansion rectangles, there is a direct and indirect method. The 1140706f2543Smrg direct method sends all data through a memory mapped aperature. 1141706f2543Smrg The indirect method sends the data to an intermediated buffer scanline 1142706f2543Smrg at a time. 1143706f2543Smrg 1144706f2543Smrg The direct and indirect methods have separate flags fields, the 1145706f2543Smrg ImageWriteFlags and ScanlineImageWriteFlags respectively. 1146706f2543Smrg Flags specific to one method or the other are described in sections 1147706f2543Smrg 2.8.1 and 2.8.2 but for both cases the GXCOPY_ONLY, ROP_NEEDS_SOURCE 1148706f2543Smrg and NO_PLANEMASK flags described in Section 2.0 are valid as well as 1149706f2543Smrg the following: 1150706f2543Smrg 1151706f2543Smrg NO_GXCOPY 1152706f2543Smrg 1153706f2543Smrg In order to have accelerated image transfers faster than the 1154706f2543Smrg software versions for GXcopy, the engine needs to support clipping, 1155706f2543Smrg be using the direct method and have a large enough image transfer 1156706f2543Smrg range so that CPU_TRANSFER_BASE_FIXED doesn't need to be set. 1157706f2543Smrg If these are not supported, then it is unlikely that transfering 1158706f2543Smrg the data through the accelerator will be of any advantage for the 1159706f2543Smrg simple case of GXcopy. In fact, it may be much slower. For such 1160706f2543Smrg cases it's probably best to set the NO_GXCOPY flag so that 1161706f2543Smrg Image writes will only be used for the more complicated rops. 1162706f2543Smrg 1163706f2543Smrg /* transparency restrictions */ 1164706f2543Smrg 1165706f2543Smrg NO_TRANSPARENCY 1166706f2543Smrg 1167706f2543Smrg This indicates that the accelerator does not support skipping 1168706f2543Smrg of color keyed pixels when copying from the source to the destination. 1169706f2543Smrg 1170706f2543Smrg TRANSPARENCY_GXCOPY_ONLY 1171706f2543Smrg 1172706f2543Smrg This indicates that the accelerator supports skipping of color keyed 1173706f2543Smrg pixels only when the rop is GXcopy. 1174706f2543Smrg 1175706f2543Smrg /* clipping (optional) */ 1176706f2543Smrg 1177706f2543Smrg LEFT_EDGE_CLIPPING 1178706f2543Smrg 1179706f2543Smrg This indicates that the accelerator supports omission of up to 1180706f2543Smrg 3 pixels on the left edge of the rectangle to be filled. This 1181706f2543Smrg is beneficial since it allows transfer from the source pixmap to 1182706f2543Smrg always occur from DWORD boundaries. 1183706f2543Smrg 1184706f2543Smrg LEFT_EDGE_CLIPPING_NEGATIVE_X 1185706f2543Smrg 1186706f2543Smrg This flag indicates that the accelerator can fill areas with 1187706f2543Smrg image write data even if the value of x origin is negative (off of 1188706f2543Smrg the screen on the left edge). 1189706f2543Smrg 1190706f2543Smrg 1191706f2543Smrg2.8.1 The Direct Method 1192706f2543Smrg 1193706f2543Smrg Using the direct method of ImageWrite XAA will send all 1194706f2543Smrg bitmap data to the accelerator serially through an memory mapped 1195706f2543Smrg transfer window defined by the following two fields: 1196706f2543Smrg 1197706f2543Smrg unsigned char *ImageWriteBase 1198706f2543Smrg 1199706f2543Smrg This indicates the memory address of the beginning of the aperture. 1200706f2543Smrg 1201706f2543Smrg int ImageWriteRange 1202706f2543Smrg 1203706f2543Smrg This indicates the size in bytes of the aperture. 1204706f2543Smrg 1205706f2543Smrg The driver should specify how the transfered data should be padded. 1206706f2543Smrg There are options for both the padding of each Y scanline and for the 1207706f2543Smrg total transfer to the aperature. 1208706f2543Smrg One of the following two flags must be set: 1209706f2543Smrg 1210706f2543Smrg CPU_TRANSFER_PAD_DWORD 1211706f2543Smrg 1212706f2543Smrg This indicates that the total transfer (sum of all scanlines) sent 1213706f2543Smrg to the aperature must be DWORD padded. This is the default behavior. 1214706f2543Smrg 1215706f2543Smrg CPU_TRANSFER_PAD_QWORD 1216706f2543Smrg 1217706f2543Smrg This indicates that the total transfer (sum of all scanlines) sent 1218706f2543Smrg to the aperature must be QWORD padded. With this set, XAA will send 1219706f2543Smrg an extra DWORD to the aperature when needed to ensure that only 1220706f2543Smrg an even number of DWORDs are sent. 1221706f2543Smrg 1222706f2543Smrg And then there are the flags for padding of each scanline: 1223706f2543Smrg 1224706f2543Smrg SCANLINE_PAD_DWORD 1225706f2543Smrg 1226706f2543Smrg This indicates that each Y scanline should be DWORD padded. 1227706f2543Smrg This is the only option available and is the default. 1228706f2543Smrg 1229706f2543Smrg Finally, there is the CPU_TRANSFER_BASE_FIXED flag which indicates 1230706f2543Smrg that the aperture is a single register rather than a range of 1231706f2543Smrg registers, and XAA should write all of the data to the first DWORD. 1232706f2543Smrg XAA will automatically select CPU_TRANSFER_BASE_FIXED if the 1233706f2543Smrg ImageWriteRange is not large enough to accomodate an entire scanline. 1234706f2543Smrg 1235706f2543Smrg 1236706f2543Smrgvoid SetupForImageWrite(ScrnInfoPtr pScrn, int rop, unsigned int planemask, 1237706f2543Smrg int trans_color, int bpp, int depth) 1238706f2543Smrg 1239706f2543Smrg If trans_color is not -1 then trans_color indicates the transparency 1240706f2543Smrg color key and pixels with color trans_color passed through the 1241706f2543Smrg aperature should not be transfered to the screen but should be 1242706f2543Smrg skipped. Bpp and depth indicate the bits per pixel and depth of 1243706f2543Smrg the source pixmap. Trans_color is always -1 if the NO_TRANSPARENCY 1244706f2543Smrg flag is set. 1245706f2543Smrg 1246706f2543Smrg 1247706f2543Smrgvoid SubsequentImageWriteRect(ScrnInfoPtr pScrn, 1248706f2543Smrg int x, int y, int w, int h, int skipleft) 1249706f2543Smrg 1250706f2543Smrg 1251706f2543Smrg Data passed through the aperature should be copied to a rectangle 1252706f2543Smrg of width "w" and height "h" with origin (x,y). If LEFT_EDGE_CLIPPING 1253706f2543Smrg has been enabled, skipleft will correspond to the number of pixels 1254706f2543Smrg on the left edge that should not be drawn. Skipleft is zero 1255706f2543Smrg otherwise. 1256706f2543Smrg 1257706f2543Smrg It can be arranged for XAA to call Sync() after it is through 1258706f2543Smrg calling the Subsequent functions by setting SYNC_AFTER_IMAGE_WRITE 1259706f2543Smrg in the ImageWriteFlags. This can provide the driver with an 1260706f2543Smrg oportunity to reset a clipping window if needed. 1261706f2543Smrg 1262706f2543Smrg2.8.2 The Indirect Method 1263706f2543Smrg 1264706f2543Smrg Using the indirect method, XAA will render the pixel data scanline 1265706f2543Smrg at a time to one or more buffers. These buffers may be memory 1266706f2543Smrg mapped apertures or just intermediate storage. 1267706f2543Smrg 1268706f2543Smrg int NumScanlineImageWriteBuffers 1269706f2543Smrg 1270706f2543Smrg This indicates the number of buffers available. 1271706f2543Smrg 1272706f2543Smrg unsigned char **ScanlineImageWriteBuffers 1273706f2543Smrg 1274706f2543Smrg This is an array of pointers to the memory locations of each buffer. 1275706f2543Smrg Each buffer is expected to be large enough to accommodate scanlines 1276706f2543Smrg the width of the screen. That is: 1277706f2543Smrg 1278706f2543Smrg pScrn->VirtualX * pScreen->bitsPerPixel/8 bytes or more. 1279706f2543Smrg 1280706f2543Smrg If LEFT_EDGE_CLIPPING_NEGATIVE_X is set, add an additional 4 1281706f2543Smrg bytes to that requirement in 8 and 16bpp, 12 bytes in 24bpp. 1282706f2543Smrg 1283706f2543Smrg Scanlines are always DWORD padded. 1284706f2543Smrg 1285706f2543Smrgvoid SetupForScanlineImageWrite(ScrnInfoPtr pScrn, int rop, 1286706f2543Smrg unsigned int planemask, int trans_color, 1287706f2543Smrg int bpp, int depth) 1288706f2543Smrg 1289706f2543Smrg If trans_color is not -1 then trans_color indicates the transparency 1290706f2543Smrg color key and pixels with color trans_color in the buffer should not 1291706f2543Smrg be transfered to the screen but should be skipped. Bpp and depth 1292706f2543Smrg indicate the bits per pixel and depth of the source bitmap. 1293706f2543Smrg Trans_color is always -1 if the NO_TRANSPARENCY flag is set. 1294706f2543Smrg 1295706f2543Smrg 1296706f2543Smrgvoid SubsequentImageWriteRect(ScrnInfoPtr pScrn, 1297706f2543Smrg int x, int y, int w, int h, int skipleft) 1298706f2543Smrg 1299706f2543Smrg 1300706f2543Smrgvoid SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno) 1301706f2543Smrg 1302706f2543Smrg 1303706f2543Smrg When SubsequentImageWriteRect is called, XAA will begin 1304706f2543Smrg transfering the source data scanline at a time, calling 1305706f2543Smrg SubsequentImageWriteScanline after each scanline. If more than 1306706f2543Smrg one buffer is available, XAA will cycle through the buffers. 1307706f2543Smrg Subsequent scanlines will use the next buffer and go back to the 1308706f2543Smrg buffer 0 again when the last buffer is reached. The index into 1309706f2543Smrg the ScanlineImageWriteBuffers array is presented as "bufno" 1310706f2543Smrg with each SubsequentImageWriteScanline call. 1311706f2543Smrg 1312706f2543Smrg The skipleft field is the same as for the direct method. 1313706f2543Smrg 1314706f2543Smrg The indirect method can be use to send the source data directly 1315706f2543Smrg to a memory mapped aperture represented by a single image write 1316706f2543Smrg buffer, scanline at a time, but more commonly it is used to place 1317706f2543Smrg the data into offscreen video memory so that the accelerator can 1318706f2543Smrg blit it to the visible screen from there. In the case where the 1319706f2543Smrg accelerator permits rendering into offscreen video memory while 1320706f2543Smrg the accelerator is active, several buffers can be used so that 1321706f2543Smrg XAA can be placing source data into the next buffer while the 1322706f2543Smrg accelerator is blitting the current buffer. For cases where 1323706f2543Smrg the accelerator requires some special manipulation of the source 1324706f2543Smrg data first, the buffers can be in system memory. The CPU can 1325706f2543Smrg manipulate these buffers and then send the data to the accelerator. 1326706f2543Smrg 1327706f2543Smrg 1328706f2543Smrg2.9 Clipping 1329706f2543Smrg 1330706f2543Smrg XAA supports hardware clipping rectangles. To use clipping 1331706f2543Smrg in this way it is expected that the graphics accelerator can 1332706f2543Smrg clip primitives with verticies anywhere in the 16 bit signed 1333706f2543Smrg coordinate system. 1334706f2543Smrg 1335706f2543Smrgvoid SetClippingRectangle ( ScrnInfoPtr pScrn, 1336706f2543Smrg int left, int top, int right, int bottom) 1337706f2543Smrg 1338706f2543Smrgvoid DisableClipping (ScrnInfoPtr pScrn) 1339706f2543Smrg 1340706f2543Smrg When SetClippingRectangle is called, all hardware rendering 1341706f2543Smrg following it should be clipped to the rectangle specified 1342706f2543Smrg until DisableClipping is called. 1343706f2543Smrg 1344706f2543Smrg The ClippingFlags field indicates which operations this sort 1345706f2543Smrg of Set/Disable pairing can be used with. Any of the following 1346706f2543Smrg flags may be OR'd together. 1347706f2543Smrg 1348706f2543Smrg HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND 1349706f2543Smrg HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY 1350706f2543Smrg HARDWARE_CLIP_MONO_8x8_FILL 1351706f2543Smrg HARDWARE_CLIP_COLOR_8x8_FILL 1352706f2543Smrg HARDWARE_CLIP_SOLID_FILL 1353706f2543Smrg HARDWARE_CLIP_DASHED_LINE 1354706f2543Smrg HARDWARE_CLIP_SOLID_LINE 1355706f2543Smrg 1356706f2543Smrg 1357706f2543Smrg 1358706f2543Smrg3) XAA PIXMAP CACHE 1359706f2543Smrg 1360706f2543Smrg /* NOTE: XAA has no knowledge of framebuffer particulars so until 1361706f2543Smrg the framebuffer is able to render into offscreen memory, usage 1362706f2543Smrg of the pixmap cache requires that the driver provide ImageWrite 1363706f2543Smrg routines or a WritePixmap or WritePixmapToCache replacement so 1364706f2543Smrg that patterns can even be placed in the cache. 1365706f2543Smrg 1366706f2543Smrg ADDENDUM: XAA can now load the pixmap cache without requiring 1367706f2543Smrg that the driver supply an ImageWrite function, but this can 1368706f2543Smrg only be done on linear framebuffers. If you have a linear 1369706f2543Smrg framebuffer, set LINEAR_FRAMEBUFFER in the XAAInfoRec.Flags 1370706f2543Smrg field and XAA will then be able to upload pixmaps into the 1371706f2543Smrg cache without the driver providing functions to do so. 1372706f2543Smrg */ 1373706f2543Smrg 1374706f2543Smrg 1375706f2543Smrg The XAA pixmap cache provides a mechanism for caching of patterns 1376706f2543Smrg in offscreen video memory so that tiled fills and in some cases 1377706f2543Smrg stippling can be done by blitting the source patterns from offscreen 1378706f2543Smrg video memory. The pixmap cache also provides the mechanism for caching 1379706f2543Smrg of 8x8 color and mono hardware patterns. Any unused offscreen video 1380706f2543Smrg memory gets used for the pixmap cache and that information is 1381706f2543Smrg provided by the XFree86 Offscreen Memory Manager. XAA registers a 1382706f2543Smrg callback with the manager so that it can be informed of any changes 1383706f2543Smrg in the offscreen memory configuration. The driver writer does not 1384706f2543Smrg need to deal with any of this since it is all automatic. The driver 1385706f2543Smrg merely needs to initialize the Offscreen Memory Manager as described 1386706f2543Smrg in the DESIGN document and set the PIXMAP_CACHE flag in the 1387706f2543Smrg XAAInfoRec.Flags field. The Offscreen Memory Manager initialization 1388706f2543Smrg must occur before XAA is initialized or else pixmap cache 1389706f2543Smrg initialization will fail. 1390706f2543Smrg 1391706f2543Smrg PixmapCacheFlags is an XAAInfoRec field which allows the driver to 1392706f2543Smrg control pixmap cache behavior to some extent. Currently only one 1393706f2543Smrg flag is defined: 1394706f2543Smrg 1395706f2543Smrg DO_NOT_BLIT_STIPPLES 1396706f2543Smrg 1397706f2543Smrg This indicates that the stippling should not be done by blitting 1398706f2543Smrg from the pixmap cache. This does not apply to 8x8 pattern fills. 1399706f2543Smrg 1400706f2543Smrg 1401706f2543Smrg CachePixelGranularity is an optional field. If the hardware requires 1402706f2543Smrg that a 8x8 patterns have some particular pixel alignment it should 1403706f2543Smrg be reflected in this field. Ignoring this field or setting it to 1404706f2543Smrg zero or one means there are no alignment issues. 1405706f2543Smrg 1406706f2543Smrg 1407706f2543Smrg4) OFFSCREEN PIXMAPS 1408706f2543Smrg 1409706f2543Smrg XAA has the ability to store pixmap drawables in offscreen video 1410706f2543Smrg memory and render into them with full hardware acceleration. Placement 1411706f2543Smrg of pixmaps in the cache is done automatically on a first-come basis and 1412706f2543Smrg only if there is room. To enable this feature, set the OFFSCREEN_PIXMAPS 1413706f2543Smrg flag in the XAAInfoRec.Flags field. This is only available when a 1414706f2543Smrg ScreenToScreenCopy function is provided, when the Offscreen memory 1415706f2543Smrg manager has been initialized and when the LINEAR_FRAMEBUFFER flag is 1416706f2543Smrg also set. 1417706f2543Smrg 1418706f2543Smrg int maxOffPixWidth 1419706f2543Smrg int maxOffPixHeight 1420706f2543Smrg 1421706f2543Smrg These two fields allow the driver to limit the maximum dimensions 1422706f2543Smrg of an offscreen pixmap. If one of these is not set, it is assumed 1423706f2543Smrg that there is no limit on that dimension. Note that if an offscreen 1424706f2543Smrg pixmap with a particular dimension is allowed, then your driver will be 1425706f2543Smrg expected to render primitives as large as that pixmap. 1426706f2543Smrg 1427706f2543Smrg$XFree86: xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO,v 1.12 2000/04/12 14:44:42 tsi Exp $ 1428