[PATCH 2/5] ddraw: Implement IDirectDrawClipper::SetClipList().
Henri Verbeet
hverbeet at codeweavers.com
Fri Jan 6 04:20:04 CST 2012
---
dlls/ddraw/clipper.c | 83 +++++++++++++++++++++++++++----------------
dlls/ddraw/ddraw_private.h | 1 +
dlls/ddraw/tests/ddraw1.c | 12 +++----
dlls/ddraw/tests/ddraw2.c | 12 +++----
dlls/ddraw/tests/ddraw4.c | 12 +++----
dlls/ddraw/tests/ddraw7.c | 12 +++----
6 files changed, 73 insertions(+), 59 deletions(-)
diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c
index 5b8e9ce..5c605d8 100644
--- a/dlls/ddraw/clipper.c
+++ b/dlls/ddraw/clipper.c
@@ -69,7 +69,11 @@ static ULONG WINAPI ddraw_clipper_Release(IDirectDrawClipper *iface)
TRACE("%p decreasing refcount to %u.\n", clipper, refcount);
if (!refcount)
+ {
+ if (clipper->region)
+ DeleteObject(clipper->region);
HeapFree(GetProcessHeap(), 0, clipper);
+ }
return refcount;
}
@@ -141,7 +145,6 @@ static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT
RGNDATA *clip_list, DWORD *clip_list_size)
{
struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
- static unsigned int once;
HRGN region;
TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
@@ -157,47 +160,49 @@ static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT
ERR("Failed to get window region.\n");
return E_FAIL;
}
-
- if (rect)
+ }
+ else
+ {
+ if (!(region = clipper->region))
{
- HRGN clip_region;
- int ret;
+ wined3d_mutex_unlock();
+ WARN("No clip list set.\n");
+ return DDERR_NOCLIPLIST;
+ }
+ }
- if (!(clip_region = CreateRectRgnIndirect(rect)))
- {
- wined3d_mutex_unlock();
- ERR("Failed to create region.\n");
+ if (rect)
+ {
+ HRGN clip_region;
+
+ if (!(clip_region = CreateRectRgnIndirect(rect)))
+ {
+ wined3d_mutex_unlock();
+ ERR("Failed to create region.\n");
+ if (clipper->window)
DeleteObject(region);
- return E_FAIL;
- }
+ return E_FAIL;
+ }
- ret = CombineRgn(region, region, clip_region, RGN_AND);
+ if (CombineRgn(clip_region, region, clip_region, RGN_AND) == ERROR)
+ {
+ wined3d_mutex_unlock();
+ ERR("Failed to combine regions.\n");
DeleteObject(clip_region);
- if (ret == ERROR)
- {
- wined3d_mutex_unlock();
- ERR("Failed to combine regions.\n");
+ if (clipper->window)
DeleteObject(region);
- return E_FAIL;
- }
+ return E_FAIL;
}
- *clip_list_size = GetRegionData(region, *clip_list_size, clip_list);
- DeleteObject(region);
-
- wined3d_mutex_unlock();
- return DD_OK;
+ region = clip_region;
}
- if (!once++)
- FIXME("clipper %p, rect %s, clip_list %p, clip_list_size %p stub!\n",
- clipper, wine_dbgstr_rect(rect), clip_list, clip_list_size);
-
- if (clip_list_size)
- *clip_list_size = 0;
+ *clip_list_size = GetRegionData(region, *clip_list_size, clip_list);
+ if (rect || clipper->window)
+ DeleteObject(region);
wined3d_mutex_unlock();
- return DDERR_NOCLIPLIST;
+ return DD_OK;
}
/*****************************************************************************
@@ -218,10 +223,26 @@ static HRESULT WINAPI ddraw_clipper_SetClipList(IDirectDrawClipper *iface, RGNDA
{
struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
- FIXME("iface %p, region %p, flags %#x stub!\n", iface, region, flags);
+ TRACE("iface %p, region %p, flags %#x.\n", iface, region, flags);
+
+ wined3d_mutex_lock();
if (clipper->window)
+ {
+ wined3d_mutex_unlock();
return DDERR_CLIPPERISUSINGHWND;
+ }
+
+ if (clipper->region)
+ DeleteObject(clipper->region);
+ if (!(clipper->region = ExtCreateRegion(NULL, 0, region)))
+ {
+ wined3d_mutex_unlock();
+ ERR("Failed to create creation.\n");
+ return E_FAIL;
+ }
+
+ wined3d_mutex_unlock();
return DD_OK;
}
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index df96402..38541cd 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -361,6 +361,7 @@ struct ddraw_clipper
IDirectDrawClipper IDirectDrawClipper_iface;
LONG ref;
HWND window;
+ HRGN region;
BOOL initialized;
};
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index e700919..7275df6 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -210,6 +210,8 @@ static void test_clipper_blt(void)
hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL);
ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+ hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
+ ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
@@ -314,7 +316,7 @@ static void test_clipper_blt(void)
U5(fx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
- todo_wine ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+ ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
@@ -322,12 +324,8 @@ static void test_clipper_blt(void)
x = 80 * ((2 * j) + 1);
y = 60 * ((2 * i) + 1);
color = get_surface_color(dst_surface, x, y);
- if ((i < 2 && j < 2) || (i >= 2 && j >= 2))
- todo_wine ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
- else
- ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+ ok(compare_color(color, expected2[i * 4 + j], 1),
+ "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
}
}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index f99d480..71a57a8 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -217,6 +217,8 @@ static void test_clipper_blt(void)
hr = IDirectDraw2_CreateClipper(ddraw, 0, &clipper, NULL);
ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+ hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
+ ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
@@ -321,7 +323,7 @@ static void test_clipper_blt(void)
U5(fx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
- todo_wine ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+ ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
@@ -329,12 +331,8 @@ static void test_clipper_blt(void)
x = 80 * ((2 * j) + 1);
y = 60 * ((2 * i) + 1);
color = get_surface_color(dst_surface, x, y);
- if ((i < 2 && j < 2) || (i >= 2 && j >= 2))
- todo_wine ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
- else
- ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+ ok(compare_color(color, expected2[i * 4 + j], 1),
+ "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
}
}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index e2687fb..db8d005 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -513,6 +513,8 @@ static void test_clipper_blt(void)
hr = IDirectDraw4_CreateClipper(ddraw, 0, &clipper, NULL);
ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+ hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
+ ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
@@ -616,7 +618,7 @@ static void test_clipper_blt(void)
U5(fx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface4_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
- todo_wine ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+ ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
@@ -624,12 +626,8 @@ static void test_clipper_blt(void)
x = 80 * ((2 * j) + 1);
y = 60 * ((2 * i) + 1);
color = get_surface_color(dst_surface, x, y);
- if ((i < 2 && j < 2) || (i >= 2 && j >= 2))
- todo_wine ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
- else
- ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+ ok(compare_color(color, expected2[i * 4 + j], 1),
+ "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
}
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 3dcb007..630247b 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -506,6 +506,8 @@ static void test_clipper_blt(void)
hr = IDirectDraw7_CreateClipper(ddraw, 0, &clipper, NULL);
ok(SUCCEEDED(hr), "Failed to create clipper, hr %#x.\n", hr);
+ hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
+ ok(hr == DDERR_NOCLIPLIST, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawClipper_SetHWnd(clipper, 0, window);
ok(SUCCEEDED(hr), "Failed to set clipper window, hr %#x.\n", hr);
hr = IDirectDrawClipper_GetClipList(clipper, NULL, NULL, &ret);
@@ -609,7 +611,7 @@ static void test_clipper_blt(void)
U5(fx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface7_Blt(dst_surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
- todo_wine ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
+ ok(SUCCEEDED(hr), "Failed to clear destination surface, hr %#x.\n", hr);
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 4; ++j)
@@ -617,12 +619,8 @@ static void test_clipper_blt(void)
x = 80 * ((2 * j) + 1);
y = 60 * ((2 * i) + 1);
color = get_surface_color(dst_surface, x, y);
- if ((i < 2 && j < 2) || (i >= 2 && j >= 2))
- todo_wine ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
- else
- ok(compare_color(color, expected2[i * 4 + j], 1),
- "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
+ ok(compare_color(color, expected2[i * 4 + j], 1),
+ "Expected color 0x%08x at %u,%u, got 0x%08x.\n", expected2[i * 4 + j], x, y, color);
}
}
--
1.7.3.4
More information about the wine-patches
mailing list