Fix two more corner cases in UNIXFS_get_unix_path and UNIXFS_path_to_pidl.
[wine/multimedia.git] / dlls / ddraw / palette_hal.c
blob54de447ef92ba20de7a0eecebc38d73a79d72010
1 /* DirectDrawPalette HAL driver
3 * Copyright 2001 TransGaming Technologies Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "config.h"
21 #include "winerror.h"
22 #include "wine/debug.h"
24 #include <assert.h>
25 #include <string.h>
27 #define CONST_VTABLE
29 #include "ddraw_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
33 static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable;
35 /******************************************************************************
36 * IDirectDrawPalette
38 HRESULT HAL_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
39 IDirectDrawImpl* pDD, DWORD dwFlags)
41 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
42 DDHAL_CREATEPALETTEDATA data;
43 HRESULT hr;
45 hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
46 if (FAILED(hr)) return hr;
48 This->final_release = HAL_DirectDrawPalette_final_release;
49 ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_HAL_Palette_VTable);
51 /* initialize HAL palette */
52 data.lpDD = dd_gbl;
53 data.lpDDPalette = &This->global;
54 data.lpColorTable = NULL;
55 data.ddRVal = 0;
56 data.CreatePalette = dd_gbl->lpDDCBtmp->HALDD.CreatePalette;
57 if (data.CreatePalette)
58 data.CreatePalette(&data);
60 return DD_OK;
63 HRESULT
64 HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
65 LPDIRECTDRAWPALETTE* ppPalette,
66 LPUNKNOWN pUnkOuter)
68 IDirectDrawPaletteImpl* This;
69 HRESULT hr;
71 if (pUnkOuter != NULL)
72 return CLASS_E_NOAGGREGATION; /* unchecked */
74 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
75 if (This == NULL) return E_OUTOFMEMORY;
77 hr = HAL_DirectDrawPalette_Construct(This, pDD, dwFlags);
78 if (FAILED(hr))
79 HeapFree(GetProcessHeap(), 0, This);
80 else
81 *ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
83 return hr;
86 HRESULT WINAPI
87 HAL_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
88 DWORD dwStart, DWORD dwCount,
89 LPPALETTEENTRY palent)
91 IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
92 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
93 DDHAL_SETENTRIESDATA data;
95 TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
96 palent);
98 data.lpDD = dd_gbl;
99 data.lpDDPalette = &This->global;
100 data.dwBase = dwStart;
101 data.dwNumEntries = dwCount;
102 data.lpEntries = palent;
103 data.ddRVal = 0;
104 data.SetEntries = dd_gbl->lpDDCBtmp->HALDDPalette.SetEntries;
105 if (data.SetEntries)
106 data.SetEntries(&data);
108 return Main_DirectDrawPalette_SetEntries(iface, dwFlags, dwStart, dwCount, palent);
111 void HAL_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
113 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
114 DDHAL_DESTROYPALETTEDATA data;
116 /* destroy HAL palette */
117 data.lpDD = dd_gbl;
118 data.lpDDPalette = &This->global;
119 data.ddRVal = 0;
120 data.DestroyPalette = dd_gbl->lpDDCBtmp->HALDDPalette.DestroyPalette;
121 if (data.DestroyPalette)
122 data.DestroyPalette(&data);
124 Main_DirectDrawPalette_final_release(This);
127 static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable =
129 Main_DirectDrawPalette_QueryInterface,
130 Main_DirectDrawPalette_AddRef,
131 Main_DirectDrawPalette_Release,
132 Main_DirectDrawPalette_GetCaps,
133 Main_DirectDrawPalette_GetEntries,
134 Main_DirectDrawPalette_Initialize,
135 HAL_DirectDrawPalette_SetEntries