Changeset 4127 for trunk/src


Ignore:
Timestamp:
Aug 30, 2000, 8:05:25 PM (25 years ago)
Author:
sandervl
Message:

workaround for palette problems in PowerDVD

Location:
trunk/src/gdi32
Files:
4 edited

Legend:

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

    r4034 r4127  
    1 /* $Id: blit.cpp,v 1.16 2000-08-18 18:14:56 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.17 2000-08-30 18:05:24 sandervl Exp $ */
    22
    33/*
     
    225225                           const BITMAPINFO *info, UINT wUsage, DWORD dwRop )
    226226{
    227 #if 1
    228227 INT rc;
    229228
     
    263262                DIBSection *destdib = DIBSection::findHDC(hdc);
    264263                if(destdib) {
    265                         destdib->sync(hdc, yDst, heightDst);
     264                        if(widthDst == widthSrc && heightDst == heightSrc &&
     265                           destdib->GetBitCount() == infoLoc->bmiHeader.biBitCount &&
     266                           destdib->GetBitCount() == 8)
     267                        {
     268                                destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);
     269                        }
     270                        else    destdib->sync(hdc, yDst, heightDst);
    266271                }
    267272        }
     
    277282    else {
    278283        DIBSection *destdib = DIBSection::findHDC(hdc);
    279         if(destdib) {
    280                 destdib->sync(hdc, yDst, heightDst);
    281         }
     284        if(destdib) {
     285                if(widthDst == widthSrc && heightDst == heightSrc &&
     286                   destdib->GetBitCount() == info->bmiHeader.biBitCount &&
     287                   destdib->GetBitCount() == 8)
     288                {
     289                        destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);
     290                }
     291                else    destdib->sync(hdc, yDst, heightDst);
     292        }
    282293    }
    283294
    284295    return rc;
    285 #else
    286     dprintf(("GDI32: StretchDIBits\n"));
    287     return O32_StretchDIBits(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, (void *)arg10, (PBITMAPINFO)arg11, arg12, arg13);
    288 #endif
    289296}
    290297//******************************************************************************
  • trunk/src/gdi32/dibsect.cpp

    r4034 r4127  
    1 /* $Id: dibsect.cpp,v 1.37 2000-08-18 18:14:57 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.38 2000-08-30 18:05:24 sandervl Exp $ */
    22
    33/*
     
    4141                : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsDblBuffer(NULL)
    4242{
     43 int  palsize=0;
     44
    4345  bmpsize = pbmi->biWidth;
    4446  /* @@@PH 98/06/07 -- high-color bitmaps don't have palette */
     
    5052  {
    5153        case 1:
    52                 bmpsize = ((bmpsize + 31) & ~31) / 8;
    53                 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     54                bmpsize = ((bmpsize + 31) & ~31) / 8;
     55                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     56                os2bmphdrsize += palsize;
    5457                break;
    5558        case 4:
    5659                bmpsize = ((bmpsize + 7) & ~7) / 2;
    57                 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     60                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     61                os2bmphdrsize += palsize;
    5862                break;
    5963        case 8:
    60                 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     64                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     65                os2bmphdrsize += palsize;
    6166                bmpsize = (bmpsize + 3) & ~3;
    6267                break;
     
    7984
    8085   this->hSection = hSection;
     86   this->dwOffset = dwOffset;
    8187   if(hSection) {
    8288        bmpBits = (char *)MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS_W, 0, dwOffset, bmpsize*pbmi->biHeight);
     
    130136   dibinfo.dsBm.bmBits      = bmpBits;
    131137
    132    dibinfo.dshSection       = handle;
     138   dibinfo.dshSection       = hSection;
    133139   dibinfo.dsOffset         = dwOffset;
    134140
     
    136142   {
    137143        dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
     144        if(palsize) {
     145                SetDIBColorTable(0, (1 << pbmi->biBitCount), (RGBQUAD *)(pbmi+1));
     146        }
    138147   }
    139148   else {
     
    305314
    306315   dibinfo.dshSection       = hSection;
    307    dibinfo.dsOffset         = 0; // TODO: put the correct value here (if createdibsection with file handle)
     316   dibinfo.dsOffset         = dwOffset;
    308317
    309318   if(coloruse == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
     
    377386  {
    378387    pOS2bmp->argbColor[i].fcOptions = 0;
     388#ifdef DEBUG_PALETTE
    379389    dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&pOS2bmp->argbColor[i])) ));
     390#endif
    380391  }
    381392
     
    547558}
    548559//******************************************************************************
     560int WIN32API GetDIBits(HDC hdc, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines,
     561                       void *lpvBits, BITMAPINFO_W * lpbi, UINT uUsage);
     562
    549563//******************************************************************************
    550564void DIBSection::sync(HDC hdc, DWORD nYdest, DWORD nDestHeight)
     
    555569  dprintf(("Sync destination dibsection %x (%x)", handle, hdc));
    556570
     571#if 0
     572  BITMAPINFO_W *tmphdr = (BITMAPINFO_W *)malloc(os2bmphdrsize + sizeof(BITMAPINFO_W));
     573  tmphdr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER_W);
     574  GetDIBits(hdc, handle, nYdest, nDestHeight, NULL, tmphdr, 0);
     575  destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
     576  rc = GetDIBits(hdc, handle, nYdest, nDestHeight, destBuf, tmphdr, 0);
     577#ifdef DEBUG_PALETTE
     578  if(rc && tmphdr->bmiHeader.biBitCount <= 8) {
     579        for(int i=0;i<(1<<tmphdr->bmiHeader.biBitCount);i++)
     580        {
     581                dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&tmphdr->bmiColors[i])) ));
     582        }
     583  }
     584#endif
     585
     586#else
    557587  BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize);
    558588  memcpy(tmphdr, pOS2bmp, os2bmphdrsize);
     
    576606        rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
    577607                          tmphdr);
    578   }
     608#ifdef DEBUG_PALETTE
     609        if(rc != GPI_ALTERROR && tmphdr->cBitCount <= 8) {
     610                for(int i=0;i<(1<<tmphdr->cBitCount);i++)
     611                {
     612                        dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&tmphdr->argbColor[i])) ));
     613                }
     614        }
     615#endif
     616  }
     617#endif
     618#if 0
    579619  if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
    580620        dprintf(("DIBSection::sync: convert RGB 565 to RGB 555"));
     
    587627        else    RGB565to555((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD));
    588628  }
     629#endif
    589630  free(tmphdr);
    590631  if(rc != nDestHeight) {
    591632        DebugInt3();
    592633  }
     634}
     635//******************************************************************************
     636//manual sync if no stretching and bpp is the same
     637//WARNING: this also assumes the colortables are the same
     638//******************************************************************************
     639void DIBSection::sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits)
     640{
     641 char *srcbuf, *destbuf;
     642 int  linesize;
     643
     644   srcbuf  = (char *)bits + dibinfo.dsBm.bmWidthBytes*yDst +
     645                    (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
     646   destbuf = (char *)GetDIBObject() + dibinfo.dsBm.bmWidthBytes*yDst +
     647                    (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
     648   linesize = (widthDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
     649   for(int i=0;i<heightDst;i++) {
     650        memcpy(destbuf, srcbuf, linesize);
     651        destbuf += dibinfo.dsBm.bmWidthBytes;
     652        srcbuf  += linesize;
     653   }
    593654}
    594655//******************************************************************************
  • trunk/src/gdi32/dibsect.h

    r3711 r4127  
    1 /* $Id: dibsect.h,v 1.19 2000-06-14 18:30:18 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.20 2000-08-30 18:05:24 sandervl Exp $ */
    22
    33/*
     
    4949} BITMAP_W, *LPBITMAP_W;
    5050
     51typedef struct {
     52        BITMAPINFOHEADER_W bmiHeader;
     53        RGBQUAD bmiColors[1];
     54} BITMAPINFO_W;
     55typedef BITMAPINFO *LPBITMAPINFO;
     56
    5157#ifdef OS2_ONLY
    5258#define DIB_RGB_COLORS   0
     
    7682
    7783              DWORD GetBitmapHandle()        { return handle; };
     84              void  SetBitmapHandle(DWORD bmphandle) { handle = bmphandle; };
    7885              DWORD GetRGBUsage()            { return iUsage; };
    7986
     
    8491                           DWORD Rop);
    8592              void  sync(HDC hdc, DWORD nYdest, DWORD nDestHeight);
     93              void  sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits);
    8694               int  SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
    8795
     
    100108private:
    101109          DWORD handle, iUsage;
    102           DWORD hSection;
     110          DWORD hSection, dwOffset;
    103111          HWND  hwndParent;
    104112          HDC   hdc;
  • trunk/src/gdi32/palette.cpp

    r4034 r4127  
    1 /* $Id: palette.cpp,v 1.6 2000-08-18 18:14:58 sandervl Exp $ */
     1/* $Id: palette.cpp,v 1.7 2000-08-30 18:05:25 sandervl Exp $ */
    22
    33/*
     
    6666  HPALETTE rc;
    6767
     68#ifdef DEBUG_PALETTE
    6869   for(int i=0; i<arg1->palNumEntries;i++)
    6970   {
    7071        dprintf2(("Index %d : 0x%08X\n",i, *((DWORD*)(&arg1->palPalEntry[i])) ));
    7172   }
     73#endif
    7274   rc = O32_CreatePalette(arg1);
    7375   dprintf(("GDI32: CreatePalette %x %d returns 0x%08X\n", arg1, arg1->palNumEntries, rc));
Note: See TracChangeset for help on using the changeset viewer.