Index: ddraw/glDirectDraw.cpp |
— | — | @@ -581,6 +581,7 @@ |
582 | 582 | glD3D3 = new glDirect3D3(glD3D7);
|
583 | 583 | glD3D2 = new glDirect3D2(glD3D7);
|
584 | 584 | glD3D1 = new glDirect3D1(glD3D7);
|
| 585 | + clippers = NULL;
|
585 | 586 | surfaces = NULL;
|
586 | 587 | initialized = false;
|
587 | 588 | devid.liDriverVersion.QuadPart = DXGLVERQWORD;
|
— | — | @@ -644,6 +645,15 @@ |
645 | 646 | {
|
646 | 647 | if (fullscreen) UninstallDXGLFullscreenHook(hWnd);
|
647 | 648 | 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 | + }
|
648 | 658 | if(surfaces)
|
649 | 659 | {
|
650 | 660 | for(int i = 0; i < surfacecount; i++)
|
— | — | @@ -849,6 +859,11 @@ |
850 | 860 | TRACE_ENTER(4, 14, this, 9, dwFlags, 14, lplpDDClipper, 14, pUnkOuter);
|
851 | 861 | if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
852 | 862 | HRESULT ret = CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
|
| 863 | + if (ret == DD_OK)
|
| 864 | + {
|
| 865 | + this->AddRef();
|
| 866 | + ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
|
| 867 | + }
|
853 | 868 | TRACE_EXIT(23, ret);
|
854 | 869 | return ret;
|
855 | 870 | }
|
— | — | @@ -858,6 +873,16 @@ |
859 | 874 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
860 | 875 | if(!lplpDDClipper) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
861 | 876 | 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 | + }
|
862 | 887 | TRACE_RET(HRESULT,23,glDirectDrawClipper_Create(dwFlags, this, lplpDDClipper));
|
863 | 888 | }
|
864 | 889 | HRESULT WINAPI glDirectDraw7::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
|
— | — | @@ -1360,6 +1385,11 @@ |
1361 | 1386 | surfacecount = 0;
|
1362 | 1387 | surfacecountmax = 1024;
|
1363 | 1388 | 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;
|
1364 | 1394 | bool useguid = false;
|
1365 | 1395 | switch((INT_PTR)lpGUID)
|
1366 | 1396 | {
|
— | — | @@ -2026,6 +2056,14 @@ |
2027 | 2057 | TRACE_EXIT(0,0);
|
2028 | 2058 | }
|
2029 | 2059 |
|
| 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 | +
|
2030 | 2068 | HRESULT glDirectDraw7::SetupTempSurface(DWORD width, DWORD height)
|
2031 | 2069 | {
|
2032 | 2070 | DDSURFACEDESC2 ddsd;
|
— | — | @@ -2126,7 +2164,11 @@ |
2127 | 2165 | TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
|
2128 | 2166 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2129 | 2167 | 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);
|
2131 | 2173 | return ret;
|
2132 | 2174 | }
|
2133 | 2175 | HRESULT WINAPI glDirectDraw1::CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter)
|
— | — | @@ -2326,6 +2368,11 @@ |
2327 | 2369 | TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
|
2328 | 2370 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2329 | 2371 | HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
|
| 2372 | + if (ret == DD_OK)
|
| 2373 | + {
|
| 2374 | + this->AddRef();
|
| 2375 | + ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
|
| 2376 | + }
|
2330 | 2377 | TRACE_EXIT(23, ret);
|
2331 | 2378 | return ret;
|
2332 | 2379 | }
|
— | — | @@ -2550,6 +2597,11 @@ |
2551 | 2598 | TRACE_ENTER(4,14,this,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
|
2552 | 2599 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2553 | 2600 | HRESULT ret = glDD7->CreateClipper2(dwFlags, lplpDDClipper, pUnkOuter);
|
| 2601 | + if (ret == DD_OK)
|
| 2602 | + {
|
| 2603 | + this->AddRef();
|
| 2604 | + ((glDirectDrawClipper*)*lplpDDClipper)->creator = this;
|
| 2605 | + }
|
2554 | 2606 | TRACE_EXIT(23, ret);
|
2555 | 2607 | return ret;
|
2556 | 2608 | }
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -100,6 +100,7 @@ |
101 | 101 | DWORD primaryx,primaryy,primaryrefresh,primarybpp;
|
102 | 102 | bool GetFullscreen(){return fullscreen;};
|
103 | 103 | void DeleteSurface(glDirectDrawSurface7 *surface);
|
| 104 | + void DeleteClipper(glDirectDrawClipper *clipper);
|
104 | 105 | HRESULT SetupTempSurface(DWORD width, DWORD height);
|
105 | 106 | void DeleteTempSurface();
|
106 | 107 | glDirectDrawSurface7 *primary;
|
— | — | @@ -127,6 +128,8 @@ |
128 | 129 | LONG_PTR winstyle,winstyleex;
|
129 | 130 | glDirectDrawSurface7 **surfaces;
|
130 | 131 | int surfacecount, surfacecountmax;
|
| 132 | + glDirectDrawClipper **clippers;
|
| 133 | + int clippercount, clippercountmax;
|
131 | 134 | DEVMODE oldmode;
|
132 | 135 | bool initialized;
|
133 | 136 | glDirect3D7 *glD3D7;
|
Index: ddraw/glDirectDrawClipper.cpp |
— | — | @@ -45,6 +45,7 @@ |
46 | 46 | newclipper->refcount = 1;
|
47 | 47 | newclipper->initialized = false;
|
48 | 48 | newclipper->lpVtbl = &glDirectDrawClipper_iface;
|
| 49 | + newclipper->creator = NULL;
|
49 | 50 | if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
|
50 | 51 | TRACE_EXIT(23, DD_OK);
|
51 | 52 | return DD_OK;
|
— | — | @@ -62,6 +63,7 @@ |
63 | 64 | newclipper->refcount = 1;
|
64 | 65 | newclipper->initialized = false;
|
65 | 66 | newclipper->lpVtbl = &glDirectDrawClipper_iface;
|
| 67 | + newclipper->creator = NULL;
|
66 | 68 | glDirectDrawClipper_Initialize(newclipper, (LPDIRECTDRAW)parent, dwFlags);
|
67 | 69 | if (lplpDDClipper) *lplpDDClipper = (LPDIRECTDRAWCLIPPER)newclipper;
|
68 | 70 | TRACE_EXIT(23, DD_OK);
|
— | — | @@ -112,6 +114,8 @@ |
113 | 115 | if (This->cliplist) free(This->cliplist);
|
114 | 116 | if (This->vertices) free(This->vertices);
|
115 | 117 | if (This->indices) free(This->indices);
|
| 118 | + if (This->glDD7) This->glDD7->DeleteClipper(This);
|
| 119 | + if (This->creator) This->creator->Release();
|
116 | 120 | free(This);
|
117 | 121 | };
|
118 | 122 | TRACE_EXIT(8,ret);
|
Index: ddraw/glDirectDrawClipper.h |
— | — | @@ -38,6 +38,7 @@ |
39 | 39 | int maxsize;
|
40 | 40 | bool hascliplist;
|
41 | 41 | bool dirty;
|
| 42 | + IUnknown *creator;
|
42 | 43 | BOOL cliplistchanged;
|
43 | 44 | WINDOWPLACEMENT lastpos;
|
44 | 45 | } glDirectDrawClipper;
|