ReactOS 0.4.15-dev-8145-ga541a46
createpalette.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS DirectX
4 * FILE: dll/directx/ddraw/Palette/createpalette.c
5 * PURPOSE: IDirectDrawPalette Creation
6 * PROGRAMMER: Jérôme Gardou
7 *
8 */
9#include "rosdraw.h"
10
12{
13 DWORD ret = 0;
28
29 return ret;
30}
31
34 LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter)
35{
36 DDHAL_CREATEPALETTEDATA mDdCreatePalette = { 0 };
37
41
43
44 if(pUnkOuter)
45 {
47 }
48
50 {
52 }
53
54
55 if (pDDraw->lpLcl->dwProcessId != GetCurrentProcessId() )
56 {
58 }
59
60 /* Allocate the palette interface and needed members */
61 DxHeapMemAlloc(ThisPalInt, sizeof( DDRAWI_DDRAWPALETTE_INT ) );
62 if( ThisPalInt == NULL )
63 {
65 goto cleanup;
66 }
67
68 DxHeapMemAlloc(ThisPalLcl, sizeof( DDRAWI_DDRAWPALETTE_LCL ) );
69 if( ThisPalLcl == NULL )
70 {
72 goto cleanup;
73 }
74
75 DxHeapMemAlloc(ThisPalGbl, sizeof( DDRAWI_DDRAWPALETTE_GBL ) );
76 if( ThisPalGbl == NULL )
77 {
79 goto cleanup;
80 }
81
82 /*Some initial setup*/
83
84 ThisPalInt->lpLcl = ThisPalLcl;
85 ThisPalLcl->lpGbl = ThisPalGbl;
86
87 ThisPalLcl->lpDD_lcl = ThisPalGbl->lpDD_lcl = pDDraw->lpLcl;
88 ThisPalGbl->dwFlags = ConvertPCapsFlags(dwFlags);
89
91 ThisPalGbl->dwProcessId = GetCurrentProcessId();
92
93 mDdCreatePalette.lpDD = pDDraw->lpLcl->lpGbl;
94 mDdCreatePalette.lpDDPalette = ThisPalGbl;
96 mDdCreatePalette.CreatePalette = pDDraw->lpLcl->lpGbl->lpDDCBtmp->HALDD.CreatePalette;
97 DX_STUB_str("Using HAL CreatePalette\n");
98 }
99 else {
100 mDdCreatePalette.CreatePalette = pDDraw->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette;
101 DX_STUB_str("Using HEL CreatePalette\n");
102 }
103 mDdCreatePalette.ddRVal = DDERR_GENERIC;
104 mDdCreatePalette.lpColorTable = palent;
105
106 if (mDdCreatePalette.CreatePalette(&mDdCreatePalette) == DDHAL_DRIVER_NOTHANDLED)
107 {
108 DX_STUB_str("mDdCreateSurface failed with DDHAL_DRIVER_NOTHANDLED.");
110 goto cleanup;
111 }
112
113 if (mDdCreatePalette.ddRVal != DD_OK)
114 {
115 DX_STUB_str("mDdCreateSurface failed.");
116 ret = mDdCreatePalette.ddRVal;
117 goto cleanup;
118 }
119
120 *ppPalette = (LPDIRECTDRAWPALETTE)ThisPalInt;
121 ThisPalInt->lpLink = pDDraw->lpLcl->lpGbl->palList;
122 pDDraw->lpLcl->lpGbl->palList = ThisPalInt;
123 ThisPalInt->lpLcl->dwReserved1 = (ULONG_PTR)pDDraw;
124 IDirectDrawPalette_AddRef(*ppPalette);
125
126 return DD_OK;
127
128cleanup:
129 if(ThisPalInt) DxHeapMemFree(ThisPalInt);
130 if(ThisPalLcl) DxHeapMemFree(ThisPalLcl);
131 if(ThisPalGbl) DxHeapMemFree(ThisPalGbl);
132
133 return ret;
134}
DWORD ConvertPCapsFlags(DWORD dwFlags)
Definition: createpalette.c:11
HRESULT Internal_CreatePalette(LPDDRAWI_DIRECTDRAW_INT pDDraw, DWORD dwFlags, LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE *ppPalette, LPUNKNOWN pUnkOuter)
Definition: createpalette.c:33
#define DDRAWIPAL_2
Definition: ddrawi.h:1572
#define DDRAWIPAL_16
Definition: ddrawi.h:1562
#define DDRAWIPAL_ALLOW256
Definition: ddrawi.h:1570
#define DDHAL_CB32_CREATEPALETTE
Definition: ddrawi.h:659
#define DDRAWIPAL_4
Definition: ddrawi.h:1571
#define DDRAWILCL_SETCOOPCALLED
Definition: ddrawi.h:1196
#define DDRAWIPAL_256
Definition: ddrawi.h:1561
#define DDRAWIPAL_ALPHA
Definition: ddrawi.h:1574
#define DDRAWIPAL_STORED_8INDEX
Definition: ddrawi.h:1573
#define DDHAL_DRIVER_NOTHANDLED
Definition: ddrawi.h:320
#define NULL
Definition: types.h:112
const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable
Definition: palette.c:147
static void cleanup(void)
Definition: main.c:1335
#define ULONG_PTR
Definition: config.h:101
unsigned long DWORD
Definition: ntddk_ex.h:95
static LPUNKNOWN
Definition: ndr_ole.c:49
#define DX_STUB_str(x)
Definition: rosdraw.h:254
#define DxHeapMemAlloc(p, m)
Definition: rosdraw.h:113
#define DxHeapMemFree(p)
Definition: rosdraw.h:120
#define DDPCAPS_ALLOW256
Definition: ddraw.h:458
#define DDPCAPS_8BITENTRIES
Definition: ddraw.h:454
#define DDERR_INVALIDOBJECT
Definition: ddraw.h:78
#define DDERR_OUTOFMEMORY
Definition: ddraw.h:111
#define DDPCAPS_1BIT
Definition: ddraw.h:460
#define DDERR_NOTINITIALIZED
Definition: ddraw.h:185
#define DDPCAPS_2BIT
Definition: ddraw.h:461
#define DDERR_NOCOOPERATIVELEVELSET
Definition: ddraw.h:89
#define DD_OK
Definition: ddraw.h:186
#define DDPCAPS_8BIT
Definition: ddraw.h:455
struct IDirectDrawPalette * LPDIRECTDRAWPALETTE
Definition: ddraw.h:720
#define DDERR_GENERIC
Definition: ddraw.h:72
#define DDPCAPS_ALPHA
Definition: ddraw.h:462
#define DDPCAPS_4BIT
Definition: ddraw.h:453
DDHAL_DDCALLBACKS HALDD
Definition: ddrawi.h:735
DDHAL_DDCALLBACKS HELDD
Definition: ddrawi.h:738
LPDDRAWI_DIRECTDRAW_GBL lpDD
Definition: ddrawi.h:792
LPPALETTEENTRY lpColorTable
Definition: ddrawi.h:794
LPDDHAL_CREATEPALETTE CreatePalette
Definition: ddrawi.h:796
LPDDRAWI_DDRAWPALETTE_GBL lpDDPalette
Definition: ddrawi.h:793
LPDDHAL_CREATEPALETTE CreatePalette
Definition: ddrawi.h:355
LPDDRAWI_DIRECTDRAW_LCL lpDD_lcl
Definition: ddrawi.h:1548
LPDDRAWI_DDRAWPALETTE_LCL lpLcl
Definition: ddrawi.h:1540
LPDDRAWI_DDRAWPALETTE_INT lpLink
Definition: ddrawi.h:1541
LPDDRAWI_DDRAWPALETTE_GBL lpGbl
Definition: ddrawi.h:1643
LPDDRAWI_DIRECTDRAW_LCL lpDD_lcl
Definition: ddrawi.h:1651
LPDDRAWI_DDRAWPALETTE_INT palList
Definition: ddrawi.h:1226
LPDDHAL_CALLBACKS lpDDCBtmp
Definition: ddrawi.h:1224
LPDDRAWI_DIRECTDRAW_LCL lpLcl
Definition: ddrawi.h:1148
LPDDRAWI_DIRECTDRAW_GBL lpGbl
Definition: ddrawi.h:1155
void * PVOID
Definition: typedefs.h:50
int ret
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662