[PATCH 5/5] ddraw/tests: Remove p8_primary_test.
Stefan Dösinger
stefandoesinger at gmx.at
Sun Jun 5 16:56:58 CDT 2016
Signed-off-by: Stefan Dösinger <stefandoesinger at gmx.at>
---
Other than being in the old place, this test doesn't initialize Surface1
and randomly crashes when SetDisplayMode fails.
---
dlls/ddraw/tests/visual.c | 344 ----------------------------------------------
1 file changed, 344 deletions(-)
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index 17f89aa..4f62133 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -1197,32 +1197,6 @@ static void D3D3_ViewportClearTest(void)
if(window) DestroyWindow(window);
}
-static void p8_surface_fill_rect(IDirectDrawSurface *dest, UINT x, UINT y, UINT w, UINT h, BYTE colorindex)
-{
- DDSURFACEDESC ddsd;
- HRESULT hr;
- UINT i, i1;
- BYTE *p;
-
- memset(&ddsd, 0, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
-
- hr = IDirectDrawSurface_Lock(dest, NULL, &ddsd, DDLOCK_WRITEONLY | DDLOCK_WAIT, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_Lock returned: %x\n", hr);
-
- p = (BYTE *)ddsd.lpSurface + U1(ddsd).lPitch * y + x;
-
- for (i = 0; i < h; i++) {
- for (i1 = 0; i1 < w; i1++) {
- p[i1] = colorindex;
- }
- p += U1(ddsd).lPitch;
- }
-
- hr = IDirectDrawSurface_Unlock(dest, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_UnLock returned: %x\n", hr);
-}
-
static COLORREF getPixelColor_GDI(IDirectDrawSurface *Surface, UINT x, UINT y)
{
COLORREF clr = CLR_INVALID;
@@ -1242,323 +1216,6 @@ static COLORREF getPixelColor_GDI(IDirectDrawSurface *Surface, UINT x, UINT y)
return clr;
}
-static BOOL colortables_check_equality(PALETTEENTRY table1[256], RGBQUAD table2[256])
-{
- int i;
-
- for (i = 0; i < 256; i++) {
- if (table1[i].peRed != table2[i].rgbRed || table1[i].peGreen != table2[i].rgbGreen ||
- table1[i].peBlue != table2[i].rgbBlue) return FALSE;
- }
-
- return TRUE;
-}
-
-static void p8_primary_test(void)
-{
- /* Test 8bit mode used by games like StarCraft, C&C Red Alert I etc */
- DDSURFACEDESC ddsd;
- HDC hdc;
- HRESULT hr;
- PALETTEENTRY entries[256];
- RGBQUAD coltable[256];
- UINT i, i1, i2;
- IDirectDrawPalette *ddprimpal = NULL;
- IDirectDrawSurface *offscreen = NULL;
- WNDCLASSA wc = {0};
- DDBLTFX ddbltfx;
- COLORREF color;
- RECT rect;
- DDCOLORKEY clrKey;
- unsigned differences;
- IDirectDraw *DirectDraw1;
- IDirectDrawSurface *Surface1;
-
- /* An IDirect3DDevice cannot be queryInterfaced from an IDirect3DDevice7 on windows */
- hr = DirectDrawCreate(NULL, &DirectDraw1, NULL);
-
- ok(hr==DD_OK || hr==DDERR_NODIRECTDRAWSUPPORT, "DirectDrawCreate returned: %x\n", hr);
- if (FAILED(hr)) {
- goto out;
- }
-
- wc.lpfnWndProc = DefWindowProcA;
- wc.lpszClassName = "p8_primary_test_wc";
- RegisterClassA(&wc);
- window = CreateWindowA("p8_primary_test_wc", "p8_primary_test",
- WS_MAXIMIZE | WS_VISIBLE | WS_CAPTION, 0, 0, 640, 480, 0, 0, 0, 0);
-
- hr = IDirectDraw_SetCooperativeLevel(DirectDraw1, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
- ok(hr==DD_OK, "SetCooperativeLevel returned: %x\n", hr);
- if(FAILED(hr)) {
- goto out;
- }
-
- hr = IDirectDraw_SetDisplayMode(DirectDraw1, 640, 480, 8);
- ok(hr==DD_OK || hr == DDERR_UNSUPPORTED, "SetDisplayMode returned: %x\n", hr);
- if (FAILED(hr)) {
- goto out;
- }
-
- memset(&ddsd, 0, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &Surface1, NULL);
- ok(hr==DD_OK, "CreateSurface returned: %x\n", hr);
- if (FAILED(hr)) {
- goto out;
- }
-
- memset(entries, 0, sizeof(entries));
- entries[0].peRed = 0xff;
- entries[1].peGreen = 0xff;
- entries[2].peBlue = 0xff;
-
- hr = IDirectDraw_CreatePalette(DirectDraw1, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, entries, &ddprimpal, NULL);
- ok(hr == DD_OK, "CreatePalette returned %08x\n", hr);
- if (FAILED(hr)) {
- skip("IDirectDraw_CreatePalette failed; skipping further tests\n");
- goto out;
- }
-
- hr = IDirectDrawSurface_SetPalette(Surface1, ddprimpal);
- ok(hr==DD_OK, "IDirectDrawSurface_SetPalette returned: %x\n", hr);
-
- p8_surface_fill_rect(Surface1, 0, 0, 640, 480, 2);
-
- color = getPixelColor_GDI(Surface1, 10, 10);
- ok(GetRValue(color) == 0 && GetGValue(color) == 0 && GetBValue(color) == 0xFF,
- "got R %02X G %02X B %02X, expected R 00 G 00 B FF\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- memset(&ddbltfx, 0, sizeof(ddbltfx));
- ddbltfx.dwSize = sizeof(ddbltfx);
- U5(ddbltfx).dwFillColor = 0;
- hr = IDirectDrawSurface_Blt(Surface1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
- ok(hr == DD_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
-
- color = getPixelColor_GDI(Surface1, 10, 10);
- ok(GetRValue(color) == 0xFF && GetGValue(color) == 0 && GetBValue(color) == 0,
- "got R %02X G %02X B %02X, expected R FF G 00 B 00\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- memset(&ddbltfx, 0, sizeof(ddbltfx));
- ddbltfx.dwSize = sizeof(ddbltfx);
- U5(ddbltfx).dwFillColor = 1;
- hr = IDirectDrawSurface_Blt(Surface1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
- ok(hr == DD_OK, "IDirectDrawSurface_Blt failed with %08x\n", hr);
-
- color = getPixelColor_GDI(Surface1, 10, 10);
- ok(GetRValue(color) == 0 && GetGValue(color) == 0xFF && GetBValue(color) == 0,
- "got R %02X G %02X B %02X, expected R 00 G FF B 00\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- memset (&ddsd, 0, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
- ddsd.dwWidth = 16;
- ddsd.dwHeight = 16;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
- ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
- U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 8;
- hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &offscreen, NULL);
- ok(hr == DD_OK ||
- broken(hr == DDERR_INVALIDPIXELFORMAT) || /* VMware */
- broken(hr == DDERR_NODIRECTDRAWHW), /* VMware */
- "IDirectDraw_CreateSurface returned %08x\n", hr);
- if (FAILED(hr)) goto out;
-
- memset(entries, 0, sizeof(entries));
- for (i = 0; i < 256; i++) {
- entries[i].peBlue = i;
- }
- hr = IDirectDrawPalette_SetEntries(ddprimpal, 0, 0, 256, entries);
- ok(hr == DD_OK, "IDirectDrawPalette_SetEntries failed with %08x\n", hr);
-
- hr = IDirectDrawSurface_GetDC(offscreen, &hdc);
- ok(hr==DD_OK, "IDirectDrawSurface_GetDC returned: %x\n", hr);
- i = GetDIBColorTable(hdc, 0, 256, coltable);
- ok(i == 256, "GetDIBColorTable returned %u, last error: %x\n", i, GetLastError());
- hr = IDirectDrawSurface_ReleaseDC(offscreen, hdc);
- ok(hr==DD_OK, "IDirectDrawSurface_ReleaseDC returned: %x\n", hr);
-
- ok(colortables_check_equality(entries, coltable), "unexpected colortable on offscreen surface\n");
-
- p8_surface_fill_rect(offscreen, 0, 0, 16, 16, 2);
-
- memset(entries, 0, sizeof(entries));
- entries[0].peRed = 0xff;
- entries[1].peGreen = 0xff;
- entries[2].peBlue = 0xff;
- entries[3].peRed = 0x80;
- hr = IDirectDrawPalette_SetEntries(ddprimpal, 0, 0, 256, entries);
- ok(hr == DD_OK, "IDirectDrawPalette_SetEntries failed with %08x\n", hr);
-
- hr = IDirectDrawSurface_BltFast(Surface1, 0, 0, offscreen, NULL, 0);
- ok(hr==DD_OK, "IDirectDrawSurface_BltFast returned: %x\n", hr);
-
- color = getPixelColor_GDI(Surface1, 1, 1);
- ok(GetRValue(color) == 0 && GetGValue(color) == 0x00 && GetBValue(color) == 0xFF,
- "got R %02X G %02X B %02X, expected R 00 G 00 B FF\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- /* Color keyed blit. */
- p8_surface_fill_rect(offscreen, 0, 0, 8, 8, 3);
- clrKey.dwColorSpaceLowValue = 3;
- clrKey.dwColorSpaceHighValue = 3;
- hr = IDirectDrawSurface_SetColorKey(offscreen, DDCKEY_SRCBLT, &clrKey);
- ok(hr==D3D_OK, "IDirectDrawSurfac_SetColorKey returned: %x\n", hr);
-
- hr = IDirectDrawSurface_BltFast(Surface1, 100, 100, offscreen, NULL, DDBLTFAST_SRCCOLORKEY);
- ok(hr==DD_OK, "IDirectDrawSurface_BltFast returned: %x\n", hr);
-
- color = getPixelColor_GDI(Surface1, 105, 105);
- ok(GetRValue(color) == 0 && GetGValue(color) == 0xFF && GetBValue(color) == 0,
- "got R %02X G %02X B %02X, expected R 00 G FF B 00\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- color = getPixelColor_GDI(Surface1, 112, 112);
- ok(GetRValue(color) == 0 && GetGValue(color) == 0x00 && GetBValue(color) == 0xFF,
- "got R %02X G %02X B %02X, expected R 00 G 00 B FF\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- rect.left = 100;
- rect.top = 200;
- rect.right = 116;
- rect.bottom = 216;
-
- memset(&ddbltfx, 0, sizeof(ddbltfx));
- ddbltfx.dwSize = sizeof(ddbltfx);
- ddbltfx.ddckSrcColorkey.dwColorSpaceLowValue = ddbltfx.ddckSrcColorkey.dwColorSpaceHighValue = 2;
- hr = IDirectDrawSurface_Blt(Surface1, &rect, offscreen, NULL,
- DDBLT_WAIT | DDBLT_KEYSRC | DDBLT_KEYSRCOVERRIDE, &ddbltfx);
- ok(hr==DDERR_INVALIDPARAMS, "IDirectDrawSurface_Blt returned: %x\n", hr);
- hr = IDirectDrawSurface_Blt(Surface1, &rect, offscreen, NULL,
- DDBLT_WAIT | DDBLT_KEYSRCOVERRIDE, &ddbltfx);
- ok(hr==DD_OK, "IDirectDrawSurface_Blt returned: %x\n", hr);
-
- color = getPixelColor_GDI(Surface1, 105, 205);
- ok(GetRValue(color) == 0x80 && GetGValue(color) == 0 && GetBValue(color) == 0,
- "got R %02X G %02X B %02X, expected R 80 G 00 B 00\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- color = getPixelColor_GDI(Surface1, 112, 212);
- ok(GetRValue(color) == 0 && GetGValue(color) == 0xFF && GetBValue(color) == 0,
- "got R %02X G %02X B %02X, expected R 00 G FF B 00\n",
- GetRValue(color), GetGValue(color), GetBValue(color));
-
- /* Test blitting and locking patterns that are likely to trigger bugs in opengl renderer (p8
- surface conversion and uploading/downloading to/from opengl texture). Similar patterns (
- blitting front buffer areas to/from an offscreen surface mixed with locking) are used by C&C
- Red Alert I. */
- IDirectDrawSurface_Release(offscreen);
-
- memset (&ddsd, 0, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
- ddsd.dwWidth = 640;
- ddsd.dwHeight = 480;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
- ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
- U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 8;
- hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &offscreen, NULL);
- ok(hr == DD_OK, "IDirectDraw_CreateSurface returned %08x\n", hr);
-
- if (FAILED(hr)) goto out;
-
- /* Test two times, first time front buffer has a palette and second time front buffer
- has no palette; the latter is somewhat contrived example, but an app could set
- front buffer palette later. */
- for (i2 = 0; i2 < 2; i2++) {
- if (i2 == 1) {
- hr = IDirectDrawSurface_SetPalette(Surface1, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_SetPalette returned: %x\n", hr);
- }
-
- memset(&ddsd, 0, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
- hr = IDirectDrawSurface_Lock(Surface1, NULL, &ddsd, DDLOCK_WAIT, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_Lock returned: %x\n", hr);
-
- for (i = 0; i < 256; i++) {
- unsigned x = (i % 128) * 4;
- unsigned y = (i / 128) * 4;
- BYTE *p = (BYTE *)ddsd.lpSurface + U1(ddsd).lPitch * y + x;
-
- for (i1 = 0; i1 < 4; i1++) {
- p[0] = p[1] = p[2] = p[3] = i;
- p += U1(ddsd).lPitch;
- }
- }
-
- hr = IDirectDrawSurface_Unlock(Surface1, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_UnLock returned: %x\n", hr);
-
- hr = IDirectDrawSurface_BltFast(offscreen, 0, 0, Surface1, NULL, 0);
- ok(hr==DD_OK, "IDirectDrawSurface_BltFast returned: %x\n", hr);
-
- /* This ensures offscreen surface contents will be downloaded to system memory. */
- memset(&ddsd, 0, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
- hr = IDirectDrawSurface_Lock(offscreen, NULL, &ddsd, DDLOCK_WAIT, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_Lock returned: %x\n", hr);
- hr = IDirectDrawSurface_Unlock(offscreen, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_UnLock returned: %x\n", hr);
-
- /* Offscreen surface data will have to be converted and uploaded to texture. */
- rect.left = 0;
- rect.top = 0;
- rect.right = 16;
- rect.bottom = 16;
- hr = IDirectDrawSurface_BltFast(offscreen, 600, 400, Surface1, &rect, 0);
- ok(hr==DD_OK, "IDirectDrawSurface_BltFast returned: %x\n", hr);
-
- /* This ensures offscreen surface contents will be downloaded to system memory. */
- memset(&ddsd, 0, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
- hr = IDirectDrawSurface_Lock(offscreen, NULL, &ddsd, DDLOCK_WAIT, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_Lock returned: %x\n", hr);
- hr = IDirectDrawSurface_Unlock(offscreen, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_UnLock returned: %x\n", hr);
-
- hr = IDirectDrawSurface_BltFast(Surface1, 0, 0, offscreen, NULL, 0);
- ok(hr==DD_OK, "IDirectDrawSurface_BltFast returned: %x\n", hr);
-
- memset(&ddsd, 0, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
- hr = IDirectDrawSurface_Lock(Surface1, NULL, &ddsd, DDLOCK_WAIT, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_Lock returned: %x\n", hr);
-
- differences = 0;
-
- for (i = 0; i < 256; i++) {
- unsigned x = (i % 128) * 4 + 1;
- unsigned y = (i / 128) * 4 + 1;
- BYTE *p = (BYTE *)ddsd.lpSurface + U1(ddsd).lPitch * y + x;
-
- if (*p != i) differences++;
- }
-
- hr = IDirectDrawSurface_Unlock(Surface1, NULL);
- ok(hr==DD_OK, "IDirectDrawSurface_UnLock returned: %x\n", hr);
-
- ok(differences == 0, i2 == 0 ? "Pass 1. Unexpected front buffer contents after blit (%u differences)\n" :
- "Pass 2 (with NULL front buffer palette). Unexpected front buffer contents after blit (%u differences)\n",
- differences);
- }
-
- out:
-
- if(ddprimpal) IDirectDrawPalette_Release(ddprimpal);
- if(offscreen) IDirectDrawSurface_Release(offscreen);
- if(Surface1) IDirectDrawSurface_Release(Surface1);
- if(DirectDraw1) IDirectDraw_Release(DirectDraw1);
- if(window) DestroyWindow(window);
-}
-
static void cubemap_test(IDirect3DDevice7 *device)
{
IDirect3D7 *d3d;
@@ -2034,7 +1691,6 @@ START_TEST(visual)
releaseObjects(); /* release DX7 interfaces to test D3D1 */
D3D3_ViewportClearTest();
- p8_primary_test();
DX1_BackBufferFlipTest();
return ;
--
2.7.3
More information about the wine-patches
mailing list