void
miImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
		unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase)
{
    ExtentInfoRec info;		/* used by QueryGlyphExtents() */
    XID gcvals[3];
    int oldAlu, oldFS;
    unsigned long	oldFG;
    xRectangle backrect;

    QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);

    if (info.overallWidth >= 0)
    {
    	backrect.x = x;
    	backrect.width = info.overallWidth;
    }
    else
    {
	backrect.x = x + info.overallWidth;
	backrect.width = -info.overallWidth;
    }
    backrect.y = y - FONTASCENT(pGC->font);
    backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);

    oldAlu = pGC->alu;
    oldFG = pGC->fgPixel;
    oldFS = pGC->fillStyle;

    /* fill in the background */
    gcvals[0] = GXcopy;
    gcvals[1] = pGC->bgPixel;
    gcvals[2] = FillSolid;
    DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
    ValidateGC(pDrawable, pGC);
    (*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &backrect);

    /* put down the glyphs */
    gcvals[0] = oldFG;
    DoChangeGC(pGC, GCForeground, gcvals, 0);
    ValidateGC(pDrawable, pGC);
    (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci,
			      pglyphBase);

    /* put all the toys away when done playing */
    gcvals[0] = oldAlu;
    gcvals[1] = oldFG;
    gcvals[2] = oldFS;
    DoChangeGC(pGC, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
    ValidateGC(pDrawable, pGC);

}
Example #2
0
int
ProcXFixesSetGCClipRegion (ClientPtr client)
{
    GCPtr	pGC;
    RegionPtr	pRegion;
    XID		vals[2];
    int		rc;
    REQUEST(xXFixesSetGCClipRegionReq);
    REQUEST_SIZE_MATCH(xXFixesSetGCClipRegionReq);

    rc = dixLookupGC(&pGC, stuff->gc, client, DixWriteAccess);
    if (rc != Success)
	return rc;

    VERIFY_REGION_OR_NONE (pRegion, stuff->region, client, DixReadAccess);

    if (pRegion)
    {
	pRegion = XFixesRegionCopy (pRegion);
	if (!pRegion)
	    return BadAlloc;
    }
    
    vals[0] = stuff->xOrigin;
    vals[1] = stuff->yOrigin;
    DoChangeGC (pGC, GCClipXOrigin|GCClipYOrigin, vals, 0);
    (*pGC->funcs->ChangeClip)(pGC, pRegion ? CT_REGION : CT_NONE, (pointer)pRegion, 0);

    return (client->noClientException);
}
void
miPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, int x, int y,
	       unsigned int nglyph, CharInfoPtr *ppci, pointer pglyphBase)
{
    int width, height;
    PixmapPtr pPixmap;
    int nbyLine;			/* bytes per line of padded pixmap */
    FontPtr pfont;
    GCPtr pGCtmp;
    int i;
    int j;
    unsigned char *pbits;		/* buffer for PutImage */
    unsigned char *pb;		/* temp pointer into buffer */
    CharInfoPtr pci;		/* currect char info */
    unsigned char *pglyph;	/* pointer bits in glyph */
    int gWidth, gHeight;		/* width and height of glyph */
    int nbyGlyphWidth;		/* bytes per scanline of glyph */
    int nbyPadGlyph;			/* server padded line of glyph */

    XID gcvals[3];

    if (pGC->miTranslate)
    {
	x += pDrawable->x;
	y += pDrawable->y;
    }

    pfont = pGC->font;
    width = FONTMAXBOUNDS(pfont,rightSideBearing) - 
	    FONTMINBOUNDS(pfont,leftSideBearing);
    height = FONTMAXBOUNDS(pfont,ascent) +
	     FONTMAXBOUNDS(pfont,descent);

    pPixmap = (*pDrawable->pScreen->CreatePixmap)(pDrawable->pScreen,
						  width, height, 1);
    if (!pPixmap)
	return;

    pGCtmp = GetScratchGC(1, pDrawable->pScreen);
    if (!pGCtmp)
    {
	(*pDrawable->pScreen->DestroyPixmap)(pPixmap);
	return;
    }

    gcvals[0] = GXcopy;
    gcvals[1] = 1;
    gcvals[2] = 0;

    DoChangeGC(pGCtmp, GCFunction|GCForeground|GCBackground, gcvals, 0);

    nbyLine = BitmapBytePad(width);
    pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
    if (!pbits)
    {
	(*pDrawable->pScreen->DestroyPixmap)(pPixmap);
	FreeScratchGC(pGCtmp);
        return;
    }
    while(nglyph--)
    {
	pci = *ppci++;
	pglyph = FONTGLYPHBITS(pglyphBase, pci);
	gWidth = GLYPHWIDTHPIXELS(pci);
	gHeight = GLYPHHEIGHTPIXELS(pci);
	if (gWidth && gHeight)
	{
	    nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
	    nbyPadGlyph = BitmapBytePad(gWidth);

	    if (nbyGlyphWidth == nbyPadGlyph
#if GLYPHPADBYTES != 4
	        && (((int) pglyph) & 3) == 0
#endif
		)
	    {
		pb = pglyph;
	    }
	    else
	    {
		for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph))
		    for (j = 0; j < nbyGlyphWidth; j++)
			*pb++ = *pglyph++;
		pb = pbits;
	    }

	    if ((pGCtmp->serialNumber) != (pPixmap->drawable.serialNumber))
		ValidateGC((DrawablePtr)pPixmap, pGCtmp);
	    (*pGCtmp->ops->PutImage)((DrawablePtr)pPixmap, pGCtmp,
				pPixmap->drawable.depth,
				0, 0, gWidth, gHeight, 
				0, XYBitmap, (char *)pb);

	    if ((pGC->serialNumber) != (pDrawable->serialNumber))
		ValidateGC(pDrawable, pGC);
	    (*pGC->ops->PushPixels)(pGC, pPixmap, pDrawable,
			       gWidth, gHeight,
			       x + pci->metrics.leftSideBearing,
			       y - pci->metrics.ascent);
	}
	x += pci->metrics.characterWidth;
    }
    (*pDrawable->pScreen->DestroyPixmap)(pPixmap);
    DEALLOCATE_LOCAL(pbits);
    FreeScratchGC(pGCtmp);
}
Example #4
0
void
PsPaintWindow(
  WindowPtr pWin,
  RegionPtr pRegion,
  int       what)
{
  int       status;
  WindowPtr pRoot;

#define FUNCTION        0
#define FOREGROUND      1
#define TILE            2
#define FILLSTYLE       3
#define ABSX            4
#define ABSY            5
#define CLIPMASK        6
#define SUBWINDOW       7
#define COUNT_BITS      8

  pointer              gcval[7];
  pointer              newValues [COUNT_BITS];

  BITS32               gcmask, index, mask;
  RegionRec            prgnWin;
  DDXPointRec          oldCorner;
  BoxRec               box;
  WindowPtr            pBgWin;
  GCPtr                pGC;
  register int         i;
  register BoxPtr      pbox;
  register ScreenPtr   pScreen = pWin->drawable.pScreen;
  register xRectangle *prect;
  int                  numRects;

  gcmask = 0;

  /*
   * We don't want to paint a window that has no place to put the
   * PS output.
   */
  if( PsGetContextFromWindow(pWin)==(XpContextPtr)NULL ) return;

  if( what==PW_BACKGROUND )
  {
    switch(pWin->backgroundState)
    {
      case None: return;
      case ParentRelative:
        (*pWin->parent->drawable.pScreen->PaintWindowBackground)
          (pWin->parent, pRegion, what);
        return;
      case BackgroundPixel:
        newValues[FOREGROUND] = (pointer)pWin->background.pixel;
        newValues[FILLSTYLE] = (pointer)FillSolid;
        gcmask |= GCForeground | GCFillStyle;
        break;
      case BackgroundPixmap:
        newValues[TILE] = (pointer)pWin->background.pixmap;
        newValues[FILLSTYLE] = (pointer)FillTiled;
        gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
        break;
    }
  }
  else
  {
    if( pWin->borderIsPixel )
    {
      newValues[FOREGROUND] = (pointer)pWin->border.pixel;
      newValues[FILLSTYLE] = (pointer)FillSolid;
      gcmask |= GCForeground | GCFillStyle;
    }
    else
    {
      newValues[TILE] = (pointer)pWin->border.pixmap;
      newValues[FILLSTYLE] = (pointer)FillTiled;
      gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
    }
  }

  prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
                                         sizeof(xRectangle));
  if( !prect ) return;

  newValues[FUNCTION] = (pointer)GXcopy;
  gcmask |= GCFunction | GCClipMask;

  i = pScreen->myNum;
  pRoot = WindowTable[i];

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

  pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
  if( !pGC )
  {
    DEALLOCATE_LOCAL(prect);
    return;
  }
  /*
   * mash the clip list so we can paint the border by
   * mangling the window in place, pretending it
   * spans the entire screen
   */
  if( what==PW_BORDER )
  {
    prgnWin = pWin->clipList;
    oldCorner.x = pWin->drawable.x;
    oldCorner.y = pWin->drawable.y;
    pWin->drawable.x = pWin->drawable.y = 0;
    box.x1 = 0;
    box.y1 = 0;
    box.x2 = pScreen->width;
    box.y2 = pScreen->height;
    REGION_INIT(pScreen, &pWin->clipList, &box, 1);
    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
    newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
    newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
  }
  else
  {
    newValues[ABSX] = (pointer)0;
    newValues[ABSY] = (pointer)0;
  }

