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
22 #include "wine/debug.h"
27 #include "ddraw_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
31 static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable;
33 /******************************************************************************
36 HRESULT HAL_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
37 IDirectDrawImpl* pDD, DWORD dwFlags)
39 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
40 DDHAL_CREATEPALETTEDATA data;
43 hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
44 if (FAILED(hr)) return hr;
46 This->final_release = HAL_DirectDrawPalette_final_release;
47 ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_HAL_Palette_VTable);
49 /* initialize HAL palette */
51 data.lpDDPalette = &This->global;
52 data.lpColorTable = NULL;
54 data.CreatePalette = dd_gbl->lpDDCBtmp->HALDD.CreatePalette;
55 if (data.CreatePalette)
56 data.CreatePalette(&data);
62 HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
63 LPDIRECTDRAWPALETTE* ppPalette,
66 IDirectDrawPaletteImpl* This;
69 if (pUnkOuter != NULL)
70 return CLASS_E_NOAGGREGATION; /* unchecked */
72 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
73 if (This == NULL) return E_OUTOFMEMORY;
75 hr = HAL_DirectDrawPalette_Construct(This, pDD, dwFlags);
77 HeapFree(GetProcessHeap(), 0, This);
79 *ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
85 HAL_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
86 DWORD dwStart, DWORD dwCount,
87 LPPALETTEENTRY palent)
89 IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
90 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
91 DDHAL_SETENTRIESDATA data;
93 TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
97 data.lpDDPalette = &This->global;
98 data.dwBase = dwStart;
99 data.dwNumEntries = dwCount;
100 data.lpEntries = palent;
102 data.SetEntries = dd_gbl->lpDDCBtmp->HALDDPalette.SetEntries;
104 data.SetEntries(&data);
106 return Main_DirectDrawPalette_SetEntries(iface, dwFlags, dwStart, dwCount, palent);
109 void HAL_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
111 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
112 DDHAL_DESTROYPALETTEDATA data;
114 /* destroy HAL palette */
116 data.lpDDPalette = &This->global;
118 data.DestroyPalette = dd_gbl->lpDDCBtmp->HALDDPalette.DestroyPalette;
119 if (data.DestroyPalette)
120 data.DestroyPalette(&data);
122 Main_DirectDrawPalette_final_release(This);
125 static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable =
127 Main_DirectDrawPalette_QueryInterface,
128 Main_DirectDrawPalette_AddRef,
129 Main_DirectDrawPalette_Release,
130 Main_DirectDrawPalette_GetCaps,
131 Main_DirectDrawPalette_GetEntries,
132 Main_DirectDrawPalette_Initialize,
133 HAL_DirectDrawPalette_SetEntries