diff --git a/dlls/wined3d/Makefile.in b/dlls/wined3d/Makefile.in index 09f22781c37..24e1e26c962 100644 --- a/dlls/wined3d/Makefile.in +++ b/dlls/wined3d/Makefile.in @@ -15,6 +15,7 @@ C_SRCS = \ directx.c \ drawprim.c \ indexbuffer.c \ + palette.c \ pixelshader.c \ query.c \ resource.c \ diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 4f9d569edc0..4cded1827e4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1668,6 +1668,26 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface, CONST return hr; } +HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags, PALETTEENTRY *PalEnt, IWineD3DPalette **Palette, IUnknown *Parent) { + IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; + IWineD3DPaletteImpl *object; + TRACE("(%p)->(%lx, %p, %p, %p)\n", This, Flags, PalEnt, Palette, Parent); + + /* Create the new object */ + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DPaletteImpl)); + if(!object) { + ERR("Out of memory when allocating memory for a IWineD3DPalette implementation\n"); + return DDERR_OUTOFVIDEOMEMORY; + } + + object->lpVtbl = &IWineD3DPalette_Vtbl; + object->ref = 1; + + *Palette = (IWineD3DPalette *) object; + + return DD_OK; +} + HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters, D3DCB_CREATEADDITIONALSWAPCHAIN D3DCB_CreateAdditionalSwapChain) { FIXME("This call is a d3d7 merge stub. It will be implemented later\n"); return WINED3DERR_INVALIDCALL; @@ -6819,6 +6839,7 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl = IWineD3DDeviceImpl_CreateVertexDeclaration, IWineD3DDeviceImpl_CreateVertexShader, IWineD3DDeviceImpl_CreatePixelShader, + IWineD3DDeviceImpl_CreatePalette, /*** Odd functions **/ IWineD3DDeviceImpl_Init3D, IWineD3DDeviceImpl_Uninit3D, diff --git a/dlls/wined3d/palette.c b/dlls/wined3d/palette.c new file mode 100644 index 00000000000..650ac4e54d4 --- /dev/null +++ b/dlls/wined3d/palette.c @@ -0,0 +1,101 @@ +/* DirectDraw - IDirectPalette base interface + * + * Copyright 1997-2000 Marcus Meissner + * Copyright 2000-2001 TransGaming Technologies Inc. + * Copyright 2006 Stefan Dösinger for CodeWeavers + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "config.h" +#include "winerror.h" +#include "wine/debug.h" + +#include +#include + +#include "wined3d_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d3d); + +HRESULT WINAPI IWineD3DPaletteImpl_QueryInterface(IWineD3DPalette *iface, REFIID refiid, void **obj) { + IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface; + TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj); + + if (IsEqualGUID(refiid, &IID_IUnknown) + || IsEqualGUID(refiid, &IID_IWineD3DPalette)) { + *obj = iface; + IWineD3DPalette_AddRef(iface); + return S_OK; + } + else { + return E_NOINTERFACE; + } +} + +ULONG WINAPI IWineD3DPaletteImpl_AddRef(IWineD3DPalette *iface) { + IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface; + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1); + + return ref; +} + +ULONG WINAPI IWineD3DPaletteImpl_Release(IWineD3DPalette *iface) { + IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface; + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1); + + if (!ref) { + HeapFree(GetProcessHeap(), 0, This); + return 0; + } + + return ref; +} + +HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt) { + FIXME("This is unimplemented for now(d3d7 merge)\n"); + return DDERR_INVALIDPARAMS; +} + +HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt) { + FIXME("This is unimplemented for now(d3d7 merge)\n"); + return DDERR_INVALIDPARAMS; +} + +HRESULT WINAPI IWineD3DPaletteImpl_GetCaps(IWineD3DPalette *iface, DWORD *Caps) { + FIXME("This is unimplemented for now(d3d7 merge)\n"); + return DDERR_INVALIDPARAMS; +} + +HRESULT WINAPI IWineD3DPaletteImpl_GetParent(IWineD3DPalette *iface, IUnknown **Parent) { + FIXME("This is unimplemented for now(d3d7 merge)\n"); + return DDERR_INVALIDPARAMS; +} + +const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl = +{ + /*** IUnknown ***/ + IWineD3DPaletteImpl_QueryInterface, + IWineD3DPaletteImpl_AddRef, + IWineD3DPaletteImpl_Release, + /*** IWineD3DPalette ***/ + IWineD3DPaletteImpl_GetParent, + IWineD3DPaletteImpl_GetEntries, + IWineD3DPaletteImpl_GetCaps, + IWineD3DPaletteImpl_SetEntries +}; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7d8cd36e1ef..e9ffbe7dec5 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -283,6 +283,7 @@ do { /* Advance declaration of structures to satisfy compiler */ typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl; typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl; +typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl; /* Tracking */ @@ -1265,4 +1266,16 @@ typedef struct IWineD3DPixelShaderImpl { extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[]; extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl; + +/***************************************************************************** + * IWineD3DPalette implementation structure + */ +struct IWineD3DPaletteImpl { + /* IUnknown parts */ + const IWineD3DPaletteVtbl *lpVtbl; + LONG ref; +}; + +extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl; + #endif diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h index 9a31acf253e..af58fb45428 100644 --- a/include/wine/wined3d_interface.h +++ b/include/wine/wined3d_interface.h @@ -83,6 +83,7 @@ struct IWineD3D; struct IWineD3DBase; struct IWineD3DDevice; +struct IWineD3DPalette; struct IWineD3DResource; struct IWineD3DVertexBuffer; struct IWineD3DIndexBuffer; @@ -112,6 +113,9 @@ DEFINE_GUID(IID_IWineD3DBase, DEFINE_GUID(IID_IWineD3DDevice, 0x108f9c44, 0x6f30, 0x11d9, 0xc6, 0x87, 0x0, 0x4, 0x61, 0x42, 0xc1, 0x4f); +/* {f756720c-32b9-4439-b5a3-1d6c97037d9e} */ +DEFINE_GUID(IID_IWineD3DPalette, +0xf756720c, 0x32b9, 0x4439, 0xb5, 0xa3, 0x1d, 0x6c, 0x97, 0x03, 0x7d, 0x9e); /* {1F3BFB34-6F30-11d9-C687-00046142C14F} */ DEFINE_GUID(IID_IWineD3DResource, @@ -366,6 +370,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase) STDMETHOD(CreateVertexDeclaration)(THIS_ CONST VOID* pDeclaration, struct IWineD3DVertexDeclaration** ppDecl, IUnknown* pParent) PURE; STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD *pDeclaration, CONST DWORD* pFunction, struct IWineD3DVertexShader** ppShader, IUnknown *pParent) PURE; STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction, struct IWineD3DPixelShader** ppShader, IUnknown *pParent) PURE; + STDMETHOD_(HRESULT,CreatePalette)(THIS_ DWORD Flags, PALETTEENTRY *PalEnt, struct IWineD3DPalette **Palette, IUnknown *Parent); STDMETHOD(Init3D)(THIS_ WINED3DPRESENT_PARAMETERS* pPresentationParameters, D3DCB_CREATEADDITIONALSWAPCHAIN D3DCB_CreateAdditionalSwapChain); STDMETHOD(Uninit3D)(THIS); STDMETHOD(EvictManagedResources)(THIS) PURE; @@ -509,6 +514,7 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase) #define IWineD3DDevice_CreateVertexDeclaration(p,b,c,d) (p)->lpVtbl->CreateVertexDeclaration(p,b,c,d) #define IWineD3DDevice_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) #define IWineD3DDevice_CreatePixelShader(p,a,b,c) (p)->lpVtbl->CreatePixelShader(p,a,b,c) +#define IWineD3DDevice_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) #define IWineD3DDevice_Init3D(p, a, b) (p)->lpVtbl->Init3D(p, a, b) #define IWineD3DDevice_Uninit3D(p) (p)->lpVtbl->Uninit3D(p) #define IWineD3DDevice_EvictManagedResources(p) (p)->lpVtbl->EvictManagedResources(p) @@ -1491,6 +1497,36 @@ DECLARE_INTERFACE_(IWineD3DPixelShader,IWineD3DBaseShader) #define IWineD3DPixelShader_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b) #endif +/***************************************************************************** + * IWineD3DPalette interface + */ +#define INTERFACE IWineD3DPalette +DECLARE_INTERFACE_(IWineD3DPalette,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + /*** IWineD3DPalette methods ***/ + STDMETHOD_(HRESULT,GetParent)(THIS_ IUnknown **Parent); + STDMETHOD_(HRESULT,GetEntries)(THIS_ DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt); + STDMETHOD_(HRESULT,GetCaps)(THIS_ DWORD *Caps); + STDMETHOD_(HRESULT,SetEntries)(THIS_ DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt); +}; +#undef INTERFACE + +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IWineD3DPalette_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IWineD3DPalette_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IWineD3DPalette_Release(p) (p)->lpVtbl->Release(p) +/*** IWineD3DPalette methods ***/ +#define IWineD3DPalette_GetParent(p, a) (p)->lpVtbl->GetParent(p, a) +#define IWineD3DPalette_GetEntries(p, a, b, c, d) (p)->lpVtbl->GetEntries(p, a, b, c, d) +#define IWineD3DPalette_GetCaps(p, a) (p)->lpVtbl->GetCaps(p, a) +#define IWineD3DPalette_SetEntries(p, a, b, c, d) (p)->lpVtbl->SetEntries(p, a, b, c, d) +#endif + #if 0 /* FIXME: During porting in from d3d8 - the following will be used */ extern HRESULT WINAPI IDirect3DVertexShaderImpl_ParseProgram(IDirect3DVertexShaderImpl* This, CONST DWORD* pFunction); /* internal Interfaces */