#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "win.h"
void
winGetSpansNativeGDI (DrawablePtr pDrawable,
int nMax,
DDXPointPtr pPoints,
int *piWidths,
int iSpans,
char *pDsts)
{
PixmapPtr pPixmap = NULL;
winPrivPixmapPtr pPixmapPriv = NULL;
int iSpan;
DDXPointPtr pPoint = NULL;
int *piWidth = NULL;
char *pDst = pDsts;
HBITMAP hbmpWindow, hbmpOrig, hbmpOrig1;
BYTE *pbWindow = NULL;
HDC hdcMem, hdcMem1;
ScreenPtr pScreen = pDrawable->pScreen;
winScreenPriv(pScreen);
switch (pDrawable->type)
{
case DRAWABLE_PIXMAP:
#if 0
ErrorF ("winGetSpans - DRAWABLE_PIXMAP %08x\n",
pDrawable);
#endif
pPixmap = (PixmapPtr) pDrawable;
pPixmapPriv = winGetPixmapPriv (pPixmap);
hdcMem1 = CreateCompatibleDC (NULL);
hdcMem = CreateCompatibleDC (NULL);
hbmpOrig1 = SelectObject (hdcMem1, pPixmapPriv->hBitmap);
if (hbmpOrig1 == NULL)
FatalError ("winGetSpans - DRAWABLE_PIXMAP - SelectObject () "
"failed on pPixmapPriv->hBitmap\n");
for (iSpan = 0; iSpan < iSpans; ++iSpan)
{
pPoint = pPoints + iSpan;
piWidth = piWidths + iSpan;
hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1,
pDrawable->depth,
&pbWindow,
NULL);
hbmpOrig = SelectObject (hdcMem, hbmpWindow);
BitBlt (hdcMem,
0, 0,
*piWidth, 1,
hdcMem1,
pPoint->x, pPoint->y,
SRCCOPY);
memcpy (pDst,
(char*) pbWindow,
PixmapBytePad (*piWidth, pDrawable->depth));
SelectObject (hdcMem, hbmpOrig);
DeleteObject (hbmpWindow);
#if 0
ErrorF ("(%dx%dx%d) (%d,%d) w: %d\n",
pDrawable->width, pDrawable->height, pDrawable->depth,
pPoint->x, pPoint->y, *piWidth);
#endif
pDst += PixmapBytePad (*piWidth, pDrawable->depth);
}
SelectObject (hdcMem1, hbmpOrig1);
DeleteDC (hdcMem1);
DeleteDC (hdcMem);
break;
case DRAWABLE_WINDOW:
#if 0
ErrorF ("winGetSpans - DRAWABLE_WINDOW\n");
#endif
hdcMem = CreateCompatibleDC (NULL);
for (iSpan = 0; iSpan < iSpans; ++iSpan)
{
pPoint = pPoints + iSpan;
piWidth = piWidths + iSpan;
hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1,
pDrawable->depth,
&pbWindow,
NULL);
hbmpOrig = SelectObject (hdcMem, hbmpWindow);
BitBlt (hdcMem,
0, 0,
*piWidth, 1,
pScreenPriv->hdcScreen,
pPoint->x, pPoint->y,
SRCCOPY);
memcpy (pDst,
(char*) pbWindow,
PixmapBytePad (*piWidth, pDrawable->depth));
SelectObject (hdcMem, hbmpOrig);
DeleteObject (hbmpWindow);
#if 0
ErrorF ("(%dx%dx%d) (%d,%d) w: %d\n",
pDrawable->width, pDrawable->height, pDrawable->depth,
pPoint->x, pPoint->y, *piWidth);
#endif
pDst += PixmapBytePad (*piWidth, pDrawable->depth);
}
DeleteDC (hdcMem);
break;
case UNDRAWABLE_WINDOW:
FatalError ("winGetSpans - UNDRAWABLE_WINDOW\n");
break;
case DRAWABLE_BUFFER:
FatalError ("winGetSpans - DRAWABLE_BUFFER\n");
break;
default:
FatalError ("winGetSpans - Unknown drawable type\n");
break;
}
}