ddraw: Move clipper handling to ddraw.

This commit is contained in:
Henri Verbeet 2011-12-12 20:53:55 +01:00 committed by Alexandre Julliard
parent 68e0cd430f
commit e6fb4537f0
10 changed files with 140 additions and 434 deletions

View File

@ -26,117 +26,71 @@
WINE_DEFAULT_DEBUG_CHANNEL(ddraw); WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
static inline IDirectDrawClipperImpl *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) static inline struct ddraw_clipper *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
{ {
return CONTAINING_RECORD(iface, IDirectDrawClipperImpl, IDirectDrawClipper_iface); return CONTAINING_RECORD(iface, struct ddraw_clipper, IDirectDrawClipper_iface);
} }
/***************************************************************************** static HRESULT WINAPI ddraw_clipper_QueryInterface(IDirectDrawClipper *iface, REFIID iid, void **object)
* IDirectDrawClipper::QueryInterface
*
* Can query the IUnknown and IDirectDrawClipper interface from a
* Clipper object. The IUnknown Interface is equal to the IDirectDrawClipper
* interface. Can't create other interfaces.
*
* Arguments:
* riid: Interface id asked for
* ppvObj: Returns the pointer to the interface
*
* Return values:
* DD_OK on success
* E_NOINTERFACE if the requested interface wasn't found.
*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(IDirectDrawClipper *iface, REFIID riid,
void **ppvObj)
{ {
struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppvObj); TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object);
if (IsEqualGUID(&IID_IDirectDrawClipper, riid) if (IsEqualGUID(&IID_IDirectDrawClipper, iid)
|| IsEqualGUID(&IID_IUnknown, riid)) || IsEqualGUID(&IID_IUnknown, iid))
{ {
IUnknown_AddRef(iface); IDirectDrawClipper_AddRef(&clipper->IDirectDrawClipper_iface);
*ppvObj = iface; *object = &clipper->IDirectDrawClipper_iface;
return S_OK; return S_OK;
} }
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
*object = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
/***************************************************************************** static ULONG WINAPI ddraw_clipper_AddRef(IDirectDrawClipper *iface)
* IDirectDrawClipper::AddRef
*
* Increases the reference count of the interface, returns the new count
*
*****************************************************************************/
static ULONG WINAPI IDirectDrawClipperImpl_AddRef(IDirectDrawClipper *iface)
{ {
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG refcount = InterlockedIncrement(&clipper->ref);
TRACE("%p increasing refcount to %u.\n", This, ref); TRACE("%p increasing refcount to %u.\n", clipper, refcount);
return ref; return refcount;
} }
/***************************************************************************** static ULONG WINAPI ddraw_clipper_Release(IDirectDrawClipper *iface)
* IDirectDrawClipper::Release
*
* Decreases the reference count of the interface, returns the new count
* If the refcount is decreased to 0, the interface is destroyed.
*
*****************************************************************************/
static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface)
{ {
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG refcount = InterlockedDecrement(&clipper->ref);
TRACE("%p decreasing refcount to %u.\n", This, ref); TRACE("%p decreasing refcount to %u.\n", clipper, refcount);
if (ref == 0) if (!refcount)
HeapFree(GetProcessHeap(), 0, clipper);
return refcount;
}
static HRESULT WINAPI ddraw_clipper_SetHWnd(IDirectDrawClipper *iface, DWORD flags, HWND window)
{
struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
TRACE("iface %p, flags %#x, window %p.\n", iface, flags, window);
if (flags)
{ {
wined3d_mutex_lock(); FIXME("flags %#x, not supported.\n", flags);
wined3d_clipper_decref(This->wineD3DClipper); return DDERR_INVALIDPARAMS;
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
return 0;
} }
else return ref;
}
/*****************************************************************************
* IDirectDrawClipper::SetHWnd
*
* Assigns a hWnd to the clipper interface.
*
* Arguments:
* Flags: Unsupported so far
* hWnd: The hWnd to set
*
* Return values:
* DD_OK on success
* DDERR_INVALIDPARAMS if Flags was != 0
*
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_SetHWnd(IDirectDrawClipper *iface, DWORD dwFlags,
HWND hWnd)
{
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
HRESULT hr;
TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_clipper_set_window(This->wineD3DClipper, dwFlags, hWnd); clipper->window = window;
wined3d_mutex_unlock(); wined3d_mutex_unlock();
switch(hr) return DD_OK;
{
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
default: return hr;
}
} }
/***************************************************************************** /*****************************************************************************
@ -145,175 +99,157 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHWnd(IDirectDrawClipper *iface,
* Retrieve a copy of the clip list * Retrieve a copy of the clip list
* *
* Arguments: * Arguments:
* Rect: Rectangle to be used to clip the clip list or NULL for the * rect: Rectangle to be used to clip the clip list or NULL for the
* entire clip list * entire clip list.
* ClipList: structure for the resulting copy of the clip list. * clip_list: structure for the resulting copy of the clip list.
* If NULL, fills Size up to the number of bytes necessary to hold * If NULL, fills Size up to the number of bytes necessary to hold
* the entire clip. * the entire clip.
* Size: Size of resulting clip list; size of the buffer at ClipList * clip_list_size: Size of resulting clip list; size of the buffer at clip_list
* or, if ClipList is NULL, receives the required size of the buffer * or, if clip_list is NULL, receives the required size of the buffer
* in bytes * in bytes.
* *
* RETURNS * RETURNS
* Either DD_OK or DDERR_* * Either DD_OK or DDERR_*
************************************************************************/ ************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *iface, RECT *lpRect, static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT *rect,
RGNDATA *lpClipList, DWORD *lpdwSize) RGNDATA *clip_list, DWORD *clip_list_size)
{ {
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
HRESULT hr; static unsigned int once;
TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n", TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize); iface, wine_dbgstr_rect(rect), clip_list, clip_list_size);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_clipper_get_clip_list(This->wineD3DClipper, lpRect, lpClipList, lpdwSize);
wined3d_mutex_unlock();
return hr; if (clipper->window)
{
HDC dc = GetDCEx(clipper->window, NULL, DCX_WINDOW);
if (dc)
{
HRGN rgn = CreateRectRgn(0, 0, 0, 0);
if (GetRandomRgn(dc, rgn, SYSRGN))
{
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);
}
DeleteObject(rgn);
ReleaseDC(clipper->window, dc);
}
wined3d_mutex_unlock();
return DD_OK;
}
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;
wined3d_mutex_unlock();
return DDERR_NOCLIPLIST;
} }
/***************************************************************************** /*****************************************************************************
* IDirectDrawClipper::SetClipList * IDirectDrawClipper::SetClipList
* *
* Sets or deletes (if lprgn is NULL) the clip list * Sets or deletes (if region is NULL) the clip list
* *
* This implementation is a stub and returns DD_OK always to make the app * This implementation is a stub and returns DD_OK always to make the app
* happy. * happy.
* *
* PARAMS * PARAMS
* lprgn Pointer to a LRGNDATA structure or NULL * region Pointer to a LRGNDATA structure or NULL
* dwFlags not used, must be 0 * flags not used, must be 0
* RETURNS * RETURNS
* Either DD_OK or DDERR_* * Either DD_OK or DDERR_*
*****************************************************************************/ *****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *iface, RGNDATA *lprgn, static HRESULT WINAPI ddraw_clipper_SetClipList(IDirectDrawClipper *iface, RGNDATA *region, DWORD flags)
DWORD dwFlag)
{ {
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); FIXME("iface %p, region %p, flags %#x stub!\n", iface, region, flags);
HRESULT hr;
TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag); return DD_OK;
wined3d_mutex_lock();
hr = wined3d_clipper_set_clip_list(This->wineD3DClipper, lprgn, dwFlag);
wined3d_mutex_unlock();
return hr;
} }
/***************************************************************************** static HRESULT WINAPI ddraw_clipper_GetHWnd(IDirectDrawClipper *iface, HWND *window)
* IDirectDrawClipper::GetHWnd
*
* Returns the hwnd assigned with SetHWnd
*
* Arguments:
* hWndPtr: Address to store the HWND at
*
* Return values:
* Always returns DD_OK;
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(IDirectDrawClipper *iface, HWND *hWndPtr)
{ {
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
HRESULT hr;
TRACE("iface %p, window %p.\n", iface, hWndPtr); TRACE("iface %p, window %p.\n", iface, window);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_clipper_get_window(This->wineD3DClipper, hWndPtr); *window = clipper->window;
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return DD_OK;
} }
/***************************************************************************** static HRESULT WINAPI ddraw_clipper_Initialize(IDirectDrawClipper *iface,
* IDirectDrawClipper::Initialize IDirectDraw *ddraw, DWORD flags)
*
* Initializes the interface. Well, there isn't much to do for this
* implementation, but it stores the DirectDraw Interface.
*
* Arguments:
* DD: Pointer to a IDirectDraw interface
* Flags: Unsupported by now
*
* Return values:
* DD_OK on success
* DDERR_ALREADYINITIALIZED if this interface isn't initialized already
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(IDirectDrawClipper *iface,
IDirectDraw *ddraw, DWORD dwFlags)
{ {
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface); struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, dwFlags); TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, flags);
wined3d_mutex_lock(); wined3d_mutex_lock();
if (This->initialized) if (clipper->initialized)
{ {
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DDERR_ALREADYINITIALIZED; return DDERR_ALREADYINITIALIZED;
} }
This->initialized = TRUE; clipper->initialized = TRUE;
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DD_OK; return DD_OK;
} }
/***************************************************************************** static HRESULT WINAPI ddraw_clipper_IsClipListChanged(IDirectDrawClipper *iface, BOOL *changed)
* IDirectDrawClipper::IsClipListChanged
*
* This function is a stub
*
* Arguments:
* Changed:
*
* Return values:
* DD_OK, because it's a stub
*****************************************************************************/
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(IDirectDrawClipper *iface,
BOOL *lpbChanged)
{ {
FIXME("iface %p, changed %p stub!\n", iface, lpbChanged); FIXME("iface %p, changed %p stub!\n", iface, changed);
/* XXX What is safest? */ /* XXX What is safest? */
*lpbChanged = FALSE; *changed = FALSE;
return DD_OK; return DD_OK;
} }
/*****************************************************************************
* The VTable
*****************************************************************************/
static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl = static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl =
{ {
IDirectDrawClipperImpl_QueryInterface, ddraw_clipper_QueryInterface,
IDirectDrawClipperImpl_AddRef, ddraw_clipper_AddRef,
IDirectDrawClipperImpl_Release, ddraw_clipper_Release,
IDirectDrawClipperImpl_GetClipList, ddraw_clipper_GetClipList,
IDirectDrawClipperImpl_GetHWnd, ddraw_clipper_GetHWnd,
IDirectDrawClipperImpl_Initialize, ddraw_clipper_Initialize,
IDirectDrawClipperImpl_IsClipListChanged, ddraw_clipper_IsClipListChanged,
IDirectDrawClipperImpl_SetClipList, ddraw_clipper_SetClipList,
IDirectDrawClipperImpl_SetHWnd ddraw_clipper_SetHWnd,
}; };
HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper)
{ {
clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl; clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl;
clipper->ref = 1; clipper->ref = 1;
clipper->wineD3DClipper = wined3d_clipper_create();
if (!clipper->wineD3DClipper)
{
WARN("Failed to create wined3d clipper.\n");
return E_OUTOFMEMORY;
}
return DD_OK; return DD_OK;
} }
IDirectDrawClipperImpl *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
{ {
if (!iface) if (!iface)
return NULL; return NULL;

View File

@ -3514,25 +3514,21 @@ static HRESULT WINAPI ddraw1_EnumSurfaces(IDirectDraw *iface, DWORD flags,
* E_OUTOFMEMORY if allocating the object failed * E_OUTOFMEMORY if allocating the object failed
* *
*****************************************************************************/ *****************************************************************************/
HRESULT WINAPI HRESULT WINAPI DirectDrawCreateClipper(DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
DirectDrawCreateClipper(DWORD Flags,
LPDIRECTDRAWCLIPPER *Clipper,
IUnknown *UnkOuter)
{ {
IDirectDrawClipperImpl* object; struct ddraw_clipper *object;
HRESULT hr; HRESULT hr;
TRACE("flags %#x, clipper %p, outer_unknown %p.\n", TRACE("flags %#x, clipper %p, outer_unknown %p.\n",
Flags, Clipper, UnkOuter); flags, clipper, outer_unknown);
if (UnkOuter) if (outer_unknown)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
wined3d_mutex_lock(); wined3d_mutex_lock();
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
sizeof(IDirectDrawClipperImpl)); if (!object)
if (object == NULL)
{ {
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -3548,7 +3544,7 @@ DirectDrawCreateClipper(DWORD Flags,
} }
TRACE("Created clipper %p.\n", object); TRACE("Created clipper %p.\n", object);
*Clipper = &object->IDirectDrawClipper_iface; *clipper = &object->IDirectDrawClipper_iface;
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DD_OK; return DD_OK;

View File

@ -43,7 +43,6 @@ extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HI
/* Typdef the interfaces */ /* Typdef the interfaces */
typedef struct IDirectDrawImpl IDirectDrawImpl; typedef struct IDirectDrawImpl IDirectDrawImpl;
typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl; typedef struct IDirectDrawSurfaceImpl IDirectDrawSurfaceImpl;
typedef struct IDirectDrawClipperImpl IDirectDrawClipperImpl;
typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl; typedef struct IDirectDrawPaletteImpl IDirectDrawPaletteImpl;
typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl; typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
typedef struct IDirect3DLightImpl IDirect3DLightImpl; typedef struct IDirect3DLightImpl IDirect3DLightImpl;
@ -192,7 +191,7 @@ struct IDirectDrawSurfaceImpl
UINT mipmap_level; UINT mipmap_level;
/* Clipper objects */ /* Clipper objects */
IDirectDrawClipperImpl *clipper; struct ddraw_clipper *clipper;
/* For the ddraw surface list */ /* For the ddraw surface list */
struct list surface_list_entry; struct list surface_list_entry;
@ -355,20 +354,16 @@ IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice2(IDirect3DDevice2 *iface)
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) DECLSPEC_HIDDEN; IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice3(IDirect3DDevice3 *iface) DECLSPEC_HIDDEN;
IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface) DECLSPEC_HIDDEN; IDirect3DDeviceImpl *unsafe_impl_from_IDirect3DDevice7(IDirect3DDevice7 *iface) DECLSPEC_HIDDEN;
/***************************************************************************** struct ddraw_clipper
* IDirectDrawClipper implementation structure
*****************************************************************************/
struct IDirectDrawClipperImpl
{ {
IDirectDrawClipper IDirectDrawClipper_iface; IDirectDrawClipper IDirectDrawClipper_iface;
LONG ref; LONG ref;
HWND window;
struct wined3d_clipper *wineD3DClipper;
BOOL initialized; BOOL initialized;
}; };
HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) DECLSPEC_HIDDEN; HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper) DECLSPEC_HIDDEN;
IDirectDrawClipperImpl *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) DECLSPEC_HIDDEN; struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) DECLSPEC_HIDDEN;
/***************************************************************************** /*****************************************************************************
* IDirectDrawPalette implementation structure * IDirectDrawPalette implementation structure

View File

@ -3907,10 +3907,9 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
IDirectDrawClipper *iclipper) IDirectDrawClipper *iclipper)
{ {
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface); IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
IDirectDrawClipperImpl *clipper = unsafe_impl_from_IDirectDrawClipper(iclipper); struct ddraw_clipper *clipper = unsafe_impl_from_IDirectDrawClipper(iclipper);
IDirectDrawClipperImpl *oldClipper = This->clipper; struct ddraw_clipper *old_clipper = This->clipper;
HWND clipWindow; HWND clipWindow;
HRESULT hr;
TRACE("iface %p, clipper %p.\n", iface, iclipper); TRACE("iface %p, clipper %p.\n", iface, iclipper);
@ -3925,11 +3924,8 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
if (clipper != NULL) if (clipper != NULL)
IDirectDrawClipper_AddRef(iclipper); IDirectDrawClipper_AddRef(iclipper);
if(oldClipper) if (old_clipper)
IDirectDrawClipper_Release(&oldClipper->IDirectDrawClipper_iface); IDirectDrawClipper_Release(&old_clipper->IDirectDrawClipper_iface);
hr = wined3d_surface_set_clipper(This->wined3d_surface,
This->clipper ? This->clipper->wineD3DClipper : NULL);
if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && This->ddraw->wined3d_swapchain) if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && This->ddraw->wined3d_swapchain)
{ {
@ -3952,7 +3948,7 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return DD_OK;
} }
static HRESULT WINAPI ddraw_surface4_SetClipper(IDirectDrawSurface4 *iface, IDirectDrawClipper *clipper) static HRESULT WINAPI ddraw_surface4_SetClipper(IDirectDrawSurface4 *iface, IDirectDrawClipper *clipper)

View File

@ -6,7 +6,6 @@ C_SRCS = \
arb_program_shader.c \ arb_program_shader.c \
ati_fragment_shader.c \ ati_fragment_shader.c \
buffer.c \ buffer.c \
clipper.c \
context.c \ context.c \
device.c \ device.c \
directx.c \ directx.c \

View File

@ -1,161 +0,0 @@
/*
* Copyright 2000 (c) Marcus Meissner
* Copyright 2000 (c) TransGaming Technologies Inc.
* Copyright 2006 (c) Stefan Dösinger
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdio.h>
#ifdef HAVE_FLOAT_H
# include <float.h>
#endif
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
ULONG CDECL wined3d_clipper_incref(struct wined3d_clipper *clipper)
{
ULONG refcount = InterlockedIncrement(&clipper->ref);
TRACE("%p increasing refcount to %u.\n", clipper, refcount);
return refcount;
}
ULONG CDECL wined3d_clipper_decref(struct wined3d_clipper *clipper)
{
ULONG refcount = InterlockedDecrement(&clipper->ref);
TRACE("%p decreasing refcount to %u.\n", clipper, refcount);
if (!refcount)
HeapFree(GetProcessHeap(), 0, clipper);
return refcount;
}
HRESULT CDECL wined3d_clipper_set_window(struct wined3d_clipper *clipper, DWORD flags, HWND window)
{
TRACE("clipper %p, flags %#x, window %p.\n", clipper, flags, window);
if (flags)
{
FIXME("flags %#x, not supported.\n", flags);
return WINED3DERR_INVALIDCALL;
}
clipper->hWnd = window;
return WINED3D_OK;
}
HRESULT CDECL wined3d_clipper_get_clip_list(const struct wined3d_clipper *clipper, const RECT *rect,
RGNDATA *clip_list, DWORD *clip_list_size)
{
TRACE("clipper %p, rect %s, clip_list %p, clip_list_size %p.\n",
clipper, wine_dbgstr_rect(rect), clip_list, clip_list_size);
if (clipper->hWnd)
{
HDC hDC = GetDCEx(clipper->hWnd, NULL, DCX_WINDOW);
if (hDC)
{
HRGN hRgn = CreateRectRgn(0,0,0,0);
if (GetRandomRgn(hDC, hRgn, SYSRGN))
{
if (GetVersion() & 0x80000000)
{
/* map region to screen coordinates */
POINT org;
GetDCOrgEx(hDC, &org);
OffsetRgn(hRgn, org.x, org.y);
}
if (rect)
{
HRGN hRgnClip = CreateRectRgn(rect->left, rect->top,
rect->right, rect->bottom);
CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
DeleteObject(hRgnClip);
}
*clip_list_size = GetRegionData(hRgn, *clip_list_size, clip_list);
}
DeleteObject(hRgn);
ReleaseDC(clipper->hWnd, hDC);
}
return WINED3D_OK;
}
else
{
static unsigned int once;
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;
return WINEDDERR_NOCLIPLIST;
}
}
HRESULT CDECL wined3d_clipper_set_clip_list(struct wined3d_clipper *clipper, const RGNDATA *region, DWORD flags)
{
static unsigned int once;
if (!once++ || !region)
FIXME("clipper %p, region %p, flags %#x stub!\n", clipper, region, flags);
return WINED3D_OK;
}
HRESULT CDECL wined3d_clipper_get_window(const struct wined3d_clipper *clipper, HWND *window)
{
TRACE("clipper %p, window %p.\n", clipper, window);
*window = clipper->hWnd;
return WINED3D_OK;
}
HRESULT CDECL wined3d_clipper_is_clip_list_changed(const struct wined3d_clipper *clipper, BOOL *changed)
{
FIXME("clipper %p, changed %p stub!\n", clipper, changed);
/* XXX What is safest? */
*changed = FALSE;
return WINED3D_OK;
}
struct wined3d_clipper * CDECL wined3d_clipper_create(void)
{
struct wined3d_clipper *clipper;
TRACE("\n");
clipper = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*clipper));
if (!clipper)
{
ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
return NULL;
}
wined3d_clipper_incref(clipper);
return clipper;
}

