ReactOS  0.4.14-dev-358-gbef841c
palette.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS DirectX
4  * FILE: dll/directx/ddraw/Palette/palette.c
5  * PURPOSE: IDirectDrawPalette Implementation
6  * PROGRAMMER: Jérôme Gardou
7  *
8  */
9 
10 #include "rosdraw.h"
11 
12 /*****************************************************************************
13  * IDirectDrawPalette::QueryInterface
14  *
15  * A usual QueryInterface implementation. Can only Query IUnknown and
16  * IDirectDrawPalette
17  *
18  * Params:
19  * refiid: The interface id queried for
20  * obj: Address to return the interface pointer at
21  *
22  * Returns:
23  * S_OK on success
24  * E_NOINTERFACE if the requested interface wasn't found
25  *****************************************************************************/
26 static HRESULT WINAPI
27 DirectDrawPalette_QueryInterface(IDirectDrawPalette *iface,
28  REFIID refiid,
29  void **obj)
30 {
31  if (IsEqualGUID(refiid, &IID_IUnknown)
32  || IsEqualGUID(refiid, &IID_IDirectDrawPalette))
33  {
34  *obj = iface;
35  IDirectDrawPalette_AddRef(iface);
36  return S_OK;
37  }
38  else
39  {
40  *obj = NULL;
41  return E_NOINTERFACE;
42  }
43 }
44 
45 /*****************************************************************************
46  * IDirectDrawPaletteImpl::AddRef
47  *
48  * Increases the refcount.
49  *
50  * Returns:
51  * The new refcount
52  *
53  *****************************************************************************/
54 static ULONG WINAPI
55 DirectDrawPalette_AddRef(IDirectDrawPalette *iface)
56 {
58  ULONG ref = 0;
59 
60  _SEH2_TRY
61  {
62  ref = ++This->dwIntRefCnt;
63  }
65  {
66  }
67  _SEH2_END
68 
69  return ref;
70 }
71 
72 /*****************************************************************************
73  * IDirectDrawPaletteImpl::Release
74  *
75  * Reduces the refcount. If the refcount falls to 0, the object is destroyed
76  *
77  * Returns:
78  * The new refcount
79  *
80  *****************************************************************************/
81 static ULONG WINAPI
82 DirectDrawPalette_Release(IDirectDrawPalette *iface)
83 {
85  ULONG ref = 0;
86 
87  _SEH2_TRY
88  {
89  ref = --This->dwIntRefCnt;
90  if(ref == 0)
91  {
93  if(((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw7_Vtable
94  || ((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw4_Vtable)
96  DxHeapMemFree(This); //HUGE FIXME!!!
98  }
99  }
101  {
102  }
103  _SEH2_END
104 
105  return ref;
106 }
107 
108 static HRESULT WINAPI
111  DWORD dwFlags,
112  LPPALETTEENTRY palent)
113 {
114  DX_WINDBG_trace();
115  DX_STUB;
116 }
117 
118 static HRESULT WINAPI
120  DWORD dwFlags,
121  DWORD dwStart, DWORD dwCount,
122  LPPALETTEENTRY palent)
123 {
124  DX_WINDBG_trace();
125  DX_STUB;
126 }
127 
128 static HRESULT WINAPI
130  DWORD dwFlags,
131  DWORD dwStart,
132  DWORD dwCount,
133  LPPALETTEENTRY palent)
134 {
135  DX_WINDBG_trace();
136  DX_STUB;
137 }
138 
139 static HRESULT WINAPI
141  LPDWORD lpdwCaps)
142 {
143  DX_WINDBG_trace();
144  DX_STUB;
145 }
146 
147 const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable =
148 {
156 };
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
static ULONG WINAPI DirectDrawPalette_AddRef(IDirectDrawPalette *iface)
Definition: palette.c:55
static HRESULT WINAPI DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags, DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent)
Definition: palette.c:129
static HRESULT WINAPI DirectDrawPalette_GetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags, DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent)
Definition: palette.c:119
#define DxHeapMemFree(p)
Definition: rosdraw.h:120
Definition: send.c:47
_SEH2_TRY
Definition: create.c:4250
IDirectDraw4Vtbl DirectDraw4_Vtable
Definition: ddraw_thunk.c:890
VOID WINAPI AcquireDDThreadLock()
Definition: main.c:412
static HRESULT WINAPI DirectDrawPalette_Initialize(LPDIRECTDRAWPALETTE iface, LPDIRECTDRAW ddraw, DWORD dwFlags, LPPALETTEENTRY palent)
Definition: palette.c:109
GLenum GLint ref
Definition: glext.h:6028
struct _DDRAWI_DDRAWPALETTE_INT * LPDDRAWI_DDRAWPALETTE_INT
Definition: ddrawi.h:142
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
VOID WINAPI ReleaseDDThreadLock()
Definition: main.c:421
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static HRESULT WINAPI DirectDrawPalette_QueryInterface(IDirectDrawPalette *iface, REFIID refiid, void **obj)
Definition: palette.c:27
#define DX_STUB
Definition: rosdraw.h:224
#define S_OK
Definition: intsafe.h:59
_SEH2_END
Definition: create.c:4424
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
uint32_t * LPDWORD
Definition: typedefs.h:57
static HRESULT WINAPI DirectDrawPalette_GetCaps(LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps)
Definition: palette.c:140
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable
Definition: palette.c:147
IDirectDraw7Vtbl DirectDraw7_Vtable
static ULONG WINAPI DirectDrawPalette_Release(IDirectDrawPalette *iface)
Definition: palette.c:82
ULONG WINAPI Main_DirectDraw_Release(LPDDRAWI_DIRECTDRAW_INT This)
Definition: ddraw_main.c:194
struct IDirectDrawPalette * LPDIRECTDRAWPALETTE
Definition: ddraw.h:720