Exemplo n.º 1
0
void
XAAPaintWindow(
  WindowPtr pWin,
  RegionPtr prgn,
  int what 
)
{
    ScreenPtr  pScreen = pWin->drawable.pScreen;
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
    int nBox = REGION_NUM_RECTS(prgn);
    BoxPtr pBox = REGION_RECTS(prgn);
    int fg = -1;
    PixmapPtr pPix = NULL;

    if(!infoRec->pScrn->vtSema) goto BAILOUT;	

    switch (what) {
    case PW_BACKGROUND:
	switch(pWin->backgroundState) {
	case None: return;
	case ParentRelative:
	    do { pWin = pWin->parent; }
	    while(pWin->backgroundState == ParentRelative);
	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, what);
	    return;
	case BackgroundPixel:
	    fg = pWin->background.pixel;
	    break;
	case BackgroundPixmap:
	    pPix = pWin->background.pixmap;
	    break;
	}
	break;
    case PW_BORDER:
	if (pWin->borderIsPixel) 
	    fg = pWin->border.pixel;
	else 	/* pixmap */ 
	    pPix = pWin->border.pixmap;
	break;
    default: return;
    }


    if(!pPix) {
        if(infoRec->FillSolidRects &&
           (!(infoRec->FillSolidRectsFlags & RGB_EQUAL) || 
                (CHECK_RGB_EQUAL(fg))) )  {
	    (*infoRec->FillSolidRects)(infoRec->pScrn, fg, GXcopy, ~0,
					nBox, pBox);
	    return;
	}
    } else {	/* pixmap */
        XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
	WindowPtr pBgWin = pWin;
	Bool NoCache = FALSE;
	int xorg, yorg;

	/* Hack so we can use this with the dual framebuffer layers
	   which only support the pixmap cache in the primary bpp */
	if(pPix->drawable.bitsPerPixel != infoRec->pScrn->bitsPerPixel)
	    NoCache = TRUE;

	if (what == PW_BORDER) {
	    for (pBgWin = pWin;
		 pBgWin->backgroundState == ParentRelative;
		 pBgWin = pBgWin->parent);
	}

        xorg = pBgWin->drawable.x;
        yorg = pBgWin->drawable.y;

	if(IS_OFFSCREEN_PIXMAP(pPix) && infoRec->FillCacheBltRects) {
	    XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);

	    pCache->x = pPriv->offscreenArea->box.x1;
	    pCache->y = pPriv->offscreenArea->box.y1;
	    pCache->w = pCache->orig_w = 
		pPriv->offscreenArea->box.x2 - pCache->x;
	    pCache->h = pCache->orig_h = 
		pPriv->offscreenArea->box.y2 - pCache->y;
	    pCache->trans_color = -1;
	     
	    (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
				nBox, pBox, xorg, yorg, pCache);
	    return;
	}

	if(pPriv->flags & DIRTY) {
	    pPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
	    pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
        }

    	if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
	    (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
	    XAACheckTileReducibility(pPix, infoRec->CanDoMono8x8);
	}

	if(pPriv->flags & REDUCIBLE_TO_8x8) {
	    if((pPriv->flags & REDUCIBLE_TO_2_COLOR) &&
		infoRec->CanDoMono8x8 && infoRec->FillMono8x8PatternRects &&
		!(infoRec->FillMono8x8PatternRectsFlags & TRANSPARENCY_ONLY) && 
		(!(infoRec->FillMono8x8PatternRectsFlags & RGB_EQUAL) || 
		(CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg)))) {

	    	(*infoRec->FillMono8x8PatternRects)(infoRec->pScrn,
			pPriv->fg, pPriv->bg, GXcopy, ~0, nBox, pBox,
			pPriv->pattern0, pPriv->pattern1, xorg, yorg);
		return;
	    }
	    if(infoRec->CanDoColor8x8 && !NoCache &&
				infoRec->FillColor8x8PatternRects) {
		XAACacheInfoPtr pCache = (*infoRec->CacheColor8x8Pattern)(
					infoRec->pScrn, pPix, -1, -1);

		(*infoRec->FillColor8x8PatternRects) ( infoRec->pScrn, 
				GXcopy, ~0, nBox, pBox, xorg, yorg, pCache);
		return;
	    }        
	}

	/* The window size check is to reduce pixmap cache thrashing
	   when there are lots of little windows with pixmap backgrounds
	   like are sometimes used for buttons, etc... */

	if(infoRec->UsingPixmapCache && 
	    infoRec->FillCacheBltRects && !NoCache &&
	    ((what == PW_BORDER) ||
		(pPix->drawable.height != pWin->drawable.height) ||
		(pPix->drawable.width != pWin->drawable.width)) &&
	    (pPix->drawable.height <= infoRec->MaxCacheableTileHeight) &&
	    (pPix->drawable.width <= infoRec->MaxCacheableTileWidth)) {

	     XAACacheInfoPtr pCache = 
			(*infoRec->CacheTile)(infoRec->pScrn, pPix);
	     (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
					nBox, pBox, xorg, yorg, pCache);
	     return;
	}

	if(infoRec->FillImageWriteRects && 
		!(infoRec->FillImageWriteRectsFlags & NO_GXCOPY)) {
	    (*infoRec->FillImageWriteRects) (infoRec->pScrn, GXcopy, 
                   		~0, nBox, pBox, xorg, yorg, pPix);
	    return;
	}
    }


    if(infoRec->NeedToSync) {
	(*infoRec->Sync)(infoRec->pScrn);
	infoRec->NeedToSync = FALSE;
    }

