[PATCH 1/5] ddraw: Move clipper handling to ddraw.

Henri Verbeet hverbeet at codeweavers.com
Mon Dec 12 13:53:55 CST 2011


---
 dlls/ddraw/clipper.c           |  582 ++++++++++++++++++----------------------
 dlls/ddraw/ddraw.c             |   18 +-
 dlls/ddraw/ddraw_private.h     |   15 +-
 dlls/ddraw/surface.c           |   11 +-
 dlls/wined3d/Makefile.in       |    1 -
 dlls/wined3d/clipper.c         |  161 -----------
 dlls/wined3d/surface.c         |   23 +--
 dlls/wined3d/wined3d.spec      |   11 -
 dlls/wined3d/wined3d_private.h |   10 -
 include/wine/wined3d.h         |   13 -
 10 files changed, 276 insertions(+), 569 deletions(-)
 rewrite dlls/ddraw/clipper.c (74%)
 delete mode 100644 dlls/wined3d/clipper.c

diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c
dissimilarity index 74%
index 20d3903..c67a951 100644
--- a/dlls/ddraw/clipper.c
+++ b/dlls/ddraw/clipper.c
@@ -1,323 +1,259 @@
-/* DirectDrawClipper implementation
- *
- * 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 "wine/port.h"
-
-#include "ddraw_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
-
-static inline IDirectDrawClipperImpl *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
-{
-    return CONTAINING_RECORD(iface, IDirectDrawClipperImpl, IDirectDrawClipper_iface);
-}
-
-/*****************************************************************************
- * 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)
-{
-
-    TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppvObj);
-
-    if (IsEqualGUID(&IID_IDirectDrawClipper, riid)
-            || IsEqualGUID(&IID_IUnknown, riid))
-    {
-        IUnknown_AddRef(iface);
-        *ppvObj = iface;
-        return S_OK;
-    }
-
-    return E_NOINTERFACE;
-}
-
-/*****************************************************************************
- * 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);
-    ULONG ref = InterlockedIncrement(&This->ref);
-
-    TRACE("%p increasing refcount to %u.\n", This, ref);
-
-    return ref;
-}
-
-/*****************************************************************************
- * 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);
-    ULONG ref = InterlockedDecrement(&This->ref);
-
-    TRACE("%p decreasing refcount to %u.\n", This, ref);
-
-    if (ref == 0)
-    {
-        wined3d_mutex_lock();
-        wined3d_clipper_decref(This->wineD3DClipper);
-        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();
-    hr = wined3d_clipper_set_window(This->wineD3DClipper, dwFlags, hWnd);
-    wined3d_mutex_unlock();
-
-    switch(hr)
-    {
-        case WINED3DERR_INVALIDCALL:        return DDERR_INVALIDPARAMS;
-        default:                            return hr;
-    }
-}
-
-/*****************************************************************************
- * IDirectDrawClipper::GetClipList
- *
- * Retrieve a copy of the clip list
- *
- * Arguments:
- *  Rect: Rectangle to be used to clip the clip list or NULL for the
- *        entire clip list
- *  ClipList: structure for the resulting copy of the clip list.
- *            If NULL, fills Size up to the number of bytes necessary to hold
- *            the entire clip.
- *  Size: Size of resulting clip list; size of the buffer at ClipList
- *        or, if ClipList is NULL, receives the required size of the buffer
- *        in bytes
- *
- * RETURNS
- *  Either DD_OK or DDERR_*
- ************************************************************************/
-static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *iface, RECT *lpRect,
-        RGNDATA *lpClipList, DWORD *lpdwSize)
-{
-    IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
-    HRESULT hr;
-
-    TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
-            iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize);
-
-    wined3d_mutex_lock();
-    hr = wined3d_clipper_get_clip_list(This->wineD3DClipper, lpRect, lpClipList, lpdwSize);
-    wined3d_mutex_unlock();
-
-    return hr;
-}
-
-/*****************************************************************************
- * IDirectDrawClipper::SetClipList
- *
- * Sets or deletes (if lprgn is NULL) the clip list
- *
- * This implementation is a stub and returns DD_OK always to make the app
- * happy.
- *
- * PARAMS
- *  lprgn   Pointer to a LRGNDATA structure or NULL
- *  dwFlags not used, must be 0
- * RETURNS
- *  Either DD_OK or DDERR_*
- *****************************************************************************/
-static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *iface, RGNDATA *lprgn,
-        DWORD dwFlag)
-{
-    IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
-    HRESULT hr;
-
-    TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag);
-
-    wined3d_mutex_lock();
-    hr = wined3d_clipper_set_clip_list(This->wineD3DClipper, lprgn, dwFlag);
-    wined3d_mutex_unlock();
-
-    return hr;
-}
-
-/*****************************************************************************
- * 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);
-    HRESULT hr;
-
-    TRACE("iface %p, window %p.\n", iface, hWndPtr);
-
-    wined3d_mutex_lock();
-    hr = wined3d_clipper_get_window(This->wineD3DClipper, hWndPtr);
-    wined3d_mutex_unlock();
-
-    return hr;
-}
-
-/*****************************************************************************
- * IDirectDrawClipper::Initialize
- *
- * 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);
-
-    TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, dwFlags);
-
-    wined3d_mutex_lock();
-    if (This->initialized)
-    {
-        wined3d_mutex_unlock();
-        return DDERR_ALREADYINITIALIZED;
-    }
-
-    This->initialized = TRUE;
-    wined3d_mutex_unlock();
-
-    return DD_OK;
-}
-
-/*****************************************************************************
- * 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);
-
-    /* XXX What is safest? */
-    *lpbChanged = FALSE;
-
-    return DD_OK;
-}
-
-/*****************************************************************************
- * The VTable
- *****************************************************************************/
-static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl =
-{
-    IDirectDrawClipperImpl_QueryInterface,
-    IDirectDrawClipperImpl_AddRef,
-    IDirectDrawClipperImpl_Release,
-    IDirectDrawClipperImpl_GetClipList,
-    IDirectDrawClipperImpl_GetHWnd,
-    IDirectDrawClipperImpl_Initialize,
-    IDirectDrawClipperImpl_IsClipListChanged,
-    IDirectDrawClipperImpl_SetClipList,
-    IDirectDrawClipperImpl_SetHWnd
-};
-
-HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper)
-{
-    clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl;
-    clipper->ref = 1;
-    clipper->wineD3DClipper = wined3d_clipper_create();
-    if (!clipper->wineD3DClipper)
-    {
-        WARN("Failed to create wined3d clipper.\n");
-        return E_OUTOFMEMORY;
-    }
-
-    return DD_OK;
-}
-
-IDirectDrawClipperImpl *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
-{
-    if (!iface)
-        return NULL;
-    assert(iface->lpVtbl == &ddraw_clipper_vtbl);
-
-    return impl_from_IDirectDrawClipper(iface);
-}
+/* DirectDrawClipper implementation
+ *
+ * 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 "wine/port.h"
+
+#include "ddraw_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
+
+static inline struct ddraw_clipper *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
+{
+    return CONTAINING_RECORD(iface, struct ddraw_clipper, IDirectDrawClipper_iface);
+}
+
+static HRESULT WINAPI ddraw_clipper_QueryInterface(IDirectDrawClipper *iface, REFIID iid, void **object)
+{
+    struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
+
+    TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object);
+
+    if (IsEqualGUID(&IID_IDirectDrawClipper, iid)
+            || IsEqualGUID(&IID_IUnknown, iid))
+    {
+        IDirectDrawClipper_AddRef(&clipper->IDirectDrawClipper_iface);
+        *object = &clipper->IDirectDrawClipper_iface;
+        return S_OK;
+    }
+
+    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
+    *object = NULL;
+
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI ddraw_clipper_AddRef(IDirectDrawClipper *iface)
+{
+    struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
+    ULONG refcount = InterlockedIncrement(&clipper->ref);
+
+    TRACE("%p increasing refcount to %u.\n", clipper, refcount);
+
+    return refcount;
+}
+
+static ULONG WINAPI ddraw_clipper_Release(IDirectDrawClipper *iface)
+{
+    struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
+    ULONG refcount = InterlockedDecrement(&clipper->ref);
+
+    TRACE("%p decreasing refcount to %u.\n", clipper, refcount);
+
+    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)
+    {
+        FIXME("flags %#x, not supported.\n", flags);
+        return DDERR_INVALIDPARAMS;
+    }
+
+    wined3d_mutex_lock();
+    clipper->window = window;
+    wined3d_mutex_unlock();
+
+    return DD_OK;
+}
+
+/*****************************************************************************
+ * IDirectDrawClipper::GetClipList
+ *
+ * Retrieve a copy of the clip list
+ *
+ * Arguments:
+ *  rect: Rectangle to be used to clip the clip list or NULL for the
+ *      entire 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
+ *      the entire clip.
+ *  clip_list_size: Size of resulting clip list; size of the buffer at clip_list
+ *      or, if clip_list is NULL, receives the required size of the buffer
+ *      in bytes.
+ *
+ * RETURNS
+ *  Either DD_OK or DDERR_*
+ ************************************************************************/
+static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT *rect,
+        RGNDATA *clip_list, DWORD *clip_list_size)
+{
+    struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
+    static unsigned int once;
+
+    TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
+            iface, wine_dbgstr_rect(rect), clip_list, clip_list_size);
+
+    wined3d_mutex_lock();
+
+    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
+ *
+ * Sets or deletes (if region is NULL) the clip list
+ *
+ * This implementation is a stub and returns DD_OK always to make the app
+ * happy.
+ *
+ * PARAMS
+ *  region  Pointer to a LRGNDATA structure or NULL
+ *  flags   not used, must be 0
+ * RETURNS
+ *  Either DD_OK or DDERR_*
+ *****************************************************************************/
+static HRESULT WINAPI ddraw_clipper_SetClipList(IDirectDrawClipper *iface, RGNDATA *region, DWORD flags)
+{
+    FIXME("iface %p, region %p, flags %#x stub!\n", iface, region, flags);
+
+    return DD_OK;
+}
+
+static HRESULT WINAPI ddraw_clipper_GetHWnd(IDirectDrawClipper *iface, HWND *window)
+{
+    struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
+
+    TRACE("iface %p, window %p.\n", iface, window);
+
+    wined3d_mutex_lock();
+    *window = clipper->window;
+    wined3d_mutex_unlock();
+
+    return DD_OK;
+}
+
+static HRESULT WINAPI ddraw_clipper_Initialize(IDirectDrawClipper *iface,
+        IDirectDraw *ddraw, DWORD flags)
+{
+    struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
+
+    TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, flags);
+
+    wined3d_mutex_lock();
+    if (clipper->initialized)
+    {
+        wined3d_mutex_unlock();
+        return DDERR_ALREADYINITIALIZED;
+    }
+
+    clipper->initialized = TRUE;
+    wined3d_mutex_unlock();
+
+    return DD_OK;
+}
+
+static HRESULT WINAPI ddraw_clipper_IsClipListChanged(IDirectDrawClipper *iface, BOOL *changed)
+{
+    FIXME("iface %p, changed %p stub!\n", iface, changed);
+
+    /* XXX What is safest? */
+    *changed = FALSE;
+
+    return DD_OK;
+}
+
+static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl =
+{
+    ddraw_clipper_QueryInterface,
+    ddraw_clipper_AddRef,
+    ddraw_clipper_Release,
+    ddraw_clipper_GetClipList,
+    ddraw_clipper_GetHWnd,
+    ddraw_clipper_Initialize,
+    ddraw_clipper_IsClipListChanged,
+    ddraw_clipper_SetClipList,
+    ddraw_clipper_SetHWnd,
+};
+
+HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper)
+{
+    clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl;
+    clipper->ref = 1;
+
+    return DD_OK;
+}
+
+struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
+{
+    if (!iface)
+        return NULL;
+    assert(iface->lpVtbl == &ddraw_clipper_vtbl);
+
+    return impl_from_IDirectDrawClipper(iface);
+}
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index b344b81..7ff9a73 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -3514,25 +3514,21 @@ static HRESULT WINAPI ddraw1_EnumSurfaces(IDirectDraw *iface, DWORD flags,
  *  E_OUTOFMEMORY if allocating the object failed
  *
  *****************************************************************************/
-HRESULT WINAPI
-DirectDrawCreateClipper(DWORD Flags,
-                        LPDIRECTDRAWCLIPPER *Clipper,
-                        IUnknown *UnkOuter)
+HRESULT WINAPI DirectDrawCreateClipper(DWORD flags, IDirectDrawClipper **clipper, IUnknown *outer_unknown)
 {
-    IDirectDrawClipperImpl* object;
+    struct ddraw_clipper *object;
     HRESULT hr;
 
     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;
 
     wined3d_mutex_lock();
 
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
-                     sizeof(IDirectDrawClipperImpl));
-    if (object == NULL)
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+    if (!object)
     {
         wined3d_mutex_unlock();
         return E_OUTOFMEMORY;
@@ -3548,7 +3544,7 @@ DirectDrawCreateClipper(DWORD Flags,
     }
 
     TRACE("Created clipper %p.\n", object);
-    *Clipper = &object->IDirectDrawClipper_iface;
+    *clipper = &object->IDirectDrawClipper_iface;
     wined3d_mutex_unlock();
 
     return DD_OK;
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index b85ea4a..2d1bff0 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -43,7 +43,6 @@ extern const struct wined3d_parent_ops ddraw_null_wined3d_parent_ops DECLSPEC_HI
 /* Typdef the interfaces */
 typedef struct IDirectDrawImpl            IDirectDrawImpl;
 typedef struct IDirectDrawSurfaceImpl     IDirectDrawSurfaceImpl;
-typedef struct IDirectDrawClipperImpl     IDirectDrawClipperImpl;
 typedef struct IDirectDrawPaletteImpl     IDirectDrawPaletteImpl;
 typedef struct IDirect3DDeviceImpl        IDirect3DDeviceImpl;
 typedef struct IDirect3DLightImpl         IDirect3DLightImpl;
@@ -192,7 +191,7 @@ struct IDirectDrawSurfaceImpl
     UINT                    mipmap_level;
 
     /* Clipper objects */
-    IDirectDrawClipperImpl  *clipper;
+    struct ddraw_clipper *clipper;
 
     /* For the ddraw surface list */
     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_IDirect3DDevice7(IDirect3DDevice7 *iface) DECLSPEC_HIDDEN;
 
-/*****************************************************************************
- * IDirectDrawClipper implementation structure
- *****************************************************************************/
-struct IDirectDrawClipperImpl
+struct ddraw_clipper
 {
     IDirectDrawClipper IDirectDrawClipper_iface;
     LONG ref;
-
-    struct wined3d_clipper *wineD3DClipper;
+    HWND window;
     BOOL initialized;
 };
 
-HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) DECLSPEC_HIDDEN;
-IDirectDrawClipperImpl *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) DECLSPEC_HIDDEN;
+HRESULT ddraw_clipper_init(struct ddraw_clipper *clipper) DECLSPEC_HIDDEN;
+struct ddraw_clipper *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface) DECLSPEC_HIDDEN;
 
 /*****************************************************************************
  * IDirectDrawPalette implementation structure
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 6642dea..c49b6c2 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -3907,8 +3907,8 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
         IDirectDrawClipper *iclipper)
 {
     IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
-    IDirectDrawClipperImpl *clipper = unsafe_impl_from_IDirectDrawClipper(iclipper);
-    IDirectDrawClipperImpl *oldClipper = This->clipper;
+    struct ddraw_clipper *clipper = unsafe_impl_from_IDirectDrawClipper(iclipper);
+    struct ddraw_clipper *old_clipper = This->clipper;
     HWND clipWindow;
     HRESULT hr;
 
@@ -3925,11 +3925,8 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
 
     if (clipper != NULL)
         IDirectDrawClipper_AddRef(iclipper);
-    if(oldClipper)
-        IDirectDrawClipper_Release(&oldClipper->IDirectDrawClipper_iface);
-
-    hr = wined3d_surface_set_clipper(This->wined3d_surface,
-            This->clipper ? This->clipper->wineD3DClipper : NULL);
+    if (old_clipper)
+        IDirectDrawClipper_Release(&old_clipper->IDirectDrawClipper_iface);
 
     if ((This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && This->ddraw->wined3d_swapchain)
     {
diff --git a/dlls/wined3d/Makefile.in b/dlls/wined3d/Makefile.in
index 63f7b69..fbfa1cc 100644
--- a/dlls/wined3d/Makefile.in
+++ b/dlls/wined3d/Makefile.in
@@ -6,7 +6,6 @@ C_SRCS = \
 	arb_program_shader.c \
 	ati_fragment_shader.c \
 	buffer.c \
-	clipper.c \
 	context.c \
 	device.c \
 	directx.c \
diff --git a/dlls/wined3d/clipper.c b/dlls/wined3d/clipper.c
deleted file mode 100644
index 0829cde..0000000
--- a/dlls/wined3d/clipper.c
+++ /dev/null
@@ -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;
-}
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 16e79f4..0457ac6 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -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.bottom > dst_surface->resource.height || dst_rect.bottom < 0)
     {
-        /* The destination rect can be out of bounds on the condition
-         * 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");
+        WARN("The application gave us a bad destination rectangle.\n");
         return WINEDDERR_INVALIDRECT;
     }
 
@@ -3305,22 +3300,6 @@ HRESULT CDECL wined3d_surface_update_overlay(struct wined3d_surface *surface, co
     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)
 {
     const struct wined3d_format *format = wined3d_get_format(&surface->resource.device->adapter->gl_info, format_id);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index d3fb59e..0b25f7c 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -32,15 +32,6 @@
 @ cdecl wined3d_buffer_set_priority(ptr long)
 @ 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_begin_scene(ptr)
 @ cdecl wined3d_device_begin_stateblock(ptr)
@@ -204,7 +195,6 @@
 @ cdecl wined3d_surface_decref(ptr)
 @ cdecl wined3d_surface_flip(ptr 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_overlay_position(ptr ptr ptr)
 @ cdecl wined3d_surface_get_palette(ptr)
@@ -220,7 +210,6 @@
 @ cdecl wined3d_surface_preload(ptr)
 @ cdecl wined3d_surface_releasedc(ptr 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_format(ptr long)
 @ cdecl wined3d_surface_set_mem(ptr ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 2b3d34c..1cacdea 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1972,13 +1972,6 @@ struct fbo_entry
     GLuint id;
 };
 
-struct wined3d_clipper
-{
-    LONG ref;
-
-    HWND hWnd;
-};
-
 enum wined3d_container_type
 {
     WINED3D_CONTAINER_NONE = 0,
@@ -2053,9 +2046,6 @@ struct wined3d_surface
     const struct wined3d_renderbuffer_entry *current_renderbuffer;
     SIZE ds_current_size;
 
-    /* DirectDraw clippers */
-    struct wined3d_clipper *clipper;
-
     /* DirectDraw Overlay handling */
     RECT                      overlay_srcrect;
     RECT                      overlay_destrect;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 54baa3d..cffb206 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1985,7 +1985,6 @@ struct wined3d_parent_ops
 
 struct wined3d;
 struct wined3d_buffer;
-struct wined3d_clipper;
 struct wined3d_device;
 struct wined3d_palette;
 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);
 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_begin_scene(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);
 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);
-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_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y);
 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);
 HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc);
 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,
         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);
-- 
1.7.3.4




More information about the wine-patches mailing list