Ignore:
Timestamp:
Apr 2, 2000, 2:24:40 PM (25 years ago)
Author:
sandervl
Message:

dib sync bugfixes

File:
1 edited

Legend:

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

    r3292 r3302  
    1 /* $Id: dibsect.cpp,v 1.24 2000-04-01 15:05:30 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.25 2000-04-02 12:24:40 sandervl Exp $ */
    22
    33/*
     
    4040                : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsRGB565(NULL)
    4141{
    42   int  os2bmpsize;
    43 
    4442  bmpsize = pbmi->biWidth;
    4543  /* @@@PH 98/06/07 -- high-color bitmaps don't have palette */
    4644
    4745  this->fFlip = fFlip;
    48   os2bmpsize = sizeof(BITMAPINFO2);
     46  os2bmphdrsize = sizeof(BITMAPINFO2);
    4947
    5048  switch(pbmi->biBitCount)
     
    5250        case 1:
    5351                bmpsize = ((bmpsize + 31) & ~31) / 8;
    54                 os2bmpsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     52                os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
    5553                break;
    5654        case 4:
    5755                bmpsize = ((bmpsize + 7) & ~7) / 2;
    58                 os2bmpsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     56                os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
    5957                break;
    6058        case 8:
    61                 os2bmpsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     59                os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
    6260                bmpsize = (bmpsize + 3) & ~3;
    6361                break;
     
    9290   memset(bmpBits, 0, bmpsize*pbmi->biHeight);
    9391
    94    pOS2bmp = (BITMAPINFO2 *)malloc(os2bmpsize);
     92   pOS2bmp = (BITMAPINFO2 *)malloc(os2bmphdrsize);
    9593
    9694   memset(pOS2bmp, /* set header + palette entries to zero */
    9795          0,
    98           os2bmpsize);
     96          os2bmphdrsize);
    9997
    10098   pOS2bmp->cbFix         = sizeof(BITMAPINFO2) - sizeof(RGB2);
     
    238236{
    239237  lines = (int)lines >= 0 ? (int)lines : (int)-lines;
    240   int  os2bmpsize;
    241238  int  palsize=0;
    242239
    243240  bmpsize = pbmi->biWidth;
    244   os2bmpsize = sizeof(BITMAPINFO2);
     241  os2bmphdrsize = sizeof(BITMAPINFO2);
    245242
    246243  switch(pbmi->biBitCount)
     
    249246      bmpsize = ((bmpsize + 31) & ~31) / 8;
    250247      palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
    251       os2bmpsize += palsize;
     248      os2bmphdrsize += palsize;
    252249      break;
    253250    case 4:
    254251      bmpsize = ((bmpsize + 7) & ~7) / 2;
    255252      palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
    256       os2bmpsize += palsize;
     253      os2bmphdrsize += palsize;
    257254      break;
    258255    case 8:
    259256      palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
    260       os2bmpsize += palsize;
     257      os2bmphdrsize += palsize;
    261258      bmpsize = (bmpsize + 3) & ~3;
    262259      break;
     
    285282        DosFreeMem(oldbits);
    286283   }
    287    pOS2bmp    = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmpsize);
     284   pOS2bmp    = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmphdrsize);
    288285   pOS2bmp->cbFix         = sizeof(BITMAPINFO2) - sizeof(RGB2);
    289286   pOS2bmp->cx            = pbmi->biWidth;
     
    386383 LONG   rc;
    387384 PVOID  bitmapBits = NULL;
     385 int    oldyinversion = 0;
    388386
    389387  HWND hwndDest = WindowFromDC(hdcDest);
     
    412410  if(nXsrc + nSrcWidth > pOS2bmp->cx)
    413411  {
    414     point[3].x = pOS2bmp->cx;
    415   }
    416   else
    417     point[3].x = nXsrc + nSrcWidth;
     412        point[3].x = pOS2bmp->cx;
     413        nSrcWidth  = pOS2bmp->cx - nXsrc;
     414  }
     415  else  point[3].x = nXsrc + nSrcWidth;
    418416
    419417  if(nYsrc + nSrcHeight > pOS2bmp->cy)
    420418  {
    421     point[3].y = pOS2bmp->cy;
    422   }
    423   else
    424     point[3].y = pOS2bmp->cy - nYsrc;
    425 
    426 
    427 #if 1
     419        point[3].y = pOS2bmp->cy;
     420        nSrcHeight = pOS2bmp->cy - nYsrc;
     421  }
     422  else  point[3].y = pOS2bmp->cy - nYsrc;
     423
     424  oldyinversion = GpiQueryYInversion(hps);
    428425  if(fFlip & FLIP_VERT)
    429426  {
    430     GpiEnableYInversion(hps, nDestHeight);
    431   }
     427        GpiEnableYInversion(hps, nDestHeight-1);
     428  }
     429  else  GpiEnableYInversion(hps, 0);
    432430
    433431  if(fFlip & FLIP_HOR)
    434432  {
    435     ULONG x;
    436     x = point[0].x;
    437     point[0].x = point[1].x;
    438     point[1].x = x;
    439   }
    440 #endif
     433        ULONG x;
     434        x = point[0].x;
     435        point[0].x = point[1].x;
     436        point[1].x = x;
     437  }
    441438
    442439  //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc)
     
    455452  else  rc = GpiDrawBits(hps, bmpBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, BBO_OR);
    456453
     454  if(rc == GPI_OK) {
     455        DIBSection *destdib = DIBSection::findHDC(hdcDest);
     456        if(destdib) {
     457                dprintf(("Sync destination dibsection %x (%x) (%d)", destdib->handle, hdcDest, oldyinversion));
     458
     459                //todo: rgb 565 to 555 conversion if bpp == 16
     460                BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(destdib->os2bmphdrsize);
     461                memcpy(tmphdr, destdib->pOS2bmp, destdib->os2bmphdrsize);
     462                rc = GpiQueryBitmapBits(hps, nYdest, nDestHeight, destdib->GetDIBObject(),
     463                                        tmphdr);
     464                free(tmphdr);
     465                if(rc != nDestHeight) {
     466                        DebugInt3();
     467                }
     468        }
     469        //restore old y inversion height
     470        GpiEnableYInversion(hps, oldyinversion);
     471        if(hwndDest != 0)
     472        {
     473                WinReleasePS(hps);
     474        }
     475        return(TRUE);
     476  }
     477  GpiEnableYInversion(hps, oldyinversion);
    457478  if(hwndDest != 0)
    458479  {
    459     WinReleasePS(hps);
    460   }
    461   if(rc == GPI_OK) {
    462         return(TRUE);
     480        WinReleasePS(hps);
    463481  }
    464482  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));
Note: See TracChangeset for help on using the changeset viewer.