Changeset 587 for trunk/src/ddraw/OS2SURFACE.CPP
- Timestamp:
- Aug 19, 1999, 8:08:48 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ddraw/OS2SURFACE.CPP
r522 r587 6 6 ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) ) 7 7 #include <fourcc.h> 8 #define INITGUID 9 #include "os2ddraw.h" 10 #include "os2clipper.h" 11 #include "os2palette.h" 8 12 #include "os2surface.h" 9 13 #include "rectangle.h" … … 154 158 WriteLog("\n"); 155 159 } 160 161 static void _dump_DDSCAPS2(DWORD flagmask) { 162 int i; 163 const struct { 164 DWORD mask; 165 char *name; 166 } flags[] = { 167 #define FE(x) { x, #x}, 168 FE(DDSCAPS2_HARDWAREDEINTERLACE) 169 FE(DDSCAPS2_HINTANTIALIASING) 170 FE(DDSCAPS2_HINTDYNAMIC) 171 FE(DDSCAPS2_HINTSTATIC) 172 FE(DDSCAPS2_OPAQUE) 173 FE(DDSCAPS2_TEXTUREMANAGE) 174 }; 175 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++) 176 if (flags[i].mask & flagmask) 177 WriteLog("%s ",flags[i].name); 178 WriteLog("\n"); 179 } 180 156 181 157 182 static void _dump_DDSD(DWORD flagmask) { … … 553 578 height = DDSurfaceDesc.dwHeight; 554 579 580 lpDraw->pPrimSurf = this; 581 555 582 lastError = DD_OK; 556 583 return; … … 591 618 { 592 619 WriteLog(" Use Screen Format :"); 593 dwBpp = dwBytesPPDive << 3; // No use Screenformat620 dwBpp = lpDraw->GetScreenBpp(); // No use Screenformat 594 621 lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); 595 622 lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC = (DWORD) lpDraw->GetScreenFourCC(); … … 740 767 dwPitchFB = lpDDSurfaceDesc->dwWidth * (dwBpp<8?1:dwBpp/8); 741 768 dwPitchFB = (dwPitchFB +7) & ~7; // Align on QWords 742 743 769 DDSurfaceDesc.lPitch = dwPitchFB; 744 770 lpDDSurfaceDesc->lPitch = dwPitchFB; … … 764 790 pFrameBuffer = (char*)(((int)pFBreal + 7) & ~7); // align to QWORD 765 791 766 WriteLog( " Framebuffer @ %08X QWAligned @ %08X with a Pitch of %d ",792 WriteLog( " Framebuffer @ %08X QWAligned @ %08X with a Pitch of %d\n", 767 793 pFBreal, pFrameBuffer, dwPitchFB); 768 794 … … 780 806 { 781 807 WriteLog(" Alloc CCBuf "); 808 dwPitchDB = (lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7; 782 809 if(Mainchain) 783 810 { … … 790 817 lpDDSurfaceDesc->dwWidth, 791 818 lpDDSurfaceDesc->dwHeight, 792 (lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7,819 dwPitchDB, 793 820 (PBYTE)pDiveBuffer); 794 821 } 795 822 else 796 823 { 797 WriteLog("with malloc"); 824 WriteLog( "with malloc (%dx%d) Pitch %d ", 825 lpDDSurfaceDesc->dwHeight, 826 lpDDSurfaceDesc->dwWidth, 827 dwPitchDB); 798 828 // No so we must create the Divebuffer to do the colortranslation 799 829 // and blit to the real framebuffer on Unlock to do color conversion 800 830 pDiveBuffer = (char*)malloc( lpDDSurfaceDesc->dwHeight * 801 ((lpDDSurfaceDesc->dwWidth * (lpDraw->dCaps.ulDepth/8) +7) & ~7));831 dwPitchDB); 802 832 } 833 WriteLog( " @ %08X\n", pDiveBuffer); 803 834 } 804 835 … … 1154 1185 void OS2IDirectDrawSurface::ColorConversion(LPRECT lpRect) 1155 1186 { 1187 char *pSrc,*pDst,*pSLine,*pDLine; 1188 DWORD CCwidth,CCheight,x,y; 1189 DWORD *pPal24; 1190 WORD *pPal16; 1191 1192 if(NULL== lpDraw->pPrimSurf) 1193 { 1194 WriteLog("No Primary Surface! => No CC\n"); 1195 return; 1196 } 1197 1198 if(NULL== ((OS2IDirectDrawSurface*)lpDraw->pPrimSurf)->lpPalette) 1199 { 1200 WriteLog("No DDrawpalette defined!=> No CC\n"); 1201 return; 1202 } 1203 1204 if(NULL==lpRect) 1205 { 1206 pSrc = pFrameBuffer; 1207 pDst = pDiveBuffer; 1208 CCwidth = width; 1209 CCheight = height; 1210 } 1211 else 1212 { 1213 // ToDo: Check why the top/bottom values come in swaped here 1214 // for now simply reverse them with the following 3 lines 1215 y = lpRect->top; 1216 lpRect->top = lpRect->bottom; 1217 lpRect->bottom = y; 1218 // end of hack 1219 pSrc = pFrameBuffer + 1220 (lpRect->top * dwPitchFB) + 1221 (lpRect->left* (lpDraw->dCaps.ulDepth/8)); 1222 pDst = pDiveBuffer + 1223 (lpRect->top * dwPitchDB) + 1224 (lpRect->left* dwBytesPPDive); 1225 CCwidth = lpRect->right - lpRect->left; 1226 CCheight = lpRect->bottom - lpRect->top; 1227 1228 } 1229 1230 WriteLog( "H: %d W: %d\n SRC @ %08X\n DST @ %08X\n", 1231 CCheight, CCwidth, pSrc,pDst); 1232 1233 pSLine = pSrc; 1234 pDLine = pDst; 1235 1236 switch(lpDraw->dCaps.ulDepth) 1237 { 1238 case 8: 1239 WriteLog(" 8Bit target CC not implemented\n"); 1240 break; 1241 case 15: 1242 WriteLog(" 15 Bit not implemented using 16bit might look ugly\n"); 1243 case 16: 1244 if(8==lpDraw->GetScreenBpp()) 1245 { 1246 pPal16 = ((OS2IDirectDrawSurface*)lpDraw->pPrimSurf)->lpPalette->aPal16; 1247 WriteLog("8->16Bit CC\n"); 1248 for(y=0;CCheight;CCheight--,y++) 1249 { 1250 WriteLog("Converting Line %d\n",y); 1251 for(x=0;x<width;x++) 1252 { 1253 *((WORD*)pDLine) = pPal16[pSLine[x]]; 1254 } 1255 pSLine += dwPitchFB; 1256 pDLine += dwPitchDB; 1257 } 1258 } 1259 else 1260 { 1261 WriteLog("%d ->16Bit Not implemented",lpDraw->GetScreenBpp()); 1262 } 1263 break; 1264 case 24: 1265 if(8==lpDraw->GetScreenBpp()) 1266 { 1267 WriteLog("8->24Bit CC"); 1268 } 1269 else 1270 { 1271 WriteLog("%d ->16Bit Not implemented",lpDraw->GetScreenBpp()); 1272 } 1273 break; 1274 case 32: 1275 if(8==lpDraw->GetScreenBpp()) 1276 { 1277 WriteLog("8->32Bit CC"); 1278 } 1279 else 1280 { 1281 WriteLog("%d ->16Bit Not implemented",lpDraw->GetScreenBpp()); 1282 } 1283 break; 1284 default: 1285 #ifdef DEBUG 1286 WriteLog( "Unexpected Screen Bitdepth %d\n", 1287 lpDraw->dCaps.ulDepth); 1288 #endif 1289 break; 1290 } 1291 1292 /* 1156 1293 SETUP_BLITTER sBlt; 1157 1294 ULONG ulDN1, ulDN2; … … 1182 1319 sBlt.lDstPosY = sBlt.ulSrcPosY; 1183 1320 sBlt.ulNumDstRects = DIVE_FULLY_VISIBLE; 1321 1322 WriteLog( "Colorconversion:\n FCC SRC %08X\n FCC DST %08X\n", 1323 sBlt.fccSrcColorFormat, 1324 sBlt.fccDstColorFormat ); 1184 1325 1185 1326 rc = DiveAllocImageBuffer( hDiveCC, … … 1190 1331 dwPitchFB, 1191 1332 (PBYTE)pFrameBuffer); 1192 WriteLog("AllocDiveSrc Buffer rc= %X\n",rc);1333 WriteLog("AllocDiveSrc Buffer rc= 0x%08X\n",rc); 1193 1334 1194 1335 rc = DiveAllocImageBuffer( hDiveCC, … … 1199 1340 dwPitchDB, 1200 1341 (PBYTE)pDiveBuffer); 1201 WriteLog("AllocDiveDst Buffer rc= %Xd\n",rc);1342 WriteLog("AllocDiveDst Buffer rc= 0x%08X\n",rc); 1202 1343 1203 1344 rc = DiveSetupBlitter( hDiveCC, … … 1219 1360 1220 1361 WriteLog("Free dst rc= %X\n",rc); 1221 1362 */ 1222 1363 } 1223 1364 //****************************************************************************** … … 2571 2712 BlitWidth = (SrcRect.right - SrcRect.left) * src->dwBytesPPDive; 2572 2713 2573 if(dwTrans & DDBLTFAST_NOCOLORKEY) 2714 // Remove unsupported wait flag 2715 dwTrans &= ~DDBLTFAST_WAIT; 2716 2717 if(DDBLTFAST_NOCOLORKEY == dwTrans ) 2574 2718 { 2575 2719 WriteLog("Solid Blit"); … … 2593 2737 else 2594 2738 { 2595 WriteLog("TransBlit ");2739 WriteLog("TransBlit\n"); 2596 2740 2597 2741 if(dwTrans & DDBLTFAST_SRCCOLORKEY) 2598 2742 { 2743 WriteLog("Trans SRC\n"); 2599 2744 // transparent source 2600 2745 dwSrcColor = src->DDSurfaceDesc.ddckCKSrcBlt.dwColorSpaceLowValue; 2601 2746 if(dwTrans & DDBLTFAST_DESTCOLORKEY) 2602 2747 { 2748 WriteLog("And Dest Colorkey"); 2603 2749 dwDestColor = dest->DDSurfaceDesc.ddckCKDestBlt.dwColorSpaceLowValue; 2604 2750 // Source and dest colorkeying … … 2697 2843 // This MMX detection should be moved into OS2Draw 2698 2844 // and into the surface constructor a setup for blitting pointers 2699 2845 WriteLog("Only Src ColorKey"); 2700 2846 switch(dest->dwBytesPPDive) 2701 2847 { … … 2768 2914 if(dwTrans & DDBLTFAST_DESTCOLORKEY) 2769 2915 { 2916 WriteLog("DestColorKey\n"); 2917 2770 2918 dwDestColor = dest->DDSurfaceDesc.ddckCKDestBlt.dwColorSpaceLowValue; 2771 2919 switch(dest->dwBytesPPDive) … … 2844 2992 } // End switch 2845 2993 } 2994 else 2995 { 2996 WriteLog("Unexpected Flags"); 2997 } 2846 2998 } 2847 2999 } … … 3349 3501 3350 3502 lpDDCaps->dwCaps = me->DDSurfaceDesc.ddsCaps.dwCaps; 3351 3503 #ifdef DEBUG 3504 _dump_DDSCAPS(lpDDCaps->dwCaps); 3505 #endif 3352 3506 return(DD_OK); 3353 3507 } … … 3365 3519 3366 3520 memcpy(lpDDCaps, &(me->DDSurfaceDesc.ddsCaps), sizeof(DDSCAPS2) ); 3521 #ifdef DEBUG 3522 _dump_DDSCAPS(lpDDCaps->dwCaps); 3523 _dump_DDSCAPS2(lpDDCaps->dwCaps2); 3524 3525 #endif 3367 3526 3368 3527 return(DD_OK); … … 4098 4257 // primary surface => doesn't modify physical palette 4099 4258 if(me->surfaceType & DDSCAPS_PRIMARYSURFACE) 4259 { 4100 4260 me->lpPalette->SetIsPrimary(FALSE); 4101 4261 } 4102 4262 me->lpPalette->Vtbl.Release((IDirectDrawPalette*)me->lpPalette); 4103 4263 me->lpPalette = NULL; … … 4128 4288 4129 4289 if(me->surfaceType & DDSCAPS_PRIMARYSURFACE) 4290 { 4130 4291 me->lpPalette->SetIsPrimary(TRUE); 4131 4292 } 4132 4293 me->lpVtbl->ChangeUniquenessValue(me); 4133 4294
Note:
See TracChangeset
for help on using the changeset viewer.