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"
29 #include "ddraw_private.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
33 static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable;
35 /******************************************************************************
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;
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 */
53 data.lpDDPalette = &This->global;
54 data.lpColorTable = NULL;
56 data.CreatePalette = dd_gbl->lpDDCBtmp->HALDD.CreatePalette;
57 if (data.CreatePalette)
58 data.CreatePalette(&data);
64 HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
65 LPDIRECTDRAWPALETTE* ppPalette,
68 IDirectDrawPaletteImpl* This;
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);
79 HeapFree(GetProcessHeap(), 0, This);
81 *ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
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,
99 data.lpDDPalette = &This->global;
100 data.dwBase = dwStart;
101 data.dwNumEntries = dwCount;
102 data.lpEntries = palent;
104 data.SetEntries = dd_gbl->lpDDCBtmp->HALDDPalette.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 */
118 data.lpDDPalette = &This->global;
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