View File

@ -1469,12 +1469,7 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
|| dst_rect.right > dst_surface->resource.width || dst_rect.right < 0 || dst_rect.right > dst_surface->resource.width || dst_rect.right < 0
|| dst_rect.bottom > dst_surface->resource.height || dst_rect.bottom < 0) || dst_rect.bottom > dst_surface->resource.height || dst_rect.bottom < 0)
{ {
/* The destination rect can be out of bounds on the condition WARN("The application gave us a bad destination rectangle.\n");
* that a clipper is set for the surface. */
if (dst_surface->clipper)
FIXME("Blit clipping not implemented.\n");
else
WARN("The application gave us a bad destination rectangle without a clipper set.\n");
return WINEDDERR_INVALIDRECT; return WINEDDERR_INVALIDRECT;
} }
@ -3305,22 +3300,6 @@ HRESULT CDECL wined3d_surface_update_overlay(struct wined3d_surface *surface, co
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT CDECL wined3d_surface_set_clipper(struct wined3d_surface *surface, struct wined3d_clipper *clipper)
{
TRACE("surface %p, clipper %p.\n", surface, clipper);
surface->clipper = clipper;
return WINED3D_OK;
}
struct wined3d_clipper * CDECL wined3d_surface_get_clipper(const struct wined3d_surface *surface)
{
TRACE("surface %p.\n", surface);
return surface->clipper;
}
HRESULT CDECL wined3d_surface_set_format(struct wined3d_surface *surface, enum wined3d_format_id format_id) HRESULT CDECL wined3d_surface_set_format(struct wined3d_surface *surface, enum wined3d_format_id format_id)
{ {
const struct wined3d_format *format = wined3d_get_format(&surface->resource.device->adapter->gl_info, format_id); const struct wined3d_format *format = wined3d_get_format(&surface->resource.device->adapter->gl_info, format_id);

View File

@ -32,15 +32,6 @@
@ cdecl wined3d_buffer_set_priority(ptr long) @ cdecl wined3d_buffer_set_priority(ptr long)
@ cdecl wined3d_buffer_unmap(ptr) @ cdecl wined3d_buffer_unmap(ptr)
@ cdecl wined3d_clipper_create()
@ cdecl wined3d_clipper_decref(ptr)
@ cdecl wined3d_clipper_get_clip_list(ptr ptr ptr ptr)
@ cdecl wined3d_clipper_get_window(ptr ptr)
@ cdecl wined3d_clipper_incref(ptr)
@ cdecl wined3d_clipper_is_clip_list_changed(ptr ptr)
@ cdecl wined3d_clipper_set_clip_list(ptr ptr long)
@ cdecl wined3d_clipper_set_window(ptr long ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr) @ cdecl wined3d_device_acquire_focus_window(ptr ptr)
@ cdecl wined3d_device_begin_scene(ptr) @ cdecl wined3d_device_begin_scene(ptr)
@ cdecl wined3d_device_begin_stateblock(ptr) @ cdecl wined3d_device_begin_stateblock(ptr)
@ -204,7 +195,6 @@
@ cdecl wined3d_surface_decref(ptr) @ cdecl wined3d_surface_decref(ptr)
@ cdecl wined3d_surface_flip(ptr ptr long) @ cdecl wined3d_surface_flip(ptr ptr long)
@ cdecl wined3d_surface_get_blt_status(ptr long) @ cdecl wined3d_surface_get_blt_status(ptr long)
@ cdecl wined3d_surface_get_clipper(ptr)
@ cdecl wined3d_surface_get_flip_status(ptr long) @ cdecl wined3d_surface_get_flip_status(ptr long)
@ cdecl wined3d_surface_get_overlay_position(ptr ptr ptr) @ cdecl wined3d_surface_get_overlay_position(ptr ptr ptr)
@ cdecl wined3d_surface_get_palette(ptr) @ cdecl wined3d_surface_get_palette(ptr)
@ -220,7 +210,6 @@
@ cdecl wined3d_surface_preload(ptr) @ cdecl wined3d_surface_preload(ptr)
@ cdecl wined3d_surface_releasedc(ptr ptr) @ cdecl wined3d_surface_releasedc(ptr ptr)
@ cdecl wined3d_surface_restore(ptr) @ cdecl wined3d_surface_restore(ptr)
@ cdecl wined3d_surface_set_clipper(ptr ptr)
@ cdecl wined3d_surface_set_color_key(ptr long ptr) @ cdecl wined3d_surface_set_color_key(ptr long ptr)
@ cdecl wined3d_surface_set_format(ptr long) @ cdecl wined3d_surface_set_format(ptr long)
@ cdecl wined3d_surface_set_mem(ptr ptr) @ cdecl wined3d_surface_set_mem(ptr ptr)

View File

@ -1972,13 +1972,6 @@ struct fbo_entry
GLuint id; GLuint id;
}; };
struct wined3d_clipper
{
LONG ref;
HWND hWnd;
};
enum wined3d_container_type enum wined3d_container_type
{ {
WINED3D_CONTAINER_NONE = 0, WINED3D_CONTAINER_NONE = 0,
@ -2053,9 +2046,6 @@ struct wined3d_surface
const struct wined3d_renderbuffer_entry *current_renderbuffer; const struct wined3d_renderbuffer_entry *current_renderbuffer;
SIZE ds_current_size; SIZE ds_current_size;
/* DirectDraw clippers */
struct wined3d_clipper *clipper;
/* DirectDraw Overlay handling */ /* DirectDraw Overlay handling */
RECT overlay_srcrect; RECT overlay_srcrect;
RECT overlay_destrect; RECT overlay_destrect;

View File

@ -1985,7 +1985,6 @@ struct wined3d_parent_ops
struct wined3d; struct wined3d;
struct wined3d_buffer; struct wined3d_buffer;
struct wined3d_clipper;
struct wined3d_device; struct wined3d_device;
struct wined3d_palette; struct wined3d_palette;
struct wined3d_query; struct wined3d_query;
@ -2079,16 +2078,6 @@ void __cdecl wined3d_buffer_preload(struct wined3d_buffer *buffer);
DWORD __cdecl wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD new_priority); DWORD __cdecl wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD new_priority);
void __cdecl wined3d_buffer_unmap(struct wined3d_buffer *buffer); void __cdecl wined3d_buffer_unmap(struct wined3d_buffer *buffer);
struct wined3d_clipper * __cdecl wined3d_clipper_create(void);
ULONG __cdecl wined3d_clipper_decref(struct wined3d_clipper *clipper);
HRESULT __cdecl wined3d_clipper_get_clip_list(const struct wined3d_clipper *clipper,
const RECT *rect, RGNDATA *clip_list, DWORD *clip_list_size);
HRESULT __cdecl wined3d_clipper_get_window(const struct wined3d_clipper *clipper, HWND *hwnd);
ULONG __cdecl wined3d_clipper_incref(struct wined3d_clipper *clipper);
HRESULT __cdecl wined3d_clipper_is_clip_list_changed(const struct wined3d_clipper *clipper, BOOL *changed);
HRESULT __cdecl wined3d_clipper_set_clip_list(struct wined3d_clipper *clipper, const RGNDATA *clip_list, DWORD flags);
HRESULT __cdecl wined3d_clipper_set_window(struct wined3d_clipper *clipper, DWORD flags, HWND hwnd);
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window);
HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_begin_stateblock(struct wined3d_device *device); HRESULT __cdecl wined3d_device_begin_stateblock(struct wined3d_device *device);
@ -2343,7 +2332,6 @@ HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width
ULONG __cdecl wined3d_surface_decref(struct wined3d_surface *surface); ULONG __cdecl wined3d_surface_decref(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override, DWORD flags); HRESULT __cdecl wined3d_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override, DWORD flags);
HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags); HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags);
struct wined3d_clipper * __cdecl wined3d_surface_get_clipper(const struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags); HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags);
HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y); HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y);
struct wined3d_palette * __cdecl wined3d_surface_get_palette(const struct wined3d_surface *surface); struct wined3d_palette * __cdecl wined3d_surface_get_palette(const struct wined3d_surface *surface);
@ -2361,7 +2349,6 @@ HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface,
void __cdecl wined3d_surface_preload(struct wined3d_surface *surface); void __cdecl wined3d_surface_preload(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc); HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc);
HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_set_clipper(struct wined3d_surface *surface, struct wined3d_clipper *clipper);
HRESULT __cdecl wined3d_surface_set_color_key(struct wined3d_surface *surface, HRESULT __cdecl wined3d_surface_set_color_key(struct wined3d_surface *surface,
DWORD flags, const struct wined3d_color_key *color_key); DWORD flags, const struct wined3d_color_key *color_key);
HRESULT __cdecl wined3d_surface_set_format(struct wined3d_surface *surface, enum wined3d_format_id format_id); HRESULT __cdecl wined3d_surface_set_format(struct wined3d_surface *surface, enum wined3d_format_id format_id);