Commit 3e9fe3e9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Use the window's client rect for clipping.

parent 6d238163
......@@ -93,6 +93,32 @@ static HRESULT WINAPI ddraw_clipper_SetHWnd(IDirectDrawClipper *iface, DWORD fla
return DD_OK;
}
static HRGN get_window_region(HWND window)
{
POINT origin = {0, 0};
RECT client_rect;
if (!GetClientRect(window, &client_rect))
{
ERR("Failed to get client rect.\n");
return NULL;
}
if (!ClientToScreen(window, &origin))
{
ERR("Failed to translate origin.\n");
return NULL;
}
if (!OffsetRect(&client_rect, origin.x, origin.y))
{
ERR("Failed to translate client rect.\n");
return NULL;
}
return CreateRectRgnIndirect(&client_rect);
}
/*****************************************************************************
* IDirectDrawClipper::GetClipList
*
......@@ -116,6 +142,7 @@ static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT
{
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",
iface, wine_dbgstr_rect(rect), clip_list, clip_list_size);
......@@ -124,31 +151,40 @@ static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT
if (clipper->window)
{
HDC dc = GetDCEx(clipper->window, NULL, DCX_WINDOW);
if (dc)
if (!(region = get_window_region(clipper->window)))
{
wined3d_mutex_unlock();
ERR("Failed to get window region.\n");
return E_FAIL;
}
if (rect)
{
HRGN rgn = CreateRectRgn(0, 0, 0, 0);
if (GetRandomRgn(dc, rgn, SYSRGN))
HRGN clip_region;
int ret;
if (!(clip_region = CreateRectRgnIndirect(rect)))
{
wined3d_mutex_unlock();
ERR("Failed to create region.\n");
DeleteObject(region);
return E_FAIL;
}
ret = CombineRgn(region, region, clip_region, RGN_AND);
DeleteObject(clip_region);
if (ret == ERROR)
{
if (GetVersion() & 0x80000000)
{
POINT origin;
GetDCOrgEx(dc, &origin);
OffsetRgn(rgn, origin.x, origin.y);
}
if (rect)
{
HRGN clip_rgn = CreateRectRgn(rect->left, rect->top,
rect->right, rect->bottom);
CombineRgn(rgn, rgn, clip_rgn, RGN_AND);
DeleteObject(clip_rgn);
}
*clip_list_size = GetRegionData(rgn, *clip_list_size, clip_list);
wined3d_mutex_unlock();
ERR("Failed to combine regions.\n");
DeleteObject(region);
return E_FAIL;
}
DeleteObject(rgn);
ReleaseDC(clipper->window, dc);
}
*clip_list_size = GetRegionData(region, *clip_list_size, clip_list);
DeleteObject(region);
wined3d_mutex_unlock();
return DD_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment