Changeset 2638 for trunk/src/ddraw/OS2SURFACE.CPP
- Timestamp:
- Feb 4, 2000, 8:31:26 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ddraw/OS2SURFACE.CPP
r2192 r2638 1 /* $Id: OS2SURFACE.CPP,v 1.2 2 1999-12-23 00:50:11hugh Exp $ */1 /* $Id: OS2SURFACE.CPP,v 1.23 2000-02-04 19:31:24 hugh Exp $ */ 2 2 3 3 /* … … 22 22 #include "os2palette.h" 23 23 #include "os2surface.h" 24 #include "os2util.h" 24 25 #include "rectangle.h" 25 26 #define _OS2WIN_H … … 492 493 } flags[] = { 493 494 #define FE(x) { x, #x}, 495 FE(DDCKEY_COLORSPACE) 496 FE(DDCKEY_DESTBLT) 497 FE(DDCKEY_DESTOVERLAY) 498 FE(DDCKEY_SRCBLT) 499 FE(DDCKEY_SRCOVERLAY) 500 }; 501 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++) 502 if (flags[i].mask & flagmask) 503 dprintf(("DDRAW: %s ",flags[i].name)); 504 dprintf(("DDRAW: \n")); 505 } 506 507 static void _dump_DDPIXELFORMAT(DWORD flagmask) { 508 int i; 509 const struct { 510 DWORD mask; 511 char *name; 512 } flags[] = { 513 #define FE(x) { x, #x}, 494 514 FE(DDPF_ALPHAPIXELS) 495 515 FE(DDPF_ALPHA) … … 514 534 515 535 static void _dump_pixelformat(LPDDPIXELFORMAT pf) { 516 _dump_DD COLORKEY(pf->dwFlags);536 _dump_DDPIXELFORMAT(pf->dwFlags); 517 537 dprintf(("DDRAW: dwFourCC : %ld\n", pf->dwFourCC)); 518 538 dprintf(("DDRAW: RBG bit cbout : %ld\n", pf->dwRGBBitCount)); … … 871 891 break; 872 892 } 873 if( lpDDSurfaceDesc->dwFlags & DDSD_CAPS ) 893 // hack set DDSD_CAPS if the value is other than 0 894 if( DDSurfaceDesc.ddsCaps.dwCaps) 895 DDSurfaceDesc.dwFlags |= DDSD_CAPS; 896 897 if( DDSurfaceDesc.dwFlags & DDSD_CAPS ) 874 898 { 875 899 // First check if we want to create a primary surface while the ddraw object already has one 876 surfaceType = lpDDSurfaceDesc->ddsCaps.dwCaps;900 surfaceType = DDSurfaceDesc.ddsCaps.dwCaps; 877 901 878 902 if( surfaceType & DDSCAPS_PRIMARYSURFACE) … … 891 915 } 892 916 893 if( ( lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT) ||894 ( lpDDSurfaceDesc->dwFlags & DDSD_WIDTH) ||895 ( lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT)917 if( (DDSurfaceDesc.dwFlags & DDSD_HEIGHT) || 918 (DDSurfaceDesc.dwFlags & DDSD_WIDTH) || 919 (DDSurfaceDesc.dwFlags & DDSD_PIXELFORMAT) 896 920 ) 897 921 { … … 952 976 DDSurfaceDesc.dwWidth = lpDraw->GetScreenWidth(); 953 977 DDSurfaceDesc.lpSurface = pFrameBuffer; 954 lpDDSurfaceDesc->dwFlags = DDSurfaceDesc.dwFlags;955 lpDDSurfaceDesc->dwHeight = DDSurfaceDesc.dwHeight;956 lpDDSurfaceDesc->dwWidth = DDSurfaceDesc.dwWidth;957 lpDDSurfaceDesc->lpSurface = pFrameBuffer;958 lpDDSurfaceDesc->lPitch = DDSurfaceDesc.lPitch;959 960 lpDDSurfaceDesc->ddsCaps.dwCaps |= DDSCAPS_VISIBLE;961 978 DDSurfaceDesc.ddsCaps.dwCaps |= DDSCAPS_VISIBLE; 962 979 lpDraw->SetPrimarySurface(TRUE); 963 lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);964 lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();965 lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = lpDraw->GetScreenBpp();966 980 DDSurfaceDesc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); 967 981 DDSurfaceDesc.ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC(); … … 971 985 { 972 986 case 4: 973 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;974 987 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB; 975 988 break; 976 989 case 8: 977 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;978 990 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB; 979 991 break; 980 992 case 16: 981 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;982 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x0000F800;983 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000007E0;984 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000001F;985 993 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB; 986 994 DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x0000F800; … … 990 998 case 24: 991 999 case 32: 992 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;993 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000;994 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;995 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF;996 1000 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB; 997 1001 DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x00FF0000; … … 1001 1005 default: 1002 1006 // Remove the Pixelformat flag 1003 lpDDSurfaceDesc->dwFlags &= ~DDSD_PIXELFORMAT;1004 1007 DDSurfaceDesc.dwFlags &= ~DDSD_PIXELFORMAT; 1005 #ifdef DEBUG 1006 dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp())); 1007 #endif 1008 dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp())); 1008 1009 break; 1009 1010 } // end switch 1010 1011 1011 #ifdef DEBUG 1012 dprintf(("DDRAW: Surface set up, checking other Caps\n")); 1013 #endif 1012 dprintf(("DDRAW: Surface set up, checking other Caps\n")); 1014 1013 1015 1014 if( DDSurfaceDesc.ddsCaps.dwCaps & DDSCAPS_COMPLEX) 1016 1015 { 1017 #ifdef DEBUG 1018 dprintf(("DDRAW: Complex Surface\n")); 1019 #endif 1020 1021 if(lpDDSurfaceDesc->dwFlags & DDSD_BACKBUFFERCOUNT) 1016 dprintf(("DDRAW: Complex Surface\n")); 1017 1018 if(DDSurfaceDesc.dwFlags & DDSD_BACKBUFFERCOUNT) 1022 1019 { 1023 #ifdef DEBUG 1024 dprintf(("DDRAW: Backbuffer # = %d\n",lpDDSurfaceDesc->dwBackBufferCount)); 1025 #endif 1020 dprintf(("DDRAW: Backbuffer # = %d\n",DDSurfaceDesc.dwBackBufferCount)); 1026 1021 memset( &ComplexSurfaceDesc, 1027 1022 0, … … 1042 1037 ComplexSurfaceDesc.ddpfPixelFormat.dwRGBBitCount = DDSurfaceDesc.ddpfPixelFormat.dwRGBBitCount; 1043 1038 1044 if( lpDDSurfaceDesc->dwBackBufferCount>1)1039 if(DDSurfaceDesc.dwBackBufferCount>1) 1045 1040 { 1046 1041 ComplexSurfaceDesc.dwFlags |=DDSD_BACKBUFFERCOUNT; 1047 ComplexSurfaceDesc.dwBackBufferCount = lpDDSurfaceDesc->dwBackBufferCount -1;1042 ComplexSurfaceDesc.dwBackBufferCount = DDSurfaceDesc.dwBackBufferCount -1; 1048 1043 ComplexSurfaceDesc.ddsCaps.dwCaps|= DDSCAPS_COMPLEX; 1049 1044 } … … 1057 1052 // Our Primary Buffer is also the frontbuffer of a flipchain 1058 1053 DDSurfaceDesc.ddsCaps.dwCaps |= DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP; 1059 lpDDSurfaceDesc->ddsCaps.dwCaps |= DDSCAPS_FRONTBUFFER | DDSCAPS_FLIP;1060 1054 BackBuffer->SetFrontBuffer(this); 1061 1055 } … … 1067 1061 else 1068 1062 { 1063 dprintf(("DDRAW: Unsupported Complex Surface\n")); 1069 1064 #ifdef DEBUG 1070 dprintf(("DDRAW: Unsupported Complex Surface\n")); 1071 _dump_DDSCAPS(lpDDSurfaceDesc->dwFlags); 1065 _dump_DDSCAPS(DDSurfaceDesc.dwFlags); 1072 1066 #endif 1073 1067 lastError = DDERR_OUTOFMEMORY; … … 1120 1114 dprintf(("DDRAW: Use Screen Format :")); 1121 1115 dwBpp = lpDraw->GetScreenBpp(); // No use Screenformat 1122 lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);1123 lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC();1124 lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = dwBpp;1125 1116 DDSurfaceDesc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); 1126 1117 DDSurfaceDesc.ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC(); … … 1129 1120 { 1130 1121 case 4: 1131 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB;1132 1122 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED4 | DDPF_RGB; 1133 1123 break; 1134 1124 case 8: 1135 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB;1136 1125 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_FOURCC | DDPF_RGB; 1137 1126 break; 1138 1127 case 16: 1139 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;1140 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x0000F800;1141 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000007E0;1142 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000001F;1143 1128 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB; 1144 1129 DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x0000F800; … … 1148 1133 case 24: 1149 1134 case 32: 1150 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB;1151 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000;1152 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;1153 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF;1154 1135 DDSurfaceDesc.ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_RGB; 1155 1136 DDSurfaceDesc.ddpfPixelFormat.dwRBitMask = 0x00FF0000; … … 1159 1140 default: 1160 1141 // Remove the Pixelformat flag 1161 lpDDSurfaceDesc->dwFlags &= ~DDSD_PIXELFORMAT;1162 1142 DDSurfaceDesc.dwFlags &= ~DDSD_PIXELFORMAT; 1163 #ifdef DEBUG 1164 dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp())); 1165 #endif 1143 dprintf(("DDRAW: Unexpected BitDepth : %d\n",lpDraw->GetScreenBpp())); 1166 1144 break; 1167 1145 } // end switch … … 1214 1192 // and blit to the real framebuffer on Unlock to do color conversion 1215 1193 1216 dwPitchDB = ( lpDDSurfaceDesc->dwWidth * dwBytesPPDive +7) & ~7;1194 dwPitchDB = (DDSurfaceDesc.dwWidth * dwBytesPPDive +7) & ~7; 1217 1195 1218 1196 // 24 byte more to enable alignment and speed up blitting 1219 1197 1220 pDBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight * dwPitchDB + 24);1198 pDBreal = (char*)malloc( DDSurfaceDesc.dwHeight * dwPitchDB + 24); 1221 1199 pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD 1222 1200 … … 1251 1229 1252 1230 // This surface isn't allocated yet, but when the texture is loaded 1253 #ifdef DEBUG 1254 dprintf(("DDRAW: Warning : Delayed memory allocation on request\n")); 1255 #endif 1231 dprintf(("DDRAW: Warning : Delayed memory allocation on request\n")); 1256 1232 DDSurfaceDesc.lpSurface = NULL; 1257 lpDDSurfaceDesc->lpSurface = NULL;1258 1233 } 1259 1234 else … … 1263 1238 dprintf(("DDRAW: Alloc now!\n")); 1264 1239 1265 lpDDSurfaceDesc->dwFlags |= DDSD_PITCH|DDSD_LPSURFACE; 1266 DDSurfaceDesc.dwFlags = lpDDSurfaceDesc->dwFlags; 1267 1268 dwPitchFB = lpDDSurfaceDesc->dwWidth * (dwBpp<8?1:dwBpp/8); 1240 DDSurfaceDesc.dwFlags = DDSurfaceDesc.dwFlags; 1241 1242 dwPitchFB = DDSurfaceDesc.dwWidth * (dwBpp<8?1:dwBpp/8); 1269 1243 dwPitchFB = (dwPitchFB +7) & ~7; // Align on QWords 1270 DDSurfaceDesc.lPitch = dwPitchFB;1271 lpDDSurfaceDesc->lPitch = dwPitchFB;1272 1273 1244 #ifdef DEBUG 1274 1245 if(dwBpp<8) … … 1281 1252 // 24 byte more to enable alignment and speed up blitting 1282 1253 1283 pFBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight * dwPitchFB + 24);1254 pFBreal = (char*)malloc( DDSurfaceDesc.dwHeight * dwPitchFB + 24); 1284 1255 1285 1256 if(NULL==pFBreal) … … 1294 1265 pFBreal, pFrameBuffer, dwPitchFB)); 1295 1266 1296 lpDDSurfaceDesc->lpSurface = pFrameBuffer;1297 1267 DDSurfaceDesc.lpSurface = pFrameBuffer; 1298 1299 1268 1300 1269 if( (lpDraw->dCaps.ulDepth ) == dwBpp ) … … 1307 1276 else 1308 1277 { 1309 dprintf(("DDRAW: Alloc CCBuf ")); 1310 dwPitchDB = (lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7; 1311 1312 if(Mainchain) 1313 { 1314 dprintf(("DDRAW: with DIVE\n")); 1315 // This surface is part of flipchain with the primary surface use dive to assoc memory 1316 pDBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight * 1317 dwPitchDB+24); 1318 pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD 1319 diveBufNr = 0; 1320 rc = DiveAllocImageBuffer( hDive, 1321 &diveBufNr, 1322 lpDraw->dCaps.fccColorEncoding, 1323 lpDDSurfaceDesc->dwWidth, 1324 lpDDSurfaceDesc->dwHeight, 1325 dwPitchDB, 1326 (PBYTE)pDiveBuffer); 1327 dprintf(("DDRAW: rc = 0x%08X\n",rc)); 1328 } 1329 else 1330 { 1331 dprintf( ("with malloc (%dx%d) Pitch %d ", 1332 lpDDSurfaceDesc->dwHeight, 1333 lpDDSurfaceDesc->dwWidth, 1334 dwPitchDB)); 1335 // No so we must create the Divebuffer to do the colortranslation 1336 // and blit to the real framebuffer on Unlock to do color conversion 1337 pDBreal = (char*)malloc( lpDDSurfaceDesc->dwHeight * 1338 dwPitchDB + 24); 1339 pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD 1340 } 1278 dwPitchDB = (DDSurfaceDesc.dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7; 1279 dprintf( ("DDRAW: Alloc CCBuf with malloc (%dx%d) Pitch %d ", 1280 DDSurfaceDesc.dwHeight, 1281 DDSurfaceDesc.dwWidth, 1282 dwPitchDB)); 1283 // No so we must create the Divebuffer to do the colortranslation 1284 // and blit to the real framebuffer on Unlock to do color conversion 1285 pDBreal = (char*)malloc( DDSurfaceDesc.dwHeight * 1286 dwPitchDB + 24); 1287 pDiveBuffer = (char*)(((int)pDBreal + 7) & ~7); // align to QWORD 1341 1288 dprintf(( " @ %08X\n", pDiveBuffer)); 1289 1290 } 1291 1292 if(Mainchain) 1293 { 1294 diveBufNr = 0; 1295 rc = DiveAllocImageBuffer( hDive, 1296 &diveBufNr, 1297 lpDraw->dCaps.fccColorEncoding, 1298 DDSurfaceDesc.dwWidth, 1299 DDSurfaceDesc.dwHeight, 1300 dwPitchDB, 1301 (PBYTE)pDiveBuffer); 1302 dprintf(("DDRAW: rc = 0x%08X\n",rc)); 1342 1303 } 1343 1304 … … 1352 1313 // remove the flag 1353 1314 dwCaps &= ~DDSCAPS_COMPLEX; 1354 #ifdef DEBUG 1355 dprintf(("DDRAW: Complex Surface\n")); 1356 #endif 1357 1358 if(lpDDSurfaceDesc->dwFlags & DDSD_BACKBUFFERCOUNT) 1315 dprintf(("DDRAW: Complex Surface\n")); 1316 1317 if(DDSurfaceDesc.dwFlags & DDSD_BACKBUFFERCOUNT) 1359 1318 { 1360 lpDDSurfaceDesc->dwFlags &= ~DDSD_BACKBUFFERCOUNT; 1361 #ifdef DEBUG 1362 dprintf(("DDRAW: Backbuffer # = %d\n",lpDDSurfaceDesc->dwBackBufferCount)); 1363 #endif 1364 memcpy(&ComplexSurfaceDesc,lpDDSurfaceDesc,sizeof(DDSURFACEDESC2)); 1319 dprintf(("DDRAW: Backbuffer # = %d\n",DDSurfaceDesc.dwBackBufferCount)); 1320 1321 memcpy( &ComplexSurfaceDesc, 1322 &DDSurfaceDesc, 1323 sizeof(DDSURFACEDESC2)); 1324 ComplexSurfaceDesc.dwFlags &= ~DDSD_BACKBUFFERCOUNT; 1365 1325 ComplexSurfaceDesc.ddsCaps.dwCaps |= DDSCAPS_FLIP; // set flip 1366 1326 ComplexSurfaceDesc.ddsCaps.dwCaps &= ~DDSCAPS_BACKBUFFER; // remove backbuffer … … 1388 1348 1389 1349 // MipMap Surfaces are handled here 1390 if( ( lpDDSurfaceDesc->dwFlags & DDSD_MIPMAPCOUNT) &&1350 if( (DDSurfaceDesc.dwFlags & DDSD_MIPMAPCOUNT) && 1391 1351 (dwCaps & DDSCAPS_TEXTURE) && 1392 1352 (dwCaps & DDSCAPS_MIPMAP) ) … … 1394 1354 dwCaps &= ~ (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP); 1395 1355 1396 lpDDSurfaceDesc->dwFlags &= ~DDSD_MIPMAPCOUNT; 1397 #ifdef DEBUG 1398 dprintf(("DDRAW: Mipmpa # = %d\n",lpDDSurfaceDesc->dwMipMapCount)); 1399 #endif 1356 dprintf(("DDRAW: Mipmpa # = %d\n",DDSurfaceDesc.dwMipMapCount)); 1400 1357 memcpy( &ComplexSurfaceDesc, 1401 lpDDSurfaceDesc,1358 &DDSurfaceDesc, 1402 1359 sizeof(DDSURFACEDESC2)); 1403 1360 ComplexSurfaceDesc.dwMipMapCount = 0; 1404 1405 for(int i =0; i < lpDDSurfaceDesc->dwMipMapCount; i++) 1361 ComplexSurfaceDesc.dwFlags &= ~DDSD_MIPMAPCOUNT; 1362 1363 for(int i =0; i < DDSurfaceDesc.dwMipMapCount; i++) 1406 1364 { 1407 #ifdef DEBUG 1408 dprintf(("DDRAW: Creating MipMap %d\n",i)); 1409 #endif 1365 dprintf(("DDRAW: Creating MipMap %d\n",i)); 1410 1366 // Mpmaps shirnk by 2 1411 1367 ComplexSurfaceDesc.dwWidth /= 2; … … 1422 1378 { 1423 1379 lastError = MipMapSurface->GetLastError(); 1424 #ifdef DEBUG 1425 dprintf(("DDRAW: Attached surface creation returned error %d\n",lastError)); 1426 #endif 1380 dprintf(("DDRAW: Attached surface creation returned error %d\n",lastError)); 1427 1381 return; 1428 1382 } // Endif Errorcheck 1429 } //End for(i =0; i < lpDDSurfaceDesc->dwMipMapCount; i++)1383 } //End for(i =0; i < DDSurfaceDesc.dwMipMapCount; i++) 1430 1384 } // End of MipMaps 1431 1385 1432 #if def DEBUG1433 if( lpDDSurfaceDesc->dwFlags)1386 #if 0 1387 if(DDSurfaceDesc.dwFlags) 1434 1388 dprintf(("DDRAW: Unsupported Complex Surface\n")); 1435 1389 #endif … … 1452 1406 { 1453 1407 dprintf(("DDRAW: Some Error Check Flags\n")); 1454 _dump_DDSCAPS( lpDDSurfaceDesc->dwFlags);1408 _dump_DDSCAPS(DDSurfaceDesc.dwFlags); 1455 1409 } 1456 1410 #endif … … 1462 1416 1463 1417 int i, FillWidth, FillHeight, Top, Left; 1464 //char *pLine, *pFillPos;1465 1466 //DWORD *pColor, dwColor,y;1467 1418 DWORD *pPal24; 1468 1419 WORD *pPal16; … … 1540 1491 dprintf(("DDRAW: ColorFill function is NULL!!")); 1541 1492 } 1542 /* 1543 switch(dwBytesPPDive) 1544 { 1545 case 1: 1546 dprintf(("DDRAW: 8 Bit\n")); 1547 dwColor = (dwFillColor<<24) + (dwFillColor<<16) + 1548 (dwFillColor<<8) + (dwFillColor); 1549 for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/4);i++) 1550 pColor[i] = dwColor; 1551 if(FillWidth % 4) 1552 { 1553 pFillPos = (char*) (&pColor[i-1]); 1554 for(i=0;i<FillWidth % 4;i++) 1555 pFillPos[i] = (UCHAR) dwColor; 1556 } 1557 break; 1558 case 2: 1559 dprintf(("DDRAW: 16 Bit\n")); 1560 if(pDiveBuffer!=pFrameBuffer) 1561 { 1562 if(8==lpDraw->GetScreenBpp()) 1563 dwColor = (pPal16[dwFillColor]<<16) + pPal16[dwFillColor]; 1564 } 1565 else 1566 { 1567 dwColor = (dwFillColor<<16) + (dwFillColor); 1568 } 1569 dprintf(("DDRAW: Fill with 0x%08X\n",dwColor)); 1570 for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/2);i++) 1571 pColor[i] = dwColor; 1572 if(FillWidth % 2) 1573 { 1574 pFillPos = (char*)(&pColor[i-1]); 1575 *((USHORT*)pFillPos) = (USHORT)dwColor; 1576 } 1577 break; 1578 case 3: 1579 dprintf(("DDRAW: 24 Bit\n")); 1580 1581 dwColor = (dwFillColor<<8); 1582 for(i=0 ; i<FillWidth ; i++) 1583 { 1584 char* pColor = (char*)pLine+(i*3); 1585 *pColor = dwColor; 1586 } 1587 break; 1588 case 4: 1589 dprintf(("DDRAW: 32 Bit\n")); 1590 dwColor = dwFillColor; 1591 for(i=0,pColor = (DWORD*)pLine;i<FillWidth;i++) 1592 pColor[i] = dwColor; 1593 break; 1594 default: 1595 #ifdef DEBUG 1596 dprintf(("DDRAW: Unexpected Bitdepth\n")); 1597 #endif 1598 return DDERR_GENERIC; 1599 } // end switch(dest->DDSurfaceDesc.ddpfPixelFormat.dwRGBBitCount) 1600 1601 // First Line has been Filled so FillHeight-1 are left by one 1602 FillHeight--; 1603 pFillPos = pLine + dwPitchDB; 1604 FillWidth = FillWidth*dwBytesPPDive; 1605 1606 for( y=0;y<FillHeight;y++,pFillPos+=dwPitchDB) 1607 { 1608 #ifdef USE_ASM 1609 // ToDo get the loop into an asm function as well to speed up filling 1610 // maybe remove the creation of the first fill line in an all asm 1611 // function and use MMX regs to set 8 bytes 1612 MemFlip(pFillPos,pLine,FillWidth); 1613 #else 1614 memcpy(pFillPos,pLine,FillWidth); 1615 #endif 1616 } 1617 1618 if(pDiveBuffer!=pFrameBuffer) 1619 { 1620 dprintf(("DDRAW: CC-Mode Fill FrameBuffer %08X\n",pFrameBuffer)); 1621 1622 if(NULL!=lpDestRect) 1623 { 1624 dprintf(("DDRAW: Fill only Rect(%d,%d)(%d,%d)\n", lpDestRect->left, lpDestRect->top, 1625 lpDestRect->right, lpDestRect->bottom)); 1626 FillWidth = lpDestRect->right - lpDestRect->left; 1627 FillHeight = lpDestRect->bottom - lpDestRect->top -1; 1628 pLine = pFrameBuffer + 1629 (lpDestRect->top*dwPitchFB) + 1630 (lpDestRect->left*(lpDraw->GetScreenBpp()>>3)); 1631 } 1632 else 1633 { 1634 dprintf(("DDRAW: Fill all at addr ")); 1635 FillWidth = width; 1636 FillHeight = height -1; 1637 pLine = pFrameBuffer; 1638 } 1639 dprintf(("DDRAW: 0x%08X width,height(%d/%d) \n", pLine,FillWidth,FillHeight)); 1640 1641 // Colorconversion mode we must also fill the other buffer 1642 switch(lpDraw->GetScreenBpp()) 1643 { 1644 case 8: 1645 dprintf(("DDRAW: 8 Bit\n")); 1646 dwColor = (dwFillColor<<24) + (dwFillColor<<16) + 1647 (dwFillColor<<8) + (dwFillColor); 1648 dprintf(("DDRAW: Fill with %08X => 0x%08X\n",dwFillColor,dwColor)); 1649 for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/4);i++) 1650 pColor[i] = dwColor; 1651 if(FillWidth % 4) 1652 { 1653 pFillPos = (char*) (&pColor[i-1]); 1654 for(i=0;i<FillWidth % 4;i++) 1655 pFillPos[i] = (UCHAR) dwColor; 1656 } 1657 break; 1658 case 16: 1659 dprintf(("DDRAW: 16 Bit\n")); 1660 dwColor = (dwFillColor<<16) + (dwFillColor); 1661 dprintf(("DDRAW: Fill with 0x%08X\n",dwColor)); 1662 for(i=0,pColor = (DWORD*)pLine;i<(FillWidth/2);i++) 1663 pColor[i] = dwColor; 1664 if(FillWidth % 2) 1665 { 1666 pFillPos = (char*)(&pColor[i-1]); 1667 *((USHORT*)pFillPos) = (USHORT)dwColor; 1668 } 1669 break; 1670 case 24: 1671 dprintf(("DDRAW: 24 Bit\n")); 1672 dwColor = (dwFillColor<<8); 1673 for(i=0 ; i<FillWidth ; i++) 1674 { 1675 char* pColor = (char*)pLine+(i*3); 1676 *pColor = dwColor; 1677 } 1678 break; 1679 case 32: 1680 dprintf(("DDRAW: 32 Bit\n")); 1681 dwColor = dwFillColor; 1682 for(i=0,pColor = (DWORD*)pLine;i<FillWidth;i++) 1683 pColor[i] = dwColor; 1684 break; 1685 default: 1686 dprintf(("DDRAW: Unsupported # of Bits %d",lpDraw->GetScreenBpp())); 1687 } 1688 1689 // First Line has been Filled so FillHeight-1 are left by one 1690 FillHeight--; 1691 1692 pFillPos = pLine + dwPitchFB; 1693 FillWidth = FillWidth*(lpDraw->GetScreenBpp()>>3); 1694 for( y=0;y<FillHeight;y++,pFillPos+=dwPitchFB) 1695 { 1696 #ifdef USE_ASM 1697 // ToDo get the loop into an asm function as well to speed up filling 1698 // maybe remove the creation of the first fill line in an all asm 1699 // function and use MMX regs to set 8 bytes 1700 MemFlip(pFillPos,pLine,FillWidth); 1701 #else 1702 memcpy(pFillPos,pLine,FillWidth); 1703 #endif 1704 } 1705 } 1706 */ 1493 1707 1494 return(DD_OK); 1708 1495 } … … 4051 3838 if(-1 != me->diveBufNr) 4052 3839 { 4053 dprintf(("DDRAW: DIVE Flipchain "));3840 dprintf(("DDRAW: DIVE Flipchain DiveBuffer #%d",FlipSurface->diveBufNr)); 4054 3841 4055 3842 // we got some DIVE surfaces … … 4067 3854 { 4068 3855 // advance in the flipchain if no valid override surface was passed in 4069 me->NextFlip = FlipSurface->BackBuffer!=NULL?FlipSurface->BackBuffer:me->BackBuffer; 3856 // if we reached the end of the flipchain The Frontbuffer is the next to flip to 3857 me->NextFlip = FlipSurface->BackBuffer!=NULL?FlipSurface->BackBuffer:me;//me->FrontBuffer; 4070 3858 } 4071 3859 } … … 4371 4159 rc = DDERR_GENERIC; 4372 4160 } 4161 InverseDC(me->hdcImage, LockedSurfaceDesc.dwHeight); 4373 4162 } 4374 4163 … … 4747 4536 (NULL!=hEvent) 4748 4537 ) 4538 { 4539 dprintf(("DDERR_INVALIDPARAMS")); 4749 4540 return DDERR_INVALIDPARAMS; 4750 4541 } 4751 4542 4752 4543 if (NULL!=lpRect) … … 5000 4791 OS2IDirectDrawSurface *me = (OS2IDirectDrawSurface *)This; 5001 4792 HRESULT rc; 5002 #ifdef DEBUG 5003 dprintf(("DDRAW: SurfSetColorKey\n")); 5004 #endif 4793 4794 dprintf(("DDRAW: SurfSetColorKey %d %08X\n", dwFlags, lpDDColKey)); 5005 4795 5006 4796 if (0==dwFlags) 4797 { 5007 4798 return (DDERR_INVALIDPARAMS); 4799 } 5008 4800 5009 4801 // as we report only src colorkey in the caps return error on all others flags 5010 4802 if( (DDCKEY_DESTBLT|DDCKEY_DESTOVERLAY|DDCKEY_SRCOVERLAY|DDCKEY_COLORSPACE) & dwFlags) 4803 { 4804 dprintf(("Unspported colorkey\n")); 5011 4805 return(DDERR_UNSUPPORTED); 4806 } 5012 4807 5013 4808 if(DDCKEY_SRCBLT & dwFlags) 5014 4809 { 4810 5015 4811 //(me->lpVtbl == me->Vtbl4) 5016 4812 // me->Vtbl4->ChangeUniquenessValue(me); // we changed somethin so change this value 5017 4813 if(NULL!=lpDDColKey) 5018 4814 { 4815 dprintf(("copy colorkey")); 5019 4816 memcpy(&(me->DDSurfaceDesc.ddckCKSrcBlt), lpDDColKey, sizeof(DDCOLORKEY) ); 5020 4817 me->DDSurfaceDesc.dwFlags |= DDCKEY_SRCBLT; … … 5024 4821 else 5025 4822 { 4823 dprintf(("clear colorkey")); 5026 4824 memset(&(me->DDSurfaceDesc.ddckCKSrcBlt), 0, sizeof(DDCOLORKEY) ); 5027 4825 me->DDSurfaceDesc.dwFlags &= ~DDCKEY_SRCBLT; … … 5030 4828 } 5031 4829 else 4830 { 4831 dprintf(("Unsupported flags")); 4832 #ifdef DEBUG 4833 _dump_DDCOLORKEY(dwFlags); 4834 #endif 5032 4835 rc = DDERR_INVALIDPARAMS; // some other flags where set => error 5033 4836 } 5034 4837 return rc; 5035 4838 } … … 5099 4902 { 5100 4903 me->lpPalette->Vtbl.Release((IDirectDrawPalette*)me->lpPalette); //attach other palette 5101 return(DD_OK);4904 //return(DD_OK); 5102 4905 } 5103 4906 me->lpPalette = (OS2IDirectDrawPalette *)lpPalette;
Note:
See TracChangeset
for help on using the changeset viewer.