DXGL r654 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r653‎ | r654 | r655 >
Date:03:02, 21 February 2016
Author:admin
Status:new
Tags:
Comment:
Revert clipper refcount changes from r650. Needs further testing.
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
@@ -581,6 +581,7 @@
582582 glD3D3 = new glDirect3D3(glD3D7);
583583 glD3D2 = new glDirect3D2(glD3D7);
584584 glD3D1 = new glDirect3D1(glD3D7);
 585+ clippers = NULL;
585586 surfaces = NULL;
586587 initialized = false;
587588 devid.liDriverVersion.QuadPart = DXGLVERQWORD;
@@ -644,6 +645,15 @@
645646 {
646647 if (fullscreen) UninstallDXGLFullscreenHook(hWnd);
647648 RestoreDisplayMode();
 649+ if (clippers)
 650+ {
 651+ for (int i = 0; i < clippercount; i++)
 652+ {
 653+ if (clippers[i]) glDirectDrawClipper_Release(clippers[i]);
 654+ clippers[i] = NULL;
 655+ }
 656+ free(clippers);
 657+ }
648658 if(surfaces)
649659 {
650660 for(int i = 0; i < surfacecount; i++)
@@ -849,6 +859,11 @@
850860 TRACE_ENTER(4, 14, this, 9, dwFlags, 14, lplpDDClipper, 14, pUnkOuter);
851861 if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
852862 HRESULT ret = CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
 863+ if (ret == DD_OK)
 864+ {
 865+ this->AddRef();
 866+ ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
 867+ }
853868 TRACE_EXIT(23, ret);
854869 return ret;
855870 }
@@ -858,6 +873,16 @@
859874 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
860875 if(!lplpDDClipper) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
861876 if(pUnkOuter) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 877+ clippercount++;
 878+ if (clippercount > clippercountmax)
 879+ {
 880+ glDirectDrawClipper **clippers2;
 881+ clippers2 = (glDirectDrawClipper **)realloc(clippers, (clippercountmax + 1024)*sizeof(glDirectDrawClipper *));
 882+ if (!clippers2) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
 883+ clippers = clippers2;
 884+ ZeroMemory(&clippers[clippercountmax], 1024 * sizeof(glDirectDrawClipper *));
 885+ clippercountmax += 1024;
 886+ }
862887 TRACE_RET(HRESULT,23,glDirectDrawClipper_Create(dwFlags, this, lplpDDClipper));
863888 }
864889 HRESULT WINAPI glDirectDraw7::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
@@ -1360,6 +1385,11 @@
13611386 surfacecount = 0;
13621387 surfacecountmax = 1024;
13631388 tmpsurface = NULL;
 1389+ clippers = (glDirectDrawClipper **)malloc(1024 * sizeof(glDirectDrawClipper *));
 1390+ if (!clippers) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
 1391+ ZeroMemory(clippers, 1024 * sizeof(glDirectDrawClipper *));
 1392+ clippercount = 0;
 1393+ clippercountmax = 1024;
13641394 bool useguid = false;
13651395 switch((INT_PTR)lpGUID)
13661396 {
@@ -2026,6 +2056,14 @@
20272057 TRACE_EXIT(0,0);
20282058 }
20292059
 2060+void glDirectDraw7::DeleteClipper(glDirectDrawClipper *clipper)
 2061+{
 2062+ TRACE_ENTER(2, 14, this, clipper);
 2063+ for (int i = 0; i < clippercount; i++)
 2064+ if (clippers[i] == clipper) clippers[i] = NULL;
 2065+ TRACE_EXIT(0, 0);
 2066+}
 2067+
20302068 HRESULT glDirectDraw7::SetupTempSurface(DWORD width, DWORD height)
20312069 {
20322070 DDSURFACEDESC2 ddsd;
@@ -2126,7 +2164,11 @@
21272165 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
21282166 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
21292167 HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
2130 - TRACE_EXIT(23, ret);
 2168+ if (ret == DD_OK)
 2169+ {
 2170+ this->AddRef();
 2171+ ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
 2172+ } TRACE_EXIT(23, ret);
21312173 return ret;
21322174 }
21332175 HRESULT WINAPI glDirectDraw1::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
@@ -2326,6 +2368,11 @@
23272369 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
23282370 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
23292371 HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
 2372+ if (ret == DD_OK)
 2373+ {
 2374+ this->AddRef();
 2375+ ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
 2376+ }
23302377 TRACE_EXIT(23, ret);
23312378 return ret;
23322379 }
@@ -2550,6 +2597,11 @@
25512598 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
25522599 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
25532600 HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
 2601+ if (ret == DD_OK)
 2602+ {
 2603+ this->AddRef();
 2604+ ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
 2605+ }
25542606 TRACE_EXIT(23, ret);
25552607 return ret;
25562608 }
Index: ddraw/glDirectDraw.h
@@ -100,6 +100,7 @@
101101 DWORD primaryx,primaryy,primaryrefresh,primarybpp;
102102 bool GetFullscreen(){return fullscreen;};
103103 void DeleteSurface(glDirectDrawSurface7 *surface);
 104+ void DeleteClipper(glDirectDrawClipper *clipper);
104105 HRESULT SetupTempSurface(DWORD width, DWORD height);
105106 void DeleteTempSurface();
106107 glDirectDrawSurface7 *primary;
@@ -127,6 +128,8 @@
128129 LONG_PTR winstyle,winstyleex;
129130 glDirectDrawSurface7 **surfaces;
130131 int surfacecount, surfacecountmax;
 132+ glDirectDrawClipper **clippers;
 133+ int clippercount, clippercountmax;
131134 DEVMODE oldmode;
132135 bool initialized;
133136 glDirect3D7 *glD3D7;
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;
@@ -62,6 +63,7 @@
6364 newclipper->refcount = 1;
6465 newclipper->initialized = false;
6566 newclipper->lpVtbl = &glDirectDrawClipper_iface;
 67+ newclipper->creator = NULL;
6668 glDirectDrawClipper_Initialize(newclipper, (LPDIRECTDRAW)parent, dwFlags);
6769 if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
6870 TRACE_EXIT(23, DD_OK);
@@ -112,6 +114,8 @@
113115 if (This->cliplist) free(This->cliplist);
114116 if (This->vertices) free(This->vertices);
115117 if (This->indices) free(This->indices);
 118+ if (This->glDD7) This->glDD7->DeleteClipper(This);
 119+ if (This->creator) This->creator->Release();
116120 free(This);
117121 };
118122 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 BOOL cliplistchanged;
4344 WINDOWPLACEMENT lastpos;
4445 } glDirectDrawClipper;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r650Make clipper not modify DDraw refcount....admin01:10, 9 February 2016