[PATCH 5/5] ddraw/tests: Test mipmap GetDC behavior.
Stefan Dösinger
stefan at codeweavers.com
Mon Apr 28 08:21:58 CDT 2014
---
dlls/ddraw/tests/ddraw1.c | 28 +++++++++++++++++++++++++---
dlls/ddraw/tests/ddraw2.c | 28 +++++++++++++++++++++++++---
dlls/ddraw/tests/ddraw4.c | 28 +++++++++++++++++++++++++---
dlls/ddraw/tests/ddraw7.c | 5 +++++
4 files changed, 80 insertions(+), 9 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index a3c9b82..2560d65 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -4616,7 +4616,7 @@ static void test_palette_complex(void)
IDirectDrawSurface *surface, *mipmap, *tmp;
DDSURFACEDESC surface_desc;
IDirectDraw *ddraw;
- IDirectDrawPalette *palette, *palette2;
+ IDirectDrawPalette *palette, *palette2, *palette_mipmap;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -4624,6 +4624,9 @@ static void test_palette_complex(void)
DDCAPS hal_caps;
PALETTEENTRY palette_entries[256];
unsigned int i;
+ HDC dc;
+ RGBQUAD rgbquad;
+ UINT count;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
@@ -4661,6 +4664,13 @@ static void test_palette_complex(void)
palette_entries, &palette, NULL);
ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ memset(palette_entries, 0, sizeof(palette_entries));
+ palette_entries[1].peRed = 0xff;
+ palette_entries[1].peGreen = 0x80;
+ hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ palette_entries, &palette_mipmap, NULL);
+ ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+
palette2 = (void *)0xdeadbeef;
hr = IDirectDrawSurface_GetPalette(surface, &palette2);
ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
@@ -4683,14 +4693,24 @@ static void test_palette_complex(void)
ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
- hr = IDirectDrawSurface_SetPalette(tmp, palette);
+ hr = IDirectDrawSurface_SetPalette(tmp, palette_mipmap);
ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#x.\n", i, hr);
hr = IDirectDrawSurface_GetPalette(tmp, &palette2);
ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#x.\n", i, hr);
- ok(palette == palette2, "Got unexpected palette %p.\n", palette2);
+ ok(palette_mipmap == palette2, "Got unexpected palette %p.\n", palette2);
IDirectDrawPalette_Release(palette2);
+ hr = IDirectDrawSurface_GetDC(tmp, &dc);
+ ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+ count = GetDIBColorTable(dc, 1, 1, &rgbquad);
+ ok(count == 1, "Expected count 1, got %u.\n", count);
+ ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x.\n", rgbquad.rgbRed);
+ ok(rgbquad.rgbGreen == 0x80, "Expected rgbGreen = 0x80, got %#x.\n", rgbquad.rgbGreen);
+ ok(rgbquad.rgbBlue == 0x0, "Expected rgbBlue = 0x0, got %#x.\n", rgbquad.rgbBlue);
+ hr = IDirectDrawSurface_ReleaseDC(tmp, dc);
+ ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+
IDirectDrawSurface_Release(mipmap);
mipmap = tmp;
}
@@ -4700,6 +4720,8 @@ static void test_palette_complex(void)
IDirectDrawSurface_Release(mipmap);
refcount = IDirectDrawSurface_Release(surface);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawPalette_Release(palette_mipmap);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
refcount = IDirectDrawPalette_Release(palette);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index b92c2d3..1e3972c 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -5727,7 +5727,7 @@ static void test_palette_complex(void)
IDirectDrawSurface2 *surface, *mipmap, *tmp;
DDSURFACEDESC surface_desc;
IDirectDraw2 *ddraw;
- IDirectDrawPalette *palette, *palette2;
+ IDirectDrawPalette *palette, *palette2, *palette_mipmap;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -5735,6 +5735,9 @@ static void test_palette_complex(void)
DDCAPS hal_caps;
PALETTEENTRY palette_entries[256];
unsigned int i;
+ HDC dc;
+ RGBQUAD rgbquad;
+ UINT count;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
@@ -5775,6 +5778,13 @@ static void test_palette_complex(void)
palette_entries, &palette, NULL);
ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ memset(palette_entries, 0, sizeof(palette_entries));
+ palette_entries[1].peRed = 0xff;
+ palette_entries[1].peGreen = 0x80;
+ hr = IDirectDraw2_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ palette_entries, &palette_mipmap, NULL);
+ ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+
palette2 = (void *)0xdeadbeef;
hr = IDirectDrawSurface2_GetPalette(surface, &palette2);
ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
@@ -5797,14 +5807,24 @@ static void test_palette_complex(void)
ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
- hr = IDirectDrawSurface2_SetPalette(tmp, palette);
+ hr = IDirectDrawSurface2_SetPalette(tmp, palette_mipmap);
ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#x.\n", i, hr);
hr = IDirectDrawSurface2_GetPalette(tmp, &palette2);
ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#x.\n", i, hr);
- ok(palette == palette2, "Got unexpected palette %p.\n", palette2);
+ ok(palette_mipmap == palette2, "Got unexpected palette %p.\n", palette2);
IDirectDrawPalette_Release(palette2);
+ hr = IDirectDrawSurface2_GetDC(tmp, &dc);
+ ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+ count = GetDIBColorTable(dc, 1, 1, &rgbquad);
+ ok(count == 1, "Expected count 1, got %u.\n", count);
+ ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x.\n", rgbquad.rgbRed);
+ ok(rgbquad.rgbGreen == 0x80, "Expected rgbGreen = 0x80, got %#x.\n", rgbquad.rgbGreen);
+ ok(rgbquad.rgbBlue == 0x0, "Expected rgbBlue = 0x0, got %#x.\n", rgbquad.rgbBlue);
+ hr = IDirectDrawSurface2_ReleaseDC(tmp, dc);
+ ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+
IDirectDrawSurface2_Release(mipmap);
mipmap = tmp;
}
@@ -5814,6 +5834,8 @@ static void test_palette_complex(void)
IDirectDrawSurface2_Release(mipmap);
refcount = IDirectDrawSurface2_Release(surface);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawPalette_Release(palette_mipmap);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
refcount = IDirectDrawPalette_Release(palette);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 5caf7ab..bcd53d0 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -6591,7 +6591,7 @@ static void test_palette_complex(void)
IDirectDrawSurface4 *surface, *mipmap, *tmp;
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw;
- IDirectDrawPalette *palette, *palette2;
+ IDirectDrawPalette *palette, *palette2, *palette_mipmap;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -6599,6 +6599,9 @@ static void test_palette_complex(void)
DDCAPS hal_caps;
PALETTEENTRY palette_entries[256];
unsigned int i;
+ HDC dc;
+ RGBQUAD rgbquad;
+ UINT count;
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
@@ -6636,6 +6639,13 @@ static void test_palette_complex(void)
palette_entries, &palette, NULL);
ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ memset(palette_entries, 0, sizeof(palette_entries));
+ palette_entries[1].peRed = 0xff;
+ palette_entries[1].peGreen = 0x80;
+ hr = IDirectDraw4_CreatePalette(ddraw, DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ palette_entries, &palette_mipmap, NULL);
+ ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+
palette2 = (void *)0xdeadbeef;
hr = IDirectDrawSurface4_GetPalette(surface, &palette2);
ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x.\n", hr);
@@ -6658,14 +6668,24 @@ static void test_palette_complex(void)
ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
- hr = IDirectDrawSurface4_SetPalette(tmp, palette);
+ hr = IDirectDrawSurface4_SetPalette(tmp, palette_mipmap);
ok(SUCCEEDED(hr), "Failed to set palette, i %u, hr %#x.\n", i, hr);
hr = IDirectDrawSurface4_GetPalette(tmp, &palette2);
ok(SUCCEEDED(hr), "Failed to get palette, i %u, hr %#x.\n", i, hr);
- ok(palette == palette2, "Got unexpected palette %p.\n", palette2);
+ ok(palette_mipmap == palette2, "Got unexpected palette %p.\n", palette2);
IDirectDrawPalette_Release(palette2);
+ hr = IDirectDrawSurface4_GetDC(tmp, &dc);
+ ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+ count = GetDIBColorTable(dc, 1, 1, &rgbquad);
+ ok(count == 1, "Expected count 1, got %u.\n", count);
+ ok(rgbquad.rgbRed == 0xff, "Expected rgbRed = 0xff, got %#x.\n", rgbquad.rgbRed);
+ ok(rgbquad.rgbGreen == 0x80, "Expected rgbGreen = 0x80, got %#x.\n", rgbquad.rgbGreen);
+ ok(rgbquad.rgbBlue == 0x0, "Expected rgbBlue = 0x0, got %#x.\n", rgbquad.rgbBlue);
+ hr = IDirectDrawSurface4_ReleaseDC(tmp, dc);
+ ok(SUCCEEDED(hr), "Failed to get DC, i %u, hr %#x.\n", i, hr);
+
IDirectDrawSurface4_Release(mipmap);
mipmap = tmp;
}
@@ -6675,6 +6695,8 @@ static void test_palette_complex(void)
IDirectDrawSurface4_Release(mipmap);
refcount = IDirectDrawSurface4_Release(surface);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
+ refcount = IDirectDrawPalette_Release(palette_mipmap);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
refcount = IDirectDrawPalette_Release(palette);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index ceedc15..bca8723 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -6526,6 +6526,11 @@ static void test_palette_complex(void)
ok(hr == DDERR_NOPALETTEATTACHED, "Got unexpected hr %#x, i %u.\n", hr, i);
ok(!palette2, "Got unexpected palette %p, i %u.\n", palette2, i);
+ /* Ddraw7 uses the palette of the mipmap for GetDC, just like previous
+ * ddraw versions. Combined with the test results above this means no
+ * palette is available. So depending on the driver either GetDC fails
+ * or the DIB color table contains random data. */
+
IDirectDrawSurface7_Release(mipmap);
mipmap = tmp;
}
--
1.8.3.2
More information about the wine-patches
mailing list