DXGL r650 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r649‎ | r650 | r651 >
Date:01:10, 9 February 2016
Author:admin
Status:new
Tags:
Comment:
Make clipper not modify DDraw refcount.
Make failed QueryInterface clear return value on ddraw and viewport.
Update readme version number.
Modified paths:
  • /ReadMe.md (modified) (history)
  • /ddraw/glDirect3DViewport.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.h (modified) (history)

Diff [purge]

Index: ReadMe.md
@@ -1,4 +1,4 @@
2 -# DXGL 0.5.7
 2+# DXGL 0.5.8
33 https://www.williamfeely.info/wiki/DXGL
44
55 ## Introduction
Index: ddraw/glDirect3DViewport.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2014 William Feely
 3+// Copyright (C) 2011-2016 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -101,6 +101,7 @@
102102 TRACE_EXIT(23,D3D_OK);
103103 return D3D_OK;
104104 }
 105+ *ppvObj = NULL;
105106 TRACE_EXIT(23,E_NOINTERFACE);
106107 return E_NOINTERFACE;
107108 }
Index: ddraw/glDirectDraw.cpp
@@ -581,7 +581,6 @@
582582 glD3D3 = new glDirect3D3(glD3D7);
583583 glD3D2 = new glDirect3D2(glD3D7);
584584 glD3D1 = new glDirect3D1(glD3D7);
585 - clippers = NULL;
586585 surfaces = NULL;
587586 initialized = false;
588587 devid.liDriverVersion.QuadPart = DXGLVERQWORD;
@@ -645,15 +644,6 @@
646645 {
647646 if (fullscreen) UninstallDXGLFullscreenHook(hWnd);
648647 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 - }
658648 if(surfaces)
659649 {
660650 for(int i = 0; i < surfacecount; i++)
@@ -753,6 +743,7 @@
754744 {
755745 ERR(DDERR_GENERIC);
756746 }*/
 747+ *ppvObj = NULL;
757748 TRACE_EXIT(23,E_NOINTERFACE);
758749 return E_NOINTERFACE;
759750 }
@@ -857,11 +848,6 @@
858849 TRACE_ENTER(4, 14, this, 9, dwFlags, 14, lplpDDClipper, 14, pUnkOuter);
859850 if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
860851 HRESULT ret = CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
861 - if (ret == DD_OK)
862 - {
863 - this->AddRef();
864 - ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
865 - }
866852 TRACE_EXIT(23, ret);
867853 return ret;
868854 }
@@ -871,16 +857,6 @@
872858 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
873859 if(!lplpDDClipper) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
874860 if(pUnkOuter) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
875 - clippercount++;
876 - if(clippercount > clippercountmax)
877 - {
878 - glDirectDrawClipper **clippers2;
879 - clippers2 = (glDirectDrawClipper **)realloc(clippers,(clippercountmax+1024)*sizeof(glDirectDrawClipper *));
880 - if(!clippers2) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
881 - clippers = clippers2;
882 - ZeroMemory(&clippers[clippercountmax],1024*sizeof(glDirectDrawClipper *));
883 - clippercountmax += 1024;
884 - }
885861 TRACE_RET(HRESULT,23,glDirectDrawClipper_Create(dwFlags, this, lplpDDClipper));
886862 }
887863 HRESULT WINAPI glDirectDraw7::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
@@ -1383,11 +1359,6 @@
13841360 surfacecount = 0;
13851361 surfacecountmax = 1024;
13861362 tmpsurface = NULL;
1387 - clippers = (glDirectDrawClipper **)malloc(1024*sizeof(glDirectDrawClipper *));
1388 - if(!clippers) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
1389 - ZeroMemory(clippers,1024*sizeof(glDirectDrawClipper *));
1390 - clippercount = 0;
1391 - clippercountmax = 1024;
13921363 bool useguid = false;
13931364 switch((INT_PTR)lpGUID)
13941365 {
@@ -2054,14 +2025,6 @@
20552026 TRACE_EXIT(0,0);
20562027 }
20572028
2058 -void glDirectDraw7::DeleteClipper(glDirectDrawClipper *clipper)
2059 -{
2060 - TRACE_ENTER(2,14,this,clipper);
2061 - for(int i = 0; i < clippercount; i++)
2062 - if(clippers[i] == clipper) clippers[i] = NULL;
2063 - TRACE_EXIT(0,0);
2064 -}
2065 -
20662029 HRESULT glDirectDraw7::SetupTempSurface(DWORD width, DWORD height)
20672030 {
20682031 DDSURFACEDESC2 ddsd;
@@ -2162,11 +2125,6 @@
21632126 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
21642127 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
21652128 HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
2166 - if (ret == DD_OK)
2167 - {
2168 - this->AddRef();
2169 - ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
2170 - }
21712129 TRACE_EXIT(23, ret);
21722130 return ret;
21732131 }
@@ -2367,11 +2325,6 @@
23682326 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
23692327 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
23702328 HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
2371 - if (ret == DD_OK)
2372 - {
2373 - this->AddRef();
2374 - ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
2375 - }
23762329 TRACE_EXIT(23, ret);
23772330 return ret;
23782331 }
@@ -2596,11 +2549,6 @@
25972550 TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
25982551 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
25992552 HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
2600 - if (ret == DD_OK)
2601 - {
2602 - this->AddRef();
2603 - ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
2604 - }
26052553 TRACE_EXIT(23, ret);
26062554 return ret;
26072555 }
Index: ddraw/glDirectDraw.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2015 William Feely
 3+// Copyright (C) 2011-2016 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -100,7 +100,6 @@
