Changeset 3711 for trunk/src


Ignore:
Timestamp:
Jun 14, 2000, 8:30:18 PM (25 years ago)
Author:
sandervl
Message:

dib blit fixes

Location:
trunk/src/gdi32
Files:
2 edited

Legend:

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

    r3626 r3711  
    1 /* $Id: dibsect.cpp,v 1.33 2000-05-28 17:03:18 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.34 2000-06-14 18:30:15 sandervl Exp $ */
    22
    33/*
     
    2727#include <win32wnd.h>
    2828#include <cpuhlp.h>
     29#include <dcdata.h>
    2930#include "oslibgpi.h"
    3031#include "rgbcvt.h"
     
    3839//******************************************************************************
    3940DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip)
    40                 : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsBuffer(NULL)
     41                : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsDblBuffer(NULL)
    4142{
    4243  bmpsize = pbmi->biWidth;
     
    164165   //double buffer for rgb 555 dib sections (for conversion) or flipped sections
    165166   if(dibinfo.dsBitfields[1] == 0x03e0 || (fFlip & FLIP_VERT)) {
    166         DosAllocMem((PPVOID)&bmpBitsBuffer, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
     167        DosAllocMem((PPVOID)&bmpBitsDblBuffer, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
    167168   }
    168169
     
    205206        DosFreeMem(bmpBits);
    206207
    207    if(bmpBitsBuffer)
    208         DosFreeMem(bmpBitsBuffer);
     208   if(bmpBitsDblBuffer)
     209        DosFreeMem(bmpBitsDblBuffer);
    209210
    210211   if(pOS2bmp)
     
    341342   //double buffer for rgb 555 dib sections (for conversion) or flipped sections
    342343   if(dibinfo.dsBitfields[1] == 0x03e0 || (fFlip & FLIP_VERT)) {
    343         if(bmpBitsBuffer) {
    344                 DosFreeMem(bmpBitsBuffer);
     344        if(bmpBitsDblBuffer) {
     345                DosFreeMem(bmpBitsDblBuffer);
    345346        }
    346         DosAllocMem((PPVOID)&bmpBitsBuffer, dibinfo.dsBm.bmWidthBytes*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
     347        DosAllocMem((PPVOID)&bmpBitsDblBuffer, dibinfo.dsBm.bmWidthBytes*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
    347348   }
    348349
     
    394395 BOOL   fRestoryYInversion = FALSE, fFrameWindowDC = FALSE;
    395396 HWND   hwndDest;
    396 
    397   hwndDest = WindowFromDC(hdcDest);
    398   //TODO: Test whether dc is for the client or frame window
    399 //  if(hwndDest && IsOS2FrameWindowHandle(hwndDest)) {
    400 //      fFrameWindowDC = TRUE;
    401 //  }
     397 pDCData pHps;
     398
     399  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     400  if(!pHps)
     401  {
     402      SetLastError(ERROR_INVALID_HANDLE_W);
     403      return FALSE;
     404  }
     405
     406  hwndDest = WindowFromDC(hdcDest); //could return desktop window, so check that
     407  if(hwndDest && pHps->hwnd && !pHps->isClient) {
     408        fFrameWindowDC = TRUE;
     409  }
    402410
    403411  dprintf(("DIBSection::BitBlt %x %X (hps %x) %x to(%d,%d)(%d,%d) from (%d,%d)(%d,%d) rop %x flip %x",
     
    478486        //manually reverse bitmap data
    479487        char *src = bmpBits + (pOS2bmp->cy-1)*dibinfo.dsBm.bmWidthBytes;
    480         char *dst = bmpBitsBuffer;
     488        char *dst = bmpBitsDblBuffer;
    481489        for(int i=0;i<pOS2bmp->cy;i++) {
    482490                memcpy(dst, src, dibinfo.dsBm.bmWidthBytes);
     
    484492                src -= dibinfo.dsBm.bmWidthBytes;
    485493        }
    486         bmpBits = bmpBitsBuffer;
    487   }
     494        bitmapBits = bmpBitsDblBuffer;
     495  }
     496  else  bitmapBits = bmpBits;
    488497
    489498  //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc)
     
    491500        dprintf(("DIBSection::BitBlt; convert rgb 555 to 565 (old y inv. = %d)", oldyinversion));
    492501
    493         if(bmpBitsBuffer == NULL)
     502        if(bmpBitsDblBuffer == NULL)
    494503                DebugInt3();
    495504
    496505        if(CPUFeatures & CPUID_MMX) {
    497                 RGB555to565MMX((WORD *)bmpBitsBuffer, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
     506                RGB555to565MMX((WORD *)bmpBitsDblBuffer, (WORD *)bitmapBits, pOS2bmp->cbImage/sizeof(WORD));
    498507        }
    499         else    RGB555to565((WORD *)bmpBitsBuffer, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));
    500         rc = GpiDrawBits(hps, bmpBitsBuffer, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);
    501   }
    502   else  rc = GpiDrawBits(hps, bmpBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);
     508        else    RGB555to565((WORD *)bmpBitsDblBuffer, (WORD *)bitmapBits, pOS2bmp->cbImage/sizeof(WORD));
     509        rc = GpiDrawBits(hps, bmpBitsDblBuffer, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);
     510  }
     511  else  rc = GpiDrawBits(hps, bitmapBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);
    503512
    504513  if(rc == GPI_OK) {
     
    533542  BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize);
    534543  memcpy(tmphdr, pOS2bmp, os2bmphdrsize);
    535   destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
    536   rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
     544
     545  if(fFlip & FLIP_VERT) {
     546        destBuf = bmpBitsDblBuffer + nYdest*dibinfo.dsBm.bmWidthBytes;
     547
     548        rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
     549                                tmphdr);
     550        //manually reverse bitmap data
     551        char *src = destBuf;
     552        char *dst = GetDIBObject() + (nYdest+nDestHeight-1)*dibinfo.dsBm.bmWidthBytes;
     553        for(int i=0;i<nDestHeight;i++) {
     554                memcpy(dst, src, dibinfo.dsBm.bmWidthBytes);
     555                dst -= dibinfo.dsBm.bmWidthBytes;
     556                src += dibinfo.dsBm.bmWidthBytes;
     557        }
     558  }
     559  else {
     560        destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
     561        rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
    537562                          tmphdr);
     563  }
    538564  free(tmphdr);
    539565  if(rc != nDestHeight) {
  • trunk/src/gdi32/dibsect.h

    r3594 r3711  
    1 /* $Id: dibsect.h,v 1.18 2000-05-23 18:46:20 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.19 2000-06-14 18:30:18 sandervl Exp $ */
    22
    33/*
     
    103103          HWND  hwndParent;
    104104          HDC   hdc;
    105           char *bmpBits, *bmpBitsBuffer;
     105          char *bmpBits, *bmpBitsDblBuffer;
    106106          BOOL  fFlip;
    107107          int   bmpsize, os2bmphdrsize;
Note: See TracChangeset for help on using the changeset viewer.