Changeset 352 for trunk/src


Ignore:
Timestamp:
Jul 21, 1999, 12:16:51 AM (26 years ago)
Author:
hugh
Message:

Changhed from Isequence to DPA for managing rectangles and surfaces

Location:
trunk/src/ddraw
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ddraw/OS2DDRAW.CPP

    r210 r352  
    99#define FAR
    1010#include "misc.h"
     11#include <string.h>
    1112#include <winreg.h>
    1213#include <winuser.h>
     
    3031     Referenced(0), lastError(DD_OK),
    3132     pFrameBuffer(NULL), hwndClient(0), screenwidth(640),
    32      screenheight(480), screenbpp(8),PrimaryExists(false)
     33     screenheight(480), screenbpp(8),PrimaryExists(FALSE)
    3334
    3435{
  • trunk/src/ddraw/OS2SURFACE.CPP

    r313 r352  
    77#include <fourcc.h>
    88#include "os2surface.h"
     9#include "rectangle.h"
    910#define _OS2WIN_H
    1011#define FAR
     
    241242  DDSURFACEDESC2 ComplexSurfaceDesc;
    242243  OS2IDirectDrawSurface *AttachedSurface;
     244  OS2IDirectDrawSurface *MipMapSurface;
    243245
    244246  lpVtbl                     = &Vtbl;
     
    308310
    309311  // Setting up Cursors for handling attached Surfaces
     312
     313  DPA_SurfaceMipMaps = DPA_Create(8);
     314  if(NULL==DPA_SurfaceMipMaps)
     315  {
     316    #ifdef DEBUG
     317      WriteLog("Internal : Error creating DPA for MipMaps\n");
     318    #endif
     319    lastError = DDERR_OUTOFMEMORY ;
     320    return;
     321  }
     322
     323  DPA_SurfaceAttached = DPA_Create(8);
     324  if(NULL==DPA_SurfaceAttached)
     325  {
     326    #ifdef DEBUG
     327      WriteLog("Internal : Error creating DPA for attached surfaces\n");
     328    #endif
     329    lastError = DDERR_OUTOFMEMORY ;
     330    return;
     331  }
     332
     333  DPA_LockedRects = DPA_Create(8);
     334  if(NULL==DPA_LockedRects)
     335  {
     336    #ifdef DEBUG
     337      WriteLog("Internal : Error creating DPA for Locked Rectangles\n");
     338    #endif
     339    lastError = DDERR_OUTOFMEMORY ;
     340    return;
     341  }
     342
     343  DPA_SurfacePrivateData = DPA_Create(8);
     344  if(NULL==DPA_SurfacePrivateData)
     345  {
     346    #ifdef DEBUG
     347      WriteLog("Internal : Error creating DPA for priva surface Data\n");
     348    #endif
     349    lastError = DDERR_OUTOFMEMORY ;
     350    return;
     351  }
     352
     353  /*
    310354  try
    311355  {
     
    333377    return;
    334378  }
    335 
     379  */
    336380  if( lpDDSurfaceDesc->dwFlags & DDSD_CAPS )
    337381  {
     
    766810            ComplexSurfaceDesc.dwWidth  /= 2;
    767811            ComplexSurfaceDesc.dwHeight /= 2;
    768             try
     812
     813            MipMapSurface = new OS2IDirectDrawSurface(lpDraw, &ComplexSurfaceDesc, TRUE);
     814
     815            DPA_InsertPtr( DPA_SurfaceMipMaps,
     816                           DPA_GetPtrCount(DPA_SurfaceMipMaps),
     817                           MipMapSurface);
     818
     819            if(MipMapSurface->GetLastError() != DD_OK)
    769820            {
    770               SurfaceSequenceMipMap.addAsLast(new OS2IDirectDrawSurface(lpDraw, &ComplexSurfaceDesc, TRUE),
    771                                       *SurfaceCursorMipMap);
    772             }
    773             catch(IOutOfMemory)
    774             {
     821              lastError = AttachedSurface->GetLastError();
    775822              #ifdef DEBUG
    776                 WriteLog("Internal : ISet.add OutOfMemory\n");
     823                WriteLog("Attached surface creation returned error %d\n",lastError);
    777824              #endif
    778               lastError = DDERR_OUTOFMEMORY;
    779825              return;
    780             }
    781             catch(ICursorInvalidException)
    782             {
    783               #ifdef DEBUG
    784                 WriteLog("Internal: Invalid Cursor\n");
    785               #endif
    786               lastError = DDERR_OUTOFMEMORY;
    787               return;
    788             }
    789 
    790             if( !SurfaceCursorMipMap->isValid() )
    791             {
    792               // We shouldn't get in here as add sould have raised IOutOfMemory
    793               // If it couldn't create the surface
    794               #ifdef DEBUG
    795                 WriteLog("Internal : Cursor is Invalid => OutOfMemory\n");
    796               #endif
    797               lastError = DDERR_OUTOFMEMORY;
    798               return;
    799             }
    800             else
    801             {
    802               AttachedSurface = SurfaceCursorMipMap->element();
    803               if(AttachedSurface->GetLastError() != DD_OK)
    804               {
    805                 lastError = AttachedSurface->GetLastError();
    806                 #ifdef DEBUG
    807                   WriteLog("Attached surface creation returned error %d\n",lastError);
    808                 #endif
    809                 return;
    810               } // Endif Errorcheck
    811             } //Endif Cursorcheck
     826            } // Endif Errorcheck
    812827          } //End for(i =0; i < lpDDSurfaceDesc->dwMipMapCount; i++)
    813828        } // End of MipMaps
     
    11291144//******************************************************************************
    11301145//******************************************************************************
     1146// Internal callbacks uses by destructor
     1147int  DestroyRects(LPVOID lpItem, DWORD dwRes)
     1148{
     1149  delete (DDRectangle*) lpItem;
     1150  return 1;
     1151}
     1152
     1153int ReleaseSurfaces(LPVOID lpItem, DWORD dwRes)
     1154{
     1155  OS2IDirectDrawSurface *pSurf;
     1156  pSurf = (OS2IDirectDrawSurface *)lpItem;
     1157  pSurf->Vtbl.Release(pSurf);
     1158  return 1;
     1159}
     1160//******************************************************************************
     1161//******************************************************************************
     1162
    11311163OS2IDirectDrawSurface::~OS2IDirectDrawSurface()
    11321164{
     
    11641196
    11651197  // Clear the list of locked rectangles
    1166   if (!LockedRectSequence.isEmpty())
    1167     LockedRectSequence.removeAll();
     1198  if (DPA_GetPtrCount(DPA_LockedRects)>0)
     1199  {
     1200    DPA_DestroyCallback( DPA_LockedRects,
     1201                         (DPAENUMPROC)DestroyRects,
     1202                         0);
     1203  }
    11681204
    11691205  if(lpClipper)
     
    11881224    BackBuffer->Vtbl.Release(AttachedSurface);
    11891225
    1190   while( !SurfaceSequenceMipMap.isEmpty())
    1191   {
    1192     try
    1193     {
    1194       AttachedSurface = SurfaceSequenceMipMap.firstElement();
    1195       AttachedSurface->Vtbl.Release(AttachedSurface);
    1196       SurfaceSequenceMipMap.removeFirst();
    1197     }
    1198     catch(...)
    1199     {
    1200       #ifdef DEBUG
    1201         WriteLog("Internal : Error deleting MipMap Surfaces\n");
    1202       #endif
    1203     }
    1204   }
    1205 
    1206   while( !SurfaceSequenceAttached.isEmpty())
    1207   {
    1208     try
    1209     {
    1210       AttachedSurface = SurfaceSequenceAttached.firstElement();
    1211       AttachedSurface->Vtbl.Release(AttachedSurface);
    1212       SurfaceSequenceAttached.removeFirst();
    1213     }
    1214     catch(...)
    1215     {
    1216       #ifdef DEBUG
    1217         WriteLog("Internal : Error deleting other attached\n");
    1218       #endif
    1219     }
     1226  if (DPA_GetPtrCount(DPA_SurfaceMipMaps)>0)
     1227  {
     1228    DPA_DestroyCallback( DPA_SurfaceMipMaps,
     1229                         (DPAENUMPROC)ReleaseSurfaces,
     1230                         0);
     1231  }
     1232
     1233  if (DPA_GetPtrCount(DPA_SurfaceAttached)>0)
     1234  {
     1235    DPA_DestroyCallback( DPA_SurfaceAttached,
     1236                         (DPAENUMPROC)ReleaseSurfaces,
     1237                         0);
    12201238  }
    12211239
     
    13701388      if(me->DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
    13711389      {
    1372         try
    1373         {
    1374           me->SurfaceSequenceMipMap.addAsLast(AttachedSurface);
    1375           me->SurfaceCursorMipMap->setToFirst();
    1376 
     1390        if( DPA_InsertPtr( me->DPA_SurfaceMipMaps,
     1391                           DPA_GetPtrCount(me->DPA_SurfaceMipMaps),
     1392                           AttachedSurface) >=0)
     1393        {
    13771394          me->DDSurfaceDesc.dwFlags |= DDSD_MIPMAPCOUNT;
    13781395          me->DDSurfaceDesc.dwMipMapCount++;
     
    13801397          AttachedSurface->Vtbl.AddRef(AttachedSurface);
    13811398        }
    1382         catch(...)
     1399        else
    13831400        {
    13841401          #ifdef DEBUG
     
    13981415    else
    13991416    {
    1400       try
    1401       {
    1402         me->SurfaceSequenceAttached.addAsLast(AttachedSurface);
    1403         // add made the last cursor invalid so start from the begining
    1404         me->SurfaceCursorAttached->setToFirst();
    1405 
     1417      if( DPA_InsertPtr( me->DPA_SurfaceAttached,
     1418                         DPA_GetPtrCount(me->DPA_SurfaceAttached),
     1419                         AttachedSurface) >=0)
     1420      {
    14061421        AttachedSurface->Vtbl.AddRef(AttachedSurface);
    14071422      }
    1408       catch(...)
     1423      else
    14091424      {
    14101425        #ifdef DEBUG
     
    14811496          if(me->DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
    14821497          {
    1483             try
     1498            if( DPA_InsertPtr( me->DPA_SurfaceMipMaps,
     1499                               DPA_GetPtrCount(me->DPA_SurfaceMipMaps),
     1500                               AttachedSurface) >=0)
    14841501            {
    1485               me->SurfaceSequenceMipMap.addAsLast(AttachedSurface);
    1486               me->SurfaceCursorMipMap->setToFirst();
    1487 
    14881502              me->DDSurfaceDesc.dwFlags |= DDSD_MIPMAPCOUNT;
    14891503              me->DDSurfaceDesc.dwMipMapCount++;
     
    14921506              AttachedSurface->Vtbl.AddRef(AttachedSurface);
    14931507            }
    1494             catch(...)
     1508            else
    14951509            {
    14961510              #ifdef DEBUG
    14971511                WriteLog("Internal : Error attaching to MipMap\n");
    14981512              #endif
    1499              return(DDERR_CANNOTATTACHSURFACE);
     1513              return(DDERR_CANNOTATTACHSURFACE);
    15001514            }
    15011515          }
     
    15101524        else
    15111525        {
    1512           try
     1526          if( DPA_InsertPtr( me->DPA_SurfaceAttached,
     1527                             DPA_GetPtrCount(me->DPA_SurfaceAttached),
     1528                             AttachedSurface) >=0)
    15131529          {
    1514             me->SurfaceSequenceAttached.addAsLast(AttachedSurface);
    1515             // add made the last cursor invalid so start from the begining
    1516             me->SurfaceCursorAttached->setToFirst();
    1517 
    15181530            AttachedSurface->Vtbl.AddRef(AttachedSurface);
    15191531          }
    1520           catch(...)
     1532          else
    15211533          {
    15221534            #ifdef DEBUG
    15231535              WriteLog("Internal : Error attaching to general Set\n");
    15241536            #endif
    1525            return(DDERR_CANNOTATTACHSURFACE);
     1537            return(DDERR_CANNOTATTACHSURFACE);
    15261538          }
    15271539        }
     
    15731585 OS2IDirectDrawSurface *dest = (OS2IDirectDrawSurface *)This;
    15741586 OS2IDirectDrawSurface *src  = (OS2IDirectDrawSurface *)lpDDSrcSurface;
    1575  ISequence<DDRectangle*>::Cursor *EnumCursor;
    15761587
    15771588 HRESULT                rc;
     
    16261637      // we can't blit to it
    16271638
    1628       EnumCursor = dest->LockedRectSequence.newCursor();
    1629       EnumCursor->setToFirst();
    16301639      Found = FALSE;
    1631 
    1632       while((EnumCursor->isValid() ) && !Found)
    1633       {
    1634         pIRectTest = EnumCursor->element();
     1640      i=0;
     1641      while( (i<DPA_GetPtrCount(dest->DPA_LockedRects)) && !Found)
     1642      {
     1643        pIRectTest = (DDRectangle*) DPA_FastGetPtr(dest->DPA_LockedRects,i);
    16351644        Found = pIRectDest->intersects(*pIRectTest);
    1636         EnumCursor->setToNext();
     1645        i++;
    16371646      }
    1638 
    1639       delete EnumCursor;
    16401647
    16411648    }
     
    17651772      // source surface we can't blit from it
    17661773
    1767       EnumCursor = src->LockedRectSequence.newCursor();
    1768       EnumCursor->setToFirst();
    17691774      Found = FALSE;
    1770 
    1771       while((EnumCursor->isValid() ) && !Found)
    1772       {
    1773         pIRectTest = EnumCursor->element();
    1774         Found = pIRectSrc->intersects(*pIRectTest);
    1775         EnumCursor->setToNext();
     1775      i=0;
     1776
     1777      while((i<DPA_GetPtrCount(src->DPA_LockedRects) ) && !Found)
     1778      {
     1779        pIRectTest = (DDRectangle*) DPA_FastGetPtr(src->DPA_LockedRects,i);
     1780        Found = pIRectDest->intersects(*pIRectTest);
     1781        i++;
    17761782      }
    1777 
    1778       delete EnumCursor;
    17791783
    17801784    }
     
    24522456  }
    24532457
     2458  // Todo: Test for locked src/dest
     2459
    24542460  pBltPos = (char*) dest->pDiveBuffer + (dwY * dest->dwPitchDB) +
    24552461            (dwX * dest->dwBytesPPDive);
     
    27562762  OS2IDirectDrawSurface *AttachedSurface;
    27572763  OS2IDirectDrawSurface *SurfaceCursor;
    2758 
    2759   ISequence<OS2IDirectDrawSurface*>::Cursor *EnumCursor;
     2764  int i;
     2765
    27602766  BOOL Found = FALSE;
    27612767  #ifdef DEBUG
     
    28572863  {
    28582864    // Surface seams to be a mipmap
    2859     EnumCursor = me->SurfaceSequenceMipMap.newCursor();
    2860     EnumCursor->setToFirst();
    2861     while((EnumCursor->isValid() ) && !Found)
    2862     {
    2863       if (EnumCursor->element() == AttachedSurface)
     2865    i = 0;
     2866    while((DPA_GetPtrCount(me->DPA_SurfaceMipMaps)>i ) && !Found)
     2867    {
     2868      if (DPA_FastGetPtr(me->DPA_SurfaceMipMaps,i) == AttachedSurface)
    28642869      {
    28652870        Found = TRUE;
    2866         me->SurfaceSequenceMipMap.removeAt(*EnumCursor);
    2867         me->SurfaceCursorMipMap->setToFirst();
     2871        DPA_DeletePtr(me->DPA_SurfaceMipMaps,i);
    28682872        AttachedSurface->lpVtbl->Release(AttachedSurface);
    28692873        // adjust our info
     
    28742878        }
    28752879      }
    2876     }
    2877     delete EnumCursor;
     2880      i++;
     2881    }
    28782882  }
    28792883
    28802884  if(!Found)
    28812885  {
    2882     // Surface seams to be a mipmap
    2883     EnumCursor = me->SurfaceSequenceAttached.newCursor();
    2884     EnumCursor->setToFirst();
    2885     while((EnumCursor->isValid() ) && !Found)
    2886     {
    2887       if (EnumCursor->element() == AttachedSurface)
     2886    // Surface seams to be an attached one
     2887    i = 0;
     2888    while((DPA_GetPtrCount(me->DPA_SurfaceAttached)>i ) && !Found)
     2889    {
     2890      if (DPA_FastGetPtr(me->DPA_SurfaceAttached,i) == AttachedSurface)
    28882891      {
    28892892        Found = TRUE;
    2890         me->SurfaceSequenceAttached.removeAt(*EnumCursor);
    2891         me->SurfaceCursorAttached->setToFirst();
     2893        DPA_DeletePtr(me->DPA_SurfaceAttached,i);
    28922894        AttachedSurface->lpVtbl->Release(AttachedSurface);
    28932895      }
    2894     }
    2895     delete EnumCursor;
     2896      i++;
     2897    }
    28962898  }
    28972899
     
    29162918  OS2IDirectDrawSurface *EnumSurface;
    29172919  DDSURFACEDESC2         EnumDesc;
    2918 
    2919   ISequence<OS2IDirectDrawSurface*>::Cursor *EnumCursor;
     2920  int i;
    29202921  HRESULT rc;
    29212922
     
    29342935  }
    29352936
    2936   if(!me->SurfaceSequenceMipMap.isEmpty())
    2937   {
    2938     EnumCursor = me->SurfaceSequenceMipMap.newCursor();
    2939     EnumCursor->setToFirst();
    2940     while( (DDENUMRET_OK == rc) && EnumCursor->isValid() )
    2941     {
    2942       EnumSurface = EnumCursor->element();
     2937  if(DPA_GetPtrCount(me->DPA_SurfaceMipMaps)>0)
     2938  {
     2939    i=0;
     2940    while( (DDENUMRET_OK == rc) && i<DPA_GetPtrCount(me->DPA_SurfaceMipMaps) )
     2941    {
     2942      EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceMipMaps,i);
    29432943      memcpy(&EnumDesc,&(EnumSurface->DDSurfaceDesc),sizeof(DDSURFACEDESC2));
    29442944      rc = lpCallBack((LPDIRECTDRAWSURFACE4)EnumSurface,&EnumDesc,lpContext);
    2945       EnumCursor->setToNext();
    2946     }
    2947     delete EnumCursor;
    2948   }
    2949 
    2950   if(!me->SurfaceSequenceAttached.isEmpty())
    2951   {
    2952     EnumCursor = me->SurfaceSequenceAttached.newCursor();
    2953     EnumCursor->setToFirst();
    2954     while( (DDENUMRET_OK == rc) && EnumCursor->isValid() )
    2955     {
    2956       EnumSurface = EnumCursor->element();
     2945      i++;
     2946    }
     2947  }
     2948
     2949  if(DPA_GetPtrCount(me->DPA_SurfaceAttached)>0)
     2950  {
     2951    i=0;
     2952    while( (DDENUMRET_OK == rc) && i<DPA_GetPtrCount(me->DPA_SurfaceAttached) )
     2953    {
     2954      EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceAttached,i);
    29572955      memcpy(&EnumDesc,&(EnumSurface->DDSurfaceDesc),sizeof(DDSURFACEDESC2));
    29582956      rc = lpCallBack((LPDIRECTDRAWSURFACE4)EnumSurface,&EnumDesc,lpContext);
    2959       EnumCursor->setToNext();
    2960     }
    2961     delete EnumCursor;
     2957      i++;
     2958    }
    29622959  }
    29632960
     
    31293126  OS2IDirectDrawSurface *EnumSurface = NULL;
    31303127  OS2IDirectDrawSurface *AttachedSurface = NULL;
    3131   ISequence<OS2IDirectDrawSurface*>::Cursor *EnumCursor;
     3128  int i;
     3129
    31323130  #ifdef DEBUG
    31333131    WriteLog("SurfGetAttachedSurface4\n>Requested Caps: ");
     
    31483146  }
    31493147
    3150   if(!me->SurfaceSequenceMipMap.isEmpty())
    3151   {
    3152     EnumCursor = me->SurfaceSequenceMipMap.newCursor();
    3153     EnumCursor->setToFirst();
    3154     while( EnumCursor->isValid() )
    3155     {
    3156       EnumSurface = EnumCursor->element();
     3148  if(DPA_GetPtrCount(me->DPA_SurfaceMipMaps)>0)
     3149  {
     3150    i=0;
     3151    while( i<DPA_GetPtrCount(me->DPA_SurfaceMipMaps) )
     3152    {
     3153      EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceMipMaps,i);
    31573154      if(EnumSurface->DDSurfaceDesc.ddsCaps.dwCaps == lpDDCaps->dwCaps)
    31583155      {
     
    31643161
    31653162      }
    3166       EnumCursor->setToNext();
    3167     }
    3168     delete EnumCursor;
    3169   }
    3170 
    3171   if(!me->SurfaceSequenceAttached.isEmpty())
    3172   {
    3173     EnumCursor = me->SurfaceSequenceAttached.newCursor();
    3174     EnumCursor->setToFirst();
    3175     while( EnumCursor->isValid() )
    3176     {
    3177       EnumSurface = EnumCursor->element();
     3163      i++;
     3164    }
     3165  }
     3166
     3167  if(DPA_GetPtrCount(me->DPA_SurfaceAttached)>0)
     3168  {
     3169    i=0;
     3170    while( i<DPA_GetPtrCount(me->DPA_SurfaceAttached) )
     3171    {
     3172      EnumSurface = (OS2IDirectDrawSurface*) DPA_FastGetPtr(me->DPA_SurfaceAttached,i);
    31783173      if(EnumSurface->DDSurfaceDesc.ddsCaps.dwCaps == lpDDCaps->dwCaps)
    31793174      {
     
    31853180
    31863181      }
    3187       EnumCursor->setToNext();
    3188     }
    3189     delete EnumCursor;
     3182      i++;
     3183    }
    31903184  }
    31913185
     
    36383632
    36393633  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    3640   ISequence<DDRectangle*>::Cursor *EnumCursor;
     3634  int i;
    36413635
    36423636  BOOL Found;
     
    36743668      // be locked so check for this
    36753669
    3676       EnumCursor = me->LockedRectSequence.newCursor();
    3677       EnumCursor->setToFirst();
     3670      i=0;
    36783671      Found = FALSE;
    36793672
    3680       while((EnumCursor->isValid() ) && !Found)
    3681       {
    3682         pIRectCurrent = EnumCursor->element();
     3673      while(i<DPA_GetPtrCount(me->DPA_LockedRects) && !Found)
     3674      {
     3675        pIRectCurrent = (DDRectangle*) DPA_FastGetPtr(me->DPA_LockedRects,i);
    36833676        Found = pIRectCurrent->intersects(*pIRectNew);
    3684         EnumCursor->setToNext();
     3677        i++;
    36853678      }
    3686 
    3687       delete EnumCursor;
    36883679
    36893680    }
     
    37183709  // Add the rectangle to the list of locked rectangles
    37193710
    3720   me->LockedRectSequence.addAsLast(pIRectNew);
     3711  DPA_InsertPtr( me->DPA_LockedRects,
     3712                 DPA_GetPtrCount(me->DPA_LockedRects),
     3713                 pIRectNew);
    37213714
    37223715  me->fLocked = TRUE;
     
    39673960
    39683961  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    3969   ISequence<DDRectangle*>::Cursor *EnumCursor;
     3962  int i;
    39703963  DDRectangle *pIRectUnlock;
    39713964  BOOL Found = FALSE;
     
    39873980    WriteLog("Unlock rectangle\n");
    39883981    pIRectUnlock = new DDRectangle( lpSurfaceRect->top,
    3989                                    lpSurfaceRect->left,
    3990                                    lpSurfaceRect->bottom,
    3991                                    lpSurfaceRect->right);
     3982                                    lpSurfaceRect->left,
     3983                                    lpSurfaceRect->bottom,
     3984                                    lpSurfaceRect->right);
    39923985  }
    39933986  else
     
    40013994  #endif
    40023995
    4003   EnumCursor = me->LockedRectSequence.newCursor();
    4004   EnumCursor->setToFirst();
    4005   while(EnumCursor->isValid() && !Found)
    4006   {
    4007     Found = (*(EnumCursor->element()) == *pIRectUnlock);
     3996  i=0;
     3997  while(i<DPA_GetPtrCount(me->DPA_LockedRects) && !Found)
     3998  {
     3999    Found = (*((DDRectangle*)DPA_FastGetPtr(me->DPA_LockedRects,i)) == *pIRectUnlock);
    40084000    if(!Found)
    40094001    {
     
    40114003        WriteLog("Not Found, try Next rect\n");
    40124004      #endif
    4013       EnumCursor->setToNext();
     4005      i++;
    40144006    }
    40154007    #ifdef DEBUG
     
    40334025  #endif
    40344026
    4035   me->LockedRectSequence.removeAt(*EnumCursor);
    4036 
    4037   if(me->LockedRectSequence.isEmpty())  // Do we have unlocked last rectangle
     4027  DPA_DeletePtr(me->DPA_LockedRects,i);
     4028
     4029  if(0==DPA_GetPtrCount(me->DPA_LockedRects))  // Do we have unlocked last rectangle
    40384030  {
    40394031    #ifdef DEBUG
     
    42104202{
    42114203  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    4212   ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;
     4204  int i;
    42134205  PSURFPRIVATEDATA pSData;
    42144206  void *pBuffer;
     
    42274219
    42284220  // first check if the refGUID is stored as then the content will be updated
    4229   if(! me->SurfaceSequencePrivateData.isEmpty() )
    4230   {
    4231     EnumCursor = me->SurfaceSequencePrivateData.newCursor();
    4232     EnumCursor->setToFirst();
    4233     while(EnumCursor->isValid() && !bFound)
    4234     {
    4235       pSData = EnumCursor->element();
     4221  if( DPA_GetPtrCount(me->DPA_SurfacePrivateData)>0 )
     4222  {
     4223    i=0;
     4224    while(i<DPA_GetPtrCount(me->DPA_SurfacePrivateData) && !bFound)
     4225    {
     4226      pSData = (PSURFPRIVATEDATA) DPA_FastGetPtr(me->DPA_SurfacePrivateData,i);
    42364227
    42374228      if (IsEqualGUID(pSData->guidTag,refGUID))
    42384229        bFound = TRUE;
    42394230
    4240       EnumCursor->setToNext();
    4241     }
    4242     delete EnumCursor;
     4231      i++;
     4232    }
    42434233  }
    42444234
     
    43744364        }
    43754365      }
     4366
     4367      if( DPA_InsertPtr( me->DPA_SurfacePrivateData,
     4368                         DPA_GetPtrCount(me->DPA_SurfacePrivateData),
     4369                         pSData) <0)
     4370      {
     4371        delete pSData;
     4372        return (DDERR_OUTOFMEMORY);
     4373      }
     4374
    43764375    }
    43774376    else
     
    43854384{
    43864385  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    4387   ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;
     4386  int i;
    43884387  PSURFPRIVATEDATA pSData;
    43894388  BOOL bFound = FALSE;
     4389
    43904390  #ifdef DEBUG
    43914391    WriteLog("SurfGetPrivateData\n");
    43924392  #endif
     4393
    43934394  if(NULL==me)
    43944395    return(DDERR_INVALIDOBJECT);
     
    43974398    return(DDERR_INVALIDPARAMS);
    43984399
    4399   if(! me->SurfaceSequencePrivateData.isEmpty() )
    4400   {
    4401     EnumCursor = me->SurfaceSequencePrivateData.newCursor();
    4402     EnumCursor->setToFirst();
    4403     while(EnumCursor->isValid() && !bFound)
    4404     {
    4405       pSData = EnumCursor->element();
     4400  if(DPA_GetPtrCount(me->DPA_SurfacePrivateData)>0)
     4401  {
     4402    i=0;
     4403    while(i<DPA_GetPtrCount(me->DPA_SurfacePrivateData) && !bFound)
     4404    {
     4405      pSData = (PSURFPRIVATEDATA) DPA_FastGetPtr(me->DPA_SurfacePrivateData,i);
    44064406
    44074407      if (IsEqualGUID(pSData->guidTag,refGUID))
    44084408        bFound = TRUE;
    44094409
    4410       EnumCursor->setToNext();
    4411     }
    4412     delete EnumCursor;
     4410      i++;
     4411    }
    44134412  }
    44144413
     
    44364435{
    44374436  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    4438   ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;
     4437  int i;
    44394438  PSURFPRIVATEDATA pSData;
    44404439  BOOL bFound = FALSE;
     4440
    44414441  #ifdef DEBUG
    44424442    WriteLog("SurfFreePrivateData\n");
    44434443  #endif
     4444
    44444445  if(NULL==me)
    44454446    return(DDERR_INVALIDOBJECT);
    44464447
    4447   if(! me->SurfaceSequencePrivateData.isEmpty() )
    4448   {
    4449     EnumCursor = me->SurfaceSequencePrivateData.newCursor();
    4450     EnumCursor->setToFirst();
    4451     while(EnumCursor->isValid() && !bFound)
    4452     {
    4453       pSData = EnumCursor->element();
     4448  if(DPA_GetPtrCount(me->DPA_SurfacePrivateData)>0)
     4449  {
     4450    i=0;
     4451    while(i<DPA_GetPtrCount(me->DPA_SurfacePrivateData) && !bFound)
     4452    {
     4453      pSData = (PSURFPRIVATEDATA) DPA_FastGetPtr(me->DPA_SurfacePrivateData,i);
    44544454
    44554455      if (IsEqualGUID(pSData->guidTag,refGUID))
     
    44724472        }
    44734473        // Now remove the entry from the list
    4474         me->SurfaceSequencePrivateData.removeAt(*EnumCursor);
    4475         delete pSData; // free alocated Data
     4474        DPA_DeletePtr(me->DPA_SurfacePrivateData,i);
    44764475      }
    4477       EnumCursor->setToNext();
    4478     }
    4479     delete EnumCursor;
     4476      i++;
     4477    }
    44804478  }
    44814479  return (bFound?DD_OK:DDERR_NOTFOUND);
     
    45004498{
    45014499  OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This;
    4502   ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;
     4500  int i;
    45034501  PSURFPRIVATEDATA pSData;
    45044502
     
    45084506  me->dwUniqueValue++;
    45094507
    4510   if(! me->SurfaceSequencePrivateData.isEmpty() )
    4511   {
    4512     EnumCursor = me->SurfaceSequencePrivateData.newCursor();
    4513     EnumCursor->setToFirst();
    4514     while(EnumCursor->isValid())
    4515     {
    4516       pSData = EnumCursor->element();
     4508  if(DPA_GetPtrCount(me->DPA_SurfacePrivateData)>0)
     4509  {
     4510    i=0;
     4511    while(i<DPA_GetPtrCount(me->DPA_SurfacePrivateData))
     4512    {
     4513      pSData = (PSURFPRIVATEDATA) DPA_FastGetPtr(me->DPA_SurfacePrivateData,i);
    45174514      if (pSData->dwFlags & DDSPD_VOLATILE)
    45184515      {
     
    45314528        pSData->isValid = FALSE; // set flag to invalid
    45324529      }
    4533       EnumCursor->setToNext();
    4534     }
    4535     delete EnumCursor;
     4530      i++;
     4531    }
    45364532  }
    45374533
     
    45414537//******************************************************************************
    45424538//
    4543 //  Pupose function copies one part of the bitmap inside the same bitmap
     4539//  Purpose function copies one part of the bitmap inside the same bitmap
    45444540//
    45454541//******************************************************************************
  • trunk/src/ddraw/OS2SURFACE.H

    r312 r352  
    77#include "os2palette.h"
    88#include <dive.h>
    9 #include <iseq.h>
    10 #include "rectangle.h"
     9#include <commctrl.h>
    1110
    1211#define FAR
     
    8685
    8786        DWORD                  dwUniqueValue;
    88         ISequence<PSURFPRIVATEDATA> SurfaceSequencePrivateData;
     87        HDPA DPA_SurfacePrivateData;
     88
    8989        BOOL                   fOverlayValid;
    9090        LONG                   lOverlayX;
     
    9696        OS2IDirectDrawSurface*  FrontBuffer; // NULL if the real frontbuffer of a Flipchain otherwise  the prev. Backbuffer
    9797        OS2IDirectDrawSurface*  NextFlip;    // Only valid in a frontbuffer
    98         ISequence <OS2IDirectDrawSurface*> SurfaceSequenceMipMap;    // MipMaps go in this one
    99         ISequence <OS2IDirectDrawSurface*> SurfaceSequenceAttached;  // Other attached go in this one
    100         ISequence <OS2IDirectDrawSurface*>::Cursor *SurfaceCursorMipMap;    // Iterator for MipMaps
    101         ISequence <OS2IDirectDrawSurface*>::Cursor *SurfaceCursorAttached;  // Iterator for other attached surfaces
    102 
    103         ISequence <DDRectangle*> LockedRectSequence;            // List for locked rectangles
     98
     99        HDPA DPA_SurfaceMipMaps;
     100        HDPA DPA_SurfaceAttached;
     101        HDPA DPA_LockedRects;
    104102
    105103    friend    HRESULT __stdcall SurfQueryInterface(THIS, REFIID riid, LPVOID FAR * ppvObj);
  • trunk/src/ddraw/makefile

    r212 r352  
    1313ASFLAGS = -Sc -Sv:ALP
    1414
    15 CFLAGS = $(CFLAGS) -Ft+ -I$(PDWIN32_INCLUDE);
    16 CXXFLAGS = $(CXXFLAGS) -Ft+ -I$(PDWIN32_INCLUDE);
     15CFLAGS = $(CFLAGS) -I$(PDWIN32_INCLUDE);
     16CXXFLAGS = $(CXXFLAGS) -I$(PDWIN32_INCLUDE);
    1717
    1818TARGET = ddraw
    1919
    2020OBJS =  ddraw.obj os2ddraw.obj os2clipper.obj os2d3d.obj iccio1.obj asmutil.obj\
    21         os2surface.obj os2palette.obj os2palset.obj misc.obj initterm.obj
     21        os2surface.obj os2palette.obj os2palset.obj misc.obj rectangle.obj initterm.obj
    2222
    23 LIBS =  ($PDWIN32_LIB)\pmwinx.lib mmpm2.lib CPPOOC3.lib CPPOM30.lib
     23LIBS =  ..\..\lib\pmwinx.lib mmpm2.lib ..\..\lib\comctl32.lib
    2424
    2525all: $(TARGET).dll $(TARGET).lib
     
    2727
    2828$(TARGET).dll: $(OBJS) $(TARGET).def
    29         $(LD) $(LDFLAGS) -Tdp -Fm -Fe$@ $(OBJS) $(TARGET).def $(LIBS)
     29        $(LD) $(LDFLAGS) -Fm -Fe$@ $(OBJS) $(TARGET).def $(LIBS)
    3030  $(CP) $@ $(PDWIN32_BIN)
    3131
     
    4747    $(PDWIN32_INCLUDE)\win\ddraw.h \
    4848    $(PDWIN32_INCLUDE)\win\d3d.h
     49
    4950os2d3d.obj: os2d3d.cpp \
    50     os2ddraw.h
     51    os2ddraw.h\
     52    $(PDWIN32_INCLUDE)\win\ddraw.h \
     53    $(PDWIN32_INCLUDE)\win\d3d.h
    5154
    5255misc.obj: misc.cpp
     
    6669    os2clipper.h \
    6770    os2surface.h \
    68     os2ddraw.h
     71    os2ddraw.h\
     72    $(PDWIN32_INCLUDE)\win\ddraw.h \
     73    $(PDWIN32_INCLUDE)\win\d3d.h
    6974
    7075os2surface.obj: os2surface.cpp  \
     
    7277    os2clipper.h \
    7378    os2surface.h \
    74     os2ddraw.h
     79    os2ddraw.h\
     80    $(PDWIN32_INCLUDE)\win\ddraw.h \
     81    $(PDWIN32_INCLUDE)\win\d3d.h
    7582
     83rectangle.obj: rectangle.cpp
    7684
    7785initterm.obj: initterm.cpp
  • trunk/src/ddraw/rectangle.h

    r312 r352  
    3434  height() const;
    3535
    36 /*--------------------------------- Synonyms ---------------------------------
    37 
    38 Coord
    39   bottom ( ) const,
    40   left   ( ) const,
    41   right  ( ) const,
    42   top    ( ) const;
    43 */
    44 
    4536private:
    4637  long lTop,lLeft;
     
    4839}; // class DDRectangle
    4940
    50 DDRectangle :: DDRectangle ( Coord y1,
    51                     Coord x1,
    52                     Coord y2,
    53                     Coord x2 )
    54 {
    55   lTop    = y1;
    56   lLeft   = x1;
    57   lBottom = y2;
    58   lRight  = x2;
    59 }
    60 
    61 IBase::Boolean DDRectangle :: operator == ( const DDRectangle &aRect ) const
    62   {
    63   return ( lTop == aRect.lTop && lLeft == aRect.lLeft
    64            &&
    65            lBottom == aRect.lBottom && lRight == aRect.lRight);
    66   }
    67 IBase::Boolean DDRectangle :: operator != ( const DDRectangle& aRect ) const
    68   {
    69   return !( *this == aRect );
    70   }
    71 IBase::Boolean DDRectangle :: intersects ( const DDRectangle &aRect ) const
    72 {
    73   return ( lTop < aRect.lBottom && lLeft<aRect.lRight
    74            &&
    75            aRect.lTop < lBottom && aRect.lLeft < lRight );
    76 }
    77 
    78 DDRectangle::Coord DDRectangle :: width (  ) const
    79 {
    80   return ( lRight - lLeft);
    81 }
    82 
    83 DDRectangle::Coord DDRectangle :: height (  ) const
    84 {
    85   return ( lBottom - lTop);
    86 }
    87 
    8841#endif
Note: See TracChangeset for help on using the changeset viewer.