BAILOUT:

    if(what == PW_BACKGROUND) {
	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAPaintWindow);
    } else {
	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAPaintWindow);
    }

}
Exemplo n.º 2
0
static void
XAAPaintWindow8_32(
  WindowPtr pWin,
  RegionPtr prgn,
  int what 
){
    ScreenPtr  pScreen = pWin->drawable.pScreen;
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
    int nBox = REGION_NUM_RECTS(prgn);
    BoxPtr pBox = REGION_RECTS(prgn);
    PixmapPtr pPix = NULL;
    int depth = pWin->drawable.depth;
    int fg = 0, pm;

    if(!infoRec->pScrn->vtSema) goto BAILOUT;	

    switch (what) {
    case PW_BACKGROUND:
	switch(pWin->backgroundState) {
	case None: return;
	case ParentRelative:
	    do { pWin = pWin->parent; }
	    while(pWin->backgroundState == ParentRelative);
	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, what);
	    return;
	case BackgroundPixel:
	    fg = pWin->background.pixel;
	    break;
	case BackgroundPixmap:
	    pPix = pWin->background.pixmap;
	    break;
	}
	break;
    case PW_BORDER:
	if (pWin->borderIsPixel) 
	    fg = pWin->border.pixel;
	else 	/* pixmap */ 
	    pPix = pWin->border.pixmap;
	break;
    default: return;
    }

    if(depth == 8) {
	pm = 0xff000000;
	fg <<= 24;
    } else
	pm = 0x00ffffff;

    if(!pPix) {	
        if(infoRec->FillSolidRects &&
           !(infoRec->FillSolidRectsFlags & NO_PLANEMASK) &&
           (!(infoRec->FillSolidRectsFlags & RGB_EQUAL) ||
			(depth == 8) || CHECK_RGB_EQUAL(fg)))  
	{
	    (*infoRec->FillSolidRects)(infoRec->pScrn, fg, GXcopy, 
						pm, nBox, pBox);
	    return;
	}
    } else {	/* pixmap */
        XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
	WindowPtr pBgWin = pWin;
	int xorg, yorg;

	if (what == PW_BORDER) {
	    for (pBgWin = pWin;
		 pBgWin->backgroundState == ParentRelative;
		 pBgWin = pBgWin->parent);
	}

        xorg = pBgWin->drawable.x;
        yorg = pBgWin->drawable.y;

#ifdef PANORAMIX
	if(!noPanoramiXExtension) {
	    int index = pScreen->myNum;
	    if(WindowTable[index] == pBgWin) {
		xorg -= panoramiXdataPtr[index].x;
		yorg -= panoramiXdataPtr[index].y;
	    }
	}
#endif

	if(IS_OFFSCREEN_PIXMAP(pPix) && infoRec->FillCacheBltRects) {
	    XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);

	    pCache->x = pPriv->offscreenArea->box.x1;
	    pCache->y = pPriv->offscreenArea->box.y1;
	    pCache->w = pCache->orig_w = 
		pPriv->offscreenArea->box.x2 - pCache->x;
	    pCache->h = pCache->orig_h = 
		pPriv->offscreenArea->box.y2 - pCache->y;
	    pCache->trans_color = -1;
	     
	    (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, pm,
				nBox, pBox, xorg, yorg, pCache);

	    return;
	}

	if(pPriv->flags & DIRTY) {
	    pPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
	    pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
        }

    	if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
	    (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
	    XAACheckTileReducibility(pPix, infoRec->CanDoMono8x8);
	}

	if(pPriv->flags & REDUCIBLE_TO_8x8) {
	    if((pPriv->flags & REDUCIBLE_TO_2_COLOR) &&
		infoRec->CanDoMono8x8 && infoRec->FillMono8x8PatternRects &&
		!(infoRec->FillMono8x8PatternRectsFlags & NO_PLANEMASK) &&
		!(infoRec->FillMono8x8PatternRectsFlags & TRANSPARENCY_ONLY) && 
		(!(infoRec->FillMono8x8PatternRectsFlags & RGB_EQUAL) || 
		(CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg)))) 
	    {
		(*infoRec->FillMono8x8PatternRects)(infoRec->pScrn,
			pPriv->fg, pPriv->bg, GXcopy, pm, nBox, pBox,
			pPriv->pattern0, pPriv->pattern1, xorg, yorg);
		return;
	    }
	    if(infoRec->CanDoColor8x8 && infoRec->FillColor8x8PatternRects &&
		!(infoRec->FillColor8x8PatternRectsFlags & NO_PLANEMASK)) 
	    {
		XAACacheInfoPtr pCache = (*infoRec->CacheColor8x8Pattern)(
					infoRec->pScrn, pPix, -1, -1);

		(*infoRec->FillColor8x8PatternRects) (infoRec->pScrn, 
			GXcopy, pm, nBox, pBox, xorg, yorg, pCache);
		return;
	    }        
	}

	if(infoRec->UsingPixmapCache && infoRec->FillCacheBltRects && 
	    !(infoRec->FillCacheBltRectsFlags & NO_PLANEMASK) && 
	    (pPix->drawable.height <= infoRec->MaxCacheableTileHeight) &&
	    (pPix->drawable.width <= infoRec->MaxCacheableTileWidth)) 
	{
	     XAACacheInfoPtr pCache = 
			(*infoRec->CacheTile)(infoRec->pScrn, pPix);
	     (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, pm,
				nBox, pBox, xorg, yorg, pCache);
	     return;
	}

	if(infoRec->FillImageWriteRects && 
		!(infoRec->FillImageWriteRectsFlags & NO_PLANEMASK)) 
	{
	    (*infoRec->FillImageWriteRects) (infoRec->pScrn, GXcopy, 
			pm, nBox, pBox, xorg, yorg, pPix);
	    return;
	}
    }

    if(infoRec->NeedToSync) {
	(*infoRec->Sync)(infoRec->pScrn);
	infoRec->NeedToSync = FALSE;
    }

