Fix Slovenian keyboard layout to better match the XFree86 one.
[wine/hacks.git] / dlls / d3d8 / volume.c
blob5cf44e1c693c1d45c46b4dd43464e3ec955ec449
1 /*
2 * IDirect3DVolume8 implementation
4 * Copyright 2002-2003 Jason Edmeades
5 * Raphael Junqueira
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
24 #include <stdarg.h>
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "wingdi.h"
32 #include "wine/debug.h"
34 #include "d3d8_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
38 /* IDirect3DVolume IUnknown parts follow: */
39 HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(LPDIRECT3DVOLUME8 iface, REFIID riid, LPVOID* ppobj) {
40 ICOM_THIS(IDirect3DVolume8Impl,iface);
42 if (IsEqualGUID(riid, &IID_IUnknown)
43 || IsEqualGUID(riid, &IID_IDirect3DVolume8)) {
44 IDirect3DVolume8Impl_AddRef(iface);
45 *ppobj = This;
46 return D3D_OK;
49 WARN("(%p)->(%s,%p) not found\n", This, debugstr_guid(riid), ppobj);
50 return E_NOINTERFACE;
53 ULONG WINAPI IDirect3DVolume8Impl_AddRef(LPDIRECT3DVOLUME8 iface) {
54 ICOM_THIS(IDirect3DVolume8Impl,iface);
55 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
56 return ++(This->ref);
59 ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
60 ICOM_THIS(IDirect3DVolume8Impl,iface);
61 ULONG ref = --This->ref;
62 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
63 if (ref == 0) {
64 HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
65 HeapFree(GetProcessHeap(), 0, This);
67 return ref;
70 /* IDirect3DVolume8: */
71 HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, IDirect3DDevice8** ppDevice) {
72 ICOM_THIS(IDirect3DVolume8Impl,iface);
73 TRACE("(%p) : returning %p\n", This, This->Device);
74 *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
76 /* Note Calling this method will increase the internal reference count
77 on the IDirect3DDevice8 interface. */
78 IDirect3DDevice8Impl_AddRef(*ppDevice);
80 return D3D_OK;
83 HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
84 ICOM_THIS(IDirect3DVolume8Impl,iface);
85 FIXME("(%p) : stub\n", This);
86 return D3D_OK;
89 HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
90 ICOM_THIS(IDirect3DVolume8Impl,iface);
91 FIXME("(%p) : stub\n", This);
92 return D3D_OK;
95 HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 iface, REFGUID refguid) {
96 ICOM_THIS(IDirect3DVolume8Impl,iface);
97 FIXME("(%p) : stub\n", This);
98 return D3D_OK;
101 HRESULT WINAPI IDirect3DVolume8Impl_GetContainer(LPDIRECT3DVOLUME8 iface, REFIID riid, void** ppContainer) {
102 ICOM_THIS(IDirect3DVolume8Impl,iface);
103 TRACE("(%p) : returning %p\n", This, This->Container);
104 *ppContainer = This->Container;
105 IUnknown_AddRef(This->Container);
106 return D3D_OK;
109 HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DVOLUME_DESC* pDesc) {
110 ICOM_THIS(IDirect3DVolume8Impl,iface);
111 TRACE("(%p) : copying into %p\n", This, pDesc);
112 memcpy(pDesc, &This->myDesc, sizeof(D3DVOLUME_DESC));
113 return D3D_OK;
116 HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
117 ICOM_THIS(IDirect3DVolume8Impl,iface);
118 FIXME("(%p) : pBox=%p stub\n", This, pBox);
120 /* fixme: should we really lock as such? */
121 TRACE("(%p) : box=%p, output pbox=%p, allMem=%p\n", This, pBox, pLockedVolume, This->allocatedMemory);
123 pLockedVolume->RowPitch = This->bytesPerPixel * This->myDesc.Width; /* Bytes / row */
124 pLockedVolume->SlicePitch = This->bytesPerPixel * This->myDesc.Width * This->myDesc.Height; /* Bytes / slice */
125 if (!pBox) {
126 TRACE("No box supplied - all is ok\n");
127 pLockedVolume->pBits = This->allocatedMemory;
128 This->lockedBox.Left = 0;
129 This->lockedBox.Top = 0;
130 This->lockedBox.Front = 0;
131 This->lockedBox.Right = This->myDesc.Width;
132 This->lockedBox.Bottom = This->myDesc.Height;
133 This->lockedBox.Back = This->myDesc.Depth;
134 } else {
135 TRACE("Lock Box (%p) = l %d, t %d, r %d, b %d, fr %d, ba %d\n", pBox, pBox->Left, pBox->Top, pBox->Right, pBox->Bottom, pBox->Front, pBox->Back);
136 pLockedVolume->pBits = This->allocatedMemory +
137 (pLockedVolume->SlicePitch * pBox->Front) + /* FIXME: is front < back or vica versa? */
138 (pLockedVolume->RowPitch * pBox->Top) +
139 (pBox->Left * This->bytesPerPixel);
140 This->lockedBox.Left = pBox->Left;
141 This->lockedBox.Top = pBox->Top;
142 This->lockedBox.Front = pBox->Front;
143 This->lockedBox.Right = pBox->Right;
144 This->lockedBox.Bottom = pBox->Bottom;
145 This->lockedBox.Back = pBox->Back;
148 if (Flags & (D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_READONLY)) {
149 /* Don't dirtify */
150 } else {
152 * Dirtify on lock
153 * as seen in msdn docs
155 IDirect3DVolume8Impl_AddDirtyBox(iface, &This->lockedBox);
157 /** Dirtify Container if needed */
158 if (NULL != This->Container) {
159 IDirect3DVolumeTexture8* cont = (IDirect3DVolumeTexture8*) This->Container;
160 D3DRESOURCETYPE containerType = IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) cont);
161 if (containerType == D3DRTYPE_VOLUMETEXTURE) {
162 IDirect3DBaseTexture8Impl* pTexture = (IDirect3DBaseTexture8Impl*) cont;
163 pTexture->Dirty = TRUE;
164 } else {
165 FIXME("Set dirty on container type %d\n", containerType);
170 This->locked = TRUE;
171 TRACE("returning memory@%p rpitch(%d) spitch(%d)\n", pLockedVolume->pBits, pLockedVolume->RowPitch, pLockedVolume->SlicePitch);
172 return D3D_OK;
175 HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
176 ICOM_THIS(IDirect3DVolume8Impl,iface);
177 if (FALSE == This->locked) {
178 ERR("trying to lock unlocked volume@%p\n", This);
179 return D3DERR_INVALIDCALL;
181 TRACE("(%p) : unlocking volume\n", This);
182 This->locked = FALSE;
183 memset(&This->lockedBox, 0, sizeof(RECT));
184 return D3D_OK;
188 ICOM_VTABLE(IDirect3DVolume8) Direct3DVolume8_Vtbl =
190 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
191 IDirect3DVolume8Impl_QueryInterface,
192 IDirect3DVolume8Impl_AddRef,
193 IDirect3DVolume8Impl_Release,
194 IDirect3DVolume8Impl_GetDevice,
195 IDirect3DVolume8Impl_SetPrivateData,
196 IDirect3DVolume8Impl_GetPrivateData,
197 IDirect3DVolume8Impl_FreePrivateData,
198 IDirect3DVolume8Impl_GetContainer,
199 IDirect3DVolume8Impl_GetDesc,
200 IDirect3DVolume8Impl_LockBox,
201 IDirect3DVolume8Impl_UnlockBox
205 HRESULT WINAPI IDirect3DVolume8Impl_CleanDirtyBox(LPDIRECT3DVOLUME8 iface) {
206 ICOM_THIS(IDirect3DVolume8Impl,iface);
207 This->Dirty = FALSE;
208 This->lockedBox.Left = This->myDesc.Width;
209 This->lockedBox.Top = This->myDesc.Height;
210 This->lockedBox.Front = This->myDesc.Depth;
211 This->lockedBox.Right = 0;
212 This->lockedBox.Bottom = 0;
213 This->lockedBox.Back = 0;
214 return D3D_OK;
218 * Raphael:
219 * very stupid way to handle multiple dirty box but it works :)
221 HRESULT WINAPI IDirect3DVolume8Impl_AddDirtyBox(LPDIRECT3DVOLUME8 iface, CONST D3DBOX* pDirtyBox) {
222 ICOM_THIS(IDirect3DVolume8Impl,iface);
223 This->Dirty = TRUE;
224 if (NULL != pDirtyBox) {
225 This->lockedBox.Left = min(This->lockedBox.Left, pDirtyBox->Left);
226 This->lockedBox.Top = min(This->lockedBox.Top, pDirtyBox->Top);
227 This->lockedBox.Front = min(This->lockedBox.Front, pDirtyBox->Front);
228 This->lockedBox.Right = max(This->lockedBox.Right, pDirtyBox->Right);
229 This->lockedBox.Bottom = max(This->lockedBox.Bottom, pDirtyBox->Bottom);
230 This->lockedBox.Back = max(This->lockedBox.Back, pDirtyBox->Back);
231 } else {
232 This->lockedBox.Left = 0;
233 This->lockedBox.Top = 0;
234 This->lockedBox.Front = 0;
235 This->lockedBox.Right = This->myDesc.Width;
236 This->lockedBox.Bottom = This->myDesc.Height;
237 This->lockedBox.Back = This->myDesc.Depth;
239 return D3D_OK;