Ignore:
Timestamp:
Jul 15, 2002, 12:02:30 PM (23 years ago)
Author:
sandervl
Message:

Handle management updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/blit.cpp

    r7791 r8871  
    1 /* $Id: blit.cpp,v 1.38 2002-01-29 14:36:31 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.39 2002-07-15 10:02:28 sandervl Exp $ */
    22
    33/*
     
    3232                         int nWidthSrc, int nHeightSrc, DWORD dwRop)
    3333{
    34  BOOL rc;
    35 
    36   dprintf(("GDI32: StretchBlt Dest: %x (%d, %d) size (%d, %d) ROP %x",
    37            hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop));
    38   dprintf(("GDI32: StretchBlt Src : %x (%d, %d) size (%d, %d)\n",
    39            hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc));
    40 
    41   SetLastError(ERROR_SUCCESS);
    42   if(DIBSection::getSection() != NULL)
    43   {
    44     DIBSection *dsect = DIBSection::findHDC(hdcSrc);
    45     if(dsect)
    46     {
    47         rc  = dsect->BitBlt( hdcDest,
    48                              nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
    49                              nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc,
    50                              dwRop);
    51         dprintf(("GDI32: StretchBlt returned %d", rc));
    52         return rc;
    53     }
    54   }
    55   rc = O32_StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop);
    56   if(DIBSection::getSection() != NULL) {
    57       DIBSection *destdib = DIBSection::findHDC(hdcDest);
    58       if(destdib) {
    59           destdib->sync(hdcDest, nYOriginDest, nHeightDest);
    60       }
    61   }
    62   if(rc == FALSE) {
    63       dprintf(("!WARNING!: GDI32: StretchBlt returned FALSE; last error %x", rc, GetLastError()));
    64   }
    65   return rc;
     34    BOOL rc;
     35
     36    dprintf(("GDI32: StretchBlt Dest: %x (%d, %d) size (%d, %d) ROP %x",
     37             hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop));
     38    dprintf(("GDI32: StretchBlt Src : %x (%d, %d) size (%d, %d)\n",
     39             hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc));
     40
     41    SetLastError(ERROR_SUCCESS);
     42    if(DIBSection::getSection() != NULL)
     43    {
     44        DIBSection *dsect = DIBSection::findHDC(hdcSrc);
     45        if(dsect)
     46        {
     47            rc  = dsect->BitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
     48                                nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop);
     49            dprintf(("GDI32: StretchBlt returned %d", rc));
     50            return rc;
     51        }
     52    }
     53    rc = O32_StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop);
     54    if(DIBSection::getSection() != NULL) {
     55        DIBSection *destdib = DIBSection::findHDC(hdcDest);
     56        if(destdib) {
     57            destdib->sync(hdcDest, nYOriginDest, nHeightDest);
     58        }
     59    }
     60    if(rc == FALSE) {
     61        dprintf(("!WARNING!: GDI32: StretchBlt returned FALSE; last error %x", rc, GetLastError()));
     62    }
     63    return rc;
    6664}
    6765//******************************************************************************
     
    7775                     DWORD  dwRop)
    7876{
    79   BOOL rc;
    80 
    81   POINT point1, point2;
    82   GetViewportOrgEx(hdcDest, &point1);
    83   GetViewportOrgEx(hdcSrc, &point2);
    84   dprintf(("BitBlt: Viewport origin dest (%d,%d) src (%d,%d)", point1.x, point1.y, point2.x, point2.y));
    85 
    86   SetLastError(ERROR_SUCCESS);
    87   if(DIBSection::getSection() != NULL)
    88   {
    89     DIBSection *dsect = DIBSection::findHDC(hdcSrc);
    90     if(dsect)
    91     {
    92       return dsect->BitBlt(hdcDest,
    93                            nXDest,
    94                            nYDest,
    95                            nWidth,
    96                            nHeight,
    97                            nXSrc,
    98                            nYSrc,
    99                            nWidth,
    100                            nHeight,
    101                            dwRop);
    102     }
    103   }
    104   dprintf(("GDI32: BitBlt to hdc %X from hdc %x (%d,%d) to (%d,%d), (%d,%d) rop %X\n",
    105            hdcDest, hdcSrc, nXSrc, nYSrc, nXDest, nYDest, nWidth, nHeight, dwRop));
    106 
    107   rc = O32_BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
    108 
    109   if(DIBSection::getSection() != NULL) {
    110       DIBSection *destdib = DIBSection::findHDC(hdcDest);
    111       if(destdib) {
    112           destdib->sync(hdcDest, nYDest, nHeight);
    113       }
    114   }
    115   return rc;
     77    BOOL rc;
     78
     79#ifdef DEBUG
     80      POINT point1, point2;
     81    GetViewportOrgEx(hdcDest, &point1);
     82    GetViewportOrgEx(hdcSrc, &point2);
     83    dprintf(("BitBlt: Viewport origin dest (%d,%d) src (%d,%d)", point1.x, point1.y, point2.x, point2.y));
     84#endif
     85
     86    SetLastError(ERROR_SUCCESS);
     87    if(DIBSection::getSection() != NULL)
     88    {
     89        DIBSection *dsect = DIBSection::findHDC(hdcSrc);
     90        if(dsect)
     91        {
     92            return dsect->BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc, nWidth, nHeight, dwRop);
     93        }
     94    }
     95    dprintf(("GDI32: BitBlt to hdc %X from hdc %x (%d,%d) to (%d,%d), (%d,%d) rop %X\n",
     96             hdcDest, hdcSrc, nXSrc, nYSrc, nXDest, nYDest, nWidth, nHeight, dwRop));
     97
     98    rc = O32_BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
     99
     100    if(DIBSection::getSection() != NULL) {
     101        DIBSection *destdib = DIBSection::findHDC(hdcDest);
     102        if(destdib) {
     103            destdib->sync(hdcDest, nYDest, nHeight);
     104        }
     105    }
     106    return rc;
    116107}
    117108//******************************************************************************
     
    169160    case 15:
    170161    case 16: //Default if BI_BITFIELDS not set is RGB 555
    171         bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0x7c00;
    172         bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 1) : 0x03e0;
    173         bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0x001f;
     162        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors       : DEFAULT_16BPP_RED_MASK;
     163        bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK;
     164        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK;
    174165        break;
    175166
    176167    case 24:
    177168    case 32:
    178         bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;
    179         bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 1) : 0xff00;
    180         bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0xff;
     169        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors       : DEFAULT_24BPP_RED_MASK;
     170        bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK;
     171        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK;
    181172        break;
    182173    default:
     
    205196    }
    206197    if(startscan != 0 || lines != info->bmiHeader.biHeight) {
    207         dprintf(("WARNING: SetDIBitsToDevice startscan != 0 || lines != info->bmiHeader.biHeight"));
     198            dprintf(("WARNING: SetDIBitsToDevice startscan != 0 || lines != info->bmiHeader.biHeight"));
    208199        dprintf(("info bmp (%d,%d)", info->bmiHeader.biWidth, info->bmiHeader.biHeight));
    209200    }
     
    215206    //Open32 always returns height of bitmap (regardless of how many scanlines were copied)
    216207    if(result != info->bmiHeader.biHeight) {
    217         dprintf(("SetDIBitsToDevice failed with rc %x", result));
     208            dprintf(("SetDIBitsToDevice failed with rc %x", result));
    218209    }
    219210    else
     
    240231    }
    241232    if(newbits) free(newbits);
     233
    242234    ((BITMAPINFO *)info)->bmiHeader.biSizeImage = bmpsize;
    243235    return result;
     
    413405BOOL WIN32API PatBlt(HDC hdc,int nXLeft,int nYLeft,int nWidth,int nHeight,DWORD dwRop)
    414406{
    415   BOOL rc;
    416 
    417   dprintf(("PatBlt %x (%d,%d)(%d,%d) %x", hdc, nXLeft,nYLeft,nWidth,nHeight, dwRop));
    418   //CB: Open32 bug: negative width/height not supported!
    419   if (nWidth < 0)
    420   {
    421     nXLeft += nWidth+1;
    422     nWidth = -nWidth;
    423   }
    424   if (nHeight < 0)
    425   {
    426     nYLeft += nHeight+1;
    427     nHeight = -nHeight;
    428   }
    429   rc = O32_PatBlt(hdc,nXLeft,nYLeft,nWidth,nHeight,dwRop);
    430   if(rc) {
    431         DIBSection *destdib = DIBSection::findHDC(hdc);
    432         if(destdib) {
    433                 destdib->sync(hdc, nYLeft, nHeight);
    434         }
    435   }
    436 
    437   dprintf(("GDI32: PatBlt hdc %x (%d,%d) (%d,%d) returned %d\n",hdc, nXLeft,nYLeft,nWidth,nHeight,rc));
    438   return(rc);
     407    BOOL rc;
     408
     409    dprintf(("PatBlt %x (%d,%d)(%d,%d) %x", hdc, nXLeft,nYLeft,nWidth,nHeight, dwRop));
     410    //CB: Open32 bug: negative width/height not supported!
     411    if (nWidth < 0)
     412    {
     413        nXLeft += nWidth+1;
     414        nWidth = -nWidth;
     415    }
     416    if (nHeight < 0)
     417    {
     418        nYLeft += nHeight+1;
     419        nHeight = -nHeight;
     420    }
     421    rc = O32_PatBlt(hdc,nXLeft,nYLeft,nWidth,nHeight,dwRop);
     422    if(rc) {
     423        DIBSection *destdib = DIBSection::findHDC(hdc);
     424        if(destdib) {
     425                    destdib->sync(hdc, nYLeft, nHeight);
     426            }
     427    }
     428
     429    dprintf(("GDI32: PatBlt hdc %x (%d,%d) (%d,%d) returned %d\n",hdc, nXLeft,nYLeft,nWidth,nHeight,rc));
     430    return(rc);
    439431}
    440432//******************************************************************************
     
    451443                     int xMast, int yMask)
    452444{
    453   dprintf(("GDI32: PlgBlt, not implemented\n"));
    454   return(FALSE);
     445    dprintf(("GDI32: PlgBlt, not implemented\n"));
     446    return(FALSE);
    455447}
    456448//******************************************************************************
     
    461453                           const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
    462454{
    463  INT rc;
    464  DWORD bitfields[3], compression = 0;
    465  WORD *newbits = NULL;
     455    INT rc;
     456    DWORD bitfields[3], compression = 0;
     457    WORD *newbits = NULL;
    466458
    467459    dprintf(("GDI32: StretchDIBits %x to (%d,%d) (%d,%d) from (%d,%d) (%d,%d), %x %x %x %x", hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc, widthSrc, heightSrc, bits, info, wUsage, dwRop));
     
    486478
    487479        if(GetDIBColorTable(hdc, 0, info->bmiHeader.biClrUsed, pColors) == 0) {
    488                 dprintf(("ERROR: StretchDIBits: GetDIBColorTable failed!!"));
     480                    dprintf(("ERROR: StretchDIBits: GetDIBColorTable failed!!"));
    489481                return FALSE;
    490482        }
     
    500492        //Open32 always returns height of bitmap (regardless of how many scanlines were copied)
    501493        if(rc != heightSrc && rc != infoLoc->bmiHeader.biHeight) {
    502                 dprintf(("StretchDIBits failed with rc %x", rc));
     494                    dprintf(("StretchDIBits failed with rc %x", rc));
    503495        }
    504         else {
    505                 rc = heightSrc;
    506 
    507                 DIBSection *destdib = DIBSection::findHDC(hdc);
    508                 if(destdib) {
    509                         if(widthDst == widthSrc && heightDst == heightSrc &&
    510                            destdib->GetBitCount() == infoLoc->bmiHeader.biBitCount &&
    511                            destdib->GetBitCount() == 8)
    512                         {
    513                                 destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);
    514                         }
    515                         else    destdib->sync(hdc, yDst, heightDst);
    516                 }
    517         }
    518 
    519         return rc;
     496            else {
     497                    rc = heightSrc;
     498
     499                    DIBSection *destdib = DIBSection::findHDC(hdc);
     500                    if(destdib) {
     501                        if(widthDst == widthSrc && heightDst == heightSrc &&
     502                            destdib->GetBitCount() == infoLoc->bmiHeader.biBitCount &&
     503                            destdib->GetBitCount() == 8)
     504                {
     505                                    destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);
     506                            }
     507                            else        destdib->sync(hdc, yDst, heightDst);
     508                    }
     509            }
     510   
     511        return rc;
    520512    }
    521513
     
    523515    case 15:
    524516    case 16: //Default if BI_BITFIELDS not set is RGB 555
    525         bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0x7c00;
    526         bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 1) : 0x03e0;
    527         bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0x001f;
     517        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors       : DEFAULT_16BPP_RED_MASK;
     518        bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK;
     519        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK;
    528520        break;
    529521    case 24:
    530522    case 32:
    531         bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;
    532         bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 1) : 0xff00;
    533         bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ?  *((DWORD *)info->bmiColors + 2) : 0xff;
     523        bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors       : DEFAULT_24BPP_RED_MASK;
     524        bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK;
     525        bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK;
    534526        break;
    535527    default:
     
    539531        break;
    540532    }
    541     if(bitfields[1] == 0x3E0)
     533    if(bitfields[1] == RGB555_GREEN_MASK)
    542534    {//RGB 555?
    543535        dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2]));
     
    570562    //Open32 always returns height of bitmap (regardless of how many scanlines were copied)
    571563    if(rc != heightSrc && rc != info->bmiHeader.biHeight) {
    572         dprintf(("StretchDIBits failed with rc %x", rc));
     564            dprintf(("StretchDIBits failed with rc %x", rc));
    573565    }
    574566    else
    575567    {
    576         rc = heightSrc;
    577 
    578         DIBSection *destdib = DIBSection::findHDC(hdc);
    579         if(destdib) {
    580                 if(widthDst == widthSrc && heightDst == heightSrc &&
    581                    destdib->GetBitCount() == info->bmiHeader.biBitCount &&
    582                    destdib->GetBitCount() == 8)
    583                 {
    584                         destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);
    585                 }
    586                 else    destdib->sync(hdc, yDst, heightDst);
    587         }
     568            rc = heightSrc;
     569
     570            DIBSection *destdib = DIBSection::findHDC(hdc);
     571            if(destdib) {
     572                if(widthDst == widthSrc && heightDst == heightSrc &&
     573                    destdib->GetBitCount() == info->bmiHeader.biBitCount &&
     574                    destdib->GetBitCount() == 8)
     575            {
     576                             destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);
     577                    }
     578                    else destdib->sync(hdc, yDst, heightDst);
     579            }
    588580    }
    589581
     
    636628  dprintf(("GDI32: SetStretchBltMode 0x%08X, 0x%08X\n",arg1, arg2));
    637629
    638   if(DIBSection::getSection() != NULL)
    639   {
    640     DIBSection *dsect = DIBSection::findHDC(arg1);
    641     if(dsect)
    642     {
    643       dprintf(("       - DC is DIBSection\n"));
    644     }
    645   }
    646   return O32_SetStretchBltMode(arg1, arg2);
     630    if(DIBSection::getSection() != NULL)
     631    {
     632        DIBSection *dsect = DIBSection::findHDC(arg1);
     633        if(dsect)
     634        {
     635            dprintf(("       - DC is DIBSection\n"));
     636        }
     637    }
     638    return O32_SetStretchBltMode(arg1, arg2);
    647639}
    648640//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.