Changeset 4034 for trunk/src


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

lots of small changes; CreateHalftonePalette + rgb 565 -> rgb 555 conversion

Location:
trunk/src/gdi32
Files:
11 edited

Legend:

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

    r3726 r4034  
    1 /* $Id: blit.cpp,v 1.15 2000-06-17 11:58:07 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.16 2000-08-18 18:14:56 sandervl Exp $ */
    22
    33/*
     
    244244        memcpy(infoLoc, info, sizeof(BITMAPINFO));
    245245
    246         if(GetDIBColorTable(hdc, 0, info->bmiHeader.biClrUsed, pColors) == 0)
     246        if(GetDIBColorTable(hdc, 0, info->bmiHeader.biClrUsed, pColors) == 0) {
     247                dprintf(("ERROR: StretchDIBits: GetDIBColorTable failed!!"));
    247248                return FALSE;
    248 
     249        }
    249250        for(i=0;i<info->bmiHeader.biClrUsed;i++, pColorIndex++)
    250251        {
     
    268269        return rc;
    269270    }
    270 
    271271    rc = O32_StretchDIBits(hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc,
    272272                             widthSrc, heightSrc, (void *)bits,
  • trunk/src/gdi32/dbglocal.cpp

    r3705 r4034  
    1 /* $Id: dbglocal.cpp,v 1.3 2000-06-14 13:17:49 sandervl Exp $ */
     1/* $Id: dbglocal.cpp,v 1.4 2000-08-18 18:14:56 sandervl Exp $ */
    22
    33/*
     
    1616#ifdef DEBUG
    1717
    18 USHORT DbgEnabled[DBG_MAXFILES];
     18USHORT DbgEnabled[DBG_MAXFILES] = {0};
     19USHORT DbgEnabledLvl2[DBG_MAXFILES] = {0};
     20
    1921char  *DbgFileNames[DBG_MAXFILES] =
    2022{
     
    4345{
    4446 char *envvar = getenv(DBG_ENVNAME);
     47 char *envvar2= getenv(DBG_ENVNAME_LVL2);
    4548 char *dbgvar;
    4649 int   i;
     
    7376        }
    7477    }
     78    if(envvar2) {
     79        dbgvar = strstr(envvar2, "dll");
     80        if(dbgvar) {
     81                if(*(dbgvar-1) == '+') {
     82                    for(i=0;i<DBG_MAXFILES;i++) {
     83                        DbgEnabledLvl2[i] = 1;
     84                    }
     85                }
     86        }
     87        for(i=0;i<DBG_MAXFILES;i++) {
     88                dbgvar = strstr(envvar2, DbgFileNames[i]);
     89                if(dbgvar) {
     90                    if(*(dbgvar-1) == '-') {
     91                            DbgEnabledLvl2[i] = 0;
     92                    }
     93                    else   
     94                    if(*(dbgvar-1) == '+') {
     95                        DbgEnabledLvl2[i] = 1;
     96                    }
     97                }
     98        }
     99    }
    75100}
    76101//******************************************************************************
  • trunk/src/gdi32/dbglocal.h

    r3705 r4034  
    1 /* $Id: dbglocal.h,v 1.3 2000-06-14 13:17:49 sandervl Exp $ */
     1/* $Id: dbglocal.h,v 1.4 2000-08-18 18:14:56 sandervl Exp $ */
    22
    33/*
     
    1818
    1919#define DBG_ENVNAME        "dbg_gdi32"
     20#define DBG_ENVNAME_LVL2   "dbg_user32_lvl2"
    2021
    2122#define DBG_gdi32           0
     
    4041
    4142extern USHORT DbgEnabled[DBG_MAXFILES];
     43extern USHORT DbgEnabledLvl2[DBG_MAXFILES];
    4244
    4345#ifdef dprintf
     
    4648
    4749#define dprintf(a)      if(DbgEnabled[DBG_LOCALLOG] == 1) WriteLog a
     50
     51#ifdef dprintf2
     52#undef dprintf2
     53#endif
     54
     55#define dprintf2(a)     if(DbgEnabledLvl2[DBG_LOCALLOG] == 1) WriteLog a
    4856
    4957#else
  • trunk/src/gdi32/dibitmap.cpp

    r3235 r4034  
    1 /* $Id: dibitmap.cpp,v 1.7 2000-03-25 12:19:07 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.8 2000-08-18 18:14:56 sandervl Exp $ */
    22
    33/*
     
    9292 BOOL    fCreateDC = FALSE;
    9393
    94   dprintf(("GDI32: CreateDIBSection %x %x %x %x %d", hdc, iUsage, ppvBits, hSection, dwOffset));
     94  dprintf(("GDI32: CreateDIBSection %x %x %x %x %x %d", hdc, pbmi, iUsage, ppvBits, hSection, dwOffset));
    9595
    9696  //SvL: 13-9-98: StarCraft uses bitmap with negative height
     
    128128      if(PalSize <= 8)
    129129      {
    130        ULONG Pal[256];
     130       ULONG Pal[256], nrcolors;
    131131       LOGPALETTE tmpPal = { 0x300,1,{0,0,0,0}};
    132132       HPALETTE hpalCur, hpalTmp;
     
    137137
    138138        // and use it to set the DIBColorTable
    139         GetPaletteEntries( hpalCur, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
    140         dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal);
     139        nrcolors = GetPaletteEntries( hpalCur, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
     140        dsect->SetDIBColorTable(0, nrcolors, (RGBQUAD*)&Pal);
    141141
    142142        // Restore the DC Palette
  • trunk/src/gdi32/dibsect.cpp

    r3755 r4034  
    1 /* $Id: dibsect.cpp,v 1.36 2000-06-26 10:27:45 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.37 2000-08-18 18:14:57 sandervl Exp $ */
    22
    33/*
    44 * GDI32 DIB sections
    55 *
    6  * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
    77 * Copyright 1998 Patrick Haller
    88 *
     
    131131
    132132   dibinfo.dshSection       = handle;
    133    dibinfo.dsOffset         = 0; // TODO: put the correct value here (if createdibsection with file handle)
     133   dibinfo.dsOffset         = dwOffset;
    134134
    135135   if(iUsage == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
     
    555555  dprintf(("Sync destination dibsection %x (%x)", handle, hdc));
    556556
    557   //todo: rgb 565 to 555 conversion if bpp == 16
    558   if(GetBitCount() == 16) {
    559         dprintf(("WARNING: need to convert RGB 565 to RGB 555!!"));
    560   }
    561 
    562557  BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize);
    563558  memcpy(tmphdr, pOS2bmp, os2bmphdrsize);
     
    582577                          tmphdr);
    583578  }
     579  if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
     580        dprintf(("DIBSection::sync: convert RGB 565 to RGB 555"));
     581
     582        destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
     583
     584        if(CPUFeatures & CPUID_MMX) {
     585                RGB565to555MMX((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD));
     586        }
     587        else    RGB565to555((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD));
     588  }
    584589  free(tmphdr);
    585590  if(rc != nDestHeight) {
  • trunk/src/gdi32/gdi32.cpp

    r3929 r4034  
    1 /* $Id: gdi32.cpp,v 1.53 2000-08-02 16:26:43 bird Exp $ */
     1/* $Id: gdi32.cpp,v 1.54 2000-08-18 18:14:57 sandervl Exp $ */
    22
    33/*
     
    102102//******************************************************************************
    103103//******************************************************************************
    104 HPEN WIN32API CreatePen( int fnPenStyle, int nWidth, COLORREF crColor)
    105 {
    106     dprintf(("GDI32: CreatePen\n"));
    107 
     104ODINFUNCTION3(HPEN, CreatePen, int, fnPenStyle, int, nWidth, COLORREF, crColor)
     105{
    108106    //CB: todo: PS_DOT is different in Win32 (. . . . and not - - - -)
    109107    //    Open32 looks like LINETYPE_SHORTDASH instead of LINETYPE_DOT!!!
     
    114112//******************************************************************************
    115113//******************************************************************************
    116 HPEN WIN32API CreatePenIndirect( const LOGPEN * lplgpn)
    117 {
    118     dprintf(("GDI32: CreatePenIndirect\n"));
     114HPEN WIN32API CreatePenIndirect(const LOGPEN * lplgpn)
     115{
     116    dprintf(("GDI32: CreatePenIndirect %x", lplgpn));
    119117    return O32_CreatePenIndirect(lplgpn);
    120118}
     
    449447//******************************************************************************
    450448//******************************************************************************
    451 HBRUSH WIN32API CreateSolidBrush( COLORREF arg1)
    452 {
    453     dprintf(("GDI32: CreateSolidBrush\n"));
    454     return O32_CreateSolidBrush(arg1);
     449ODINFUNCTION1(HBRUSH, CreateSolidBrush, COLORREF, color)
     450{
     451    return O32_CreateSolidBrush(color);
    455452}
    456453//******************************************************************************
     
    491488//******************************************************************************
    492489//******************************************************************************
    493 BOOL WIN32API Rectangle( HDC arg1, int arg2, int arg3, int arg4, int  arg5)
    494 {
    495     dprintf(("GDI32: Rectangle\n"));
    496     return O32_Rectangle(arg1, arg2, arg3, arg4, arg5);
     490ODINFUNCTION5(BOOL, Rectangle, HDC, hdc, int, left, int, top, int, right, int, bottom)
     491{
     492    return O32_Rectangle(hdc, left, top, right, bottom);
    497493}
    498494//******************************************************************************
     
    592588//******************************************************************************
    593589//******************************************************************************
    594 int WIN32API Escape( HDC arg1, int arg2, int arg3, LPCSTR arg4, PVOID  arg5)
    595 {
    596     dprintf(("GDI32: Escape"));
    597     return O32_Escape(arg1, arg2, arg3, arg4, arg5);
     590int WIN32API Escape( HDC hdc, int nEscape, int cbInput, LPCSTR lpvInData, PVOID lpvOutData)
     591{
     592 int rc;
     593
     594    rc = O32_Escape(hdc, nEscape, cbInput, lpvInData, lpvOutData);
     595    if(rc == 0) {
     596         dprintf(("GDI32: Escape %x %d %d %x %x returned %d (WARNING: might not be implemented!!) ", hdc, nEscape, cbInput, lpvInData, lpvOutData, rc));
     597    }
     598    else dprintf(("GDI32: Escape %x %d %d %x %x returned %d ", hdc, nEscape, cbInput, lpvInData, lpvOutData, rc));
     599
     600    return rc;
    598601}
    599602//******************************************************************************
  • trunk/src/gdi32/objhandle.cpp

    r3705 r4034  
    1 /* $Id: objhandle.cpp,v 1.1 2000-06-14 13:17:51 sandervl Exp $ */
     1/* $Id: objhandle.cpp,v 1.2 2000-08-18 18:14:57 sandervl Exp $ */
    22/*
    33 * Win32 Handle Management Code for OS/2
     
    124124        return 0;
    125125  }
     126  dprintf(("GDI32: GetObject %X %X %X\n", hObject, size, lpBuffer));
    126127  if(DIBSection::getSection() != NULL)
    127128  {
     
    139140  }
    140141
    141   dprintf(("GDI32: GetObject %X %X %X\n", hObject, size, lpBuffer));
    142142  return O32_GetObject(hObject, size, lpBuffer);
    143143}
  • trunk/src/gdi32/palette.cpp

    r3594 r4034  
    1 /* $Id: palette.cpp,v 1.5 2000-05-23 18:46:21 sandervl Exp $ */
     1/* $Id: palette.cpp,v 1.6 2000-08-18 18:14:58 sandervl Exp $ */
    22
    33/*
     
    7171   }
    7272   rc = O32_CreatePalette(arg1);
    73    dprintf(("GDI32: CreatePalette returns 0x%08X\n",rc));
     73   dprintf(("GDI32: CreatePalette %x %d returns 0x%08X\n", arg1, arg1->palNumEntries, rc));
    7474
    7575   return rc;
     
    7777//******************************************************************************
    7878//******************************************************************************
    79 HPALETTE WIN32API SelectPalette(HDC arg1, HPALETTE arg2, BOOL arg3)
     79HPALETTE WIN32API SelectPalette(HDC hdc, HPALETTE hPalette, BOOL bForceBackground)
    8080{
    81   dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)\n", arg1, arg2, arg3));
     81  dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)", hdc, hPalette, bForceBackground));
    8282  if(DIBSection::getSection() != NULL)
    8383  {
    84     DIBSection *dsect = DIBSection::findHDC(arg1);
     84    DIBSection *dsect = DIBSection::findHDC(hdc);
    8585    if(dsect)
    8686    {
     87      int nrcolors;
    8788      PALETTEENTRY Pal[256];
    8889      char PalSize = dsect->GetBitCount();
     
    9091      if(PalSize<=8)
    9192      {
    92         GetPaletteEntries( arg2, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
    93         dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal);
     93        nrcolors = GetPaletteEntries( hPalette, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
     94        dsect->SetDIBColorTable(0, nrcolors, (RGBQUAD*)&Pal);
    9495      }
    9596
    9697    }
    9798  }
    98   return O32_SelectPalette(arg1, arg2, arg3);
     99  return O32_SelectPalette(hdc, hPalette, bForceBackground);
    99100}
    100101//******************************************************************************
     
    117118//******************************************************************************
    118119//******************************************************************************
    119 UINT WIN32API GetPaletteEntries( HPALETTE hPalette, UINT arg2, UINT arg3, PPALETTEENTRY  arg4)
     120UINT WIN32API GetPaletteEntries(HPALETTE hPalette, UINT iStart, UINT count, PPALETTEENTRY entries)
    120121{
    121     dprintf(("GDI32: GetPaletteEntries %x %d-%d %x", hPalette, arg2, arg3, arg4));
    122     return O32_GetPaletteEntries(hPalette, arg2, arg3, arg4);
     122 UINT rc;
     123
     124    rc = O32_GetPaletteEntries(hPalette, iStart, count, entries);
     125    dprintf(("GDI32: GetPaletteEntries %x %d-%d %x returned %d", hPalette, iStart, count, entries, rc));
     126    return rc;
    123127}
    124128//******************************************************************************
     
    151155HPALETTE WIN32API CreateHalftonePalette(HDC hdc)
    152156{
    153     dprintf(("GDI32: CreateHalftonePalette, not implemented\n"));
    154     return(NULL);
     157    int i, r, g, b;
     158    struct {
     159        WORD Version;
     160        WORD NumberOfEntries;
     161        PALETTEENTRY aEntries[256];
     162    } Palette = {
     163        0x300, 256
     164    };
     165
     166    dprintf(("GDI32: CreateHalftonePalette %x", hdc));
     167    GetSystemPaletteEntries(hdc, 0, 256, Palette.aEntries);
     168    return CreatePalette((LOGPALETTE *)&Palette);
     169
     170    for (r = 0; r < 6; r++) {
     171        for (g = 0; g < 6; g++) {
     172            for (b = 0; b < 6; b++) {
     173                i = r + g*6 + b*36 + 10;
     174                Palette.aEntries[i].peRed = r * 51;
     175                Palette.aEntries[i].peGreen = g * 51;
     176                Palette.aEntries[i].peBlue = b * 51;
     177            }   
     178          }
     179        }
     180       
     181    for (i = 216; i < 246; i++) {
     182        int v = (i - 216) * 8;
     183        Palette.aEntries[i].peRed = v;
     184        Palette.aEntries[i].peGreen = v;
     185        Palette.aEntries[i].peBlue = v;
     186        }
     187       
     188    return CreatePalette((LOGPALETTE *)&Palette);
    155189}
    156190//******************************************************************************
  • trunk/src/gdi32/rgbcvt.asm

    r2614 r4034  
    1 ; $Id: rgbcvt.asm,v 1.3 2000-02-03 18:59:04 sandervl Exp $
     1; $Id: rgbcvt.asm,v 1.4 2000-08-18 18:14:58 sandervl Exp $
    22; Copyright 2000 Daniela Engert (dani@ngrt.de)
    33
     
    99
    1010        align   4
    11   and1mask dd    001F001Fh
    12            dd    001F001Fh
     11  and1mask dd   0001F001Fh
     12           dd   0001F001Fh
    1313  and2mask dd   0FFC0FFC0h
    1414           dd   0FFC0FFC0h
     15  and2mask565 dd 0FFE07FE0h
     16              dd 07FE07FE0h
    1517
    1618        .CODE
     
    3739        shl     eax, 1
    3840
    39         and     edx, 001F001Fh
     41        and     edx, 0001F001Fh
    4042        and     eax, 0FFC0FFC0h
    4143
     
    5153        mov     ax, [esi]
    5254        mov     dx, ax
    53         and     dx, 001Fh
     55        and     dx, 0001Fh
    5456        shl     ax, 1
    5557        and     ax, 0FFC0h
     
    6365
    6466RGB555to565 ENDP
     67
     68        PUBLIC RGB565to555
     69
     70RGB565to555 PROC NEAR
     71
     72        push    esi
     73        push    edi
     74        cld
     75
     76        mov     edi, eax                ; _Optlink arg1 = EAX
     77        mov     esi, edx                ; _Optlink arg2 = EDX
     78        shr     ecx, 1                  ; _Optlink arg3 = ECX
     79        pushf
     80cvt:
     81        mov     eax, [esi]
     82        mov     edx, eax
     83
     84        add     esi, 4
     85        shr     eax, 1
     86
     87        and     edx, 0001F001Fh
     88        and     eax, 0FFE07FE0h
     89
     90        add     edi, 4
     91        or      eax, edx
     92
     93        mov     [edi-4], eax
     94        loop    cvt
     95
     96        popf
     97        jnc     SHORT done
     98
     99        mov     ax, [esi]
     100        mov     dx, ax
     101        and     dx, 0001Fh
     102        shr     ax, 1
     103        and     ax, 0FFE0h
     104        or      ax, dx
     105        mov     [edi], ax
     106
     107done:
     108        pop     edi
     109        pop     esi
     110        ret
     111
     112RGB565to555 ENDP
    65113
    66114; void _Optlink RGB555to565MMX(WORD *dest, WORD *src, ULONG num);
     
    151199RGB555to565MMX ENDP
    152200
     201
     202; void _Optlink RGB565to555MMX(WORD *dest, WORD *src, ULONG num);
     203
     204        PUBLIC RGB565to555MMX
     205
     206RGB565to555MMX PROC NEAR
     207        push    esi
     208        push    edi
     209        cld
     210
     211        cmp     ecx, 0
     212        jz      done
     213
     214        push    ecx
     215       
     216        mov     edi, eax                ; _Optlink arg1 = EAX
     217        mov     esi, edx                ; _Optlink arg2 = EDX
     218        shr     ecx, 3                  ; _Optlink arg3 = ECX
     219        jz      lastpixels
     220
     221        sub     esp, 108
     222        fsaved  dword ptr [esp]
     223
     224        movq    mm2, qword ptr and1mask                 ;  0001F001F001F001Fh
     225        movq    mm3, qword ptr and2mask565              ;  FFE07FE007FE07FE0h
     226
     227cvt:
     228        movq    mm0, qword ptr [esi]
     229        add     edi, 16
     230
     231        movq    mm4, qword ptr [esi+8]
     232        movq    mm1, mm0
     233
     234        movq    mm5, mm4
     235        psrlq   mm0, 1
     236
     237        psrlq   mm4, 1
     238        pand    mm1, mm2
     239
     240        pand    mm0, mm3
     241        pand    mm5, mm2
     242
     243        pand    mm4, mm3
     244        por     mm0, mm1
     245
     246        por     mm4, mm5
     247        add     esi, 16
     248
     249        movq    qword ptr [edi-16], mm0
     250        dec     ecx
     251
     252        movq    qword ptr [edi-8], mm4
     253        jnz     cvt
     254
     255        nop
     256        nop
     257
     258        frstord dword ptr [esp]
     259        add     esp, 108
     260
     261lastpixels:
     262        pop     ecx
     263        and     ecx, 3
     264        jz      short done
     265
     266cvt2loop:
     267        mov     ax, [esi]
     268        mov     dx, ax
     269
     270        add     esi, 2
     271        and     dx, 001Fh
     272
     273        shr     ax, 1
     274        add     edi, 2
     275
     276        and     ax, 0FFE0h
     277        or      ax, dx
     278
     279        mov     [edi-2], ax
     280        loop    cvt2loop
     281
     282done:
     283        pop     edi
     284        pop     esi
     285        ret
     286
     287RGB565to555MMX ENDP
     288
    153289        END
  • trunk/src/gdi32/rgbcvt.h

    r2614 r4034  
    1 //$Id: rgbcvt.h,v 1.1 2000-02-03 18:59:04 sandervl Exp $
     1//$Id: rgbcvt.h,v 1.2 2000-08-18 18:14:58 sandervl Exp $
    22#ifndef __RGBCVT_H__
    33#define __RGBCVT_H__
     
    66void _Optlink RGB555to565MMX(WORD *dest, WORD *src, ULONG num);
    77
     8void _Optlink RGB565to555(WORD *dest, WORD *src, ULONG num);
     9void _Optlink RGB565to555MMX(WORD *dest, WORD *src, ULONG num);
     10
    811#endif //__RGBCVT_H__
  • trunk/src/gdi32/text.cpp

    r4012 r4034  
    1 /* $Id: text.cpp,v 1.11 2000-08-14 15:51:20 cbratschi Exp $ */
     1/* $Id: text.cpp,v 1.12 2000-08-18 18:14:59 sandervl Exp $ */
    22
    33/*
     
    426426  INT  rc;
    427427
     428  dprintf(("InternalDrawTextExW %x %s %d %x", hdc, astring, cchText, dwDTFormat));
    428429  rc = InternalDrawTextExA(hdc,astring,cchText,lprc,dwDTFormat,lpDTParams,isDrawTextEx);
    429430  if (dwDTFormat & DT_MODIFYSTRING && (dwDTFormat & (DT_END_ELLIPSIS | DT_PATH_ELLIPSIS))) AsciiToUnicode(astring,(LPWSTR)lpchText);
Note: See TracChangeset for help on using the changeset viewer.