Change SHChangeNotify to be Unicode and ANSI indifferent, as the type
[wine] / dlls / d3d8 / volume.c
1 /*
2  * IDirect3DVolume8 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 "windef.h"
22 #include "winbase.h"
23 #include "winuser.h"
24 #include "wingdi.h"
25 #include "wine/debug.h"
26
27 #include "d3d8_private.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
30
31 /* IDirect3DVolume IUnknown parts follow: */
32 HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface,REFIID riid,LPVOID *ppobj)
33 {
34     ICOM_THIS(IDirect3DVolume8Impl,iface);
35
36     if (IsEqualGUID(riid, &IID_IUnknown)
37         || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
38         IDirect3DVolume8Impl_AddRef(iface);
39         *ppobj = This;
40         return D3D_OK;
41     }
42
43     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
44     return E_NOINTERFACE;
45 }
46
47 ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
48     ICOM_THIS(IDirect3DVolume8Impl,iface);
49     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
50     return ++(This->ref);
51 }
52
53 ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
54     ICOM_THIS(IDirect3DVolume8Impl,iface);
55     ULONG ref = --This->ref;
56     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
57     if (ref == 0) {
58         HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
59         HeapFree(GetProcessHeap(), 0, This);
60     }
61     return ref;
62 }
63
64 /* IDirect3DVolume8: */
65 HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8** ppDevice) {
66     ICOM_THIS(IDirect3DVolume8Impl,iface);
67     TRACE("(%p) : returning %p\n", This, This->Device);
68     *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
69
70     /* Note  Calling this method will increase the internal reference count 
71        on the IDirect3DDevice8 interface. */
72     IDirect3DDevice8Impl_AddRef(*ppDevice);
73
74     return D3D_OK;
75 }
76 HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
77     ICOM_THIS(IDirect3DVolume8Impl,iface);
78     FIXME("(%p) : stub\n", This);    return D3D_OK;
79 }
80 HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID  refguid, void* pData, DWORD* pSizeOfData) {
81     ICOM_THIS(IDirect3DVolume8Impl,iface);
82     FIXME("(%p) : stub\n", This);    return D3D_OK;
83 }
84 HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
85     ICOM_THIS(IDirect3DVolume8Impl,iface);
86     FIXME("(%p) : stub\n", This);    return D3D_OK;
87 }
88
89 HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void** ppContainer) {
90     ICOM_THIS(IDirect3DVolume8Impl,iface);
91     TRACE("(%p) : returning %p\n", This, This->Container);
92     *ppContainer = This->Container;
93     return D3D_OK;
94 }
95 HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC* pDesc) {
96     ICOM_THIS(IDirect3DVolume8Impl,iface);
97     TRACE("(%p) : copying into %p\n", This, pDesc);
98     memcpy(pDesc, &This->myDesc, sizeof(D3DVOLUME_DESC));
99     return D3D_OK;
100 }
101 HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox, DWORD Flags) {
102     ICOM_THIS(IDirect3DVolume8Impl,iface);
103     FIXME("(%p) : pBox=%p stub\n", This, pBox);    
104
105     /* fixme: should we really lock as such? */
106     TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->allocatedMemory);
107
108     pLockedVolume->RowPitch   = This->bytesPerPixel * This->myDesc.Width;                        /* Bytes / row   */
109     pLockedVolume->SlicePitch = This->bytesPerPixel * This->myDesc.Width * This->myDesc.Height;  /* Bytes / slice */
110     if (!pBox) {
111         TRACE("No box supplied - all is ok\n");
112         pLockedVolume->pBits = This->allocatedMemory;
113     } else {
114         TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, 
115                   pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
116         pLockedVolume->pBits = This->allocatedMemory + 
117             (pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
118             (pLockedVolume->RowPitch * pBox->Top) + 
119             (pBox->Left * This->bytesPerPixel);
120     }
121     TRACE("returning pBits=%p, rpitch=%d, spitch=%d\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
122     return D3D_OK;
123
124
125
126     return D3D_OK;
127 }
128 HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
129     ICOM_THIS(IDirect3DVolume8Impl,iface);
130     TRACE("(%p) : stub\n", This);
131     if (This->Container) {
132         IDirect3DVolumeTexture8 *cont = This->Container;
133
134         int containerType = IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) cont);
135         if (containerType == D3DRTYPE_VOLUMETEXTURE) {
136             IDirect3DTexture8Impl *pTexture = (IDirect3DTexture8Impl *)cont;
137             pTexture->Dirty = TRUE;
138         } else {
139             FIXME("Set dirty on container type %d\n", containerType);
140         }
141     }
142     return D3D_OK;
143 }
144
145
146 ICOM_VTABLE(IDirect3DVolume8) Direct3DVolume8_Vtbl =
147 {
148     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
149     IDirect3DVolume8Impl_QueryInterface,
150     IDirect3DVolume8Impl_AddRef,
151     IDirect3DVolume8Impl_Release,
152     IDirect3DVolume8Impl_GetDevice,
153     IDirect3DVolume8Impl_SetPrivateData,
154     IDirect3DVolume8Impl_GetPrivateData,
155     IDirect3DVolume8Impl_FreePrivateData,
156     IDirect3DVolume8Impl_GetContainer,
157     IDirect3DVolume8Impl_GetDesc,
158     IDirect3DVolume8Impl_LockBox,
159     IDirect3DVolume8Impl_UnlockBox
160 };