Index: ddraw/glDirectDraw.cpp |
— | — | @@ -867,7 +867,7 @@ |
868 | 868 | if (ret == DD_OK)
|
869 | 869 | {
|
870 | 870 | this->AddRef();
|
871 | | - ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
|
| 871 | + ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
|
872 | 872 | }
|
873 | 873 | TRACE_EXIT(23, ret);
|
874 | 874 | return ret;
|
— | — | @@ -892,6 +892,20 @@ |
893 | 893 | }
|
894 | 894 | HRESULT WINAPI glDirectDraw7::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
|
895 | 895 | {
|
| 896 | + TRACE_ENTER(5, 14, this, 9, dwFlags, 14, lpDDColorArray, 14, lplpDDPalette, 14, pUnkOuter);
|
| 897 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 898 | + HRESULT ret = CreatePalette2(dwFlags, lpDDColorArray, lplpDDPalette, pUnkOuter);
|
| 899 | + if (ret == DD_OK)
|
| 900 | + {
|
| 901 | + this->AddRef();
|
| 902 | + ((glDirectDrawPalette*)*lplpDDPalette)->creator = this;
|
| 903 | + }
|
| 904 | + TRACE_EXIT(23, ret);
|
| 905 | + return ret;
|
| 906 | +}
|
| 907 | +
|
| 908 | +HRESULT glDirectDraw7::CreatePalette2(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
|
| 909 | +{
|
896 | 910 | TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette,14,pUnkOuter);
|
897 | 911 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
898 | 912 | if(!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
— | — | @@ -2027,7 +2041,7 @@ |
2028 | 2042 | if (ret == DD_OK)
|
2029 | 2043 | {
|
2030 | 2044 | this->AddRef();
|
2031 | | - ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
|
| 2045 | + ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
|
2032 | 2046 | }
|
2033 | 2047 | TRACE_EXIT(23, ret);
|
2034 | 2048 | return ret;
|
— | — | @@ -2034,9 +2048,11 @@ |
2035 | 2049 | }
|
2036 | 2050 | HRESULT WINAPI glDirectDraw1::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
|
2037 | 2051 | {
|
2038 | | - TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette,14,pUnkOuter);
|
2039 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2040 | | - TRACE_RET(HRESULT,23,glDD7->CreatePalette(dwFlags,lpDDColorArray,lplpDDPalette,pUnkOuter));
|
| 2052 | + TRACE_ENTER(5, 14, this, 9, dwFlags, 14, lpDDColorArray, 14, lplpDDPalette, 14, pUnkOuter);
|
| 2053 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 2054 | + HRESULT ret = glDD7->CreatePalette2(dwFlags, lpDDColorArray, lplpDDPalette, pUnkOuter);
|
| 2055 | + TRACE_EXIT(23, ret);
|
| 2056 | + return ret;
|
2041 | 2057 | }
|
2042 | 2058 | HRESULT WINAPI glDirectDraw1::CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
|
2043 | 2059 | {
|
— | — | @@ -2228,7 +2244,7 @@ |
2229 | 2245 | if (ret == DD_OK)
|
2230 | 2246 | {
|
2231 | 2247 | this->AddRef();
|
2232 | | - ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
|
| 2248 | + ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
|
2233 | 2249 | }
|
2234 | 2250 | TRACE_EXIT(23, ret);
|
2235 | 2251 | return ret;
|
— | — | @@ -2235,9 +2251,11 @@ |
2236 | 2252 | }
|
2237 | 2253 | HRESULT WINAPI glDirectDraw2::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
|
2238 | 2254 | {
|
2239 | | - TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette,14,pUnkOuter);
|
2240 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2241 | | - TRACE_RET(HRESULT,23,glDD7->CreatePalette(dwFlags,lpDDColorArray,lplpDDPalette,pUnkOuter));
|
| 2255 | + TRACE_ENTER(5, 14, this, 9, dwFlags, 14, lpDDColorArray, 14, lplpDDPalette, 14, pUnkOuter);
|
| 2256 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 2257 | + HRESULT ret = glDD7->CreatePalette2(dwFlags, lpDDColorArray, lplpDDPalette, pUnkOuter);
|
| 2258 | + TRACE_EXIT(23, ret);
|
| 2259 | + return ret;
|
2242 | 2260 | }
|
2243 | 2261 | HRESULT WINAPI glDirectDraw2::CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
|
2244 | 2262 | {
|
— | — | @@ -2453,7 +2471,7 @@ |
2454 | 2472 | if (ret == DD_OK)
|
2455 | 2473 | {
|
2456 | 2474 | this->AddRef();
|
2457 | | - ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
|
| 2475 | + ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
|
2458 | 2476 | }
|
2459 | 2477 | TRACE_EXIT(23, ret);
|
2460 | 2478 | return ret;
|
— | — | @@ -2460,9 +2478,16 @@ |
2461 | 2479 | }
|
2462 | 2480 | HRESULT WINAPI glDirectDraw4::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
|
2463 | 2481 | {
|
2464 | | - TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette,14,pUnkOuter);
|
2465 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2466 | | - TRACE_RET(HRESULT,23,glDD7->CreatePalette(dwFlags,lpDDColorArray,lplpDDPalette,pUnkOuter));
|
| 2482 | + TRACE_ENTER(5, 14, this, 9, dwFlags, 14, lpDDColorArray, 14, lplpDDPalette, 14, pUnkOuter);
|
| 2483 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 2484 | + HRESULT ret = glDD7->CreatePalette2(dwFlags, lpDDColorArray, lplpDDPalette, pUnkOuter);
|
| 2485 | + if (ret == DD_OK)
|
| 2486 | + {
|
| 2487 | + this->AddRef();
|
| 2488 | + ((glDirectDrawPalette*)*lplpDDPalette)->creator = this;
|
| 2489 | + }
|
| 2490 | + TRACE_EXIT(23, ret);
|
| 2491 | + return ret;
|
2467 | 2492 | }
|
2468 | 2493 | HRESULT WINAPI glDirectDraw4::CreateSurface(LPDDSURFACEDESC2 lpDDSurfaceDesc, LPDIRECTDRAWSURFACE4 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
|
2469 | 2494 | {
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -89,6 +89,7 @@ |
90 | 90 | ULONG WINAPI Release1();
|
91 | 91 | HRESULT CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface);
|
92 | 92 | HRESULT CreateClipper2(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter);
|
| 93 | + HRESULT CreatePalette2(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter);
|
93 | 94 | HRESULT err() { return error; }
|
94 | 95 | void RemoveSurface(glDirectDrawSurface7 *surface);
|
95 | 96 | void GetSizes(LONG *sizes);
|
Index: ddraw/glDirectDrawPalette.c |
— | — | @@ -120,7 +120,11 @@ |
121 | 121 | if(!This) return 0;
|
122 | 122 | This->refcount--;
|
123 | 123 | ret = This->refcount;
|
124 | | - if (This->refcount == 0) free(This);
|
| 124 | + if (This->refcount == 0)
|
| 125 | + {
|
| 126 | + if (This->creator) This->creator->lpVtbl->Release(This->creator);
|
| 127 | + free(This);
|
| 128 | + }
|
125 | 129 | TRACE_EXIT(8,ret);
|
126 | 130 | return ret;
|
127 | 131 | }
|
— | — | @@ -209,7 +213,7 @@ |
210 | 214 | {
|
211 | 215 | glDirectDrawPalette *newpal;
|
212 | 216 | TRACE_ENTER(3,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette);
|
213 | | - if (!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 217 | + if (!lplpDDPalette) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
214 | 218 | if (dwFlags & 0xFFFFF000) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
215 | 219 | if ((dwFlags & DDPCAPS_8BIT) && (dwFlags & DDPCAPS_8BITENTRIES)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
216 | 220 | if (((dwFlags & DDPCAPS_1BIT) || (dwFlags & DDPCAPS_2BIT) || (dwFlags & DDPCAPS_4BIT)) && (dwFlags & DDPCAPS_ALLOW256))
|
— | — | @@ -220,6 +224,7 @@ |
221 | 225 | newpal->refcount = 1;
|
222 | 226 | newpal->flags = dwFlags;
|
223 | 227 | newpal->lpVtbl = &glDirectDrawPalette_iface;
|
| 228 | + newpal->creator = NULL;
|
224 | 229 | if (lpDDColorArray == NULL)
|
225 | 230 | {
|
226 | 231 | if (dwFlags & 0x800) memcpy(newpal->palette, DefaultPalette, 1024);
|
Index: ddraw/glDirectDrawPalette.h |
— | — | @@ -31,6 +31,7 @@ |
32 | 32 | ULONG refcount;
|
33 | 33 | PALETTEENTRY palette[256];
|
34 | 34 | DWORD flags;
|
| 35 | + IUnknown *creator;
|
35 | 36 | } glDirectDrawPalette;
|
36 | 37 |
|
37 | 38 | typedef struct glDirectDrawPaletteVtbl
|