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 { 57 LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface; 58 ULONG ref = 0; 59 60 _SEH2_TRY 61 { 62 ref = ++This->dwIntRefCnt; 63 } 64 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 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 { 84 LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface; 85 ULONG ref = 0; 86 87 _SEH2_TRY 88 { 89 ref = --This->dwIntRefCnt; 90 if(ref == 0) 91 { 92 AcquireDDThreadLock(); 93 if(((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw7_Vtable 94 || ((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw4_Vtable) 95 Main_DirectDraw_Release((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1) ; 96 DxHeapMemFree(This); //HUGE FIXME!!! 97 ReleaseDDThreadLock(); 98 } 99 } 100 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 101 { 102 } 103 _SEH2_END 104 105 return ref; 106 } 107 108 static HRESULT WINAPI 109 DirectDrawPalette_Initialize( LPDIRECTDRAWPALETTE iface, 110 LPDIRECTDRAW ddraw, 111 DWORD dwFlags, 112 LPPALETTEENTRY palent) 113 { 114 DX_WINDBG_trace(); 115 DX_STUB; 116 } 117 118 static HRESULT WINAPI 119 DirectDrawPalette_GetEntries( LPDIRECTDRAWPALETTE iface, 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 129 DirectDrawPalette_SetEntries( LPDIRECTDRAWPALETTE iface, 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 140 DirectDrawPalette_GetCaps( LPDIRECTDRAWPALETTE iface, 141 LPDWORD lpdwCaps) 142 { 143 DX_WINDBG_trace(); 144 DX_STUB; 145 } 146 147 const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable = 148 { 149 DirectDrawPalette_QueryInterface, 150 DirectDrawPalette_AddRef, 151 DirectDrawPalette_Release, 152 DirectDrawPalette_GetCaps, 153 DirectDrawPalette_GetEntries, 154 DirectDrawPalette_Initialize, 155 DirectDrawPalette_SetEntries 156 }; 157