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"
30 #include "dpalette/main.h"
31 #include "dpalette/hal.h"
32 #include "ddraw/main.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
36 static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable;
38 /******************************************************************************
41 HRESULT HAL_DirectDrawPalette_Construct(IDirectDrawPaletteImpl* This,
42 IDirectDrawImpl* pDD, DWORD dwFlags)
44 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = pDD->local.lpGbl;
45 DDHAL_CREATEPALETTEDATA data;
48 hr = Main_DirectDrawPalette_Construct(This, pDD, dwFlags);
49 if (FAILED(hr)) return hr;
51 This->final_release = HAL_DirectDrawPalette_final_release;
52 ICOM_INIT_INTERFACE(This, IDirectDrawPalette, DDRAW_HAL_Palette_VTable);
54 /* initialize HAL palette */
56 data.lpDDPalette = &This->global;
57 data.lpColorTable = NULL;
59 data.CreatePalette = dd_gbl->lpDDCBtmp->HALDD.CreatePalette;
60 if (data.CreatePalette)
61 data.CreatePalette(&data);
67 HAL_DirectDrawPalette_Create(IDirectDrawImpl* pDD, DWORD dwFlags,
68 LPDIRECTDRAWPALETTE* ppPalette,
71 IDirectDrawPaletteImpl* This;
74 if (pUnkOuter != NULL)
75 return CLASS_E_NOAGGREGATION; /* unchecked */
77 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
78 if (This == NULL) return E_OUTOFMEMORY;
80 hr = HAL_DirectDrawPalette_Construct(This, pDD, dwFlags);
82 HeapFree(GetProcessHeap(), 0, This);
84 *ppPalette = ICOM_INTERFACE(This, IDirectDrawPalette);
90 HAL_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags,
91 DWORD dwStart, DWORD dwCount,
92 LPPALETTEENTRY palent)
94 IDirectDrawPaletteImpl *This = (IDirectDrawPaletteImpl *)iface;
95 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
96 DDHAL_SETENTRIESDATA data;
98 TRACE("(%p)->SetEntries(%08lx,%ld,%ld,%p)\n",This,dwFlags,dwStart,dwCount,
102 data.lpDDPalette = &This->global;
103 data.dwBase = dwStart;
104 data.dwNumEntries = dwCount;
105 data.lpEntries = palent;
107 data.SetEntries = dd_gbl->lpDDCBtmp->HALDDPalette.SetEntries;
109 data.SetEntries(&data);
111 return Main_DirectDrawPalette_SetEntries(iface, dwFlags, dwStart, dwCount, palent);
114 void HAL_DirectDrawPalette_final_release(IDirectDrawPaletteImpl* This)
116 LPDDRAWI_DIRECTDRAW_GBL dd_gbl = This->local.lpDD_lcl->lpGbl;
117 DDHAL_DESTROYPALETTEDATA data;
119 /* destroy HAL palette */
121 data.lpDDPalette = &This->global;
123 data.DestroyPalette = dd_gbl->lpDDCBtmp->HALDDPalette.DestroyPalette;
124 if (data.DestroyPalette)
125 data.DestroyPalette(&data);
127 Main_DirectDrawPalette_final_release(This);
130 static const IDirectDrawPaletteVtbl DDRAW_HAL_Palette_VTable =
132 Main_DirectDrawPalette_QueryInterface,
133 Main_DirectDrawPalette_AddRef,
134 Main_DirectDrawPalette_Release,
135 Main_DirectDrawPalette_GetCaps,
136 Main_DirectDrawPalette_GetEntries,
137 Main_DirectDrawPalette_Initialize,
138 HAL_DirectDrawPalette_SetEntries