#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "win.h"
void
winSetSpansNativeGDI (DrawablePtr pDrawable,
GCPtr pGC,
char *pSrcs,
DDXPointPtr pPoints,
int *piWidths,
int iSpans,
int fSorted)
{
winGCPriv(pGC);
PixmapPtr pPixmap = NULL;
winPrivPixmapPtr pPixmapPriv = NULL;
HBITMAP hbmpOrig = NULL;
BITMAPINFO bmi;
HRGN hrgn = NULL, combined = NULL;
int nbox;
BoxPtr pbox;
nbox = REGION_NUM_RECTS (pGC->pCompositeClip);
pbox = REGION_RECTS (pGC->pCompositeClip);
if (!nbox) return;
combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
nbox--; pbox++;
while (nbox--)
{
hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
CombineRgn (combined, combined, hrgn, RGN_OR);
DeleteObject (hrgn);
hrgn = NULL;
pbox++;
}
switch (pDrawable->type)
{
case DRAWABLE_PIXMAP:
SelectClipRgn (pGCPriv->hdcMem, combined);
DeleteObject (combined);
combined = NULL;
pPixmap = (PixmapPtr) pDrawable;
pPixmapPriv = winGetPixmapPriv (pPixmap);
hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
if (hbmpOrig == NULL)
FatalError ("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
"failed on pPixmapPriv->hBitmap\n");
while (iSpans--)
{
ZeroMemory (&bmi, sizeof (BITMAPINFO));
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = *piWidths;
bmi.bmiHeader.biHeight = 1;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = pDrawable->depth;
bmi.bmiHeader.biCompression = BI_RGB;
if (pDrawable->depth == 1)
{
bmi.bmiColors[1].rgbBlue = 255;
bmi.bmiColors[1].rgbGreen = 255;
bmi.bmiColors[1].rgbRed = 255;
}
StretchDIBits (pGCPriv->hdcMem,
pPoints->x, pPoints->y,
*piWidths, 1,
0, 0,
*piWidths, 1,
pSrcs,
(BITMAPINFO *) &bmi,
DIB_RGB_COLORS,
g_copyROP[pGC->alu]);
pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
pPoints++;
piWidths++;
}
SelectClipRgn (pGCPriv->hdcMem, NULL);
SelectObject (pGCPriv->hdcMem, hbmpOrig);
break;
case DRAWABLE_WINDOW:
SelectClipRgn (pGCPriv->hdc, combined);
DeleteObject (combined);
combined = NULL;
while (iSpans--)
{
ZeroMemory (&bmi, sizeof (BITMAPINFO));
bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = *piWidths;
bmi.bmiHeader.biHeight = 1;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = pDrawable->depth;
bmi.bmiHeader.biCompression = BI_RGB;
if (pDrawable->depth == 1)
{
bmi.bmiColors[1].rgbBlue = 255;
bmi.bmiColors[1].rgbGreen = 255;
bmi.bmiColors[1].rgbRed = 255;
}
StretchDIBits (pGCPriv->hdc,
pPoints->x, pPoints->y,
*piWidths, 1,
0, 0,
*piWidths, 1,
pSrcs,
(BITMAPINFO *) &bmi,
DIB_RGB_COLORS,
g_copyROP[pGC->alu]);
pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
pPoints++;
piWidths++;
}
SelectClipRgn (pGCPriv->hdc, NULL);
break;
case UNDRAWABLE_WINDOW:
FatalError ("\nwinSetSpansNativeGDI - UNDRAWABLE_WINDOW\n\n");
break;
case DRAWABLE_BUFFER:
FatalError ("\nwinSetSpansNativeGDI - DRAWABLE_BUFFER\n\n");
break;
default:
FatalError ("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");
break;
}
}