/*
 * XXX Backing store is turned off for the PS driver

  if( pWin->backStorage )
    (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
 */

  mask = gcmask;
  gcmask = 0;
  i = 0;
  while( mask )
  {
    index = lowbit (mask);
    mask &= ~index;
    switch(index)
    {
      case GCFunction:
        if( (pointer)(long)pGC->alu!=newValues[FUNCTION] )
        {
          gcmask |= index;
          gcval[i++] = newValues[FUNCTION];
        }
        break;
      case GCTileStipXOrigin:
        if( (pointer)(long)pGC->patOrg.x!=newValues[ABSX] )
        {
          gcmask |= index;
          gcval[i++] = newValues[ABSX];
        }
        break;
      case GCTileStipYOrigin:
        if( (pointer)(long)pGC->patOrg.y!=newValues[ABSY] )
        {
          gcmask |= index;
          gcval[i++] = newValues[ABSY];
        }
        break;
      case GCClipMask:
        if( (pointer)pGC->clientClipType!=(pointer)CT_NONE )
        {
          gcmask |= index;
          gcval[i++] = (pointer)CT_NONE;
        }
        break;
      case GCSubwindowMode:
        if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] )
        {
          gcmask |= index;
          gcval[i++] = newValues[SUBWINDOW];
        }
        break;
      case GCTile:
        if( pGC->tileIsPixel || (pointer)pGC->tile.pixmap!=newValues[TILE] )
        {
          gcmask |= index;
          gcval[i++] = newValues[TILE];
        }
        break;
      case GCFillStyle:
        if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] )
        {
          gcmask |= index;
          gcval[i++] = newValues[FILLSTYLE];
        }
        break;
      case GCForeground:
        if( (pointer)pGC->fgPixel!=newValues[FOREGROUND] )
        {
          gcmask |= index;
          gcval[i++] = newValues[FOREGROUND];
        }
        break;
    }
  }

  if( gcmask ) DoChangeGC(pGC, gcmask, (XID *)gcval, 1);

  if( pWin->drawable.serialNumber!=pGC->serialNumber )
    ValidateGC((DrawablePtr)pWin, pGC);

  numRects = REGION_NUM_RECTS(pRegion);
  pbox = REGION_RECTS(pRegion);
  for( i=numRects ; --i >= 0 ; pbox++,prect++ )
  {
    prect->x = pbox->x1 - pWin->drawable.x;
    prect->y = pbox->y1 - pWin->drawable.y;
    prect->width = pbox->x2 - pbox->x1;
    prect->height = pbox->y2 - pbox->y1;
  }
  prect -= numRects;
  (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
  DEALLOCATE_LOCAL(prect);

/*
 * XXX Backing store is turned off for the PS driver

  if( pWin->backStorage )
    (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
 */

  if( what==PW_BORDER )
  {
    REGION_UNINIT(pScreen, &pWin->clipList);
    pWin->clipList = prgnWin;
    pWin->drawable.x = oldCorner.x;
    pWin->drawable.y = oldCorner.y;
    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
  }
  FreeScratchGC(pGC);
}
Example #5
0
static void
miFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC, unsigned long pixel,
		  SpanDataPtr spanData, int y, int overall_height,
		  PolyEdgePtr left, PolyEdgePtr right,
		  int left_count, int right_count)
{
    int left_x = 0, left_e = 0;
    int	left_stepx = 0;
    int	left_signdx = 0;
    int	left_dy = 0, left_dx = 0;

    int right_x = 0, right_e = 0;
    int	right_stepx = 0;
    int	right_signdx = 0;
    int	right_dy = 0, right_dx = 0;

    int	height = 0;
    int	left_height = 0, right_height = 0;

    DDXPointPtr ppt;
    DDXPointPtr pptInit = NULL;
    int 	*pwidth;
    int 	*pwidthInit = NULL;
    XID		oldPixel;
    int		xorg;
    Spans	spanRec;

    left_height = 0;
    right_height = 0;
    
    if (!spanData)
    {
    	pptInit = (DDXPointPtr) ALLOCATE_LOCAL (overall_height * sizeof(*ppt));
    	if (!pptInit)
	    return;
    	pwidthInit = (int *) ALLOCATE_LOCAL (overall_height * sizeof(*pwidth));
    	if (!pwidthInit)
    	{
	    DEALLOCATE_LOCAL (pptInit);
	    return;
    	}
	ppt = pptInit;
	pwidth = pwidthInit;
    	oldPixel = pGC->fgPixel;
    	if (pixel != oldPixel)
    	{
	    XID tmpPixel = (XID)pixel;
    	    DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE);
    	    ValidateGC (pDrawable, pGC);
    	}
    }
    else
    {
	spanRec.points = (DDXPointPtr) xalloc (overall_height * sizeof (*ppt));
	if (!spanRec.points)
	    return;
	spanRec.widths = (int *) xalloc (overall_height * sizeof (int));
	if (!spanRec.widths)
	{
	    xfree (spanRec.points);
	    return;
	}
	ppt = spanRec.points;
	pwidth = spanRec.widths;
    }

    xorg = 0;
    if (pGC->miTranslate)
    {
	y += pDrawable->y;
	xorg = pDrawable->x;
    }
    while ((left_count || left_height) &&
	   (right_count || right_height))
    {
	MIPOLYRELOADLEFT
	MIPOLYRELOADRIGHT

	height = left_height;
	if (height > right_height)
	    height = right_height;

	left_height -= height;
	right_height -= height;

	while (--height >= 0)
	{
	    if (right_x >= left_x)
	    {
		ppt->y = y;
		ppt->x = left_x + xorg;
		ppt++;
		*pwidth++ = right_x - left_x + 1;
	    }
    	    y++;
    	
	    MIPOLYSTEPLEFT

	    MIPOLYSTEPRIGHT
	}
    }
    if (!spanData)
    {
    	(*pGC->ops->FillSpans) (pDrawable, pGC, ppt - pptInit, pptInit, pwidthInit, TRUE);
    	DEALLOCATE_LOCAL (pwidthInit);
    	DEALLOCATE_LOCAL (pptInit);
    	if (pixel != oldPixel)
    	{
	    DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
	    ValidateGC (pDrawable, pGC);
    	}
    }
    else
    {
	spanRec.count = ppt - spanRec.points;
	AppendSpanGroup (pGC, pixel, &spanRec, spanData)
    }
}
Example #6
0
static void
miFillRectPolyHelper (
    DrawablePtr	pDrawable,
    GCPtr	pGC,
    unsigned long   pixel,
    SpanDataPtr	spanData,
    int		x,
    int		y,
    int		w,
    int		h)
{
    DDXPointPtr ppt;
    int 	*pwidth;
    XID		oldPixel;
    Spans	spanRec;
    xRectangle  rect;

    if (!spanData)
    {
	rect.x = x;
	rect.y = y;
	rect.width = w;
	rect.height = h;
    	oldPixel = pGC->fgPixel;
    	if (pixel != oldPixel)
    	{
	    XID tmpPixel = (XID)pixel;
    	    DoChangeGC (pGC, GCForeground, &tmpPixel, FALSE);
    	    ValidateGC (pDrawable, pGC);
    	}
	(*pGC->ops->PolyFillRect) (pDrawable, pGC, 1, &rect);
    	if (pixel != oldPixel)
    	{
	    DoChangeGC (pGC, GCForeground, &oldPixel, FALSE);
	    ValidateGC (pDrawable, pGC);
    	}
    }
    else
    {
	spanRec.points = (DDXPointPtr) xalloc (h * sizeof (*ppt));
	if (!spanRec.points)
	    return;
	spanRec.widths = (int *) xalloc (h * sizeof (int));
	if (!spanRec.widths)
	{
	    xfree (spanRec.points);
	    return;
	}
	ppt = spanRec.points;
	pwidth = spanRec.widths;

    	if (pGC->miTranslate)
    	{
	    y += pDrawable->y;
	    x += pDrawable->x;
    	}
	while (h--)
	{
	    ppt->x = x;
	    ppt->y = y;
	    ppt++;
	    *pwidth++ = w;
	    y++;
	}
	spanRec.count = ppt - spanRec.points;
	AppendSpanGroup (pGC, pixel, &spanRec, spanData)
    }
}