Ignore:
Timestamp:
Jul 3, 2002, 5:44:39 PM (23 years ago)
Author:
sandervl
Message:

MoveRect fixes (src & dest surfaces the same + overlap); fill fixes + optimizations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ddraw/fillfunc.cpp

    r8821 r8830  
    1 /* $Id: fillfunc.cpp,v 1.7 2002-07-02 09:55:13 sandervl Exp $ */
     1/* $Id: fillfunc.cpp,v 1.8 2002-07-03 15:44:39 sandervl Exp $ */
    22
    33/*
     
    1616#include <misc.h>
    1717#include "fillfunc.h"
     18#include "asmutil.h"
    1819
    1920//
     
    2122//
    2223
    23 #ifndef USE_ASM
    24 void __cdecl Fill8( char* pDst,
    25                     DWORD dwWidth,
    26                     DWORD dwHeight,
    27                     DWORD dwPitch,
    28                     DWORD dwColor)
    29 {
    30   DWORD *pColor;
    31   char  *pFillPos;
    32   int i;
    33   dprintf(("DDRAW:Fill8 with %08X\n",dwColor));
    34 
    35   // First Fill First row with the color
    36 
    37   for( i=0,pColor = (DWORD*)pDst;i<(dwWidth/4);i++)
    38     pColor[i] = dwColor;
    39 
    40   if(dwWidth % 4)
    41   {
    42     if(i==0) i = 1;     //or else next line will corrupt heap
    43     pFillPos = (char*) (&pColor[i-1]);
    44     for(i=0;i<dwWidth % 4;i++)
    45       pFillPos[i] = (UCHAR) dwColor;
     24//*****************************************************************************
     25//*****************************************************************************
     26void CDECL Fill8(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
     27{
     28    DWORD *pColor;
     29    char  *pFillPos;
     30   
     31    dprintf(("DDRAW:Fill8 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
     32
     33    if(dwWidth == dwPitch)
     34    {
     35        // Width = Pitch => fill buffer so no need to take care of lines
     36        memset(pDst, dwColor, dwWidth*dwHeight);
     37    }
     38    else
     39    {
     40        pFillPos = pDst;
     41
     42        while(dwHeight)
     43        {
     44            memset(pFillPos, dwColor, dwWidth);
     45            pFillPos += dwPitch;
     46            dwHeight--;
     47        }
     48    }
     49}
     50//*****************************************************************************
     51//*****************************************************************************
     52void CDECL Fill16(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
     53{
     54    DWORD *pColor;
     55    char  *pFillPos;
     56   
     57    dprintf(("DDRAW:Fill16 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
     58
     59    dwWidth *=2;
     60
     61    if(dwWidth == dwPitch)
     62    {
     63        // Width = Pitch => fill buffer so no need to take care of lines
     64        ddmemfill16(pDst, dwColor, dwWidth*dwHeight);
     65    }
     66    else
     67    {
     68        pFillPos = pDst;
     69
     70        while(dwHeight)
     71        {
     72            ddmemfill16(pFillPos, dwColor, dwWidth);
     73            pFillPos += dwPitch;
     74            dwHeight--;
     75        }
     76    }
     77}
     78//*****************************************************************************
     79//*****************************************************************************
     80void CDECL Fill24(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
     81{
     82    DWORD *pColor;
     83    char  *pFillPos;
     84    int i;
     85
     86    dprintf(("DDRAW:Fill24 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
     87
     88    // First Fill First row with the color
     89
     90    for(i=0 ; i<dwWidth ; i++)
     91    {
     92        pColor = (DWORD*)(pDst+(i*3));
     93        *pColor = dwColor;
     94    }
     95    dwWidth *=3;
     96    dwHeight--;
     97
     98    if(dwWidth == dwPitch)
     99    {
     100        // Width = Pitch => fill buffer so no need to take care of lines
     101        memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
     102    }
     103    else
     104    {
     105        pFillPos = pDst+dwPitch;
     106        while(dwHeight)
     107        {
     108            memcpy(pFillPos,pDst,dwWidth);
     109            pFillPos += dwPitch;
     110            dwHeight--;
     111        }
     112    }
     113}
     114//*****************************************************************************
     115//*****************************************************************************
     116void CDECL Fill32(char* pDst, DWORD dwWidth, DWORD dwHeight, DWORD dwPitch, DWORD dwColor)
     117{
     118    DWORD *pColor;
     119    char  *pFillPos;
     120   
     121    dprintf(("DDRAW:Fill32 %x (%d,%d) %d with %x \n", pDst, dwWidth, dwHeight, dwPitch, dwColor));
     122
     123    dwWidth *= 4;
     124
     125    if(dwWidth == dwPitch)
     126    {
     127        // Width = Pitch => fill buffer so no need to take care of lines
     128        ddmemfill32(pDst, dwColor, dwWidth*dwHeight);
     129    }
     130    else
     131    {
     132        pFillPos = pDst;
     133
     134        while(dwHeight)
     135        {
     136            ddmemfill32(pFillPos, dwColor, dwWidth);
     137            pFillPos += dwPitch;
     138            dwHeight--;
     139        }
    46140  }
    47 
    48   dwHeight--;
    49 
    50   if(dwWidth == dwPitch)
    51   {
    52     // Width = Pitch => fill buffer so no need to take care of lines
    53     memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
    54   }
    55   else
    56   {
    57     pFillPos = pDst+dwPitch;
    58     while(dwHeight)
    59     {
    60       memcpy(pFillPos,pDst,dwWidth);
    61       pFillPos += dwPitch;
    62       dwHeight--;
    63     }
    64   }
    65 }
    66 void __cdecl Fill16( char* pDst,
    67                      DWORD dwWidth,
    68                      DWORD dwHeight,
    69                      DWORD dwPitch,
    70                      DWORD dwColor)
    71 {
    72   DWORD *pColor;
    73   char  *pFillPos;
    74   int i;
    75   dprintf(("DDRAW:Fill16 with %08X \n",dwColor));
    76 
    77   // First Fill First row with the color
    78 
    79   for( i=0,pColor = (DWORD*)pDst;i<(dwWidth/2);i++)
    80     pColor[i] = dwColor;
    81 
    82   if(dwWidth % 2)
    83   {
    84      if(i==0) i = 1;    //or else next line will corrupt heap
    85      pFillPos = (char*)(&pColor[i-1]);
    86     *((USHORT*)pFillPos) = (USHORT)dwColor;
    87   }
    88 
    89   dwWidth *=2;
    90   dwHeight--;
    91 
    92   if(dwWidth == dwPitch)
    93   {
    94     // Width = Pitch => fill buffer so no need to take care of lines
    95     memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
    96   }
    97   else
    98   {
    99     pFillPos = pDst+dwPitch;
    100     while(dwHeight)
    101     {
    102       memcpy(pFillPos,pDst,dwWidth);
    103       pFillPos += dwPitch;
    104       dwHeight--;
    105     }
    106   }
    107 }
    108 void __cdecl Fill24( char* pDst,
    109                      DWORD dwWidth,
    110                      DWORD dwHeight,
    111                      DWORD dwPitch,
    112                      DWORD dwColor)
    113 {
    114   DWORD *pColor;
    115   char  *pFillPos;
    116   int i;
    117   dprintf(("DDRAW:Fill24 with %08X \n",dwColor));
    118 
    119   // First Fill First row with the color
    120 
    121   for(i=0 ; i<dwWidth ; i++)
    122   {
    123     pColor = (DWORD*)(pDst+(i*3));
    124     *pColor = dwColor;
    125   }
    126   dwWidth *=3;
    127   dwHeight--;
    128 
    129   if(dwWidth == dwPitch)
    130   {
    131     // Width = Pitch => fill buffer so no need to take care of lines
    132     memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
    133   }
    134   else
    135   {
    136     pFillPos = pDst+dwPitch;
    137     while(dwHeight)
    138     {
    139       memcpy(pFillPos,pDst,dwWidth);
    140       pFillPos += dwPitch;
    141       dwHeight--;
    142     }
    143   }
    144 }
    145 
    146 void __cdecl Fill32( char* pDst,
    147                      DWORD dwWidth,
    148                      DWORD dwHeight,
    149                      DWORD dwPitch,
    150                      DWORD dwColor)
    151 {
    152   DWORD *pColor;
    153   char  *pFillPos;
    154   int i;
    155   dprintf(("DDRAW:Fill24 with %08X \n",dwColor));
    156 
    157   // First Fill First row with the color
    158 
    159   for(i=0 ; i<dwWidth ; i++)
    160   {
    161     pColor[i] = dwColor;
    162   }
    163   dwWidth *=4;
    164   dwHeight--;
    165 
    166   if(dwWidth == dwPitch)
    167   {
    168     // Width = Pitch => fill buffer so no need to take care of lines
    169     memcpy(pDst+dwPitch, pDst, dwWidth*dwHeight);
    170   }
    171   else
    172   {
    173     pFillPos = pDst+dwPitch;
    174     while(dwHeight)
    175     {
    176       memcpy(pFillPos,pDst,dwWidth);
    177       pFillPos += dwPitch;
    178       dwHeight--;
    179     }
    180   }
    181 }
    182 #else
    183   #define Fill8  Fill8ASM
    184   #define Fill16 Fill16ASM
    185   #define Fill24 Fill24ASM
    186   #define Fill32 Fill32ASM
    187 #endif
    188 
    189 
    190 
    191 // without ColorConversion
    192  void __cdecl Fill8on8( char *pDB,
     141}
     142//*****************************************************************************
     143//*****************************************************************************
     144void CDECL Fill8on8( char *pDB,
    193145                        char *pFB,
    194146                        DWORD dwTop,
     
    212164         dwColor);
    213165}
    214  void __cdecl Fill16on16( char *pDB,
     166//*****************************************************************************
     167//*****************************************************************************
     168void CDECL Fill16on16( char *pDB,
    215169                          char *pFB,
    216170                          DWORD dwTop,
     
    234188          dwColor);
    235189}
    236  void __cdecl Fill24on24( char *pDB,
     190//*****************************************************************************
     191//*****************************************************************************
     192void CDECL Fill24on24( char *pDB,
    237193                          char *pFB,
    238194                          DWORD dwTop,
     
    256212
    257213}
    258  void __cdecl Fill32on32( char *pDB,
     214//*****************************************************************************
     215//*****************************************************************************
     216void CDECL Fill32on32( char *pDB,
    259217                          char *pFB,
    260218                          DWORD dwTop,
     
    275233          dwColor);
    276234}
    277 
    278  void __cdecl Fill8on16( char *pDB,
     235//*****************************************************************************
     236//*****************************************************************************
     237void CDECL Fill8on16( char *pDB,
    279238                         char *pFB,
    280239                         DWORD dwTop,
     
    307266          dwCol);
    308267}
    309 
    310  void __cdecl Fill8on24( char *pDB,
     268//*****************************************************************************
     269//*****************************************************************************
     270void CDECL Fill8on24( char *pDB,
    311271                         char *pFB,
    312272                         DWORD dwTop,
     
    339299          dwCol);
    340300}
    341  void __cdecl Fill8on32( char *pDB,
     301//*****************************************************************************
     302//*****************************************************************************
     303void CDECL Fill8on32( char *pDB,
    342304                         char *pFB,
    343305                         DWORD dwTop,
     
    369331          dwCol);
    370332}
    371  void __cdecl Fill16on8( char *pDB,
     333//*****************************************************************************
     334//*****************************************************************************
     335void CDECL Fill16on8( char *pDB,
    372336                         char *pFB,
    373337                         DWORD dwTop,
     
    381345                        )
    382346{
    383   dprintf(("Fill16on8 NOT Implemented \n"));
    384 }
    385  void __cdecl Fill16on24( char *pDB,
     347    dprintf(("Fill16on8 NOT Implemented \n"));
     348    DebugInt3();
     349}
     350//*****************************************************************************
     351//*****************************************************************************
     352void CDECL Fill16on24( char *pDB,
    386353                          char *pFB,
    387354                          DWORD dwTop,
     
    414381          dwCol);
    415382}
    416  void __cdecl Fill16on32( char *pDB,
     383//*****************************************************************************
     384//*****************************************************************************
     385void CDECL Fill16on32( char *pDB,
    417386                          char *pFB,
    418387                          DWORD dwTop,
     
    445414          dwCol);
    446415}
    447 
    448  void __cdecl Fill24on8( char *pDB,
     416//*****************************************************************************
     417//*****************************************************************************
     418void CDECL Fill24on8( char *pDB,
    449419                         char *pFB,
    450420                         DWORD dwTop,
     
    458428                        )
    459429{
    460   dprintf(("Fill24on8 NOT implemented\n"));
    461 }
    462  void __cdecl Fill24on16( char *pDB,
     430    dprintf(("Fill24on8 NOT implemented\n"));
     431    DebugInt3();
     432}
     433//*****************************************************************************
     434//*****************************************************************************
     435void CDECL Fill24on16( char *pDB,
    463436                          char *pFB,
    464437                          DWORD dwTop,
     
    493466          dwCol);
    494467}
    495  void __cdecl Fill24on32( char *pDB,
     468//*****************************************************************************
     469//*****************************************************************************
     470void CDECL Fill24on32( char *pDB,
    496471                          char *pFB,
    497472                          DWORD dwTop,
     
    519494          dwColor);
    520495}
    521  void __cdecl Fill32on8( char *pDB,
     496//*****************************************************************************
     497//*****************************************************************************
     498void CDECL Fill32on8( char *pDB,
    522499                         char *pFB,
    523500                         DWORD dwTop,
     
    531508                        )
    532509{
    533   dprintf(("Fill32on8 NOT implemented\n"));
    534 }
    535  void __cdecl Fill32on16( char *pDB,
     510    dprintf(("Fill32on8 NOT implemented\n"));
     511    DebugInt3();
     512}
     513//*****************************************************************************
     514//*****************************************************************************
     515void CDECL Fill32on16( char *pDB,
    536516                          char *pFB,
    537517                          DWORD dwTop,
     
    565545          dwCol);
    566546}
    567  void __cdecl Fill32on24( char *pDB,
     547//*****************************************************************************
     548//*****************************************************************************
     549void CDECL Fill32on24( char *pDB,
    568550                          char *pFB,
    569551                          DWORD dwTop,
     
    590572          dwColor);
    591573}
    592 
     574//*****************************************************************************
     575//*****************************************************************************
     576
Note: See TracChangeset for help on using the changeset viewer.