Commit e6fb4537 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Move clipper handling to ddraw.

parent 68e0cd43
......@@ -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;
......
......@@ -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
......
......@@ -3907,10 +3907,9 @@ 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;
TRACE("iface %p, clipper %p.\n", iface, iclipper);
......@@ -3925,11 +3924,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)
{
......@@ -3952,7 +3948,7 @@ static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
wined3d_mutex_unlock();
return hr;
return DD_OK;
}
static HRESULT WINAPI ddraw_surface4_SetClipper(IDirectDrawSurface4 *iface, IDirectDrawClipper *clipper)
......
......@@ -6,7 +6,6 @@ C_SRCS = \
arb_program_shader.c \
ati_fragment_shader.c \
buffer.c \
clipper.c \
context.c \
device.c \
directx.c \
......
/*
* 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;
}
......@@ -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);
......
......@@ -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)
......
......@@ -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;
......
......@@ -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);
......
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