1706f2543Smrg#ifdef HAVE_XORG_CONFIG_H
2706f2543Smrg#include <xorg-config.h>
3706f2543Smrg#endif
4706f2543Smrg
5706f2543Smrg#include <string.h>
6706f2543Smrg
7706f2543Smrg#include "misc.h"
8706f2543Smrg#include "xf86.h"
9706f2543Smrg#include "xf86_OSproc.h"
10706f2543Smrg
11706f2543Smrg#include <X11/X.h>
12706f2543Smrg#include "scrnintstr.h"
13706f2543Smrg#include "xf86str.h"
14706f2543Smrg#include "xaa.h"
15706f2543Smrg#include "xaalocal.h"
16706f2543Smrg#include "xf86fbman.h"
17706f2543Smrg#include "servermd.h"
18706f2543Smrg
19706f2543Smrg/*
20706f2543Smrg * XAA Config options
21706f2543Smrg */
22706f2543Smrg
23706f2543Smrgtypedef enum {
24706f2543Smrg    XAAOPT_SCREEN_TO_SCREEN_COPY,
25706f2543Smrg    XAAOPT_SOLID_FILL_RECT,
26706f2543Smrg    XAAOPT_SOLID_FILL_TRAP,
27706f2543Smrg    XAAOPT_SOLID_TWO_POINT_LINE,
28706f2543Smrg    XAAOPT_SOLID_BRESENHAM_LINE,
29706f2543Smrg    XAAOPT_SOLID_HORVERT_LINE,
30706f2543Smrg    XAAOPT_DASHED_TWO_POINT_LINE,
31706f2543Smrg    XAAOPT_DASHED_BRESENHAM_LINE,
32706f2543Smrg    XAAOPT_MONO_8x8_PATTERN_FILL_RECT,
33706f2543Smrg    XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,
34706f2543Smrg    XAAOPT_COL_8x8_PATTERN_FILL_RECT,
35706f2543Smrg    XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
36706f2543Smrg    XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
37706f2543Smrg    XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
38706f2543Smrg    XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
39706f2543Smrg    XAAOPT_IMAGE_WRITE_RECT,
40706f2543Smrg    XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
41706f2543Smrg    XAAOPT_WRITE_BITMAP,
42706f2543Smrg    XAAOPT_WRITE_PIXMAP,
43706f2543Smrg    XAAOPT_PIXMAP_CACHE,
44706f2543Smrg    XAAOPT_OFFSCREEN_PIXMAPS,
45706f2543Smrg    XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE
46706f2543Smrg} XAAOpts;
47706f2543Smrg
48706f2543Smrgstatic const OptionInfoRec XAAOptions[] = {
49706f2543Smrg    {XAAOPT_SCREEN_TO_SCREEN_COPY,	"XaaNoScreenToScreenCopy",
50706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
51706f2543Smrg    {XAAOPT_SOLID_FILL_RECT,		"XaaNoSolidFillRect",
52706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
53706f2543Smrg    {XAAOPT_SOLID_FILL_TRAP,		"XaaNoSolidFillTrap",
54706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
55706f2543Smrg    {XAAOPT_SOLID_TWO_POINT_LINE,	"XaaNoSolidTwoPointLine",
56706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
57706f2543Smrg    {XAAOPT_SOLID_BRESENHAM_LINE,	"XaaNoSolidBresenhamLine",
58706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
59706f2543Smrg    {XAAOPT_SOLID_HORVERT_LINE,		"XaaNoSolidHorVertLine",
60706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
61706f2543Smrg    {XAAOPT_DASHED_TWO_POINT_LINE,	"XaaNoDashedTwoPointLine",
62706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
63706f2543Smrg    {XAAOPT_DASHED_BRESENHAM_LINE,	"XaaNoDashedBresenhamLine",
64706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
65706f2543Smrg    {XAAOPT_MONO_8x8_PATTERN_FILL_RECT,	"XaaNoMono8x8PatternFillRect",
66706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
67706f2543Smrg    {XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,	"XaaNoMono8x8PatternFillTrap",
68706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
69706f2543Smrg    {XAAOPT_COL_8x8_PATTERN_FILL_RECT,	"XaaNoColor8x8PatternFillRect",
70706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
71706f2543Smrg    {XAAOPT_COL_8x8_PATTERN_FILL_TRAP,	"XaaNoColor8x8PatternFillTrap",
72706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
73706f2543Smrg    {XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,	"XaaNoCPUToScreenColorExpandFill",
74706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
75706f2543Smrg    {XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,"XaaNoScanlineCPUToScreenColorExpandFill",
76706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
77706f2543Smrg    {XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,	"XaaNoScreenToScreenColorExpandFill",
78706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
79706f2543Smrg    {XAAOPT_IMAGE_WRITE_RECT,		"XaaNoImageWriteRect",
80706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
81706f2543Smrg    {XAAOPT_SCANLINE_IMAGE_WRITE_RECT,	"XaaNoScanlineImageWriteRect",
82706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
83706f2543Smrg    {XAAOPT_WRITE_BITMAP,		"XaaNoWriteBitmap",
84706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
85706f2543Smrg    {XAAOPT_WRITE_PIXMAP,		"XaaNoWritePixmap",
86706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
87706f2543Smrg    {XAAOPT_PIXMAP_CACHE,		"XaaNoPixmapCache",
88706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
89706f2543Smrg    {XAAOPT_OFFSCREEN_PIXMAPS,		"XaaNoOffscreenPixmaps",
90706f2543Smrg				OPTV_BOOLEAN,	{0}, FALSE },
91706f2543Smrg    {XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE, "XaaOffscreenPixmaps",
92706f2543Smrg				OPTV_BOOLEAN,   {0}, FALSE },
93706f2543Smrg    { -1,				NULL,
94706f2543Smrg				OPTV_NONE,	{0}, FALSE }
95706f2543Smrg};
96706f2543Smrg
97706f2543Smrgstatic XF86ModuleVersionInfo xaaVersRec =
98706f2543Smrg{
99706f2543Smrg	"xaa",
100706f2543Smrg	MODULEVENDORSTRING,
101706f2543Smrg	MODINFOSTRING1,
102706f2543Smrg	MODINFOSTRING2,
103706f2543Smrg	XORG_VERSION_CURRENT,
104706f2543Smrg	XAA_VERSION_MAJOR,
105706f2543Smrg	XAA_VERSION_MINOR,
106706f2543Smrg	XAA_VERSION_RELEASE,
107706f2543Smrg	ABI_CLASS_VIDEODRV,		/* requires the video driver ABI */
108706f2543Smrg	ABI_VIDEODRV_VERSION,
109706f2543Smrg	MOD_CLASS_NONE,
110706f2543Smrg	{0,0,0,0}
111706f2543Smrg};
112706f2543Smrg
113706f2543Smrg_X_EXPORT XF86ModuleData xaaModuleData = { &xaaVersRec, NULL, NULL };
114706f2543Smrg
115706f2543SmrgBool
116706f2543SmrgXAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
117706f2543Smrg{
118706f2543Smrg    int index = pScreen->myNum;
119706f2543Smrg    ScrnInfoPtr pScrn = xf86Screens[index];
120706f2543Smrg    Bool HaveScreenToScreenCopy = FALSE;
121706f2543Smrg    Bool HaveColorExpansion = FALSE;
122706f2543Smrg    Bool HaveScanlineColorExpansion = FALSE;
123706f2543Smrg    Bool HaveSolidFillRect = FALSE;
124706f2543Smrg    Bool HaveMono8x8PatternFillRect = FALSE;
125706f2543Smrg    Bool HaveColor8x8PatternFillRect = FALSE;
126706f2543Smrg    Bool HaveSolidFillTrap = FALSE;
127706f2543Smrg    Bool HaveMono8x8PatternFillTrap = FALSE;
128706f2543Smrg    Bool HaveColor8x8PatternFillTrap = FALSE;
129706f2543Smrg    Bool HaveSolidTwoPointLine = FALSE;
130706f2543Smrg    Bool HaveSolidBresenhamLine = FALSE;
131706f2543Smrg    Bool HaveSolidHorVertLine = FALSE;
132706f2543Smrg    Bool HaveDashedTwoPointLine = FALSE;
133706f2543Smrg    Bool HaveDashedBresenhamLine = FALSE;
134706f2543Smrg    Bool HaveImageWriteRect = FALSE;
135706f2543Smrg    Bool HaveScanlineImageWriteRect = FALSE;
136706f2543Smrg    Bool HaveScreenToScreenColorExpandFill = FALSE;
137706f2543Smrg    OptionInfoPtr options;
138706f2543Smrg    int is_shared = 0;
139706f2543Smrg    int i;
140706f2543Smrg
141706f2543Smrg    options = xnfalloc(sizeof(XAAOptions));
142706f2543Smrg    (void)memcpy(options, XAAOptions, sizeof(XAAOptions));
143706f2543Smrg    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
144706f2543Smrg
145706f2543Smrg    infoRec->pScrn = pScrn;
146706f2543Smrg    infoRec->NeedToSync = FALSE;
147706f2543Smrg
148706f2543Smrg    /* must have a Sync function */
149706f2543Smrg    if(!infoRec->Sync) return FALSE;
150706f2543Smrg    for(i = 0; i < pScrn->numEntities; i++) {
151706f2543Smrg        if(xf86IsEntityShared(pScrn->entityList[i])) is_shared = 1;
152706f2543Smrg    }
153706f2543Smrg
154706f2543Smrg    /* If this PCI entity has IS_SHARED_ACCEL set in entityProp
155706f2543Smrg     * then a RestoreAccelState function is required
156706f2543Smrg     */
157706f2543Smrg    if(!infoRec->RestoreAccelState && is_shared) return FALSE;
158706f2543Smrg
159706f2543Smrg    if(infoRec->RestoreAccelState) {
160706f2543Smrg        if(!XAAInitStateWrap(pScreen, infoRec)) return FALSE;
161706f2543Smrg    }
162706f2543Smrg
163706f2543Smrg    if (serverGeneration == 1)
164706f2543Smrg	xf86DrvMsg(index, X_INFO,
165706f2543Smrg		"Using XFree86 Acceleration Architecture (XAA)\n");
166706f2543Smrg
167706f2543Smrg
168706f2543Smrg    /************** Low Level *************/
169706f2543Smrg
170706f2543Smrg    if(!infoRec->SetClippingRectangle || !infoRec->DisableClipping) {
171706f2543Smrg	infoRec->ClippingFlags = 0;
172706f2543Smrg	infoRec->SetClippingRectangle = NULL;
173706f2543Smrg	infoRec->DisableClipping = NULL;
174706f2543Smrg    }
175706f2543Smrg
176706f2543Smrg    /**** CopyArea ****/
177706f2543Smrg
178706f2543Smrg    if(infoRec->SetupForScreenToScreenCopy &&
179706f2543Smrg       infoRec->SubsequentScreenToScreenCopy &&
180706f2543Smrg       !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COPY, FALSE)) {
181706f2543Smrg	HaveScreenToScreenCopy = TRUE;
182706f2543Smrg    } else {
183706f2543Smrg	infoRec->ScreenToScreenCopyFlags = 0;
184706f2543Smrg	infoRec->SetupForScreenToScreenCopy = NULL;
185706f2543Smrg	infoRec->SubsequentScreenToScreenCopy = NULL;
186706f2543Smrg    }
187706f2543Smrg
188706f2543Smrg    /**** Solid Filled Rects ****/
189706f2543Smrg
190706f2543Smrg    if(infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect &&
191706f2543Smrg       !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_RECT, FALSE)) {
192706f2543Smrg		HaveSolidFillRect = TRUE;
193706f2543Smrg	if(infoRec->SubsequentSolidFillTrap &&
194706f2543Smrg	   !xf86ReturnOptValBool(options, XAAOPT_SOLID_FILL_TRAP, FALSE))
195706f2543Smrg		HaveSolidFillTrap = TRUE;
196706f2543Smrg	else
197706f2543Smrg		infoRec->SubsequentSolidFillTrap = NULL;
198706f2543Smrg    } else {
199706f2543Smrg	infoRec->SolidFillFlags = 0;
200706f2543Smrg	infoRec->SetupForSolidFill = NULL;
201706f2543Smrg	infoRec->SubsequentSolidFillRect = NULL;
202706f2543Smrg	infoRec->SubsequentSolidFillTrap = NULL;
203706f2543Smrg    }
204706f2543Smrg
205706f2543Smrg    /**** Solid lines ****/
206706f2543Smrg
207706f2543Smrg    if(infoRec->SetupForSolidLine) {
208706f2543Smrg	if(infoRec->SubsequentSolidTwoPointLine &&
209706f2543Smrg		!xf86ReturnOptValBool(options,
210706f2543Smrg		                      XAAOPT_SOLID_TWO_POINT_LINE, FALSE))
211706f2543Smrg	    HaveSolidTwoPointLine = TRUE;
212706f2543Smrg	if(infoRec->SubsequentSolidBresenhamLine &&
213706f2543Smrg		!xf86ReturnOptValBool(options, XAAOPT_SOLID_BRESENHAM_LINE, FALSE)) {
214706f2543Smrg	    HaveSolidBresenhamLine = TRUE;
215706f2543Smrg
216706f2543Smrg	    if(infoRec->SolidBresenhamLineErrorTermBits)
217706f2543Smrg		infoRec->SolidBresenhamLineErrorTermBits =
218706f2543Smrg			~((1 << infoRec->SolidBresenhamLineErrorTermBits) - 1);
219706f2543Smrg	}
220706f2543Smrg
221706f2543Smrg	if(infoRec->SubsequentSolidHorVertLine &&
222706f2543Smrg		!xf86ReturnOptValBool(options,
223706f2543Smrg		                      XAAOPT_SOLID_HORVERT_LINE, FALSE))
224706f2543Smrg	    HaveSolidHorVertLine = TRUE;
225706f2543Smrg	else if(HaveSolidTwoPointLine) {
226706f2543Smrg	    infoRec->SubsequentSolidHorVertLine =
227706f2543Smrg			XAASolidHorVertLineAsTwoPoint;
228706f2543Smrg	    HaveSolidHorVertLine = TRUE;
229706f2543Smrg	} else if(HaveSolidBresenhamLine) {
230706f2543Smrg	    infoRec->SubsequentSolidHorVertLine =
231706f2543Smrg			XAASolidHorVertLineAsBresenham;
232706f2543Smrg	    HaveSolidHorVertLine = TRUE;
233706f2543Smrg	}
234706f2543Smrg    }
235706f2543Smrg
236706f2543Smrg    /* XXX Should this also check for XAAOPT_SOLID_HORVERT_LINE? */
237706f2543Smrg    if (!HaveSolidTwoPointLine &&
238706f2543Smrg	!HaveSolidBresenhamLine &&
239706f2543Smrg	!HaveSolidHorVertLine &&
240706f2543Smrg	HaveSolidFillRect) {
241706f2543Smrg	infoRec->SetupForSolidLine = infoRec->SetupForSolidFill;
242706f2543Smrg	infoRec->SubsequentSolidHorVertLine = XAASolidHorVertLineAsRects;
243706f2543Smrg	infoRec->SolidLineFlags = infoRec->SolidFillFlags;
244706f2543Smrg	HaveSolidHorVertLine = TRUE;
245706f2543Smrg    }
246706f2543Smrg
247706f2543Smrg    if (!HaveSolidTwoPointLine)
248706f2543Smrg	infoRec->SubsequentSolidTwoPointLine = NULL;
249706f2543Smrg    if (!HaveSolidBresenhamLine)
250706f2543Smrg	infoRec->SubsequentSolidBresenhamLine = NULL;
251706f2543Smrg    if (!HaveSolidHorVertLine)
252706f2543Smrg	infoRec->SubsequentSolidHorVertLine = NULL;
253706f2543Smrg
254706f2543Smrg    /* Disable all if nothing left over */
255706f2543Smrg    if (!HaveSolidTwoPointLine &&
256706f2543Smrg	!HaveSolidBresenhamLine &&
257706f2543Smrg	!HaveSolidHorVertLine) {
258706f2543Smrg	infoRec->SolidLineFlags = 0;
259706f2543Smrg	infoRec->SetupForSolidLine = NULL;
260706f2543Smrg    }
261706f2543Smrg
262706f2543Smrg    /**** 8x8 Mono Pattern Filled Rects ****/
263706f2543Smrg
264706f2543Smrg   if(infoRec->SetupForMono8x8PatternFill &&
265706f2543Smrg		infoRec->SubsequentMono8x8PatternFillRect &&
266706f2543Smrg		!xf86ReturnOptValBool(options,
267706f2543Smrg		                      XAAOPT_MONO_8x8_PATTERN_FILL_RECT,
268706f2543Smrg		                      FALSE)) {
269706f2543Smrg	HaveMono8x8PatternFillRect = TRUE;
270706f2543Smrg	if(infoRec->SubsequentMono8x8PatternFillTrap &&
271706f2543Smrg		!xf86ReturnOptValBool(options,
272706f2543Smrg		                      XAAOPT_MONO_8x8_PATTERN_FILL_TRAP,
273706f2543Smrg		                      FALSE))
274706f2543Smrg		HaveMono8x8PatternFillTrap = TRUE;
275706f2543Smrg
276706f2543Smrg        if(infoRec->Mono8x8PatternFillFlags &
277706f2543Smrg				HARDWARE_PATTERN_PROGRAMMED_BITS) {
278706f2543Smrg	    infoRec->CanDoMono8x8 = TRUE;
279706f2543Smrg	} else {	/* others require caching */
280706f2543Smrg           int min_pitch;
281706f2543Smrg	   infoRec->PixmapCacheFlags |= CACHE_MONO_8x8;
282706f2543Smrg
283706f2543Smrg	   switch(pScrn->bitsPerPixel) {
284706f2543Smrg	   case 32: min_pitch = 2; break;
285706f2543Smrg	   case 24: min_pitch = 3; break;
286706f2543Smrg	   case 16: min_pitch = 4; break;
287706f2543Smrg	   default: min_pitch = 8; break;
288706f2543Smrg	   }
289706f2543Smrg
290706f2543Smrg           if(min_pitch > infoRec->MonoPatternPitch)
291706f2543Smrg		infoRec->MonoPatternPitch = min_pitch;
292706f2543Smrg
293706f2543Smrg	   if(infoRec->Mono8x8PatternFillFlags &
294706f2543Smrg				HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
295706f2543Smrg		if(!infoRec->CacheWidthMono8x8Pattern ||
296706f2543Smrg		   !infoRec->CacheHeightMono8x8Pattern) {
297706f2543Smrg			infoRec->CacheWidthMono8x8Pattern =
298706f2543Smrg						infoRec->MonoPatternPitch;
299706f2543Smrg			infoRec->CacheHeightMono8x8Pattern = 1;
300706f2543Smrg		}
301706f2543Smrg	   } else {
302706f2543Smrg		int numPerLine = 128/infoRec->MonoPatternPitch;
303706f2543Smrg
304706f2543Smrg		if(!infoRec->CacheWidthMono8x8Pattern ||
305706f2543Smrg		   !infoRec->CacheHeightMono8x8Pattern) {
306706f2543Smrg			infoRec->CacheWidthMono8x8Pattern =
307706f2543Smrg				numPerLine * infoRec->MonoPatternPitch;
308706f2543Smrg			infoRec->CacheHeightMono8x8Pattern =
309706f2543Smrg				(64 + numPerLine - 1)/numPerLine;
310706f2543Smrg		}
311706f2543Smrg	   }
312706f2543Smrg	}
313706f2543Smrg   } else {
314706f2543Smrg	infoRec->Mono8x8PatternFillFlags = 0;
315706f2543Smrg	infoRec->SetupForMono8x8PatternFill = NULL;
316706f2543Smrg	infoRec->SubsequentMono8x8PatternFillRect = NULL;
317706f2543Smrg   }
318706f2543Smrg
319706f2543Smrg    /**** Dashed lines ****/
320706f2543Smrg
321706f2543Smrg    if(infoRec->SetupForDashedLine && infoRec->DashPatternMaxLength) {
322706f2543Smrg	if(infoRec->SubsequentDashedTwoPointLine &&
323706f2543Smrg		!xf86ReturnOptValBool(options, XAAOPT_DASHED_TWO_POINT_LINE,
324706f2543Smrg		                      FALSE))
325706f2543Smrg	    HaveDashedTwoPointLine = TRUE;
326706f2543Smrg	if(infoRec->SubsequentDashedBresenhamLine &&
327706f2543Smrg		!xf86ReturnOptValBool(options, XAAOPT_DASHED_BRESENHAM_LINE,
328706f2543Smrg		                      FALSE)) {
329706f2543Smrg	    HaveDashedBresenhamLine = TRUE;
330706f2543Smrg
331706f2543Smrg	    if(infoRec->DashedBresenhamLineErrorTermBits)
332706f2543Smrg		infoRec->DashedBresenhamLineErrorTermBits =
333706f2543Smrg			~((1 << infoRec->DashedBresenhamLineErrorTermBits) - 1);
334706f2543Smrg	}
335706f2543Smrg    }
336706f2543Smrg
337706f2543Smrg    if (!HaveDashedTwoPointLine)
338706f2543Smrg	infoRec->SubsequentDashedTwoPointLine = NULL;
339706f2543Smrg    if (!HaveDashedBresenhamLine)
340706f2543Smrg	infoRec->SubsequentDashedBresenhamLine = NULL;
341706f2543Smrg
342706f2543Smrg    /* Disable all if nothing left over */
343706f2543Smrg    if (!HaveDashedTwoPointLine && !HaveDashedBresenhamLine) {
344706f2543Smrg	infoRec->DashedLineFlags = 0;
345706f2543Smrg	infoRec->SetupForDashedLine = NULL;
346706f2543Smrg    }
347706f2543Smrg
348706f2543Smrg    /**** 8x8 Color Pattern Filled Rects ****/
349706f2543Smrg
350706f2543Smrg   if(infoRec->SetupForColor8x8PatternFill &&
351706f2543Smrg      infoRec->SubsequentColor8x8PatternFillRect &&
352706f2543Smrg      !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_RECT, FALSE)) {
353706f2543Smrg	HaveColor8x8PatternFillRect = TRUE;
354706f2543Smrg	if(infoRec->SubsequentColor8x8PatternFillTrap &&
355706f2543Smrg	   !xf86ReturnOptValBool(options, XAAOPT_COL_8x8_PATTERN_FILL_TRAP,
356706f2543Smrg	                         FALSE))
357706f2543Smrg		HaveColor8x8PatternFillTrap = TRUE;
358706f2543Smrg	else
359706f2543Smrg		infoRec->SubsequentColor8x8PatternFillTrap = NULL;
360706f2543Smrg
361706f2543Smrg	infoRec->PixmapCacheFlags |= CACHE_COLOR_8x8;
362706f2543Smrg
363706f2543Smrg	if(infoRec->Color8x8PatternFillFlags &
364706f2543Smrg				HARDWARE_PATTERN_PROGRAMMED_ORIGIN) {
365706f2543Smrg	    if(!infoRec->CacheWidthColor8x8Pattern ||
366706f2543Smrg	       !infoRec->CacheHeightColor8x8Pattern) {
367706f2543Smrg		infoRec->CacheWidthColor8x8Pattern = 64;
368706f2543Smrg		infoRec->CacheHeightColor8x8Pattern = 1;
369706f2543Smrg	    }
370706f2543Smrg	} else {
371706f2543Smrg	    if(!infoRec->CacheWidthColor8x8Pattern ||
372706f2543Smrg	       !infoRec->CacheHeightColor8x8Pattern) {
373706f2543Smrg		infoRec->CacheWidthColor8x8Pattern = 128;
374706f2543Smrg		infoRec->CacheHeightColor8x8Pattern = 8;
375706f2543Smrg	    }
376706f2543Smrg	}
377706f2543Smrg   } else {
378706f2543Smrg	infoRec->Color8x8PatternFillFlags = 0;
379706f2543Smrg	infoRec->SetupForColor8x8PatternFill = NULL;
380706f2543Smrg	infoRec->SubsequentColor8x8PatternFillRect = NULL;
381706f2543Smrg	infoRec->SubsequentColor8x8PatternFillTrap = NULL;
382706f2543Smrg   }
383706f2543Smrg
384706f2543Smrg    /**** Color Expansion ****/
385706f2543Smrg
386706f2543Smrg    if(infoRec->SetupForCPUToScreenColorExpandFill &&
387706f2543Smrg	infoRec->ColorExpandBase &&
388706f2543Smrg       	infoRec->SubsequentCPUToScreenColorExpandFill &&
389706f2543Smrg        !xf86ReturnOptValBool(options, XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL,
390706f2543Smrg	                      FALSE)) {
391706f2543Smrg	int dwordsNeeded = pScrn->virtualX;
392706f2543Smrg
393706f2543Smrg	infoRec->ColorExpandRange >>= 2;	/* convert to DWORDS */
394706f2543Smrg	HaveColorExpansion = TRUE;
395706f2543Smrg
396706f2543Smrg	if(infoRec->CPUToScreenColorExpandFillFlags &
397706f2543Smrg				LEFT_EDGE_CLIPPING_NEGATIVE_X)
398706f2543Smrg	    dwordsNeeded += 31;
399706f2543Smrg	dwordsNeeded = (dwordsNeeded + 31) >> 5;
400706f2543Smrg	if(dwordsNeeded > infoRec->ColorExpandRange)
401706f2543Smrg	   infoRec->CPUToScreenColorExpandFillFlags |= CPU_TRANSFER_BASE_FIXED;
402706f2543Smrg    } else {
403706f2543Smrg	infoRec->CPUToScreenColorExpandFillFlags = 0;
404706f2543Smrg	infoRec->SetupForCPUToScreenColorExpandFill = NULL;
405706f2543Smrg	infoRec->SubsequentCPUToScreenColorExpandFill = NULL;
406706f2543Smrg    }
407706f2543Smrg
408706f2543Smrg    /**** Scanline Color Expansion ****/
409706f2543Smrg
410706f2543Smrg    if(infoRec->SetupForScanlineCPUToScreenColorExpandFill &&
411706f2543Smrg       infoRec->SubsequentScanlineCPUToScreenColorExpandFill &&
412706f2543Smrg       infoRec->SubsequentColorExpandScanline &&
413706f2543Smrg       infoRec->ScanlineColorExpandBuffers &&
414706f2543Smrg       (infoRec->NumScanlineColorExpandBuffers > 0) &&
415706f2543Smrg       !xf86ReturnOptValBool(options,
416706f2543Smrg                             XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL,
417706f2543Smrg                             FALSE)) {
418706f2543Smrg	HaveScanlineColorExpansion = TRUE;
419706f2543Smrg    } else {
420706f2543Smrg	infoRec->ScanlineCPUToScreenColorExpandFillFlags = 0;
421706f2543Smrg	infoRec->SetupForScanlineCPUToScreenColorExpandFill = NULL;
422706f2543Smrg	infoRec->SubsequentScanlineCPUToScreenColorExpandFill = NULL;
423706f2543Smrg	infoRec->SubsequentColorExpandScanline = NULL;
424706f2543Smrg    }
425706f2543Smrg
426706f2543Smrg    /**** Screen to Screen Color Expansion ****/
427706f2543Smrg
428706f2543Smrg    if(infoRec->SetupForScreenToScreenColorExpandFill &&
429706f2543Smrg       infoRec->SubsequentScreenToScreenColorExpandFill &&
430706f2543Smrg       !xf86ReturnOptValBool(options, XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
431706f2543Smrg                             FALSE)) {
432706f2543Smrg	HaveScreenToScreenColorExpandFill = TRUE;
433706f2543Smrg	if (!infoRec->CacheColorExpandDensity)
434706f2543Smrg	    infoRec->CacheColorExpandDensity = 1;
435706f2543Smrg    } else {
436706f2543Smrg	infoRec->ScreenToScreenColorExpandFillFlags = 0;
437706f2543Smrg	infoRec->SetupForScreenToScreenColorExpandFill = NULL;
438706f2543Smrg	infoRec->SubsequentScreenToScreenColorExpandFill = NULL;
439706f2543Smrg    }
440706f2543Smrg
441706f2543Smrg    /**** Image Writes ****/
442706f2543Smrg
443706f2543Smrg    if(infoRec->SetupForImageWrite && infoRec->ImageWriteBase &&
444706f2543Smrg       infoRec->SubsequentImageWriteRect &&
445706f2543Smrg       !xf86ReturnOptValBool(options, XAAOPT_IMAGE_WRITE_RECT, FALSE)) {
446706f2543Smrg
447706f2543Smrg	infoRec->ImageWriteRange >>= 2;	/* convert to DWORDS */
448706f2543Smrg	if(infoRec->ImageWriteFlags & CPU_TRANSFER_BASE_FIXED)
449706f2543Smrg	   infoRec->ImageWriteRange = 0;
450706f2543Smrg	HaveImageWriteRect = TRUE;
451706f2543Smrg    } else {
452706f2543Smrg	infoRec->ImageWriteFlags = 0;
453706f2543Smrg	infoRec->SetupForImageWrite = NULL;
454706f2543Smrg	infoRec->SubsequentImageWriteRect = NULL;
455706f2543Smrg    }
456706f2543Smrg
457706f2543Smrg    /**** Scanline Image Writes ****/
458706f2543Smrg
459706f2543Smrg    if(infoRec->SetupForScanlineImageWrite &&
460706f2543Smrg       infoRec->SubsequentScanlineImageWriteRect &&
461706f2543Smrg       infoRec->SubsequentImageWriteScanline &&
462706f2543Smrg       infoRec->ScanlineImageWriteBuffers &&
463706f2543Smrg       (infoRec->NumScanlineImageWriteBuffers > 0) &&
464706f2543Smrg       !xf86ReturnOptValBool(options, XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
465706f2543Smrg                             FALSE)) {
466706f2543Smrg	HaveScanlineImageWriteRect = TRUE;
467706f2543Smrg    } else {
468706f2543Smrg	infoRec->ScanlineImageWriteFlags = 0;
469706f2543Smrg	infoRec->SetupForScanlineImageWrite = NULL;
470706f2543Smrg	infoRec->SubsequentScanlineImageWriteRect = NULL;
471706f2543Smrg	infoRec->SubsequentImageWriteScanline = NULL;
472706f2543Smrg    }
473706f2543Smrg
474706f2543Smrg#ifndef __i386__
475706f2543Smrg   /* XAA makes some unaligned accesses when clipping is not available */
476706f2543Smrg#  define CLIP_FLAGS (LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X)
477706f2543Smrg   if(HaveImageWriteRect &&
478706f2543Smrg      ((infoRec->ImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS))
479706f2543Smrg   {
480706f2543Smrg        HaveImageWriteRect = FALSE;
481706f2543Smrg   }
482706f2543Smrg   if(HaveScanlineImageWriteRect &&
483706f2543Smrg      ((infoRec->ScanlineImageWriteFlags & CLIP_FLAGS) != CLIP_FLAGS))
484706f2543Smrg   {
485706f2543Smrg        HaveScanlineImageWriteRect = FALSE;
486706f2543Smrg   }
487706f2543Smrg#endif
488706f2543Smrg
489706f2543Smrg    if (serverGeneration == 1) {
490706f2543Smrg	if(HaveScreenToScreenCopy)
491706f2543Smrg	    xf86ErrorF("\tScreen to screen bit blits\n");
492706f2543Smrg	if(HaveSolidFillRect)
493706f2543Smrg	    xf86ErrorF("\tSolid filled rectangles\n");
494706f2543Smrg	if(HaveSolidFillTrap)
495706f2543Smrg	    xf86ErrorF("\tSolid filled trapezoids\n");
496706f2543Smrg	if(HaveMono8x8PatternFillRect)
497706f2543Smrg	    xf86ErrorF("\t8x8 mono pattern filled rectangles\n");
498706f2543Smrg	if(HaveMono8x8PatternFillTrap)
499706f2543Smrg	    xf86ErrorF("\t8x8 mono pattern filled trapezoids\n");
500706f2543Smrg	if(HaveColor8x8PatternFillRect)
501706f2543Smrg	    xf86ErrorF("\t8x8 color pattern filled rectangles\n");
502706f2543Smrg	if(HaveColor8x8PatternFillTrap)
503706f2543Smrg	    xf86ErrorF("\t8x8 color pattern filled trapezoids\n");
504706f2543Smrg
505706f2543Smrg	if(HaveColorExpansion)
506706f2543Smrg	    xf86ErrorF("\tCPU to Screen color expansion\n");
507706f2543Smrg	else if(HaveScanlineColorExpansion)
508706f2543Smrg	    xf86ErrorF("\tIndirect CPU to Screen color expansion\n");
509706f2543Smrg
510706f2543Smrg	if(HaveScreenToScreenColorExpandFill)
511706f2543Smrg	    xf86ErrorF("\tScreen to Screen color expansion\n");
512706f2543Smrg
513706f2543Smrg	if(HaveSolidTwoPointLine || HaveSolidBresenhamLine)
514706f2543Smrg	    xf86ErrorF("\tSolid Lines\n");
515706f2543Smrg	else if(HaveSolidHorVertLine)
516706f2543Smrg	    xf86ErrorF("\tSolid Horizontal and Vertical Lines\n");
517706f2543Smrg
518706f2543Smrg	if(HaveDashedTwoPointLine || HaveDashedBresenhamLine)
519706f2543Smrg	    xf86ErrorF("\tDashed Lines\n");
520706f2543Smrg
521706f2543Smrg	if(HaveImageWriteRect)
522706f2543Smrg	    xf86ErrorF("\tImage Writes\n");
523706f2543Smrg	else if(HaveScanlineImageWriteRect)
524706f2543Smrg	    xf86ErrorF("\tScanline Image Writes\n");
525706f2543Smrg
526706f2543Smrg    }
527706f2543Smrg
528706f2543Smrg#define XAAMSG(s) do { if (serverGeneration == 1) xf86ErrorF(s); } while (0)
529706f2543Smrg
530706f2543Smrg    if((infoRec->Flags & OFFSCREEN_PIXMAPS) && HaveScreenToScreenCopy &&
531706f2543Smrg		xf86ReturnOptValBool(options,
532706f2543Smrg				     XAAOPT_HAS_DUMB_INVERTED_OPTION_SENSE,
533706f2543Smrg				     FALSE))
534706f2543Smrg    {
535706f2543Smrg	XAAMSG("\tOffscreen Pixmaps\n");
536706f2543Smrg    } else {
537706f2543Smrg	infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
538706f2543Smrg    }
539706f2543Smrg
540706f2543Smrg
541706f2543Smrg    /************** Mid Level *************/
542706f2543Smrg
543706f2543Smrg    /**** ScreenToScreenBitBlt ****/
544706f2543Smrg
545706f2543Smrg    if(infoRec->ScreenToScreenBitBlt) {
546706f2543Smrg	XAAMSG("\tDriver provided ScreenToScreenBitBlt replacement\n");
547706f2543Smrg    } else if(HaveScreenToScreenCopy) {
548706f2543Smrg	infoRec->ScreenToScreenBitBlt = XAAScreenToScreenBitBlt;
549706f2543Smrg	infoRec->ScreenToScreenBitBltFlags = infoRec->ScreenToScreenCopyFlags;
550706f2543Smrg    }
551706f2543Smrg
552706f2543Smrg    /**** FillSolidRects ****/
553706f2543Smrg
554706f2543Smrg    if(infoRec->FillSolidRects) {
555706f2543Smrg	XAAMSG("\tDriver provided FillSolidRects replacement\n");
556706f2543Smrg    } else if(HaveSolidFillRect) {
557706f2543Smrg	infoRec->FillSolidRects = XAAFillSolidRects;
558706f2543Smrg	infoRec->FillSolidRectsFlags = infoRec->SolidFillFlags;
559706f2543Smrg    }
560706f2543Smrg
561706f2543Smrg    /**** FillSolidSpans ****/
562706f2543Smrg
563706f2543Smrg    if(infoRec->FillSolidSpans) {
564706f2543Smrg	XAAMSG("\tDriver provided FillSolidSpans replacement\n");
565706f2543Smrg    } else if(HaveSolidFillRect) {
566706f2543Smrg	infoRec->FillSolidSpans = XAAFillSolidSpans;
567706f2543Smrg	infoRec->FillSolidSpansFlags = infoRec->SolidFillFlags;
568706f2543Smrg    }
569706f2543Smrg
570706f2543Smrg    /**** FillMono8x8PatternRects ****/
571706f2543Smrg
572706f2543Smrg    if(infoRec->FillMono8x8PatternRects) {
573706f2543Smrg	XAAMSG("\tDriver provided FillMono8x8PatternRects replacement\n");
574706f2543Smrg    } else if(HaveMono8x8PatternFillRect) {
575706f2543Smrg	infoRec->FillMono8x8PatternRects =
576706f2543Smrg	  (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
577706f2543Smrg	  XAAFillMono8x8PatternRectsScreenOrigin :
578706f2543Smrg	  XAAFillMono8x8PatternRects;
579706f2543Smrg
580706f2543Smrg	infoRec->FillMono8x8PatternRectsFlags =
581706f2543Smrg			infoRec->Mono8x8PatternFillFlags;
582706f2543Smrg    }
583706f2543Smrg
584706f2543Smrg    /**** FillMono8x8PatternSpans ****/
585706f2543Smrg
586706f2543Smrg    if(infoRec->FillMono8x8PatternSpans) {
587706f2543Smrg	XAAMSG("\tDriver provided FillMono8x8PatternSpans replacement\n");
588706f2543Smrg    } else if(HaveMono8x8PatternFillRect) {
589706f2543Smrg	infoRec->FillMono8x8PatternSpans =
590706f2543Smrg	  (infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
591706f2543Smrg	  XAAFillMono8x8PatternSpansScreenOrigin:
592706f2543Smrg	  XAAFillMono8x8PatternSpans;
593706f2543Smrg
594706f2543Smrg	infoRec->FillMono8x8PatternSpansFlags =
595706f2543Smrg		infoRec->Mono8x8PatternFillFlags;
596706f2543Smrg    }
597706f2543Smrg
598706f2543Smrg    /**** FillColor8x8Rects ****/
599706f2543Smrg
600706f2543Smrg    if(infoRec->FillColor8x8PatternRects) {
601706f2543Smrg	XAAMSG("\tDriver provided FillColor8x8PatternRects replacement\n");
602706f2543Smrg    } else if(HaveColor8x8PatternFillRect) {
603706f2543Smrg	infoRec->FillColor8x8PatternRects =
604706f2543Smrg	  (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
605706f2543Smrg	  XAAFillColor8x8PatternRectsScreenOrigin :
606706f2543Smrg	  XAAFillColor8x8PatternRects;
607706f2543Smrg
608706f2543Smrg	infoRec->FillColor8x8PatternRectsFlags =
609706f2543Smrg			infoRec->Color8x8PatternFillFlags;
610706f2543Smrg    }
611706f2543Smrg
612706f2543Smrg    /**** FillColor8x8Spans ****/
613706f2543Smrg
614706f2543Smrg    if(infoRec->FillColor8x8PatternSpans) {
615706f2543Smrg	XAAMSG("\tDriver provided FillColor8x8PatternSpans replacement\n");
616706f2543Smrg    } else if(HaveColor8x8PatternFillRect) {
617706f2543Smrg	infoRec->FillColor8x8PatternSpans =
618706f2543Smrg	  (infoRec->Color8x8PatternFillFlags & HARDWARE_PATTERN_SCREEN_ORIGIN) ?
619706f2543Smrg	  XAAFillColor8x8PatternSpansScreenOrigin:
620706f2543Smrg	  XAAFillColor8x8PatternSpans;
621706f2543Smrg
622706f2543Smrg	infoRec->FillColor8x8PatternSpansFlags =
623706f2543Smrg		infoRec->Color8x8PatternFillFlags;
624706f2543Smrg    }
625706f2543Smrg
626706f2543Smrg    /**** FillCacheBltRects ****/
627706f2543Smrg
628706f2543Smrg    if(infoRec->FillCacheBltRects) {
629706f2543Smrg	XAAMSG("\tDriver provided FillCacheBltRects replacement\n");
630706f2543Smrg    } else if(HaveScreenToScreenCopy) {
631706f2543Smrg	infoRec->FillCacheBltRects = XAAFillCacheBltRects;
632706f2543Smrg	infoRec->FillCacheBltRectsFlags = infoRec->ScreenToScreenCopyFlags;
633706f2543Smrg    }
634706f2543Smrg
635706f2543Smrg    /**** FillCacheBltSpans ****/
636706f2543Smrg
637706f2543Smrg    if(infoRec->FillCacheBltSpans) {
638706f2543Smrg	XAAMSG("\tDriver provided FillCacheBltSpans replacement\n");
639706f2543Smrg    } else if(HaveScreenToScreenCopy) {
640706f2543Smrg	infoRec->FillCacheBltSpans = XAAFillCacheBltSpans;
641706f2543Smrg	infoRec->FillCacheBltSpansFlags = infoRec->ScreenToScreenCopyFlags;
642706f2543Smrg    }
643706f2543Smrg
644706f2543Smrg    /**** FillCacheExpandRects ****/
645706f2543Smrg
646706f2543Smrg    if(infoRec->FillCacheExpandRects) {
647706f2543Smrg	XAAMSG("\tDriver provided FillCacheExpandRects replacement\n");
648706f2543Smrg    } else if(HaveScreenToScreenColorExpandFill) {
649706f2543Smrg	infoRec->FillCacheExpandRects = XAAFillCacheExpandRects;
650706f2543Smrg	infoRec->FillCacheExpandRectsFlags =
651706f2543Smrg		infoRec->ScreenToScreenColorExpandFillFlags;
652706f2543Smrg    }
653706f2543Smrg
654706f2543Smrg    /**** FillCacheExpandSpans ****/
655706f2543Smrg
656706f2543Smrg    if(infoRec->FillCacheExpandSpans) {
657706f2543Smrg	XAAMSG("\tDriver provided FillCacheExpandSpans replacement\n");
658706f2543Smrg    } else if(HaveScreenToScreenColorExpandFill) {
659706f2543Smrg	infoRec->FillCacheExpandSpans = XAAFillCacheExpandSpans;
660706f2543Smrg	infoRec->FillCacheExpandSpansFlags =
661706f2543Smrg		infoRec->ScreenToScreenColorExpandFillFlags;
662706f2543Smrg    }
663706f2543Smrg
664706f2543Smrg    /**** FillColorExpandRects ****/
665706f2543Smrg
666706f2543Smrg    if(infoRec->FillColorExpandRects) {
667706f2543Smrg	XAAMSG("\tDriver provided FillColorExpandRects replacement\n");
668706f2543Smrg    } else if(HaveColorExpansion) {
669706f2543Smrg	if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
670706f2543Smrg	    if(infoRec->CPUToScreenColorExpandFillFlags &
671706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST) {
672706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
673706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
674706f2543Smrg		    infoRec->FillColorExpandRects =
675706f2543Smrg			XAAFillColorExpandRects3MSBFirstFixedBase;
676706f2543Smrg		else
677706f2543Smrg		    infoRec->FillColorExpandRects =
678706f2543Smrg			XAAFillColorExpandRects3MSBFirst;
679706f2543Smrg	    } else {
680706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
681706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
682706f2543Smrg		    infoRec->FillColorExpandRects =
683706f2543Smrg			XAAFillColorExpandRects3LSBFirstFixedBase;
684706f2543Smrg		else
685706f2543Smrg		    infoRec->FillColorExpandRects =
686706f2543Smrg			XAAFillColorExpandRects3LSBFirst;
687706f2543Smrg	    }
688706f2543Smrg	} else {
689706f2543Smrg	    if(infoRec->CPUToScreenColorExpandFillFlags &
690706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST) {
691706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
692706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
693706f2543Smrg		    infoRec->FillColorExpandRects =
694706f2543Smrg			XAAFillColorExpandRectsMSBFirstFixedBase;
695706f2543Smrg		else
696706f2543Smrg		    infoRec->FillColorExpandRects =
697706f2543Smrg				XAAFillColorExpandRectsMSBFirst;
698706f2543Smrg	    } else {
699706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
700706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
701706f2543Smrg		    infoRec->FillColorExpandRects =
702706f2543Smrg			XAAFillColorExpandRectsLSBFirstFixedBase;
703706f2543Smrg		else
704706f2543Smrg		    infoRec->FillColorExpandRects =
705706f2543Smrg			XAAFillColorExpandRectsLSBFirst;
706706f2543Smrg	    }
707706f2543Smrg	}
708706f2543Smrg	infoRec->FillColorExpandRectsFlags =
709706f2543Smrg	    infoRec->CPUToScreenColorExpandFillFlags;
710706f2543Smrg    } else if(HaveScanlineColorExpansion) {
711706f2543Smrg	if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
712706f2543Smrg					TRIPLE_BITS_24BPP) {
713706f2543Smrg	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
714706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST)
715706f2543Smrg		infoRec->FillColorExpandRects =
716706f2543Smrg		    XAAFillScanlineColorExpandRects3MSBFirst;
717706f2543Smrg	    else
718706f2543Smrg		infoRec->FillColorExpandRects =
719706f2543Smrg		    XAAFillScanlineColorExpandRects3LSBFirst;
720706f2543Smrg	} else {
721706f2543Smrg	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
722706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST)
723706f2543Smrg		infoRec->FillColorExpandRects =
724706f2543Smrg		    XAAFillScanlineColorExpandRectsMSBFirst;
725706f2543Smrg	    else
726706f2543Smrg		infoRec->FillColorExpandRects =
727706f2543Smrg		    XAAFillScanlineColorExpandRectsLSBFirst;
728706f2543Smrg	}
729706f2543Smrg	infoRec->FillColorExpandRectsFlags =
730706f2543Smrg	    infoRec->ScanlineCPUToScreenColorExpandFillFlags;
731706f2543Smrg    }
732706f2543Smrg
733706f2543Smrg    /**** FillColorExpandSpans ****/
734706f2543Smrg
735706f2543Smrg    if(infoRec->FillColorExpandSpans) {
736706f2543Smrg	XAAMSG("\tDriver provided FillColorExpandSpans replacement\n");
737706f2543Smrg    } else if(HaveColorExpansion) {
738706f2543Smrg	if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
739706f2543Smrg	    if(infoRec->CPUToScreenColorExpandFillFlags &
740706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST) {
741706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
742706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
743706f2543Smrg		    infoRec->FillColorExpandSpans =
744706f2543Smrg			XAAFillColorExpandSpans3MSBFirstFixedBase;
745706f2543Smrg		else
746706f2543Smrg		    infoRec->FillColorExpandSpans =
747706f2543Smrg			XAAFillColorExpandSpans3MSBFirst;
748706f2543Smrg	    } else {
749706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
750706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
751706f2543Smrg		    infoRec->FillColorExpandSpans =
752706f2543Smrg			XAAFillColorExpandSpans3LSBFirstFixedBase;
753706f2543Smrg		else
754706f2543Smrg		    infoRec->FillColorExpandSpans =
755706f2543Smrg			XAAFillColorExpandSpans3LSBFirst;
756706f2543Smrg	    }
757706f2543Smrg	} else {
758706f2543Smrg	    if(infoRec->CPUToScreenColorExpandFillFlags &
759706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST) {
760706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
761706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
762706f2543Smrg		    infoRec->FillColorExpandSpans =
763706f2543Smrg			XAAFillColorExpandSpansMSBFirstFixedBase;
764706f2543Smrg		else
765706f2543Smrg		    infoRec->FillColorExpandSpans =
766706f2543Smrg				XAAFillColorExpandSpansMSBFirst;
767706f2543Smrg	    } else {
768706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
769706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
770706f2543Smrg		    infoRec->FillColorExpandSpans =
771706f2543Smrg			XAAFillColorExpandSpansLSBFirstFixedBase;
772706f2543Smrg		else
773706f2543Smrg		    infoRec->FillColorExpandSpans =
774706f2543Smrg			XAAFillColorExpandSpansLSBFirst;
775706f2543Smrg	    }
776706f2543Smrg	}
777706f2543Smrg	infoRec->FillColorExpandSpansFlags =
778706f2543Smrg	    infoRec->CPUToScreenColorExpandFillFlags;
779706f2543Smrg    } else if(HaveScanlineColorExpansion) {
780706f2543Smrg	if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
781706f2543Smrg					TRIPLE_BITS_24BPP) {
782706f2543Smrg	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
783706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST)
784706f2543Smrg		infoRec->FillColorExpandSpans =
785706f2543Smrg		    XAAFillScanlineColorExpandSpans3MSBFirst;
786706f2543Smrg	    else
787706f2543Smrg		infoRec->FillColorExpandSpans =
788706f2543Smrg		    XAAFillScanlineColorExpandSpans3LSBFirst;
789706f2543Smrg	} else {
790706f2543Smrg	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
791706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST)
792706f2543Smrg		infoRec->FillColorExpandSpans =
793706f2543Smrg		    XAAFillScanlineColorExpandSpansMSBFirst;
794706f2543Smrg	    else
795706f2543Smrg		infoRec->FillColorExpandSpans =
796706f2543Smrg		    XAAFillScanlineColorExpandSpansLSBFirst;
797706f2543Smrg	}
798706f2543Smrg	infoRec->FillColorExpandSpansFlags =
799706f2543Smrg	    infoRec->ScanlineCPUToScreenColorExpandFillFlags;
800706f2543Smrg    }
801706f2543Smrg
802706f2543Smrg    /**** FillImageWriteRects ****/
803706f2543Smrg
804706f2543Smrg    if(infoRec->FillImageWriteRects) {
805706f2543Smrg	XAAMSG("\tDriver provided FillImageWriteRects replacement\n");
806706f2543Smrg    } else if(HaveImageWriteRect &&
807706f2543Smrg		(infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
808706f2543Smrg		(infoRec->ImageWriteFlags & LEFT_EDGE_CLIPPING)) {
809706f2543Smrg	infoRec->FillImageWriteRects = XAAFillImageWriteRects;
810706f2543Smrg	infoRec->FillImageWriteRectsFlags = infoRec->ImageWriteFlags;
811706f2543Smrg    }
812706f2543Smrg
813706f2543Smrg    /**** FillScanlineImageWriteRects ****/
814706f2543Smrg
815706f2543Smrg    if(!infoRec->FillImageWriteRects) {
816706f2543Smrg        if(HaveScanlineImageWriteRect &&
817706f2543Smrg               (infoRec->ScanlineImageWriteFlags &
818706f2543Smrg                LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
819706f2543Smrg               (infoRec->ScanlineImageWriteFlags & LEFT_EDGE_CLIPPING)) {
820706f2543Smrg           infoRec->FillImageWriteRects = XAAFillScanlineImageWriteRects;
821706f2543Smrg           infoRec->FillImageWriteRectsFlags =
822706f2543Smrg               infoRec->ScanlineImageWriteFlags;
823706f2543Smrg       }
824706f2543Smrg    }
825706f2543Smrg
826706f2543Smrg    /**** WriteBitmap ****/
827706f2543Smrg
828706f2543Smrg    if(infoRec->WriteBitmap &&
829706f2543Smrg      !xf86ReturnOptValBool(options, XAAOPT_WRITE_BITMAP, FALSE)) {
830706f2543Smrg	XAAMSG("\tDriver provided WriteBitmap replacement\n");
831706f2543Smrg    } else if(HaveColorExpansion) {
832706f2543Smrg	if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
833706f2543Smrg	    if(infoRec->CPUToScreenColorExpandFillFlags &
834706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST) {
835706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
836706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
837706f2543Smrg		    infoRec->WriteBitmap =
838706f2543Smrg			XAAWriteBitmapColorExpand3MSBFirstFixedBase;
839706f2543Smrg		else
840706f2543Smrg		    infoRec->WriteBitmap = XAAWriteBitmapColorExpand3MSBFirst;
841706f2543Smrg	    } else {
842706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
843706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
844706f2543Smrg		    infoRec->WriteBitmap =
845706f2543Smrg			XAAWriteBitmapColorExpand3LSBFirstFixedBase;
846706f2543Smrg		else
847706f2543Smrg		    infoRec->WriteBitmap = XAAWriteBitmapColorExpand3LSBFirst;
848706f2543Smrg	    }
849706f2543Smrg	} else {
850706f2543Smrg	    if(infoRec->CPUToScreenColorExpandFillFlags &
851706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST) {
852706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
853706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
854706f2543Smrg		    infoRec->WriteBitmap =
855706f2543Smrg			XAAWriteBitmapColorExpandMSBFirstFixedBase;
856706f2543Smrg		else
857706f2543Smrg		    infoRec->WriteBitmap = XAAWriteBitmapColorExpandMSBFirst;
858706f2543Smrg	    } else {
859706f2543Smrg		if(infoRec->CPUToScreenColorExpandFillFlags &
860706f2543Smrg					CPU_TRANSFER_BASE_FIXED)
861706f2543Smrg		    infoRec->WriteBitmap =
862706f2543Smrg			XAAWriteBitmapColorExpandLSBFirstFixedBase;
863706f2543Smrg		else
864706f2543Smrg		    infoRec->WriteBitmap = XAAWriteBitmapColorExpandLSBFirst;
865706f2543Smrg	    }
866706f2543Smrg	}
867706f2543Smrg	infoRec->WriteBitmapFlags = infoRec->CPUToScreenColorExpandFillFlags;
868706f2543Smrg    } else if(HaveScanlineColorExpansion) {
869706f2543Smrg	if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
870706f2543Smrg					TRIPLE_BITS_24BPP) {
871706f2543Smrg	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
872706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST)
873706f2543Smrg		infoRec->WriteBitmap =
874706f2543Smrg		    XAAWriteBitmapScanlineColorExpand3MSBFirst;
875706f2543Smrg	    else
876706f2543Smrg		infoRec->WriteBitmap =
877706f2543Smrg		    XAAWriteBitmapScanlineColorExpand3LSBFirst;
878706f2543Smrg	} else {
879706f2543Smrg	    if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
880706f2543Smrg					BIT_ORDER_IN_BYTE_MSBFIRST)
881706f2543Smrg		infoRec->WriteBitmap =
882706f2543Smrg		    XAAWriteBitmapScanlineColorExpandMSBFirst;
883706f2543Smrg	    else
884706f2543Smrg		infoRec->WriteBitmap =
885706f2543Smrg		    XAAWriteBitmapScanlineColorExpandLSBFirst;
886706f2543Smrg	}
887706f2543Smrg	infoRec->WriteBitmapFlags =
888706f2543Smrg		infoRec->ScanlineCPUToScreenColorExpandFillFlags;
889706f2543Smrg    } else
890706f2543Smrg	infoRec->WriteBitmap = NULL;
891706f2543Smrg
892706f2543Smrg    /**** TE Glyphs ****/
893706f2543Smrg
894706f2543Smrg    if (infoRec->TEGlyphRenderer) {
895706f2543Smrg	XAAMSG("\tDriver provided TEGlyphRenderer replacement\n");
896706f2543Smrg    } else if (HaveColorExpansion) {
897706f2543Smrg	infoRec->TEGlyphRendererFlags =
898706f2543Smrg	    infoRec->CPUToScreenColorExpandFillFlags;
899706f2543Smrg
900706f2543Smrg	if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
901706f2543Smrg	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
902706f2543Smrg		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
903706f2543Smrg		    infoRec->TEGlyphRenderer =
904706f2543Smrg			XAATEGlyphRenderer3MSBFirstFixedBase;
905706f2543Smrg		else
906706f2543Smrg		    infoRec->TEGlyphRenderer = XAATEGlyphRenderer3MSBFirst;
907706f2543Smrg	    } else {
908706f2543Smrg		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
909706f2543Smrg		    infoRec->TEGlyphRenderer =
910706f2543Smrg			XAATEGlyphRenderer3LSBFirstFixedBase;
911706f2543Smrg		else
912706f2543Smrg		    infoRec->TEGlyphRenderer = XAATEGlyphRenderer3LSBFirst;
913706f2543Smrg	    }
914706f2543Smrg
915706f2543Smrg	    if (!HaveSolidFillRect &&
916706f2543Smrg		(infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
917706f2543Smrg		infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
918706f2543Smrg		XAAMSG("WARNING:  TEGlyphRenderer cannot support RGB_EQUAL"
919706f2543Smrg		       " without solid fills\n");
920706f2543Smrg	    }
921706f2543Smrg	} else {
922706f2543Smrg	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
923706f2543Smrg		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
924706f2543Smrg		    infoRec->TEGlyphRenderer =
925706f2543Smrg			XAATEGlyphRendererMSBFirstFixedBase;
926706f2543Smrg		else
927706f2543Smrg		    infoRec->TEGlyphRenderer = XAATEGlyphRendererMSBFirst;
928706f2543Smrg	    } else {
929706f2543Smrg		if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
930706f2543Smrg		    infoRec->TEGlyphRenderer =
931706f2543Smrg			XAATEGlyphRendererLSBFirstFixedBase;
932706f2543Smrg		else
933706f2543Smrg		    infoRec->TEGlyphRenderer = XAATEGlyphRendererLSBFirst;
934706f2543Smrg	    }
935706f2543Smrg	}
936706f2543Smrg
937706f2543Smrg	if (!HaveSolidFillRect &&
938706f2543Smrg	    (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
939706f2543Smrg	    infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
940706f2543Smrg	    XAAMSG("WARNING:  TEGlyphRenderer cannot support TRANPARENCY_ONLY"
941706f2543Smrg		   " without solid fills\n");
942706f2543Smrg	}
943706f2543Smrg
944706f2543Smrg    } else if (HaveScanlineColorExpansion) {
945706f2543Smrg	infoRec->TEGlyphRendererFlags =
946706f2543Smrg	    infoRec->ScanlineCPUToScreenColorExpandFillFlags;
947706f2543Smrg
948706f2543Smrg	if (infoRec->TEGlyphRendererFlags & TRIPLE_BITS_24BPP) {
949706f2543Smrg	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
950706f2543Smrg		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3MSBFirst;
951706f2543Smrg	    else
952706f2543Smrg		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanline3LSBFirst;
953706f2543Smrg
954706f2543Smrg	    if (!HaveSolidFillRect &&
955706f2543Smrg		(infoRec->TEGlyphRendererFlags & RGB_EQUAL)) {
956706f2543Smrg		infoRec->TEGlyphRendererFlags &= ~RGB_EQUAL;
957706f2543Smrg		XAAMSG("WARNING:  TEGlyphRenderer cannot support RGB_EQUAL"
958706f2543Smrg		       " without solid fills\n");
959706f2543Smrg	    }
960706f2543Smrg	} else {
961706f2543Smrg	    if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
962706f2543Smrg		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineMSBFirst;
963706f2543Smrg	    else
964706f2543Smrg		infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineLSBFirst;
965706f2543Smrg	}
966706f2543Smrg
967706f2543Smrg	if (!HaveSolidFillRect &&
968706f2543Smrg	    (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
969706f2543Smrg	    infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
970706f2543Smrg	    XAAMSG("WARNING:  TEGlyphRenderer cannot support TRANPARENCY_ONLY"
971706f2543Smrg		   " without solid fills\n");
972706f2543Smrg	}
973706f2543Smrg    }
974706f2543Smrg
975706f2543Smrg    /**** NonTE Glyphs ****/
976706f2543Smrg
977706f2543Smrg    if(infoRec->NonTEGlyphRenderer) {
978706f2543Smrg	XAAMSG("\tDriver provided NonTEGlyphRenderer replacement\n");
979706f2543Smrg    } else if(infoRec->WriteBitmap &&
980706f2543Smrg	!(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
981706f2543Smrg	infoRec->NonTEGlyphRenderer = XAANonTEGlyphRenderer;
982706f2543Smrg	infoRec->NonTEGlyphRendererFlags = infoRec->WriteBitmapFlags;
983706f2543Smrg    }
984706f2543Smrg
985706f2543Smrg    /**** WritePixmap ****/
986706f2543Smrg
987706f2543Smrg    if(infoRec->WritePixmap &&
988706f2543Smrg      !xf86ReturnOptValBool(options, XAAOPT_WRITE_PIXMAP, FALSE)) {
989706f2543Smrg	XAAMSG("\tDriver provided WritePixmap replacement\n");
990706f2543Smrg    } else if(HaveImageWriteRect) {
991706f2543Smrg	infoRec->WritePixmap = XAAWritePixmap;
992706f2543Smrg	infoRec->WritePixmapFlags =
993706f2543Smrg		infoRec->ImageWriteFlags | CONVERT_32BPP_TO_24BPP;
994706f2543Smrg    } else if(HaveScanlineImageWriteRect) {
995706f2543Smrg	infoRec->WritePixmap = XAAWritePixmapScanline;
996706f2543Smrg	infoRec->WritePixmapFlags = infoRec->ScanlineImageWriteFlags;
997706f2543Smrg    } else
998706f2543Smrg	infoRec->WritePixmap = NULL;
999706f2543Smrg
1000706f2543Smrg    /**** ReadPixmap ****/
1001706f2543Smrg
1002706f2543Smrg    if(infoRec->ReadPixmap) {
1003706f2543Smrg	XAAMSG("\tDriver provided ReadPixmap replacement\n");
1004706f2543Smrg    }
1005706f2543Smrg
1006706f2543Smrg
1007706f2543Smrg    /************** GC Level *************/
1008706f2543Smrg
1009706f2543Smrg    /**** CopyArea ****/
1010706f2543Smrg
1011706f2543Smrg    if(infoRec->CopyArea) {
1012706f2543Smrg	XAAMSG("\tDriver provided GC level CopyArea replacement\n");
1013706f2543Smrg    } else if(infoRec->ScreenToScreenBitBlt) {
1014706f2543Smrg	infoRec->CopyArea = XAACopyArea;
1015706f2543Smrg	infoRec->CopyAreaFlags = infoRec->ScreenToScreenBitBltFlags;
1016706f2543Smrg
1017706f2543Smrg	/* most GC level primitives use one mid-level primitive so
1018706f2543Smrg	   the GC level primitive gets the mid-level primitive flag
1019706f2543Smrg	   and we use that at GC validation time.  But CopyArea uses
1020706f2543Smrg	   more than one mid-level primitive so we have to essentially
1021706f2543Smrg	   do a GC validation every time that primitive is used.
1022706f2543Smrg	   The CopyAreaFlags would only be used for filtering out the
1023706f2543Smrg	   common denominators.  Here we assume that if you don't do
1024706f2543Smrg	   ScreenToScreenBitBlt you aren't going to do the others.
1025706f2543Smrg	   We also assume that ScreenToScreenBitBlt has the least
1026706f2543Smrg	   restrictions. */
1027706f2543Smrg    }
1028706f2543Smrg
1029706f2543Smrg    if(infoRec->CopyPlane) {
1030706f2543Smrg	XAAMSG("\tDriver provided GC level CopyPlane replacement\n");
1031706f2543Smrg    } else if(infoRec->WriteBitmap &&
1032706f2543Smrg		!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)) {
1033706f2543Smrg	infoRec->CopyPlane = XAACopyPlaneColorExpansion;
1034706f2543Smrg	infoRec->CopyPlaneFlags = infoRec->WriteBitmapFlags;
1035706f2543Smrg    }
1036706f2543Smrg
1037706f2543Smrg    if(infoRec->PushPixelsSolid) {
1038706f2543Smrg	XAAMSG("\tDriver provided GC level PushPixelsSolid replacement\n");
1039706f2543Smrg    } else if(infoRec->WriteBitmap &&
1040706f2543Smrg		!(infoRec->WriteBitmapFlags & NO_TRANSPARENCY)) {
1041706f2543Smrg	infoRec->PushPixelsSolid = XAAPushPixelsSolidColorExpansion;
1042706f2543Smrg	infoRec->PushPixelsFlags = infoRec->WriteBitmapFlags;
1043706f2543Smrg    }
1044706f2543Smrg
1045706f2543Smrg    if(infoRec->FillSolidRects) {
1046706f2543Smrg	if(!infoRec->PolyFillRectSolid) {
1047706f2543Smrg	    infoRec->PolyFillRectSolid = XAAPolyFillRect;
1048706f2543Smrg	    infoRec->PolyFillRectSolidFlags = infoRec->FillSolidRectsFlags;
1049706f2543Smrg	}
1050706f2543Smrg    }
1051706f2543Smrg    if(infoRec->FillSolidSpans) {
1052706f2543Smrg	if(!infoRec->FillSpansSolid) {
1053706f2543Smrg	    infoRec->FillSpansSolid = XAAFillSpans;
1054706f2543Smrg	    infoRec->FillSpansSolidFlags = infoRec->FillSolidSpansFlags;
1055706f2543Smrg	}
1056706f2543Smrg    }
1057706f2543Smrg
1058706f2543Smrg    if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
1059706f2543Smrg	infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
1060706f2543Smrg	infoRec->FillCacheExpandRects) {
1061706f2543Smrg	if(!infoRec->PolyFillRectStippled) {
1062706f2543Smrg
1063706f2543Smrg	    infoRec->PolyFillRectStippled = XAAPolyFillRect;
1064706f2543Smrg	    infoRec->PolyFillRectStippledFlags = 0;
1065706f2543Smrg	}
1066706f2543Smrg    }
1067706f2543Smrg
1068706f2543Smrg    if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
1069706f2543Smrg	infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
1070706f2543Smrg	infoRec->FillCacheExpandSpans) {
1071706f2543Smrg	if(!infoRec->FillSpansStippled) {
1072706f2543Smrg
1073706f2543Smrg	    infoRec->FillSpansStippled = XAAFillSpans;
1074706f2543Smrg	    infoRec->FillSpansStippledFlags = 0;
1075706f2543Smrg	}
1076706f2543Smrg    }
1077706f2543Smrg
1078706f2543Smrg    if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
1079706f2543Smrg	infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
1080706f2543Smrg	infoRec->FillCacheExpandRects) {
1081706f2543Smrg	if(!infoRec->PolyFillRectOpaqueStippled) {
1082706f2543Smrg
1083706f2543Smrg	    infoRec->PolyFillRectOpaqueStippled = XAAPolyFillRect;
1084706f2543Smrg	    infoRec->PolyFillRectOpaqueStippledFlags = 0;
1085706f2543Smrg	}
1086706f2543Smrg    }
1087706f2543Smrg
1088706f2543Smrg    if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
1089706f2543Smrg	infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
1090706f2543Smrg	infoRec->FillCacheExpandSpans) {
1091706f2543Smrg	if(!infoRec->FillSpansOpaqueStippled) {
1092706f2543Smrg
1093706f2543Smrg	    infoRec->FillSpansOpaqueStippled = XAAFillSpans;
1094706f2543Smrg	    infoRec->FillSpansOpaqueStippledFlags = 0;
1095706f2543Smrg	}
1096706f2543Smrg    }
1097706f2543Smrg
1098706f2543Smrg    if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
1099706f2543Smrg	infoRec->FillCacheBltRects || infoRec->FillImageWriteRects) {
1100706f2543Smrg	if(!infoRec->PolyFillRectTiled) {
1101706f2543Smrg
1102706f2543Smrg	    infoRec->PolyFillRectTiled = XAAPolyFillRect;
1103706f2543Smrg	    infoRec->PolyFillRectTiledFlags = 0;
1104706f2543Smrg	}
1105706f2543Smrg    }
1106706f2543Smrg
1107706f2543Smrg    if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
1108706f2543Smrg	infoRec->FillCacheBltSpans) {
1109706f2543Smrg	if(!infoRec->FillSpansTiled) {
1110706f2543Smrg
1111706f2543Smrg	    infoRec->FillSpansTiled = XAAFillSpans;
1112706f2543Smrg	    infoRec->FillSpansTiledFlags = 0;
1113706f2543Smrg	}
1114706f2543Smrg    }
1115706f2543Smrg
1116706f2543Smrg    if(infoRec->TEGlyphRenderer &&
1117706f2543Smrg	!(infoRec->TEGlyphRendererFlags & NO_TRANSPARENCY)) {
1118706f2543Smrg
1119706f2543Smrg	if(!infoRec->PolyText8TE) {
1120706f2543Smrg	    infoRec->PolyText8TE = XAAPolyText8TEColorExpansion;
1121706f2543Smrg	    infoRec->PolyText8TEFlags = infoRec->TEGlyphRendererFlags;
1122706f2543Smrg	}
1123706f2543Smrg
1124706f2543Smrg	if(!infoRec->PolyText16TE) {
1125706f2543Smrg	    infoRec->PolyText16TE = XAAPolyText16TEColorExpansion;
1126706f2543Smrg	    infoRec->PolyText16TEFlags = infoRec->TEGlyphRendererFlags;
1127706f2543Smrg	}
1128706f2543Smrg
1129706f2543Smrg	if(!infoRec->PolyGlyphBltTE) {
1130706f2543Smrg	    infoRec->PolyGlyphBltTE = XAAPolyGlyphBltTEColorExpansion;
1131706f2543Smrg	    infoRec->PolyGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
1132706f2543Smrg	}
1133706f2543Smrg    }
1134706f2543Smrg
1135706f2543Smrg    if(infoRec->TEGlyphRenderer &&
1136706f2543Smrg	!(infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
1137706f2543Smrg
1138706f2543Smrg	if(!infoRec->ImageText8TE) {
1139706f2543Smrg	    infoRec->ImageText8TE = XAAImageText8TEColorExpansion;
1140706f2543Smrg	    infoRec->ImageText8TEFlags = infoRec->TEGlyphRendererFlags;
1141706f2543Smrg	}
1142706f2543Smrg
1143706f2543Smrg	if(!infoRec->ImageText16TE) {
1144706f2543Smrg	    infoRec->ImageText16TE = XAAImageText16TEColorExpansion;
1145706f2543Smrg	    infoRec->ImageText16TEFlags = infoRec->TEGlyphRendererFlags;
1146706f2543Smrg	}
1147706f2543Smrg
1148706f2543Smrg	if(!infoRec->ImageGlyphBltTE) {
1149706f2543Smrg	    infoRec->ImageGlyphBltTE = XAAImageGlyphBltTEColorExpansion;
1150706f2543Smrg	    infoRec->ImageGlyphBltTEFlags = infoRec->TEGlyphRendererFlags;
1151706f2543Smrg	}
1152706f2543Smrg    }
1153706f2543Smrg
1154706f2543Smrg    if(infoRec->NonTEGlyphRenderer) {
1155706f2543Smrg	if(!infoRec->PolyText8NonTE) {
1156706f2543Smrg	    infoRec->PolyText8NonTE = XAAPolyText8NonTEColorExpansion;
1157706f2543Smrg	    infoRec->PolyText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1158706f2543Smrg	}
1159706f2543Smrg
1160706f2543Smrg	if(!infoRec->PolyText16NonTE) {
1161706f2543Smrg	    infoRec->PolyText16NonTE = XAAPolyText16NonTEColorExpansion;
1162706f2543Smrg	    infoRec->PolyText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1163706f2543Smrg	}
1164706f2543Smrg	if(!infoRec->PolyGlyphBltNonTE) {
1165706f2543Smrg	    infoRec->PolyGlyphBltNonTE = XAAPolyGlyphBltNonTEColorExpansion;
1166706f2543Smrg	    infoRec->PolyGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
1167706f2543Smrg	}
1168706f2543Smrg    }
1169706f2543Smrg
1170706f2543Smrg    if(infoRec->NonTEGlyphRenderer && HaveSolidFillRect) {
1171706f2543Smrg	if(!infoRec->ImageText8NonTE) {
1172706f2543Smrg	    infoRec->ImageText8NonTE = XAAImageText8NonTEColorExpansion;
1173706f2543Smrg	    infoRec->ImageText8NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1174706f2543Smrg	}
1175706f2543Smrg
1176706f2543Smrg	if(!infoRec->ImageText16NonTE) {
1177706f2543Smrg	    infoRec->ImageText16NonTE = XAAImageText16NonTEColorExpansion;
1178706f2543Smrg	    infoRec->ImageText16NonTEFlags = infoRec->NonTEGlyphRendererFlags;
1179706f2543Smrg	}
1180706f2543Smrg
1181706f2543Smrg	if(!infoRec->ImageGlyphBltNonTE) {
1182706f2543Smrg	    infoRec->ImageGlyphBltNonTE = XAAImageGlyphBltNonTEColorExpansion;
1183706f2543Smrg	    infoRec->ImageGlyphBltNonTEFlags = infoRec->NonTEGlyphRendererFlags;
1184706f2543Smrg	}
1185706f2543Smrg    }
1186706f2543Smrg
1187706f2543Smrg    if(!infoRec->PolyRectangleThinSolid && HaveSolidHorVertLine) {
1188706f2543Smrg	infoRec->PolyRectangleThinSolid = XAAPolyRectangleThinSolid;
1189706f2543Smrg	infoRec->PolyRectangleThinSolidFlags = infoRec->SolidLineFlags;
1190706f2543Smrg    }
1191706f2543Smrg
1192706f2543Smrg    if(!infoRec->FillPolygonSolid && HaveSolidFillRect) {
1193706f2543Smrg	infoRec->FillPolygonSolid = XAAFillPolygonSolid;
1194706f2543Smrg	infoRec->FillPolygonSolidFlags = infoRec->SolidFillFlags;
1195706f2543Smrg    }
1196706f2543Smrg
1197706f2543Smrg    if(!infoRec->FillPolygonStippled && (HaveMono8x8PatternFillRect ||
1198706f2543Smrg	HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
1199706f2543Smrg	infoRec->FillPolygonStippled = XAAFillPolygonStippled;
1200706f2543Smrg	infoRec->FillPolygonStippledFlags = infoRec->SolidFillFlags;
1201706f2543Smrg    }
1202706f2543Smrg
1203706f2543Smrg    if(!infoRec->FillPolygonOpaqueStippled && (HaveMono8x8PatternFillRect ||
1204706f2543Smrg	HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
1205706f2543Smrg	infoRec->FillPolygonOpaqueStippled = XAAFillPolygonStippled;
1206706f2543Smrg	infoRec->FillPolygonOpaqueStippledFlags = infoRec->SolidFillFlags;
1207706f2543Smrg    }
1208706f2543Smrg
1209706f2543Smrg    if(!infoRec->FillPolygonTiled && (HaveMono8x8PatternFillRect ||
1210706f2543Smrg	HaveScreenToScreenColorExpandFill || HaveScreenToScreenCopy)) {
1211706f2543Smrg	infoRec->FillPolygonTiled = XAAFillPolygonTiled;
1212706f2543Smrg	infoRec->FillPolygonTiledFlags = infoRec->SolidFillFlags;
1213706f2543Smrg    }
1214706f2543Smrg
1215706f2543Smrg
1216706f2543Smrg    if(!infoRec->PolyFillArcSolid && HaveSolidFillRect) {
1217706f2543Smrg	infoRec->PolyFillArcSolid = XAAPolyFillArcSolid;
1218706f2543Smrg	infoRec->PolyFillArcSolidFlags = infoRec->SolidFillFlags;
1219706f2543Smrg    }
1220706f2543Smrg
1221706f2543Smrg    if(!infoRec->PolylinesWideSolid && HaveSolidFillRect) {
1222706f2543Smrg	infoRec->PolylinesWideSolid = XAAPolylinesWideSolid;
1223706f2543Smrg	infoRec->PolylinesWideSolidFlags =
1224706f2543Smrg			infoRec->SolidFillFlags | GXCOPY_ONLY;
1225706f2543Smrg    }
1226706f2543Smrg
1227706f2543Smrg    if(!infoRec->PutImage && (infoRec->WritePixmap ||
1228706f2543Smrg	(infoRec->WriteBitmap &&
1229706f2543Smrg			!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY)))) {
1230706f2543Smrg	infoRec->PutImage = XAAPutImage;
1231706f2543Smrg
1232706f2543Smrg	/* See comment for CopyArea above.  But here we make fewer
1233706f2543Smrg	   assumptions.  The driver can provide the PutImageFlags if
1234706f2543Smrg	   it wants too */
1235706f2543Smrg    }
1236706f2543Smrg
1237706f2543Smrg    if(HaveSolidHorVertLine &&
1238706f2543Smrg      (HaveSolidBresenhamLine || (HaveSolidTwoPointLine &&
1239706f2543Smrg		(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE)))){
1240706f2543Smrg	if(!infoRec->PolylinesThinSolid) {
1241706f2543Smrg	   infoRec->PolylinesThinSolid = XAAPolyLines;
1242706f2543Smrg	   infoRec->PolylinesThinSolidFlags = infoRec->SolidLineFlags;
1243706f2543Smrg	}
1244706f2543Smrg	if(!infoRec->PolySegmentThinSolid) {
1245706f2543Smrg	   infoRec->PolySegmentThinSolid = XAAPolySegment;
1246706f2543Smrg	   infoRec->PolySegmentThinSolidFlags = infoRec->SolidLineFlags;
1247706f2543Smrg	}
1248706f2543Smrg    }
1249706f2543Smrg
1250706f2543Smrg    if(HaveDashedBresenhamLine || (HaveDashedTwoPointLine &&
1251706f2543Smrg		(infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE))){
1252706f2543Smrg	if(!infoRec->PolylinesThinDashed) {
1253706f2543Smrg	   infoRec->PolylinesThinDashed = XAAPolyLinesDashed;
1254706f2543Smrg	   infoRec->PolylinesThinDashedFlags = infoRec->DashedLineFlags;
1255706f2543Smrg	}
1256706f2543Smrg	if(!infoRec->PolySegmentThinDashed) {
1257706f2543Smrg	   infoRec->PolySegmentThinDashed = XAAPolySegmentDashed;
1258706f2543Smrg	   infoRec->PolySegmentThinDashedFlags = infoRec->DashedLineFlags;
1259706f2543Smrg	}
1260706f2543Smrg    }
1261706f2543Smrg
1262706f2543Smrg    if(infoRec->PolylinesThinDashed || infoRec->PolySegmentThinDashed) {
1263706f2543Smrg	if(!infoRec->ComputeDash)
1264706f2543Smrg	   infoRec->ComputeDash = XAAComputeDash;
1265706f2543Smrg    }
1266706f2543Smrg
1267706f2543Smrg    {
1268706f2543Smrg	Bool haveTexture = infoRec->CPUToScreenTextureFormats &&
1269706f2543Smrg			   infoRec->CPUToScreenTextureDstFormats &&
1270706f2543Smrg	                   infoRec->SetupForCPUToScreenTexture2 &&
1271706f2543Smrg	                   infoRec->SubsequentCPUToScreenTexture;
1272706f2543Smrg        Bool haveAlphaTexture = infoRec->CPUToScreenAlphaTextureFormats &&
1273706f2543Smrg                                infoRec->CPUToScreenAlphaTextureDstFormats &&
1274706f2543Smrg                                infoRec->SetupForCPUToScreenAlphaTexture2 &&
1275706f2543Smrg                                infoRec->SubsequentCPUToScreenAlphaTexture;
1276706f2543Smrg
1277706f2543Smrg	if(!infoRec->Composite && (haveTexture || haveAlphaTexture))
1278706f2543Smrg	    infoRec->Composite = XAADoComposite;
1279706f2543Smrg
1280706f2543Smrg	if(!infoRec->Glyphs && infoRec->WriteBitmap &&
1281706f2543Smrg	   !(infoRec->WriteBitmapFlags & NO_TRANSPARENCY))
1282706f2543Smrg        {
1283706f2543Smrg            infoRec->Glyphs = XAADoGlyphs;
1284706f2543Smrg        }
1285706f2543Smrg    }
1286706f2543Smrg
1287706f2543Smrg    /************  Validation Functions **************/
1288706f2543Smrg
1289706f2543Smrg    if(!infoRec->ValidateCopyArea && infoRec->CopyArea) {
1290706f2543Smrg	infoRec->CopyAreaMask = GCWhenForced;
1291706f2543Smrg	if((infoRec->CopyAreaFlags & GXCOPY_ONLY) ||
1292706f2543Smrg		(infoRec->CopyAreaFlags & ROP_NEEDS_SOURCE))
1293706f2543Smrg	    infoRec->CopyAreaMask |= GCFunction;
1294706f2543Smrg	if(infoRec->CopyAreaFlags & NO_PLANEMASK)
1295706f2543Smrg	    infoRec->CopyAreaMask |= GCPlaneMask;
1296706f2543Smrg	infoRec->ValidateCopyArea = XAAValidateCopyArea;
1297706f2543Smrg    }
1298706f2543Smrg
1299706f2543Smrg    if(!infoRec->ValidateCopyPlane && infoRec->CopyPlane) {
1300706f2543Smrg	infoRec->CopyPlaneMask = GCWhenForced;
1301706f2543Smrg	if((infoRec->CopyPlaneFlags & GXCOPY_ONLY) ||
1302706f2543Smrg		(infoRec->CopyPlaneFlags & ROP_NEEDS_SOURCE))
1303706f2543Smrg	    infoRec->CopyPlaneMask |= GCFunction;
1304706f2543Smrg	if(infoRec->CopyPlaneFlags & NO_PLANEMASK)
1305706f2543Smrg	    infoRec->CopyPlaneMask |= GCPlaneMask;
1306706f2543Smrg	if(infoRec->CopyPlaneFlags & RGB_EQUAL)
1307706f2543Smrg	    infoRec->CopyPlaneMask |= GCForeground | GCBackground;
1308706f2543Smrg	infoRec->ValidateCopyPlane = XAAValidateCopyPlane;
1309706f2543Smrg    }
1310706f2543Smrg
1311706f2543Smrg    if(!infoRec->ValidatePutImage && infoRec->PutImage) {
1312706f2543Smrg	infoRec->PutImageMask = GCWhenForced;
1313706f2543Smrg	if((infoRec->PutImageFlags & GXCOPY_ONLY) ||
1314706f2543Smrg		(infoRec->PutImageFlags & ROP_NEEDS_SOURCE))
1315706f2543Smrg	    infoRec->PutImageMask |= GCFunction;
1316706f2543Smrg	if(infoRec->PutImageFlags & NO_PLANEMASK)
1317706f2543Smrg	    infoRec->PutImageMask |= GCPlaneMask;
1318706f2543Smrg	if(infoRec->PutImageFlags & RGB_EQUAL)
1319706f2543Smrg	    infoRec->PutImageMask |= GCForeground | GCBackground;
1320706f2543Smrg	infoRec->ValidatePutImage = XAAValidatePutImage;
1321706f2543Smrg    }
1322706f2543Smrg
1323706f2543Smrg
1324706f2543Smrg    if(!infoRec->ValidatePushPixels && infoRec->PushPixelsSolid) {
1325706f2543Smrg	infoRec->PushPixelsMask = GCFillStyle;
1326706f2543Smrg	if((infoRec->PushPixelsFlags & GXCOPY_ONLY) ||
1327706f2543Smrg		(infoRec->PushPixelsFlags & ROP_NEEDS_SOURCE) ||
1328706f2543Smrg		(infoRec->PushPixelsFlags & TRANSPARENCY_GXCOPY_ONLY))
1329706f2543Smrg	    infoRec->PushPixelsMask |= GCFunction;
1330706f2543Smrg	if(infoRec->PushPixelsFlags & NO_PLANEMASK)
1331706f2543Smrg	    infoRec->PushPixelsMask |= GCPlaneMask;
1332706f2543Smrg	if(infoRec->PushPixelsFlags & RGB_EQUAL)
1333706f2543Smrg	    infoRec->PushPixelsMask |= GCForeground;
1334706f2543Smrg	infoRec->ValidatePushPixels = XAAValidatePushPixels;
1335706f2543Smrg    }
1336706f2543Smrg
1337706f2543Smrg    /* By default XAA assumes the FillSpans, PolyFillRects, FillPolygon
1338706f2543Smrg	and PolyFillArcs have the same restrictions.  If you supply GC
1339706f2543Smrg	level replacements for any of these and alter this relationship
1340706f2543Smrg	you may need to supply replacement validation routines */
1341706f2543Smrg
1342706f2543Smrg    if(!infoRec->ValidateFillSpans &&
1343706f2543Smrg	(infoRec->FillSpansSolid || infoRec->FillSpansStippled ||
1344706f2543Smrg	infoRec->FillSpansOpaqueStippled || infoRec->FillSpansTiled)) {
1345706f2543Smrg
1346706f2543Smrg        int compositeFlags = 	infoRec->FillSpansSolidFlags |
1347706f2543Smrg				infoRec->FillSpansStippledFlags |
1348706f2543Smrg				infoRec->FillSpansOpaqueStippledFlags |
1349706f2543Smrg				infoRec->FillSpansTiledFlags;
1350706f2543Smrg
1351706f2543Smrg	infoRec->FillSpansMask = GCFillStyle | GCTile | GCStipple;
1352706f2543Smrg
1353706f2543Smrg	if((compositeFlags & GXCOPY_ONLY) ||
1354706f2543Smrg		(compositeFlags & ROP_NEEDS_SOURCE))
1355706f2543Smrg	    infoRec->FillSpansMask |= GCFunction;
1356706f2543Smrg	if(compositeFlags & NO_PLANEMASK)
1357706f2543Smrg	    infoRec->FillSpansMask |= GCPlaneMask;
1358706f2543Smrg	if(compositeFlags & RGB_EQUAL)
1359706f2543Smrg	    infoRec->FillSpansMask |= GCForeground;
1360706f2543Smrg	infoRec->ValidateFillSpans = XAAValidateFillSpans;
1361706f2543Smrg    }
1362706f2543Smrg
1363706f2543Smrg    /* By default XAA only provides Validations for the GlyphBlt
1364706f2543Smrg	functions and not the text higher up. This is because the
1365706f2543Smrg	Text8/16 and GlyphBlt are linked.  If you break this linkage,
1366706f2543Smrg	you may need to have the driver supply its own Validation
1367706f2543Smrg	routines */
1368706f2543Smrg
1369706f2543Smrg    if(!infoRec->ValidatePolyGlyphBlt &&
1370706f2543Smrg	(infoRec->PolyGlyphBltTE || infoRec->PolyGlyphBltNonTE)) {
1371706f2543Smrg        int compositeFlags = 	infoRec->PolyGlyphBltTEFlags |
1372706f2543Smrg				infoRec->PolyGlyphBltNonTEFlags;
1373706f2543Smrg
1374706f2543Smrg	infoRec->PolyGlyphBltMask = GCFillStyle | GCFont;
1375706f2543Smrg	if((compositeFlags & GXCOPY_ONLY) ||
1376706f2543Smrg		(compositeFlags & ROP_NEEDS_SOURCE) ||
1377706f2543Smrg		(infoRec->PolyGlyphBltNonTEFlags & TRANSPARENCY_GXCOPY_ONLY))
1378706f2543Smrg	    infoRec->PolyGlyphBltMask |= GCFunction;
1379706f2543Smrg	if(compositeFlags & NO_PLANEMASK)
1380706f2543Smrg	    infoRec->PolyGlyphBltMask |= GCPlaneMask;
1381706f2543Smrg	if(compositeFlags & RGB_EQUAL)
1382706f2543Smrg	    infoRec->PolyGlyphBltMask |= GCForeground;
1383706f2543Smrg	infoRec->ValidatePolyGlyphBlt = XAAValidatePolyGlyphBlt;
1384706f2543Smrg    }
1385706f2543Smrg
1386706f2543Smrg    if(!infoRec->ValidateImageGlyphBlt &&
1387706f2543Smrg	(infoRec->ImageGlyphBltTE || infoRec->ImageGlyphBltNonTE)) {
1388706f2543Smrg        int compositeFlags = 	infoRec->ImageGlyphBltTEFlags |
1389706f2543Smrg				infoRec->ImageGlyphBltNonTEFlags;
1390706f2543Smrg
1391706f2543Smrg        if(infoRec->ImageGlyphBltNonTE)
1392706f2543Smrg	    compositeFlags |= infoRec->SolidFillFlags;
1393706f2543Smrg
1394706f2543Smrg	infoRec->ImageGlyphBltMask = GCFont;
1395706f2543Smrg	if(compositeFlags & NO_PLANEMASK)
1396706f2543Smrg	    infoRec->ImageGlyphBltMask |= GCPlaneMask;
1397706f2543Smrg	if(compositeFlags & RGB_EQUAL)
1398706f2543Smrg	    infoRec->ImageGlyphBltMask |= GCForeground | GCBackground;
1399706f2543Smrg	infoRec->ValidateImageGlyphBlt = XAAValidateImageGlyphBlt;
1400706f2543Smrg    }
1401706f2543Smrg
1402706f2543Smrg    /* By default XAA only provides a Validation function for the
1403706f2543Smrg	Polylines and does segments and polylines at the same time */
1404706f2543Smrg
1405706f2543Smrg    if(!infoRec->ValidatePolylines && infoRec->ValidateFillSpans) {
1406706f2543Smrg	int compositeFlags = 	infoRec->PolyRectangleThinSolidFlags |
1407706f2543Smrg				infoRec->PolylinesWideSolidFlags |
1408706f2543Smrg				infoRec->PolylinesThinSolidFlags |
1409706f2543Smrg				infoRec->PolySegmentThinSolidFlags |
1410706f2543Smrg				infoRec->PolySegmentThinDashedFlags |
1411706f2543Smrg				infoRec->PolylinesThinDashedFlags;
1412706f2543Smrg
1413706f2543Smrg	infoRec->ValidatePolylines = XAAValidatePolylines;
1414706f2543Smrg	infoRec->PolylinesMask =
1415706f2543Smrg		infoRec->FillSpansMask | GCLineStyle | GCLineWidth;
1416706f2543Smrg
1417706f2543Smrg	if(infoRec->PolySegmentThinDashed || infoRec->PolylinesThinDashed)
1418706f2543Smrg	    infoRec->PolylinesMask |= GCDashList;
1419706f2543Smrg	if(compositeFlags & NO_PLANEMASK)
1420706f2543Smrg	    infoRec->PolylinesMask |= GCPlaneMask;
1421706f2543Smrg	if((compositeFlags & GXCOPY_ONLY) ||
1422706f2543Smrg		(compositeFlags & ROP_NEEDS_SOURCE))
1423706f2543Smrg	    infoRec->PolylinesMask |= GCFunction;
1424706f2543Smrg	if(compositeFlags & RGB_EQUAL)
1425706f2543Smrg	    infoRec->PolylinesMask |= GCForeground;
1426706f2543Smrg    }
1427706f2543Smrg
1428706f2543Smrg
1429706f2543Smrg    /**** Fill choosers ****/
1430706f2543Smrg
1431706f2543Smrg    if(!infoRec->StippledFillChooser)
1432706f2543Smrg	infoRec->StippledFillChooser = XAAStippledFillChooser;
1433706f2543Smrg
1434706f2543Smrg    if(!infoRec->OpaqueStippledFillChooser)
1435706f2543Smrg	infoRec->OpaqueStippledFillChooser = XAAOpaqueStippledFillChooser;
1436706f2543Smrg
1437706f2543Smrg    if(!infoRec->TiledFillChooser)
1438706f2543Smrg	infoRec->TiledFillChooser = XAATiledFillChooser;
1439706f2543Smrg
1440706f2543Smrg
1441706f2543Smrg    /**** Setup the pixmap cache ****/
1442706f2543Smrg
1443706f2543Smrg    if(infoRec->WriteBitmapToCache) {}
1444706f2543Smrg    else if(infoRec->WriteBitmap &&
1445706f2543Smrg	!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))
1446706f2543Smrg	infoRec->WriteBitmapToCache = XAAWriteBitmapToCache;
1447706f2543Smrg    else if(infoRec->Flags & LINEAR_FRAMEBUFFER)
1448706f2543Smrg	infoRec->WriteBitmapToCache = XAAWriteBitmapToCacheLinear;
1449706f2543Smrg    else
1450706f2543Smrg	infoRec->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES;
1451706f2543Smrg
1452706f2543Smrg    if(infoRec->WritePixmapToCache) {}
1453706f2543Smrg    else if(infoRec->WritePixmap && !(infoRec->WritePixmapFlags & NO_GXCOPY))
1454706f2543Smrg	infoRec->WritePixmapToCache = XAAWritePixmapToCache;
1455706f2543Smrg    else if(infoRec->Flags & LINEAR_FRAMEBUFFER)
1456706f2543Smrg	infoRec->WritePixmapToCache = XAAWritePixmapToCacheLinear;
1457706f2543Smrg    else
1458706f2543Smrg	infoRec->Flags &= ~PIXMAP_CACHE;
1459706f2543Smrg
1460706f2543Smrg    if (xf86ReturnOptValBool(options, XAAOPT_PIXMAP_CACHE, FALSE))
1461706f2543Smrg	infoRec->Flags &= ~PIXMAP_CACHE;
1462706f2543Smrg
1463706f2543Smrg    if(infoRec->WriteMono8x8PatternToCache) {}
1464706f2543Smrg    else if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8) {
1465706f2543Smrg	if(infoRec->WritePixmapToCache)
1466706f2543Smrg	  infoRec->WriteMono8x8PatternToCache = XAAWriteMono8x8PatternToCache;
1467706f2543Smrg	else
1468706f2543Smrg	   infoRec->PixmapCacheFlags &= ~CACHE_MONO_8x8;
1469706f2543Smrg    }
1470706f2543Smrg
1471706f2543Smrg    if(infoRec->WriteColor8x8PatternToCache) {}
1472706f2543Smrg    else if(infoRec->PixmapCacheFlags & CACHE_COLOR_8x8) {
1473706f2543Smrg	if(infoRec->WritePixmapToCache && infoRec->WriteBitmapToCache)
1474706f2543Smrg	  infoRec->WriteColor8x8PatternToCache = XAAWriteColor8x8PatternToCache;
1475706f2543Smrg	else
1476706f2543Smrg	   infoRec->PixmapCacheFlags &= ~CACHE_COLOR_8x8;
1477706f2543Smrg    }
1478706f2543Smrg
1479706f2543Smrg    if(infoRec->CachePixelGranularity < 0) {
1480706f2543Smrg	switch(pScrn->bitsPerPixel) {
1481706f2543Smrg	case 24:
1482706f2543Smrg	case 8:  infoRec->CachePixelGranularity = 4;  break;
1483706f2543Smrg	case 16: infoRec->CachePixelGranularity = 2;  break;
1484706f2543Smrg	case 32: infoRec->CachePixelGranularity = 1;  break;
1485706f2543Smrg	default: break;
1486706f2543Smrg	}
1487706f2543Smrg
1488706f2543Smrg	if(BITMAP_SCANLINE_PAD == 64)
1489706f2543Smrg	    infoRec->CachePixelGranularity *= 2;
1490706f2543Smrg    }
1491706f2543Smrg
1492706f2543Smrg    free(options);
1493706f2543Smrg
1494706f2543Smrg    if(!infoRec->CacheTile && infoRec->WritePixmapToCache)
1495706f2543Smrg	infoRec->CacheTile = XAACacheTile;
1496706f2543Smrg    if(!infoRec->CacheMonoStipple && infoRec->WritePixmapToCache)
1497706f2543Smrg	infoRec->CacheMonoStipple = XAACacheMonoStipple;
1498706f2543Smrg    if(!infoRec->CacheStipple && infoRec->WriteBitmapToCache)
1499706f2543Smrg	infoRec->CacheStipple = XAACacheStipple;
1500706f2543Smrg    if(!infoRec->CacheMono8x8Pattern && infoRec->WriteMono8x8PatternToCache)
1501706f2543Smrg	infoRec->CacheMono8x8Pattern = XAACacheMono8x8Pattern;
1502706f2543Smrg    if(!infoRec->CacheColor8x8Pattern && infoRec->WriteColor8x8PatternToCache)
1503706f2543Smrg	infoRec->CacheColor8x8Pattern = XAACacheColor8x8Pattern;
1504706f2543Smrg
1505706f2543Smrg    if((infoRec->Flags & PIXMAP_CACHE) && !infoRec->InitPixmapCache) {
1506706f2543Smrg	infoRec->InitPixmapCache = XAAInitPixmapCache;
1507706f2543Smrg	infoRec->ClosePixmapCache = XAAClosePixmapCache;
1508706f2543Smrg    }
1509706f2543Smrg
1510706f2543Smrg    return TRUE;
1511706f2543Smrg}
1512