diff --git a/rostests/dxtest/ddraw/Surface/blt.cpp b/rostests/dxtest/ddraw/Surface/blt.cpp new file mode 100644 index 00000000000..60ae645f3a9 --- /dev/null +++ b/rostests/dxtest/ddraw/Surface/blt.cpp @@ -0,0 +1,72 @@ + +DWORD GetPixel (LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y) +{ + DWORD ret; + RECT rect = {x, y, x+1, y+1}; + DDSURFACEDESC2 desc = {0}; + desc.dwSize = sizeof(DDSURFACEDESC2); + + if(Surface->Lock(&rect, &desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL)) + { + printf("ERROR: Unable to lock surface\n"); + return 0xdeadbeef; + } + + ret = *((DWORD *)desc.lpSurface); + + if(Surface->Unlock (&rect) != DD_OK) + { + printf("ERROR: Unable to unlock surface ?!\n"); + } + + return ret; +} + +VOID GetBltStatus_Test (LPDIRECTDRAWSURFACE7 Surface, INT* passed, INT* failed) +{ + TEST (Surface->GetBltStatus(0) == DDERR_INVALIDPARAMS); + TEST (Surface->GetBltStatus(DDGBS_CANBLT) == DD_OK); + TEST (Surface->GetBltStatus(DDGBS_ISBLTDONE) == DD_OK); + + // Lock Surface + DDSURFACEDESC2 desc = {0}; + desc.dwSize = sizeof(DDSURFACEDESC2); + Surface->Lock(NULL, &desc, DDLOCK_WAIT, NULL); + TEST (Surface->GetBltStatus(DDGBS_ISBLTDONE) == DD_OK); + TEST (Surface->GetBltStatus(DDGBS_CANBLT) == DD_OK); // does not return DDERR_SURFACEBUSY for me as msdn says (xp,nvidea) - mbosma + Surface->Unlock (NULL); + + // Try to produce busy surface by filling it 500 times + DDBLTFX bltfx; + bltfx.dwSize = sizeof(DDBLTFX); + bltfx.dwFillColor = RGB(0, 0, 0); + + int i; + for(i=0; i<500; i++) + Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &bltfx); + + TEST (Surface->GetBltStatus(DDGBS_ISBLTDONE) == DDERR_WASSTILLDRAWING); + TEST (Surface->GetBltStatus(DDGBS_CANBLT) == DD_OK); +} + +BOOL Test_Blt (INT* passed, INT* failed) +{ + LPDIRECTDRAWSURFACE7 Surface; + if(!CreateSurface(&Surface)) + return FALSE; + + // Test GetPixel (needs Lock API) + DDBLTFX bltfx; + bltfx.dwSize = sizeof(DDBLTFX); + bltfx.dwFillColor = RGB(0, 0, 0); + Surface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &bltfx); + if(GetPixel(Surface, 0, 0) != RGB(0, 0, 0)) + return FALSE; + + // The tests + TEST(Surface->BltBatch(NULL, 0, 0) == DDERR_UNSUPPORTED); + GetBltStatus_Test (Surface, passed, failed); + + Surface->Release(); + return TRUE; +} \ No newline at end of file diff --git a/rostests/dxtest/ddraw/testlist.cpp b/rostests/dxtest/ddraw/testlist.cpp index 9c23c74fbf8..3884961d370 100644 --- a/rostests/dxtest/ddraw/testlist.cpp +++ b/rostests/dxtest/ddraw/testlist.cpp @@ -10,6 +10,7 @@ #include "DDraw/available_mem.cpp" #include "Surface/create.cpp" #include "Surface/private_data.cpp" +#include "Surface/blt.cpp" #include "Surface/misc.cpp" /* The List of tests */ @@ -22,6 +23,7 @@ TEST TestList[] = { "IDirectDraw: GetFourCC", Test_GetFourCCCodes }, { "IDirectDraw: Cooperative Levels", Test_SetCooperativeLevel }, { "IDirectDrawSurface: Creation", Test_CreateSurface }, + { "IDirectDrawSurface: Blting", Test_Blt }, { "IDirectDrawSurface: Private Data", Test_PrivateData }, { "IDirectDrawSurface: Miscellaneous Tests", Test_Misc }, };