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"
28 #include "dpalette/main.h"
29 #include "dpalette/hal.h"
30 #include "ddraw/main.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
34 static ICOM_VTABLE(IDirectDrawPalette) DDRAW_HAL_Palette_VTable;
36 /******************************************************************************
39 HRESULT HAL_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
40 IDirectDrawImpl* pDD, DWORD dwFlags)
42 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
43 DDHAL_CREATEPALETTEDATA data;
46 hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
47 if (FAILED(hr)) return hr;
49 This->final_release = HAL_DirectDrawPalette_final_release;
50 ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_HAL_Palette_VTable);
52 /* initialize HAL palette */
54 data.lpDDPalette = &This->global;
55 data.lpColorTable = NULL;
57 data.CreatePalette = dd_gbl->lpDDCBtmp->HALDD.CreatePalette;
58 if (data.CreatePalette)
59 data.CreatePalette(&data);
65 HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
66 LPDIRECTDRAWPALETTE* ppPalette,
69 IDirectDrawPaletteImpl* This;
72 if (pUnkOuter != NULL)
73 return CLASS_E_NOAGGREGATION; /* unchecked */
75 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
76 if (This == NULL) return E_OUTOFMEMORY;
78 hr = HAL_DirectDrawPalette_Construct(This, pDD, dwFlags);
80 HeapFree(GetProcessHeap(), 0, This);
82 *ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
88 HAL_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
89 DWORD dwStart, DWORD dwCount,
90 LPPALETTEENTRY palent)
92 ICOM_THIS(IDirectDrawPaletteImpl,iface);
93 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
94 DDHAL_SETENTRIESDATA data;
96 TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
100 data.lpDDPalette = &This->global;
101 data.dwBase = dwStart;
102 data.dwNumEntries = dwCount;
103 data.lpEntries = palent;
105 data.SetEntries = dd_gbl->lpDDCBtmp->HALDDPalette.SetEntries;
107 data.SetEntries(&data);
109 return Main_DirectDrawPalette_SetEntries(iface, dwFlags, dwStart, dwCount, palent);
112 void HAL_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
114 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
115 DDHAL_DESTROYPALETTEDATA data;
117 /* destroy HAL palette */
119 data.lpDDPalette = &This->global;
121 data.DestroyPalette = dd_gbl->lpDDCBtmp->HALDDPalette.DestroyPalette;
122 if (data.DestroyPalette)
123 data.DestroyPalette(&data);
125 Main_DirectDrawPalette_final_release(This);
128 static ICOM_VTABLE(IDirectDrawPalette) DDRAW_HAL_Palette_VTable =
130 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
131 Main_DirectDrawPalette_QueryInterface,
132 Main_DirectDrawPalette_AddRef,
133 Main_DirectDrawPalette_Release,
134 Main_DirectDrawPalette_GetCaps,
135 Main_DirectDrawPalette_GetEntries,
136 Main_DirectDrawPalette_Initialize,
137 HAL_DirectDrawPalette_SetEntries