DXGL r515 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r514‎ | r515 | r516 >
Date:22:45, 1 September 2014
Author:admin
Status:new
Tags:
Comment:
Add link between glDirectDrawClipper and glDirectDraw refcount.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -861,6 +861,19 @@
862862 }
863863 HRESULT WINAPI glDirectDraw7::CreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
864864 {
 865+ TRACE_ENTER(4, 14, this, 9, dwFlags, 14, lplpDDClipper, 14, pUnkOuter);
 866+ if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
 867+ HRESULT ret = CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
 868+ if (ret == DD_OK)
 869+ {
 870+ this->AddRef();
 871+ ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
 872+ }
 873+ TRACE_EXIT(23, ret);
 874+ return ret;
 875+}
 876+HRESULT glDirectDraw7::CreateClipper2(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
 877+{
865878 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
866879 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
867880 if(!lplpDDClipper) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
@@ -875,7 +888,7 @@
876889 ZeroMemory(&clippers[clippercountmax],1024*sizeof(glDirectDrawClipper *));
877890 clippercountmax += 1024;
878891 }
879 - TRACE_RET(HRESULT, 23, glDirectDrawClipper_Create(dwFlags, this, lplpDDClipper));
 892+ TRACE_RET(HRESULT,23,glDirectDrawClipper_Create(dwFlags, this, lplpDDClipper));
880893 }
881894 HRESULT WINAPI glDirectDraw7::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
882895 {
@@ -2010,7 +2023,14 @@
20112024 {
20122025 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
20132026 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2014 - TRACE_RET(HRESULT,23,glDD7->CreateClipper(dwFlags,lplpDDClipper,pUnkOuter));
 2027+ HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
 2028+ if (ret == DD_OK)
 2029+ {
 2030+ this->AddRef();
 2031+ ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
 2032+ }
 2033+ TRACE_EXIT(23, ret);
 2034+ return ret;
20152035 }
20162036 HRESULT WINAPI glDirectDraw1::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
20172037 {
@@ -2204,7 +2224,14 @@
22052225 {
22062226 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
22072227 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2208 - TRACE_RET(HRESULT,23,glDD7->CreateClipper(dwFlags,lplpDDClipper,pUnkOuter));
 2228+ HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
 2229+ if (ret == DD_OK)
 2230+ {
 2231+ this->AddRef();
 2232+ ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
 2233+ }
 2234+ TRACE_EXIT(23, ret);
 2235+ return ret;
22092236 }
22102237 HRESULT WINAPI glDirectDraw2::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
22112238 {
@@ -2422,7 +2449,14 @@
24232450 {
24242451 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
24252452 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2426 - TRACE_RET(HRESULT,23,glDD7->CreateClipper(dwFlags,lplpDDClipper,pUnkOuter));
 2453+ HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
 2454+ if (ret == DD_OK)
 2455+ {
 2456+ this->AddRef();
 2457+ ((glDirectDrawClipper*)lplpDDClipper)->creator = this;
 2458+ }
 2459+ TRACE_EXIT(23, ret);
 2460+ return ret;
24272461 }
24282462 HRESULT WINAPI glDirectDraw4::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
24292463 {
Index: ddraw/glDirectDraw.h
@@ -88,7 +88,8 @@
8989 ULONG WINAPI AddRef1();
9090 ULONG WINAPI Release1();
9191 HRESULT CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface);
92 - HRESULT err() {return error;}
 92+ HRESULT CreateClipper2(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter);
 93+ HRESULT err() { return error; }
9394 void RemoveSurface(glDirectDrawSurface7 *surface);
9495 void GetSizes(LONG *sizes);
9596 DWORD GetBPP(){return primarybpp;}
Index: ddraw/glDirectDrawClipper.cpp
@@ -45,6 +45,7 @@
4646 newclipper->refcount = 1;
4747 newclipper->initialized = false;
4848 newclipper->lpVtbl = &glDirectDrawClipper_iface;
 49+ newclipper->creator = NULL;
4950 if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
5051 TRACE_EXIT(23, DD_OK);
5152 return DD_OK;
@@ -61,6 +62,7 @@
6263 newclipper->refcount = 1;
6364 newclipper->initialized = false;
6465 newclipper->lpVtbl = &glDirectDrawClipper_iface;
 66+ newclipper->creator = NULL;
6567 glDirectDrawClipper_Initialize(newclipper, (LPDIRECTDRAW)parent, dwFlags);
6668 if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
6769 TRACE_EXIT(23, DD_OK);
@@ -112,6 +114,7 @@
113115 if (This->vertices) free(This->vertices);
114116 if (This->indices) free(This->indices);
115117 if (This->glDD7) This->glDD7->DeleteClipper(This);
 118+ if (This->creator) This->creator->Release();
116119 free(This);
117120 };
118121 TRACE_EXIT(8,ret);
Index: ddraw/glDirectDrawClipper.h
@@ -38,6 +38,7 @@
3939 int maxsize;
4040 bool hascliplist;
4141 bool dirty;
 42+ IUnknown *creator;
4243 } glDirectDrawClipper;
4344
4445 typedef struct glDirectDrawClipperVtbl