wined3d: Directly pass the texture to texture_activate_dimensions().
[wine.git] / dlls / wined3d / clipper.c
blob48ce06f76d4cdfad6af856aae97c9956768e414b
1 /* IWineD3DClipper implementation
3 * Copyright 2000 (c) Marcus Meissner
4 * Copyright 2000 (c) TransGaming Technologies Inc.
5 * Copyright 2006 (c) Stefan Dösinger
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include <stdio.h>
24 #ifdef HAVE_FLOAT_H
25 # include <float.h>
26 #endif
27 #include "wined3d_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
31 static HRESULT WINAPI IWineD3DClipperImpl_QueryInterface(IWineD3DClipper *iface, REFIID riid, void **object)
33 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
35 if (IsEqualGUID(riid, &IID_IWineD3DClipper)
36 || IsEqualGUID(riid, &IID_IUnknown))
38 IUnknown_AddRef(iface);
39 *object = iface;
40 return S_OK;
43 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
45 *object = NULL;
46 return E_NOINTERFACE;
49 static ULONG WINAPI IWineD3DClipperImpl_AddRef(IWineD3DClipper *iface )
51 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
52 ULONG ref = InterlockedIncrement(&This->ref);
54 TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
56 return ref;
59 static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface)
61 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
62 ULONG ref = InterlockedDecrement(&This->ref);
64 TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
66 if (!ref) HeapFree(GetProcessHeap(), 0, This);
68 return ref;
71 static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD Flags, HWND hWnd)
73 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
75 TRACE("(%p)->(0x%08x,%p)\n", This, Flags, hWnd);
76 if( Flags )
78 FIXME("Flags = 0x%08x, not supported.\n",Flags);
79 return WINED3DERR_INVALIDCALL;
82 This->hWnd = hWnd;
83 return WINED3D_OK;
86 static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
87 RGNDATA *ClipList, DWORD *Size)
89 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
90 TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
92 if (This->hWnd)
94 HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW);
95 if (hDC)
97 HRGN hRgn = CreateRectRgn(0,0,0,0);
98 if (GetRandomRgn(hDC, hRgn, SYSRGN))
100 if (GetVersion() & 0x80000000)
102 /* map region to screen coordinates */
103 POINT org;
104 GetDCOrgEx( hDC, &org );
105 OffsetRgn( hRgn, org.x, org.y );
107 if (Rect)
109 HRGN hRgnClip = CreateRectRgn(Rect->left, Rect->top,
110 Rect->right, Rect->bottom);
111 CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
112 DeleteObject(hRgnClip);
114 *Size = GetRegionData(hRgn, *Size, ClipList);
116 DeleteObject(hRgn);
117 ReleaseDC(This->hWnd, hDC);
119 return WINED3D_OK;
121 else
123 static int warned = 0;
124 if (warned++ < 10)
125 FIXME("(%p,%p,%p,%p),stub!\n",This,Rect,ClipList,Size);
126 if (Size) *Size=0;
127 return WINEDDERR_NOCLIPLIST;
131 static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
133 static int warned = 0;
135 if (warned++ < 10 || !rgn)
136 FIXME("iface %p, region %p, flags %#x stub!\n", iface, rgn, Flags);
138 return WINED3D_OK;
141 static HRESULT WINAPI IWineD3DClipperImpl_GetHwnd(IWineD3DClipper *iface, HWND *hwnd)
143 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
144 TRACE("(%p)->(%p)\n", This, hwnd);
146 *hwnd = This->hWnd;
147 return WINED3D_OK;
150 static HRESULT WINAPI IWineD3DClipperImpl_IsClipListChanged(IWineD3DClipper *iface, BOOL *changed)
152 FIXME("iface %p, changed %p stub!\n", iface, changed);
154 /* XXX What is safest? */
155 *changed = FALSE;
157 return WINED3D_OK;
160 static const IWineD3DClipperVtbl IWineD3DClipper_Vtbl =
162 IWineD3DClipperImpl_QueryInterface,
163 IWineD3DClipperImpl_AddRef,
164 IWineD3DClipperImpl_Release,
165 IWineD3DClipperImpl_GetClipList,
166 IWineD3DClipperImpl_GetHwnd,
167 IWineD3DClipperImpl_IsClipListChanged,
168 IWineD3DClipperImpl_SetClipList,
169 IWineD3DClipperImpl_SetHwnd
172 IWineD3DClipper * WINAPI WineDirect3DCreateClipper(void)
174 IWineD3DClipperImpl *obj;
176 TRACE("\n");
178 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
179 if(!obj)
181 ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
182 return NULL;
185 obj->lpVtbl = &IWineD3DClipper_Vtbl;
187 IWineD3DClipper_AddRef((IWineD3DClipper *)obj);
188 return (IWineD3DClipper *) obj;