- Timestamp:
- Jul 21, 1999, 12:16:51 AM (26 years ago)
- Location:
- trunk/src/ddraw
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ddraw/OS2DDRAW.CPP
r210 r352 9 9 #define FAR 10 10 #include "misc.h" 11 #include <string.h> 11 12 #include <winreg.h> 12 13 #include <winuser.h> … … 30 31 Referenced(0), lastError(DD_OK), 31 32 pFrameBuffer(NULL), hwndClient(0), screenwidth(640), 32 screenheight(480), screenbpp(8),PrimaryExists( false)33 screenheight(480), screenbpp(8),PrimaryExists(FALSE) 33 34 34 35 { -
trunk/src/ddraw/OS2SURFACE.CPP
r313 r352 7 7 #include <fourcc.h> 8 8 #include "os2surface.h" 9 #include "rectangle.h" 9 10 #define _OS2WIN_H 10 11 #define FAR … … 241 242 DDSURFACEDESC2 ComplexSurfaceDesc; 242 243 OS2IDirectDrawSurface *AttachedSurface; 244 OS2IDirectDrawSurface *MipMapSurface; 243 245 244 246 lpVtbl = &Vtbl; … … 308 310 309 311 // 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 /* 310 354 try 311 355 { … … 333 377 return; 334 378 } 335 379 */ 336 380 if( lpDDSurfaceDesc->dwFlags & DDSD_CAPS ) 337 381 { … … 766 810 ComplexSurfaceDesc.dwWidth /= 2; 767 811 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) 769 820 { 770 SurfaceSequenceMipMap.addAsLast(new OS2IDirectDrawSurface(lpDraw, &ComplexSurfaceDesc, TRUE), 771 *SurfaceCursorMipMap); 772 } 773 catch(IOutOfMemory) 774 { 821 lastError = AttachedSurface->GetLastError(); 775 822 #ifdef DEBUG 776 WriteLog(" Internal : ISet.add OutOfMemory\n");823 WriteLog("Attached surface creation returned error %d\n",lastError); 777 824 #endif 778 lastError = DDERR_OUTOFMEMORY;779 825 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 812 827 } //End for(i =0; i < lpDDSurfaceDesc->dwMipMapCount; i++) 813 828 } // End of MipMaps … … 1129 1144 //****************************************************************************** 1130 1145 //****************************************************************************** 1146 // Internal callbacks uses by destructor 1147 int DestroyRects(LPVOID lpItem, DWORD dwRes) 1148 { 1149 delete (DDRectangle*) lpItem; 1150 return 1; 1151 } 1152 1153 int 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 1131 1163 OS2IDirectDrawSurface::~OS2IDirectDrawSurface() 1132 1164 { … … 1164 1196 1165 1197 // 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 } 1168 1204 1169 1205 if(lpClipper) … … 1188 1224 BackBuffer->Vtbl.Release(AttachedSurface); 1189 1225 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); 1220 1238 } 1221 1239 … … 1370 1388 if(me->DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) 1371 1389 { 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 { 1377 1394 me->DDSurfaceDesc.dwFlags |= DDSD_MIPMAPCOUNT; 1378 1395 me->DDSurfaceDesc.dwMipMapCount++; … … 1380 1397 AttachedSurface->Vtbl.AddRef(AttachedSurface); 1381 1398 } 1382 catch(...)1399 else 1383 1400 { 1384 1401 #ifdef DEBUG … … 1398 1415 else 1399 1416 { 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 { 1406 1421 AttachedSurface->Vtbl.AddRef(AttachedSurface); 1407 1422 } 1408 catch(...)1423 else 1409 1424 { 1410 1425 #ifdef DEBUG … … 1481 1496 if(me->DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) 1482 1497 { 1483 try 1498 if( DPA_InsertPtr( me->DPA_SurfaceMipMaps, 1499 DPA_GetPtrCount(me->DPA_SurfaceMipMaps), 1500 AttachedSurface) >=0) 1484 1501 { 1485 me->SurfaceSequenceMipMap.addAsLast(AttachedSurface);1486 me->SurfaceCursorMipMap->setToFirst();1487 1488 1502 me->DDSurfaceDesc.dwFlags |= DDSD_MIPMAPCOUNT; 1489 1503 me->DDSurfaceDesc.dwMipMapCount++; … … 1492 1506 AttachedSurface->Vtbl.AddRef(AttachedSurface); 1493 1507 } 1494 catch(...)1508 else 1495 1509 { 1496 1510 #ifdef DEBUG 1497 1511 WriteLog("Internal : Error attaching to MipMap\n"); 1498 1512 #endif 1499 return(DDERR_CANNOTATTACHSURFACE);1513 return(DDERR_CANNOTATTACHSURFACE); 1500 1514 } 1501 1515 } … … 1510 1524 else 1511 1525 { 1512 try 1526 if( DPA_InsertPtr( me->DPA_SurfaceAttached, 1527 DPA_GetPtrCount(me->DPA_SurfaceAttached), 1528 AttachedSurface) >=0) 1513 1529 { 1514 me->SurfaceSequenceAttached.addAsLast(AttachedSurface);1515 // add made the last cursor invalid so start from the begining1516 me->SurfaceCursorAttached->setToFirst();1517 1518 1530 AttachedSurface->Vtbl.AddRef(AttachedSurface); 1519 1531 } 1520 catch(...)1532 else 1521 1533 { 1522 1534 #ifdef DEBUG 1523 1535 WriteLog("Internal : Error attaching to general Set\n"); 1524 1536 #endif 1525 return(DDERR_CANNOTATTACHSURFACE);1537 return(DDERR_CANNOTATTACHSURFACE); 1526 1538 } 1527 1539 } … … 1573 1585 OS2IDirectDrawSurface *dest = (OS2IDirectDrawSurface *)This; 1574 1586 OS2IDirectDrawSurface *src = (OS2IDirectDrawSurface *)lpDDSrcSurface; 1575 ISequence<DDRectangle*>::Cursor *EnumCursor;1576 1587 1577 1588 HRESULT rc; … … 1626 1637 // we can't blit to it 1627 1638 1628 EnumCursor = dest->LockedRectSequence.newCursor();1629 EnumCursor->setToFirst();1630 1639 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); 1635 1644 Found = pIRectDest->intersects(*pIRectTest); 1636 EnumCursor->setToNext();1645 i++; 1637 1646 } 1638 1639 delete EnumCursor;1640 1647 1641 1648 } … … 1765 1772 // source surface we can't blit from it 1766 1773 1767 EnumCursor = src->LockedRectSequence.newCursor();1768 EnumCursor->setToFirst();1769 1774 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++; 1776 1782 } 1777 1778 delete EnumCursor;1779 1783 1780 1784 } … … 2452 2456 } 2453 2457 2458 // Todo: Test for locked src/dest 2459 2454 2460 pBltPos = (char*) dest->pDiveBuffer + (dwY * dest->dwPitchDB) + 2455 2461 (dwX * dest->dwBytesPPDive); … … 2756 2762 OS2IDirectDrawSurface *AttachedSurface; 2757 2763 OS2IDirectDrawSurface *SurfaceCursor; 2758 2759 ISequence<OS2IDirectDrawSurface*>::Cursor *EnumCursor; 2764 int i; 2765 2760 2766 BOOL Found = FALSE; 2761 2767 #ifdef DEBUG … … 2857 2863 { 2858 2864 // 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) 2864 2869 { 2865 2870 Found = TRUE; 2866 me->SurfaceSequenceMipMap.removeAt(*EnumCursor); 2867 me->SurfaceCursorMipMap->setToFirst(); 2871 DPA_DeletePtr(me->DPA_SurfaceMipMaps,i); 2868 2872 AttachedSurface->lpVtbl->Release(AttachedSurface); 2869 2873 // adjust our info … … 2874 2878 } 2875 2879 } 2876 }2877 delete EnumCursor;2880 i++; 2881 } 2878 2882 } 2879 2883 2880 2884 if(!Found) 2881 2885 { 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) 2888 2891 { 2889 2892 Found = TRUE; 2890 me->SurfaceSequenceAttached.removeAt(*EnumCursor); 2891 me->SurfaceCursorAttached->setToFirst(); 2893 DPA_DeletePtr(me->DPA_SurfaceAttached,i); 2892 2894 AttachedSurface->lpVtbl->Release(AttachedSurface); 2893 2895 } 2894 }2895 delete EnumCursor;2896 i++; 2897 } 2896 2898 } 2897 2899 … … 2916 2918 OS2IDirectDrawSurface *EnumSurface; 2917 2919 DDSURFACEDESC2 EnumDesc; 2918 2919 ISequence<OS2IDirectDrawSurface*>::Cursor *EnumCursor; 2920 int i; 2920 2921 HRESULT rc; 2921 2922 … … 2934 2935 } 2935 2936 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); 2943 2943 memcpy(&EnumDesc,&(EnumSurface->DDSurfaceDesc),sizeof(DDSURFACEDESC2)); 2944 2944 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); 2957 2955 memcpy(&EnumDesc,&(EnumSurface->DDSurfaceDesc),sizeof(DDSURFACEDESC2)); 2958 2956 rc = lpCallBack((LPDIRECTDRAWSURFACE4)EnumSurface,&EnumDesc,lpContext); 2959 EnumCursor->setToNext(); 2960 } 2961 delete EnumCursor; 2957 i++; 2958 } 2962 2959 } 2963 2960 … … 3129 3126 OS2IDirectDrawSurface *EnumSurface = NULL; 3130 3127 OS2IDirectDrawSurface *AttachedSurface = NULL; 3131 ISequence<OS2IDirectDrawSurface*>::Cursor *EnumCursor; 3128 int i; 3129 3132 3130 #ifdef DEBUG 3133 3131 WriteLog("SurfGetAttachedSurface4\n>Requested Caps: "); … … 3148 3146 } 3149 3147 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); 3157 3154 if(EnumSurface->DDSurfaceDesc.ddsCaps.dwCaps == lpDDCaps->dwCaps) 3158 3155 { … … 3164 3161 3165 3162 } 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); 3178 3173 if(EnumSurface->DDSurfaceDesc.ddsCaps.dwCaps == lpDDCaps->dwCaps) 3179 3174 { … … 3185 3180 3186 3181 } 3187 EnumCursor->setToNext(); 3188 } 3189 delete EnumCursor; 3182 i++; 3183 } 3190 3184 } 3191 3185 … … 3638 3632 3639 3633 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This; 3640 ISequence<DDRectangle*>::Cursor *EnumCursor;3634 int i; 3641 3635 3642 3636 BOOL Found; … … 3674 3668 // be locked so check for this 3675 3669 3676 EnumCursor = me->LockedRectSequence.newCursor(); 3677 EnumCursor->setToFirst(); 3670 i=0; 3678 3671 Found = FALSE; 3679 3672 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); 3683 3676 Found = pIRectCurrent->intersects(*pIRectNew); 3684 EnumCursor->setToNext();3677 i++; 3685 3678 } 3686 3687 delete EnumCursor;3688 3679 3689 3680 } … … 3718 3709 // Add the rectangle to the list of locked rectangles 3719 3710 3720 me->LockedRectSequence.addAsLast(pIRectNew); 3711 DPA_InsertPtr( me->DPA_LockedRects, 3712 DPA_GetPtrCount(me->DPA_LockedRects), 3713 pIRectNew); 3721 3714 3722 3715 me->fLocked = TRUE; … … 3967 3960 3968 3961 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This; 3969 ISequence<DDRectangle*>::Cursor *EnumCursor;3962 int i; 3970 3963 DDRectangle *pIRectUnlock; 3971 3964 BOOL Found = FALSE; … … 3987 3980 WriteLog("Unlock rectangle\n"); 3988 3981 pIRectUnlock = new DDRectangle( lpSurfaceRect->top, 3989 lpSurfaceRect->left,3990 lpSurfaceRect->bottom,3991 lpSurfaceRect->right);3982 lpSurfaceRect->left, 3983 lpSurfaceRect->bottom, 3984 lpSurfaceRect->right); 3992 3985 } 3993 3986 else … … 4001 3994 #endif 4002 3995 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); 4008 4000 if(!Found) 4009 4001 { … … 4011 4003 WriteLog("Not Found, try Next rect\n"); 4012 4004 #endif 4013 EnumCursor->setToNext();4005 i++; 4014 4006 } 4015 4007 #ifdef DEBUG … … 4033 4025 #endif 4034 4026 4035 me->LockedRectSequence.removeAt(*EnumCursor);4036 4037 if( me->LockedRectSequence.isEmpty()) // Do we have unlocked last rectangle4027 DPA_DeletePtr(me->DPA_LockedRects,i); 4028 4029 if(0==DPA_GetPtrCount(me->DPA_LockedRects)) // Do we have unlocked last rectangle 4038 4030 { 4039 4031 #ifdef DEBUG … … 4210 4202 { 4211 4203 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This; 4212 ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;4204 int i; 4213 4205 PSURFPRIVATEDATA pSData; 4214 4206 void *pBuffer; … … 4227 4219 4228 4220 // 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); 4236 4227 4237 4228 if (IsEqualGUID(pSData->guidTag,refGUID)) 4238 4229 bFound = TRUE; 4239 4230 4240 EnumCursor->setToNext(); 4241 } 4242 delete EnumCursor; 4231 i++; 4232 } 4243 4233 } 4244 4234 … … 4374 4364 } 4375 4365 } 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 4376 4375 } 4377 4376 else … … 4385 4384 { 4386 4385 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This; 4387 ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;4386 int i; 4388 4387 PSURFPRIVATEDATA pSData; 4389 4388 BOOL bFound = FALSE; 4389 4390 4390 #ifdef DEBUG 4391 4391 WriteLog("SurfGetPrivateData\n"); 4392 4392 #endif 4393 4393 4394 if(NULL==me) 4394 4395 return(DDERR_INVALIDOBJECT); … … 4397 4398 return(DDERR_INVALIDPARAMS); 4398 4399 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); 4406 4406 4407 4407 if (IsEqualGUID(pSData->guidTag,refGUID)) 4408 4408 bFound = TRUE; 4409 4409 4410 EnumCursor->setToNext(); 4411 } 4412 delete EnumCursor; 4410 i++; 4411 } 4413 4412 } 4414 4413 … … 4436 4435 { 4437 4436 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This; 4438 ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;4437 int i; 4439 4438 PSURFPRIVATEDATA pSData; 4440 4439 BOOL bFound = FALSE; 4440 4441 4441 #ifdef DEBUG 4442 4442 WriteLog("SurfFreePrivateData\n"); 4443 4443 #endif 4444 4444 4445 if(NULL==me) 4445 4446 return(DDERR_INVALIDOBJECT); 4446 4447 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); 4454 4454 4455 4455 if (IsEqualGUID(pSData->guidTag,refGUID)) … … 4472 4472 } 4473 4473 // 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); 4476 4475 } 4477 EnumCursor->setToNext(); 4478 } 4479 delete EnumCursor; 4476 i++; 4477 } 4480 4478 } 4481 4479 return (bFound?DD_OK:DDERR_NOTFOUND); … … 4500 4498 { 4501 4499 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This; 4502 ISequence<PSURFPRIVATEDATA>::Cursor * EnumCursor;4500 int i; 4503 4501 PSURFPRIVATEDATA pSData; 4504 4502 … … 4508 4506 me->dwUniqueValue++; 4509 4507 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); 4517 4514 if (pSData->dwFlags & DDSPD_VOLATILE) 4518 4515 { … … 4531 4528 pSData->isValid = FALSE; // set flag to invalid 4532 4529 } 4533 EnumCursor->setToNext(); 4534 } 4535 delete EnumCursor; 4530 i++; 4531 } 4536 4532 } 4537 4533 … … 4541 4537 //****************************************************************************** 4542 4538 // 4543 // Pu pose function copies one part of the bitmap inside the same bitmap4539 // Purpose function copies one part of the bitmap inside the same bitmap 4544 4540 // 4545 4541 //****************************************************************************** -
trunk/src/ddraw/OS2SURFACE.H
r312 r352 7 7 #include "os2palette.h" 8 8 #include <dive.h> 9 #include <iseq.h> 10 #include "rectangle.h" 9 #include <commctrl.h> 11 10 12 11 #define FAR … … 86 85 87 86 DWORD dwUniqueValue; 88 ISequence<PSURFPRIVATEDATA> SurfaceSequencePrivateData; 87 HDPA DPA_SurfacePrivateData; 88 89 89 BOOL fOverlayValid; 90 90 LONG lOverlayX; … … 96 96 OS2IDirectDrawSurface* FrontBuffer; // NULL if the real frontbuffer of a Flipchain otherwise the prev. Backbuffer 97 97 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; 104 102 105 103 friend HRESULT __stdcall SurfQueryInterface(THIS, REFIID riid, LPVOID FAR * ppvObj); -
trunk/src/ddraw/makefile
r212 r352 13 13 ASFLAGS = -Sc -Sv:ALP 14 14 15 CFLAGS = $(CFLAGS) - Ft+ -I$(PDWIN32_INCLUDE);16 CXXFLAGS = $(CXXFLAGS) - Ft+ -I$(PDWIN32_INCLUDE);15 CFLAGS = $(CFLAGS) -I$(PDWIN32_INCLUDE); 16 CXXFLAGS = $(CXXFLAGS) -I$(PDWIN32_INCLUDE); 17 17 18 18 TARGET = ddraw 19 19 20 20 OBJS = ddraw.obj os2ddraw.obj os2clipper.obj os2d3d.obj iccio1.obj asmutil.obj\ 21 os2surface.obj os2palette.obj os2palset.obj misc.obj initterm.obj21 os2surface.obj os2palette.obj os2palset.obj misc.obj rectangle.obj initterm.obj 22 22 23 LIBS = ($PDWIN32_LIB)\pmwinx.lib mmpm2.lib CPPOOC3.lib CPPOM30.lib23 LIBS = ..\..\lib\pmwinx.lib mmpm2.lib ..\..\lib\comctl32.lib 24 24 25 25 all: $(TARGET).dll $(TARGET).lib … … 27 27 28 28 $(TARGET).dll: $(OBJS) $(TARGET).def 29 $(LD) $(LDFLAGS) - Tdp -Fm -Fe$@ $(OBJS) $(TARGET).def $(LIBS)29 $(LD) $(LDFLAGS) -Fm -Fe$@ $(OBJS) $(TARGET).def $(LIBS) 30 30 $(CP) $@ $(PDWIN32_BIN) 31 31 … … 47 47 $(PDWIN32_INCLUDE)\win\ddraw.h \ 48 48 $(PDWIN32_INCLUDE)\win\d3d.h 49 49 50 os2d3d.obj: os2d3d.cpp \ 50 os2ddraw.h 51 os2ddraw.h\ 52 $(PDWIN32_INCLUDE)\win\ddraw.h \ 53 $(PDWIN32_INCLUDE)\win\d3d.h 51 54 52 55 misc.obj: misc.cpp … … 66 69 os2clipper.h \ 67 70 os2surface.h \ 68 os2ddraw.h 71 os2ddraw.h\ 72 $(PDWIN32_INCLUDE)\win\ddraw.h \ 73 $(PDWIN32_INCLUDE)\win\d3d.h 69 74 70 75 os2surface.obj: os2surface.cpp \ … … 72 77 os2clipper.h \ 73 78 os2surface.h \ 74 os2ddraw.h 79 os2ddraw.h\ 80 $(PDWIN32_INCLUDE)\win\ddraw.h \ 81 $(PDWIN32_INCLUDE)\win\d3d.h 75 82 83 rectangle.obj: rectangle.cpp 76 84 77 85 initterm.obj: initterm.cpp -
trunk/src/ddraw/rectangle.h
r312 r352 34 34 height() const; 35 35 36 /*--------------------------------- Synonyms ---------------------------------37 38 Coord39 bottom ( ) const,40 left ( ) const,41 right ( ) const,42 top ( ) const;43 */44 45 36 private: 46 37 long lTop,lLeft; … … 48 39 }; // class DDRectangle 49 40 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 ) const62 {63 return ( lTop == aRect.lTop && lLeft == aRect.lLeft64 &&65 lBottom == aRect.lBottom && lRight == aRect.lRight);66 }67 IBase::Boolean DDRectangle :: operator != ( const DDRectangle& aRect ) const68 {69 return !( *this == aRect );70 }71 IBase::Boolean DDRectangle :: intersects ( const DDRectangle &aRect ) const72 {73 return ( lTop < aRect.lBottom && lLeft<aRect.lRight74 &&75 aRect.lTop < lBottom && aRect.lLeft < lRight );76 }77 78 DDRectangle::Coord DDRectangle :: width ( ) const79 {80 return ( lRight - lLeft);81 }82 83 DDRectangle::Coord DDRectangle :: height ( ) const84 {85 return ( lBottom - lTop);86 }87 88 41 #endif
Note:
See TracChangeset
for help on using the changeset viewer.