diff options
Diffstat (limited to 'hw/xwin/wingetsp.c')
-rw-r--r-- | hw/xwin/wingetsp.c | 217 |
1 files changed, 102 insertions, 115 deletions
diff --git a/hw/xwin/wingetsp.c b/hw/xwin/wingetsp.c index 82208127b..049e2c939 100644 --- a/hw/xwin/wingetsp.c +++ b/hw/xwin/wingetsp.c @@ -36,149 +36,136 @@ /* See Porting Layer Definition - p. 55 */ void -winGetSpansNativeGDI (DrawablePtr pDrawable, - int nMax, - DDXPointPtr pPoints, - int *piWidths, - int iSpans, - char *pDsts) +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); - - /* Branch on the drawable type */ - switch (pDrawable->type) - { + 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); + + /* Branch on the drawable type */ + switch (pDrawable->type) { case DRAWABLE_PIXMAP: #if 0 - ErrorF ("winGetSpans - DRAWABLE_PIXMAP %08x\n", - pDrawable); + ErrorF("winGetSpans - DRAWABLE_PIXMAP %08x\n", pDrawable); #endif - pPixmap = (PixmapPtr) pDrawable; - pPixmapPriv = winGetPixmapPriv (pPixmap); - - /* Open a memory HDC */ - hdcMem1 = CreateCompatibleDC (NULL); - hdcMem = CreateCompatibleDC (NULL); - - /* Select the drawable pixmap into a DC */ - hbmpOrig1 = SelectObject (hdcMem1, pPixmapPriv->hBitmap); - - if (hbmpOrig1 == NULL) - FatalError ("winGetSpans - DRAWABLE_PIXMAP - SelectObject () " - "failed on pPixmapPriv->hBitmap\n"); - - /* Loop through spans */ - for (iSpan = 0; iSpan < iSpans; ++iSpan) - { - pPoint = pPoints + iSpan; - piWidth = piWidths + iSpan; - - hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1, - pDrawable->depth, - &pbWindow, - NULL); - - hbmpOrig = SelectObject (hdcMem, hbmpWindow); - - /* Transfer the window bits to the window bitmap */ - BitBlt (hdcMem, - 0, 0, - *piWidth, 1, - hdcMem1, - pPoint->x, pPoint->y, - SRCCOPY); - - memcpy (pDst, - (char*) pbWindow, - PixmapBytePad (*piWidth, pDrawable->depth)); - - /* Pop the window bitmap out of the HDC and delete the bitmap */ - SelectObject (hdcMem, hbmpOrig); - DeleteObject (hbmpWindow); + pPixmap = (PixmapPtr) pDrawable; + pPixmapPriv = winGetPixmapPriv(pPixmap); + + /* Open a memory HDC */ + hdcMem1 = CreateCompatibleDC(NULL); + hdcMem = CreateCompatibleDC(NULL); + + /* Select the drawable pixmap into a DC */ + hbmpOrig1 = SelectObject(hdcMem1, pPixmapPriv->hBitmap); + + if (hbmpOrig1 == NULL) + FatalError("winGetSpans - DRAWABLE_PIXMAP - SelectObject () " + "failed on pPixmapPriv->hBitmap\n"); + + /* Loop through spans */ + for (iSpan = 0; iSpan < iSpans; ++iSpan) { + pPoint = pPoints + iSpan; + piWidth = piWidths + iSpan; + + hbmpWindow = winCreateDIBNativeGDI(*piWidth, 1, + pDrawable->depth, + &pbWindow, NULL); + + hbmpOrig = SelectObject(hdcMem, hbmpWindow); + + /* Transfer the window bits to the window bitmap */ + BitBlt(hdcMem, + 0, 0, *piWidth, 1, hdcMem1, pPoint->x, pPoint->y, SRCCOPY); + + memcpy(pDst, + (char *) pbWindow, + PixmapBytePad(*piWidth, pDrawable->depth)); + + /* Pop the window bitmap out of the HDC and delete the bitmap */ + 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); + ErrorF("(%dx%dx%d) (%d,%d) w: %d\n", + pDrawable->width, pDrawable->height, pDrawable->depth, + pPoint->x, pPoint->y, *piWidth); #endif - /* Calculate offset of next bit destination */ - pDst += PixmapBytePad (*piWidth, pDrawable->depth); - } - - /* Pop the pixmap's bitmap out of the HDC */ - SelectObject (hdcMem1, hbmpOrig1); + /* Calculate offset of next bit destination */ + pDst += PixmapBytePad(*piWidth, pDrawable->depth); + } + + /* Pop the pixmap's bitmap out of the HDC */ + SelectObject(hdcMem1, hbmpOrig1); - /* Delete the HDCs */ - DeleteDC (hdcMem1); - DeleteDC (hdcMem); - break; + /* Delete the HDCs */ + DeleteDC(hdcMem1); + DeleteDC(hdcMem); + break; case DRAWABLE_WINDOW: #if 0 - ErrorF ("winGetSpans - DRAWABLE_WINDOW\n"); + ErrorF("winGetSpans - DRAWABLE_WINDOW\n"); #endif - /* Open a memory HDC */ - hdcMem = CreateCompatibleDC (NULL); + /* Open a memory HDC */ + hdcMem = CreateCompatibleDC(NULL); - /* Loop through spans */ - for (iSpan = 0; iSpan < iSpans; ++iSpan) - { - pPoint = pPoints + iSpan; - piWidth = piWidths + iSpan; + /* Loop through spans */ + for (iSpan = 0; iSpan < iSpans; ++iSpan) { + pPoint = pPoints + iSpan; + piWidth = piWidths + iSpan; - hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1, - pDrawable->depth, - &pbWindow, - NULL); + hbmpWindow = winCreateDIBNativeGDI(*piWidth, 1, + pDrawable->depth, + &pbWindow, NULL); - hbmpOrig = SelectObject (hdcMem, hbmpWindow); + hbmpOrig = SelectObject(hdcMem, hbmpWindow); - /* Transfer the window bits to the window bitmap */ - BitBlt (hdcMem, - 0, 0, - *piWidth, 1, - pScreenPriv->hdcScreen, - pPoint->x, pPoint->y, - SRCCOPY); + /* Transfer the window bits to the window bitmap */ + BitBlt(hdcMem, + 0, 0, + *piWidth, 1, + pScreenPriv->hdcScreen, pPoint->x, pPoint->y, SRCCOPY); - memcpy (pDst, - (char*) pbWindow, - PixmapBytePad (*piWidth, pDrawable->depth)); + memcpy(pDst, + (char *) pbWindow, + PixmapBytePad(*piWidth, pDrawable->depth)); - /* Pop the window bitmap out of the HDC */ - SelectObject (hdcMem, hbmpOrig); + /* Pop the window bitmap out of the HDC */ + SelectObject(hdcMem, hbmpOrig); - DeleteObject (hbmpWindow); + DeleteObject(hbmpWindow); #if 0 - ErrorF ("(%dx%dx%d) (%d,%d) w: %d\n", - pDrawable->width, pDrawable->height, pDrawable->depth, - pPoint->x, pPoint->y, *piWidth); + ErrorF("(%dx%dx%d) (%d,%d) w: %d\n", + pDrawable->width, pDrawable->height, pDrawable->depth, + pPoint->x, pPoint->y, *piWidth); #endif - /* Calculate offset of next bit destination */ - pDst += PixmapBytePad (*piWidth, pDrawable->depth); - } + /* Calculate offset of next bit destination */ + pDst += PixmapBytePad(*piWidth, pDrawable->depth); + } - /* Delete the window bitmap */ - DeleteDC (hdcMem); - break; + /* Delete the window bitmap */ + DeleteDC(hdcMem); + break; default: - FatalError ("winGetSpans - Unknown drawable type\n"); - break; + FatalError("winGetSpans - Unknown drawable type\n"); + break; } } |