Changeset 3418 for trunk/src


Ignore:
Timestamp:
Apr 18, 2000, 1:11:52 PM (25 years ago)
Author:
sandervl
Message:

dib section fixes

Location:
trunk/src/gdi32
Files:
3 edited

Legend:

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

    r3343 r3418  
    1 /* $Id: blit.cpp,v 1.9 2000-04-07 17:07:16 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.10 2000-04-18 11:11:52 sandervl Exp $ */
    22
    33/*
     
    4444    if(dsect)
    4545    {
    46         dprintf((" Do stretched DIB Blt\n"));
    4746        rc  = dsect->BitBlt( hdcDest,
    4847                             nXOriginDest, nYOriginDest, nWidthDest, nHeightDest,
     
    192191  }
    193192  rc = O32_PatBlt(hdc,nXLeft,nYLeft,nWidth,nHeight,dwRop);
    194   dprintf(("GDI32: PatBlt (%d,%d) (%d,%d) returned %d\n",nXLeft,nYLeft,nWidth,nHeight,rc));
     193  if(rc) {
     194        DIBSection *destdib = DIBSection::findHDC(hdc);
     195        if(destdib) {
     196                destdib->sync(hdc, nYLeft, nHeight);
     197        }
     198  }
     199
     200  dprintf(("GDI32: PatBlt hdc %x (%d,%d) (%d,%d) returned %d\n",hdc, nXLeft,nYLeft,nWidth,nHeight,rc));
    195201  return(rc);
    196202}
  • trunk/src/gdi32/dibsect.cpp

    r3371 r3418  
    1 /* $Id: dibsect.cpp,v 1.27 2000-04-13 18:47:16 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.28 2000-04-18 11:11:52 sandervl Exp $ */
    22
    33/*
     
    381381 HPS    hps = (HPS)hdcDest;
    382382 POINTL point[4];
    383  LONG   rc;
     383 LONG   rc, hdcHeight, hdcWidth;
    384384 PVOID  bitmapBits = NULL;
    385385 int    oldyinversion = 0;
    386  BOOL   fRestoryYInversion = FALSE;
    387 
    388 #if 1
    389   HWND hwndDest = WindowFromDC(hdcDest);
    390   hwndDest = Win32ToOS2Handle(hwndDest);
    391   if(hwndDest != 0)
    392   {
    393         hps = WinGetPS(hwndDest);
    394   }
    395   if(hps == 0)
    396   {
    397     dprintf(("ERROR: DIBSection::BitBlt, hps == 0 hwndDest = %X", hwndDest));
    398     return(FALSE);
    399   }
    400 #endif
    401 
    402   if(nDestWidth == 160 && nDestHeight == 120) {
    403         nSrcWidth = 160;
    404   }
     386 BOOL   fRestoryYInversion = FALSE, fFrameWindowDC = FALSE;
     387 HWND   hwndDest;
     388
     389  hwndDest = WindowFromDC(hdcDest);
     390  //TODO: Test whether dc is for the client or frame window
     391//  if(hwndDest && IsOS2FrameWindowHandle(hwndDest)) {
     392//      fFrameWindowDC = TRUE;
     393//  }
    405394
    406395  dprintf(("DIBSection::BitBlt %x %X (hps %x) %x to(%d,%d)(%d,%d) from (%d,%d)(%d,%d) rop %x flip %x",
    407396          handle, hdcDest, hps, hwndDest, nXdest, nYdest, nDestWidth, nDestHeight,
    408 //          handle, hdcDest, hps, 0, nXdest, nYdest, nDestWidth, nDestHeight,
    409397          nXsrc, nYsrc, nSrcWidth, nSrcHeight, Rop, fFlip));
    410398
     399  if(hwndDest) {
     400        RECT rect;
     401
     402        if(fFrameWindowDC) {
     403                GetWindowRect(hwndDest, &rect);
     404        }
     405        else    GetClientRect(hwndDest, &rect);
     406        hdcHeight = rect.bottom - rect.top;
     407        hdcWidth  = rect.right - rect.left;
     408  }
     409  else {
     410        hdcHeight = pOS2bmp->cy;
     411        hdcWidth  = pOS2bmp->cx;
     412  }
     413
    411414  //win32 coordinates are of the left top, OS/2 expects left bottom
     415  //source rectangle is non-inclusive (top, right not included)
     416  if(nXdest + nDestWidth > hdcWidth) {
     417        nDestWidth  = hdcWidth - nXdest;
     418  }
     419  if(nYdest + nDestHeight > hdcHeight) {
     420        nDestHeight = hdcHeight - nYdest;
     421  }
    412422  point[0].x = nXdest;
    413   point[0].y = pOS2bmp->cy - nYdest - nDestHeight;
    414   point[1].x = nXdest + nDestWidth - 1;
    415   point[1].y = pOS2bmp->cy - nYdest - 1;
     423  point[0].y = hdcHeight - nYdest - nDestHeight;
     424  point[1].x = nXdest + nDestWidth;
     425  point[1].y = hdcHeight - nYdest;
     426
     427  //target rectangle is inclusive-inclusive
     428  if(nXsrc + nSrcWidth > pOS2bmp->cx) {
     429        nSrcWidth  = pOS2bmp->cx - nXsrc;
     430  }
     431  if(nYsrc + nSrcHeight > pOS2bmp->cy) {
     432        nSrcHeight = pOS2bmp->cy - nYsrc;
     433  }
    416434  point[2].x = nXsrc;
    417435  point[2].y = pOS2bmp->cy - nYsrc - nSrcHeight;
    418   if(nXsrc + nSrcWidth > pOS2bmp->cx)
    419   {
    420         point[3].x = pOS2bmp->cx;
    421         nSrcWidth  = pOS2bmp->cx - nXsrc;
    422   }
    423   else  point[3].x = nXsrc + nSrcWidth;
    424 
    425   if(nYsrc + nSrcHeight > pOS2bmp->cy)
    426   {
    427         point[3].y = pOS2bmp->cy;
    428         nSrcHeight = pOS2bmp->cy - nYsrc;
    429   }
    430   else  point[3].y = pOS2bmp->cy - nYsrc;
     436  point[3].x = nXsrc + nSrcWidth - 1;
     437  point[3].y = pOS2bmp->cy - nYsrc - 1;
    431438
    432439  oldyinversion = GpiQueryYInversion(hps);
    433440  if(fFlip & FLIP_VERT)
    434441  {
    435         if(oldyinversion != pOS2bmp->cy-1) {
    436                 GpiEnableYInversion(hps, pOS2bmp->cy-1);
     442        if(oldyinversion != hdcHeight-1) {
     443                GpiEnableYInversion(hps, hdcHeight-1);
    437444                fRestoryYInversion = TRUE;
    438445        }
     
    454461  //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc)
    455462  if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
    456         dprintf(("DIBSection::BitBlt; convert rgb 555 to 565 (old y inv. = %d", oldyinversion));
     463        dprintf(("DIBSection::BitBlt; convert rgb 555 to 565 (old y inv. = %d)", oldyinversion));
    457464
    458465        if(bmpBitsRGB565 == NULL)
     
    470477        DIBSection *destdib = DIBSection::findHDC(hdcDest);
    471478        if(destdib) {
    472                 dprintf(("Sync destination dibsection %x (%x) (%d)", destdib->handle, hdcDest, oldyinversion));
    473 
    474                 //todo: rgb 565 to 555 conversion if bpp == 16
    475                 BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(destdib->os2bmphdrsize);
    476                 memcpy(tmphdr, destdib->pOS2bmp, destdib->os2bmphdrsize);
    477                 rc = GpiQueryBitmapBits(hps, nYdest, nDestHeight, destdib->GetDIBObject(),
    478                                         tmphdr);
    479                 free(tmphdr);
    480                 if(rc != nDestHeight) {
    481                         DebugInt3();
    482                 }
     479                destdib->sync(hps, nYdest, nDestHeight);
    483480        }
    484481        //restore old y inversion height
    485482        if(fRestoryYInversion) GpiEnableYInversion(hps, oldyinversion);
    486 #if 1
    487         if(hwndDest != 0)
    488         {
    489                 WinReleasePS(hps);
    490         }
    491 #endif
    492483        return(TRUE);
    493484  }
    494485  if(fRestoryYInversion) GpiEnableYInversion(hps, oldyinversion);
    495 #if 1
    496   if(hwndDest != 0)
    497   {
    498         WinReleasePS(hps);
    499   }
    500 #endif
     486
    501487  dprintf(("DIBSection::BitBlt %X (%d,%d) (%d,%d) to (%d,%d) (%d,%d) returned %d\n", hps, point[0].x, point[0].y, point[1].x, point[1].y, point[2].x, point[2].y, point[3].x, point[3].y, rc));
    502 #if 1
    503488  dprintf(("WinGetLastError returned %X\n", WinGetLastError(WinQueryAnchorBlock(hwndDest)) & 0xFFFF));
    504 #endif
    505489  return(FALSE);
    506490}
    507491//******************************************************************************
    508492//******************************************************************************
     493void DIBSection::sync(HDC hdc, DWORD nYdest, DWORD nDestHeight)
     494{
     495 APIRET rc;
     496 char  *destBuf;
     497
     498  dprintf(("Sync destination dibsection %x (%x)", handle, hdc));
     499
     500  //todo: rgb 565 to 555 conversion if bpp == 16
     501  if(GetBitCount() == 16) {
     502        dprintf(("WARNING: need to convert RGB 565 to RGB 555!!"));
     503  }
     504
     505  BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize);
     506  memcpy(tmphdr, pOS2bmp, os2bmphdrsize);
     507  destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
     508  rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
     509                          tmphdr);
     510  free(tmphdr);
     511  if(rc != nDestHeight) {
     512        DebugInt3();
     513  }
     514}
     515//******************************************************************************
     516//******************************************************************************
    509517void DIBSection::SelectDIBObject(HDC hdc)
    510518{
    511519  this->hdc  = hdc;
    512   hwndParent = WinWindowFromDC(hdc);
     520  hwndParent = WindowFromDC(hdc);
    513521  dprintf(("SelectDIBObject %x into %x hwndParent = %x", handle, hdc, hwndParent));
    514522}
  • trunk/src/gdi32/dibsect.h

    r3302 r3418  
    1 /* $Id: dibsect.h,v 1.15 2000-04-02 12:24:40 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.16 2000-04-18 11:11:52 sandervl Exp $ */
    22
    33/*
     
    8282                           int nSrcWidth, int nSrcHeight,
    8383                           DWORD Rop);
    84 
     84              void  sync(HDC hdc, DWORD nYdest, DWORD nDestHeight);
    8585               int  SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
    8686
Note: See TracChangeset for help on using the changeset viewer.