- some cleanup and warning fixes
[wine] / dlls / d3d8 / swapchain.c
1 /*
2  * IDirect3DSwapChain8 implementation
3  *
4  * Copyright 2002 Jason Edmeades
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wingdi.h"
27 #include "wine/debug.h"
28
29 #include "d3d8_private.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
32
33 /* IDirect3DSwapChain IUnknown parts follow: */
34 HRESULT WINAPI IDirect3DSwapChain8Impl_QueryInterface(LPDIRECT3DSWAPCHAIN8 iface,REFIID riid,LPVOID *ppobj)
35 {
36     ICOM_THIS(IDirect3DSwapChain8Impl,iface);
37
38     if (IsEqualGUID(riid, &IID_IUnknown)
39         || IsEqualGUID(riid, &IID_IDirect3DSwapChain8)) {
40         IDirect3DSwapChain8Impl_AddRef(iface);
41         *ppobj = This;
42         return D3D_OK;
43     }
44
45     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
46     return E_NOINTERFACE;
47 }
48
49 ULONG WINAPI IDirect3DSwapChain8Impl_AddRef(LPDIRECT3DSWAPCHAIN8 iface) {
50     ICOM_THIS(IDirect3DSwapChain8Impl,iface);
51     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
52     return ++(This->ref);
53 }
54
55 ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface) {
56     ICOM_THIS(IDirect3DSwapChain8Impl,iface);
57     ULONG ref = --This->ref;
58     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
59     if (ref == 0) {
60         HeapFree(GetProcessHeap(), 0, This);
61     }
62     return ref;
63 }
64
65 /* IDirect3DSwapChain parts follow: */
66 HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
67     ICOM_THIS(IDirect3DSwapChain8Impl,iface);
68     FIXME("(%p) : stub\n", This);
69     return D3D_OK;
70 }
71
72 HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
73     ICOM_THIS(IDirect3DSwapChain8Impl,iface);
74     *ppBackBuffer = (LPDIRECT3DSURFACE8) This->backBuffer;
75     TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, BackBuffer, Type, *ppBackBuffer);
76
77     if (BackBuffer > This->PresentParms.BackBufferCount - 1) {
78         FIXME("Only one backBuffer currently supported\n");
79         return D3DERR_INVALIDCALL;
80     }
81
82     /* Note inc ref on returned surface */
83     IDirect3DSurface8Impl_AddRef((LPDIRECT3DSURFACE8) *ppBackBuffer);
84     return D3D_OK;
85 }
86
87 ICOM_VTABLE(IDirect3DSwapChain8) Direct3DSwapChain8_Vtbl =
88 {
89     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
90     IDirect3DSwapChain8Impl_QueryInterface,
91     IDirect3DSwapChain8Impl_AddRef,
92     IDirect3DSwapChain8Impl_Release,
93     IDirect3DSwapChain8Impl_Present,
94     IDirect3DSwapChain8Impl_GetBackBuffer
95 };