101101 DWORD primaryx,primaryy,primaryrefresh,primarybpp;
102102 bool GetFullscreen(){return fullscreen;};
103103 void DeleteSurface(glDirectDrawSurface7 *surface);
104 - void DeleteClipper(glDirectDrawClipper *clipper);
105104 HRESULT SetupTempSurface(DWORD width, DWORD height);
106105 void DeleteTempSurface();
107106 glDirectDrawSurface7 *primary;
@@ -128,8 +127,6 @@
129128 LONG_PTR winstyle,winstyleex;
130129 glDirectDrawSurface7 **surfaces;
131130 int surfacecount, surfacecountmax;
132 - glDirectDrawClipper **clippers;
133 - int clippercount, clippercountmax;
134131 DEVMODE oldmode;
135132 bool initialized;
136133 glDirect3D7 *glD3D7;
Index: ddraw/glDirectDrawClipper.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011-2014 William Feely
 3+// Copyright (C) 2011-2016 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -45,7 +45,6 @@
4646 newclipper->refcount = 1;
4747 newclipper->initialized = false;
4848 newclipper->lpVtbl = &glDirectDrawClipper_iface;
49 - newclipper->creator = NULL;
5049 if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
5150 TRACE_EXIT(23, DD_OK);
5251 return DD_OK;
@@ -62,7 +61,6 @@
6362 newclipper->refcount = 1;
6463 newclipper->initialized = false;
6564 newclipper->lpVtbl = &glDirectDrawClipper_iface;
66 - newclipper->creator = NULL;
6765 glDirectDrawClipper_Initialize(newclipper, (LPDIRECTDRAW)parent, dwFlags);
6866 if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
6967 TRACE_EXIT(23, DD_OK);
@@ -113,8 +111,6 @@
114112 if (This->cliplist) free(This->cliplist);
115113 if (This->vertices) free(This->vertices);
116114 if (This->indices) free(This->indices);
117 - if (This->glDD7) This->glDD7->DeleteClipper(This);
118 - if (This->creator) This->creator->Release();
119115 free(This);
120116 };
121117 TRACE_EXIT(8,ret);
Index: ddraw/glDirectDrawClipper.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2011 William Feely
 3+// Copyright (C) 2011-2016 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -38,7 +38,6 @@
3939 int maxsize;
4040 bool hascliplist;
4141 bool dirty;
42 - IUnknown *creator;
4342 } glDirectDrawClipper;
4443
4544 typedef struct glDirectDrawClipperVtbl

Follow-up revisions

RevisionCommit summaryAuthorDate
r654Revert clipper refcount changes from r650. Needs further testing.admin03:02, 21 February 2016