BAILOUT:

    if(what == PW_BACKGROUND) {
	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAPaintWindow8_32);
    } else {
	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAPaintWindow8_32);
    }
}
Exemplo n.º 3
0
Arquivo: xaaBitmap.c Projeto: aosm/X11
EXPNAME(XAAWriteBitmapColorExpand)(
#endif
    ScrnInfoPtr pScrn,
    int x, int y, int w, int H,
    unsigned char *src,
    int srcwidth,
    int skipleft,
    int fg, int bg,
    int rop,
    unsigned int planemask 
)
{
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
    CARD32* base;
    unsigned char *srcp = src;
    int SecondPassColor = -1;
    int shift = 0, dwords;
    BitmapScanlineProcPtr firstFunc;
    BitmapScanlineProcPtr secondFunc;
    int flag;
    int h = H;

#ifdef TRIPLE_BITS
    if((bg != -1) && 
	((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) ||
	((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) && 
	(!CHECK_RGB_EQUAL(bg))))) {
#else
    if((bg != -1) && 
	(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
	if((rop == GXcopy) && infoRec->SetupForSolidFill) {
    	    (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
            (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
	} else SecondPassColor = bg;
	bg = -1;
    }

#ifdef TRIPLE_BITS
    if(skipleft) {
#else
    if(skipleft && 
	(!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) || 
	(!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) && 
		(skipleft > x)))) {
#endif
	if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
	    /* don't read past the end */
	    firstFunc = BitmapScanline_Shifted_Careful;
 	    secondFunc = BitmapScanline_Shifted_Inverted_Careful;
	} else {
	    firstFunc = BitmapScanline_Shifted;
 	    secondFunc = BitmapScanline_Shifted_Inverted;
	}
	shift = skipleft;
	skipleft = 0;
    } else {
	firstFunc = BitmapScanline;
 	secondFunc = BitmapScanline_Inverted;
	w += skipleft;
	x -= skipleft;
    }

#ifdef TRIPLE_BITS
    dwords = (3 * w + 31) >> 5;
#else
    dwords = (w + 31) >> 5;
#endif

SECOND_PASS:

    flag = (infoRec->CPUToScreenColorExpandFillFlags 
	     & CPU_TRANSFER_PAD_QWORD) && ((dwords * h) & 0x01);
    (*infoRec->SetupForCPUToScreenColorExpandFill)(
					pScrn, fg, bg, rop, planemask);
    (*infoRec->SubsequentCPUToScreenColorExpandFill)(
					pScrn, x, y, w, h, skipleft);

    base = (CARD32*)infoRec->ColorExpandBase;

#ifndef FIXEDBASE
    if((dwords * h) <= infoRec->ColorExpandRange)
	while(h--) {
	    base = (*firstFunc)((CARD32*)srcp, base, dwords, shift);
	    srcp += srcwidth;
    	}
    else
#endif
	while(h--) {
	    (*firstFunc)((CARD32*)srcp, base, dwords, shift);
	    srcp += srcwidth;
	}

    if(flag){
        base = (CARD32*)infoRec->ColorExpandBase;
	base[0] = 0x00000000;
    }

    if(SecondPassColor != -1) {
	h = H; /* Reset height */
	fg = SecondPassColor;
	SecondPassColor = -1;
	firstFunc = secondFunc;
	srcp = src;
	goto SECOND_PASS;
    }

    if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND) 
	(*infoRec->Sync)(pScrn);
    else SET_SYNC_FLAG(infoRec);
}

#ifndef FIXEDBASE

void
#ifdef TRIPLE_BITS
EXPNAME(XAAWriteBitmapScanlineColorExpand3)(
#else
EXPNAME(XAAWriteBitmapScanlineColorExpand)(
#endif
    ScrnInfoPtr pScrn,
    int x, int y, int w, int h,
    unsigned char *src,
    int srcwidth,
    int skipleft,
    int fg, int bg,
    int rop,
    unsigned int planemask 
)
{
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
    CARD32* base;
    unsigned char *srcp = src;
    int SecondPassColor = -1;
    int shift = 0, dwords, bufferNo;
    BitmapScanlineProcPtr firstFunc;
    BitmapScanlineProcPtr secondFunc;

#ifdef TRIPLE_BITS
    if((bg != -1) &&
	((infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) 
	|| ((infoRec->ScanlineCPUToScreenColorExpandFillFlags & RGB_EQUAL) && 
	(!CHECK_RGB_EQUAL(bg))))) {
#else
    if((bg != -1) && 
	(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)){
#endif
	if((rop == GXcopy) && infoRec->SetupForSolidFill) {
    	    (*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
            (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
	} else SecondPassColor = bg;
	bg = -1;
    }

#ifdef TRIPLE_BITS
    if(skipleft) {
#else
    if(skipleft && 
	(!(infoRec->ScanlineCPUToScreenColorExpandFillFlags & 
		LEFT_EDGE_CLIPPING) || 
	(!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
		 LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) {
#endif
	if((skipleft + ((w + 31) & ~31)) > ((skipleft + w + 31) & ~31)) {
	    /* don't read past the end */
	    firstFunc = BitmapScanline_Shifted_Careful;
 	    secondFunc = BitmapScanline_Shifted_Inverted_Careful;
	} else {
	    firstFunc = BitmapScanline_Shifted;
 	    secondFunc = BitmapScanline_Shifted_Inverted;
	}
	shift = skipleft;
	skipleft = 0;
    } else {
	firstFunc = BitmapScanline;
 	secondFunc = BitmapScanline_Inverted;
	w += skipleft;
	x -= skipleft;
    }

#ifdef TRIPLE_BITS
    dwords = (3 * w + 31) >> 5;
#else
    dwords = (w + 31) >> 5;
#endif

SECOND_PASS:

    (*infoRec->SetupForScanlineCPUToScreenColorExpandFill)(pScrn, fg, bg, rop, planemask);
    (*infoRec->SubsequentScanlineCPUToScreenColorExpandFill)(
					pScrn, x, y, w, h, skipleft);

    bufferNo = 0;

    while(h--) {
	base = (CARD32*)infoRec->ScanlineColorExpandBuffers[bufferNo];
	(*firstFunc)((CARD32*)srcp, base, dwords, shift);
	(*infoRec->SubsequentColorExpandScanline)(pScrn, bufferNo++);
	srcp += srcwidth;
	if(bufferNo >= infoRec->NumScanlineColorExpandBuffers)
	    bufferNo = 0;
    }

    if(SecondPassColor != -1) {
	fg = SecondPassColor;
	SecondPassColor = -1;
	firstFunc = secondFunc;
	srcp = src;
	goto SECOND_PASS;
    }

    SET_SYNC_FLAG(infoRec);
}