Changeset 3302 for trunk/src


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

dib sync bugfixes

Location:
trunk/src/gdi32
Files:
3 edited

Legend:

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

    r3298 r3302  
    1 /* $Id: blit.cpp,v 1.7 2000-04-02 10:12:53 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.8 2000-04-02 12:24:39 sandervl Exp $ */
    22
    33/*
     
    3838  dprintf(("GDI32: StretchBlt Src : %x (%d, %d) size (%d, %d)\n",
    3939           hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc));
     40  SetLastError(0);
    4041  if(DIBSection::getSection() != NULL)
    4142  {
     
    5960 BOOL rc;
    6061
     62    SetLastError(0);
    6163    if(DIBSection::getSection() != NULL) {
    6264        DIBSection *dsect = DIBSection::findHDC(hdcSrc);
    6365        if(dsect) {
    64                 rc = dsect->BitBlt(hdcDest, arg2, arg3, arg4, arg5, arg7, arg8, arg4, arg5, arg9);
    65                 if(rc) {
    66                         BITMAPINFO bmpinfo = {0};
    67                         DIBSection *dest = DIBSection::findHDC(hdcDest);
    68                         if(dest) {
    69                                 dprintf(("Sync dest DIB section"));
    70                                 bmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    71                                 GetDIBits(hdcDest, dest->GetBitmapHandle(), 0, 0, 0, &bmpinfo, dest->GetRGBUsage());
    72                                 dprintf(("height        %d", bmpinfo.bmiHeader.biHeight));
    73                                 dprintf(("width         %d", bmpinfo.bmiHeader.biWidth));
    74                                 dprintf(("biBitCount    %d", bmpinfo.bmiHeader.biBitCount));
    75                                 GetDIBits(hdcDest, dest->GetBitmapHandle(), 0, bmpinfo.bmiHeader.biHeight, dest->GetDIBObject(), &bmpinfo, dest->GetRGBUsage());
    76                         }
    77                 }
    78                 return rc;
     66                return dsect->BitBlt(hdcDest, arg2, arg3, arg4, arg5, arg7, arg8, arg4, arg5, arg9);
    7967        }
    8068    }
  • 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));
  • trunk/src/gdi32/dibsect.h

    r3235 r3302  
    1 /* $Id: dibsect.h,v 1.14 2000-03-25 12:19:08 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.15 2000-04-02 12:24:40 sandervl Exp $ */
    22
    33/*
     
    8585               int  SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
    8686
    87          int  SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
     87               int  SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
    8888                              lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
    8989                              UINT coloruse);
     
    104104          char *bmpBits, *bmpBitsRGB565;
    105105          BOOL  fFlip;
    106           int   bmpsize;
     106          int   bmpsize, os2bmphdrsize;
    107107    DIBSECTION  dibinfo;
    108108
Note: See TracChangeset for help on using the changeset viewer.