| Index: ddraw/glDirect3DTexture.cpp |
| — | — | @@ -29,18 +29,9 @@ |
| 30 | 30 | {
|
| 31 | 31 | TRACE_ENTER(2,14,this,14,glDDS7);
|
| 32 | 32 | this->glDDS7 = glDDS7;
|
| 33 | | - refcount = 1;
|
| 34 | 33 | TRACE_EXIT(-1,0);
|
| 35 | 34 | }
|
| 36 | 35 |
|
| 37 | | -glDirect3DTexture2::~glDirect3DTexture2()
|
| 38 | | -{
|
| 39 | | - TRACE_ENTER(1,14,this);
|
| 40 | | - glDDS7->d3dt2 = NULL;
|
| 41 | | - glDDS7->Release();
|
| 42 | | - TRACE_EXIT(-1,0);
|
| 43 | | -}
|
| 44 | | -
|
| 45 | 36 | HRESULT WINAPI glDirect3DTexture2::QueryInterface(REFIID riid, void** ppvObj)
|
| 46 | 37 | {
|
| 47 | 38 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -60,9 +51,7 @@ |
| 61 | 52 | {
|
| 62 | 53 | TRACE_ENTER(1,14,this);
|
| 63 | 54 | if(!this) TRACE_RET(ULONG,8,0);
|
| 64 | | - refcount++;
|
| 65 | | - TRACE_EXIT(8,refcount);
|
| 66 | | - return refcount;
|
| | 55 | + TRACE_RET(ULONG, 8, glDDS7->textureparent->AddRef());
|
| 67 | 56 | }
|
| 68 | 57 |
|
| 69 | 58 | ULONG WINAPI glDirect3DTexture2::Release()
|
| — | — | @@ -69,12 +58,7 @@ |
| 70 | 59 | {
|
| 71 | 60 | TRACE_ENTER(1,14,this);
|
| 72 | 61 | if(!this) TRACE_RET(ULONG,8,0);
|
| 73 | | - ULONG ret;
|
| 74 | | - refcount--;
|
| 75 | | - ret = refcount;
|
| 76 | | - if(refcount == 0) delete this;
|
| 77 | | - TRACE_EXIT(8,ret);
|
| 78 | | - return ret;
|
| | 62 | + TRACE_RET(ULONG, 8, glDDS7->textureparent->Release());
|
| 79 | 63 | }
|
| 80 | 64 |
|
| 81 | 65 | HRESULT WINAPI glDirect3DTexture2::GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice2, LPD3DTEXTUREHANDLE lpHandle)
|
| — | — | @@ -109,16 +93,8 @@ |
| 110 | 94 | {
|
| 111 | 95 | TRACE_ENTER(2,14,this,14,glDDS7);
|
| 112 | 96 | this->glDDS7 = glDDS7;
|
| 113 | | - refcount = 1;
|
| 114 | 97 | TRACE_EXIT(-1,0);
|
| 115 | 98 | }
|
| 116 | | -glDirect3DTexture1::~glDirect3DTexture1()
|
| 117 | | -{
|
| 118 | | - TRACE_ENTER(1,14,this);
|
| 119 | | - glDDS7->d3dt1 = NULL;
|
| 120 | | - glDDS7->Release();
|
| 121 | | - TRACE_EXIT(-1,0);
|
| 122 | | -}
|
| 123 | 99 | HRESULT WINAPI glDirect3DTexture1::QueryInterface(REFIID riid, void** ppvObj)
|
| 124 | 100 | {
|
| 125 | 101 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -137,20 +113,13 @@ |
| 138 | 114 | {
|
| 139 | 115 | TRACE_ENTER(1,14,this);
|
| 140 | 116 | if(!this) TRACE_RET(ULONG,8,0);
|
| 141 | | - refcount++;
|
| 142 | | - TRACE_EXIT(8,refcount);
|
| 143 | | - return refcount;
|
| | 117 | + TRACE_RET(ULONG, 8, glDDS7->textureparent->AddRef());
|
| 144 | 118 | }
|
| 145 | 119 | ULONG WINAPI glDirect3DTexture1::Release()
|
| 146 | 120 | {
|
| 147 | 121 | TRACE_ENTER(1,14,this);
|
| 148 | 122 | if(!this) TRACE_RET(ULONG,8,0);
|
| 149 | | - ULONG ret;
|
| 150 | | - refcount--;
|
| 151 | | - ret = refcount;
|
| 152 | | - if(refcount == 0) delete this;
|
| 153 | | - TRACE_EXIT(8,ret);
|
| 154 | | - return ret;
|
| | 123 | + TRACE_RET(ULONG, 8, glDDS7->textureparent->Release());
|
| 155 | 124 | }
|
| 156 | 125 |
|
| 157 | 126 | HRESULT WINAPI glDirect3DTexture1::GetHandle(LPDIRECT3DDEVICE lpDirect3DDevice, LPD3DTEXTUREHANDLE lpHandle)
|
| Index: ddraw/glDirect3DTexture.h |
| — | — | @@ -23,7 +23,6 @@ |
| 24 | 24 | {
|
| 25 | 25 | public:
|
| 26 | 26 | glDirect3DTexture2(glDirectDrawSurface7 *glDDS7);
|
| 27 | | - virtual ~glDirect3DTexture2();
|
| 28 | 27 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 29 | 28 | ULONG WINAPI AddRef();
|
| 30 | 29 | ULONG WINAPI Release();
|
| — | — | @@ -33,7 +32,6 @@ |
| 34 | 33 | glDirectDrawSurface7 *GetDDS7(){return glDDS7;}
|
| 35 | 34 | private:
|
| 36 | 35 | glDirectDrawSurface7 *glDDS7;
|
| 37 | | - ULONG refcount;
|
| 38 | 36 | };
|
| 39 | 37 |
|
| 40 | 38 | class glDirect3DTexture1 : public IDirect3DTexture
|
| — | — | @@ -40,7 +38,6 @@ |
| 41 | 39 | {
|
| 42 | 40 | public:
|
| 43 | 41 | glDirect3DTexture1(glDirectDrawSurface7 *glDDS7);
|
| 44 | | - virtual ~glDirect3DTexture1();
|
| 45 | 42 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 46 | 43 | ULONG WINAPI AddRef();
|
| 47 | 44 | ULONG WINAPI Release();
|
| — | — | @@ -52,7 +49,6 @@ |
| 53 | 50 | glDirectDrawSurface7 *GetDDS7(){return glDDS7;}
|
| 54 | 51 | private:
|
| 55 | 52 | glDirectDrawSurface7 *glDDS7;
|
| 56 | | - ULONG refcount;
|
| 57 | 53 | };
|
| 58 | 54 |
|
| 59 | 55 | #endif //__GLDIRECT3DTEXTURE_H |
| \ No newline at end of file |
| Index: ddraw/glDirectDraw.cpp |
| — | — | @@ -589,9 +589,6 @@ |
| 590 | 590 | refcount2 = 0;
|
| 591 | 591 | refcount1 = 0;
|
| 592 | 592 | renderer = NULL;
|
| 593 | | - d3ddesc = d3ddesc_default;
|
| 594 | | - d3ddesc3 = d3ddesc3_default;
|
| 595 | | - memcpy(stored_devices, d3ddevices, 3 * sizeof(D3DDevice));
|
| 596 | 593 | TRACE_EXIT(-1, 0);
|
| 597 | 594 | }
|
| 598 | 595 |
|
| — | — | @@ -750,12 +747,6 @@ |
| 751 | 748 | TRACE_EXIT(23,DD_OK);
|
| 752 | 749 | return DD_OK;
|
| 753 | 750 | }
|
| 754 | | - if(riid == IID_IDirectDrawGammaControl)
|
| 755 | | - {
|
| 756 | | - FIXME("Add gamma control\n");
|
| 757 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
| 758 | | - ERR(DDERR_GENERIC);
|
| 759 | | - }
|
| 760 | 751 | /*if(riid == IID_IDDVideoPortContainer)
|
| 761 | 752 | {
|
| 762 | 753 | ERR(DDERR_GENERIC);
|
| — | — | @@ -923,11 +914,11 @@ |
| 924 | 915 | if(!lpDDSurfaceDesc2) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 925 | 916 | if(pUnkOuter) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 926 | 917 | if(lpDDSurfaceDesc2->dwSize < sizeof(DDSURFACEDESC2)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 927 | | - HRESULT ret = CreateSurface2(lpDDSurfaceDesc2,lplpDDSurface,pUnkOuter,TRUE);
|
| | 918 | + HRESULT ret = CreateSurface2(lpDDSurfaceDesc2,lplpDDSurface,pUnkOuter,TRUE,7);
|
| 928 | 919 | if (ret == DD_OK)
|
| 929 | 920 | {
|
| 930 | 921 | this->AddRef();
|
| 931 | | - ((glDirectDrawSurface7*)lplpDDSurface)->creator = this;
|
| | 922 | + ((glDirectDrawSurface7*)*lplpDDSurface)->creator = this;
|
| 932 | 923 | }
|
| 933 | 924 | TRACE_EXIT(23, ret);
|
| 934 | 925 | return ret;
|
| — | — | @@ -934,7 +925,7 @@ |
| 935 | 926 | }
|
| 936 | 927 |
|
| 937 | 928 |
|
| 938 | | -HRESULT glDirectDraw7::CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface)
|
| | 929 | +HRESULT glDirectDraw7::CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface, int version)
|
| 939 | 930 | {
|
| 940 | 931 | HRESULT error;
|
| 941 | 932 | int mipcount;
|
| — | — | @@ -977,7 +968,7 @@ |
| 978 | 969 | ZeroMemory(&surfaces[surfacecountmax], 1024 * sizeof(glDirectDrawSurface7 *));
|
| 979 | 970 | surfacecountmax += 1024;
|
| 980 | 971 | }
|
| 981 | | - surfaces[surfacecount - 1] = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0);
|
| | 972 | + surfaces[surfacecount - 1] = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version);
|
| 982 | 973 | if (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
| 983 | 974 | {
|
| 984 | 975 | primary = surfaces[surfacecount - 1];
|
| — | — | @@ -988,7 +979,7 @@ |
| 989 | 980 | else
|
| 990 | 981 | {
|
| 991 | 982 | if (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 992 | | - *lplpDDSurface = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0);
|
| | 983 | + *lplpDDSurface = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version);
|
| 993 | 984 | }
|
| 994 | 985 | TRACE_VAR("*lplpDDSurface",14,*lplpDDSurface);
|
| 995 | 986 | TRACE_EXIT(23,error);
|
| — | — | @@ -1406,6 +1397,9 @@ |
| 1407 | 1398 | useguid = true;
|
| 1408 | 1399 | DEBUG("Display GUIDs not yet supported, using primary.\n");
|
| 1409 | 1400 | }
|
| | 1401 | + d3ddesc = d3ddesc_default;
|
| | 1402 | + d3ddesc3 = d3ddesc3_default;
|
| | 1403 | + memcpy(stored_devices, d3ddevices, 3 * sizeof(D3DDevice));
|
| 1410 | 1404 | initialized = true;
|
| 1411 | 1405 | TRACE_EXIT(23,DD_OK);
|
| 1412 | 1406 | return DD_OK;
|
| — | — | @@ -1951,11 +1945,11 @@ |
| 1952 | 1946 | ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
|
| 1953 | 1947 | ddsd.dwWidth = width;
|
| 1954 | 1948 | ddsd.dwHeight = height;
|
| 1955 | | - error = CreateSurface2(&ddsd, (LPDIRECTDRAWSURFACE7*)&tmpsurface, NULL, FALSE);
|
| | 1949 | + error = CreateSurface2(&ddsd, (LPDIRECTDRAWSURFACE7*)&tmpsurface, NULL, FALSE, 7);
|
| 1956 | 1950 | if (error == DDERR_OUTOFVIDEOMEMORY)
|
| 1957 | 1951 | {
|
| 1958 | 1952 | ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
| 1959 | | - error = CreateSurface2(&ddsd, (LPDIRECTDRAWSURFACE7*)&tmpsurface, NULL, FALSE);
|
| | 1953 | + error = CreateSurface2(&ddsd, (LPDIRECTDRAWSURFACE7*)&tmpsurface, NULL, FALSE, 7);
|
| 1960 | 1954 | }
|
| 1961 | 1955 | if (error != DD_OK) return error;
|
| 1962 | 1956 | }
|
| — | — | @@ -2065,7 +2059,7 @@ |
| 2066 | 2060 | ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
|
| 2067 | 2061 | memcpy(&ddsd2, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
|
| 2068 | 2062 | ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
| 2069 | | - HRESULT err = glDD7->CreateSurface2(&ddsd2,&lpDDS7,pUnkOuter,TRUE);
|
| | 2063 | + HRESULT err = glDD7->CreateSurface2(&ddsd2,&lpDDS7,pUnkOuter,TRUE,1);
|
| 2070 | 2064 | if(err == DD_OK)
|
| 2071 | 2065 | {
|
| 2072 | 2066 | lpDDS7->QueryInterface(IID_IDirectDrawSurface,(LPVOID*) lplpDDSurface);
|
| — | — | @@ -2269,7 +2263,7 @@ |
| 2270 | 2264 | ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
|
| 2271 | 2265 | memcpy(&ddsd2, lpDDSurfaceDesc, sizeof(DDSURFACEDESC));
|
| 2272 | 2266 | ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
| 2273 | | - HRESULT err = glDD7->CreateSurface2(&ddsd2, &lpDDS7, pUnkOuter, TRUE);
|
| | 2267 | + HRESULT err = glDD7->CreateSurface2(&ddsd2, &lpDDS7, pUnkOuter, TRUE, 2);
|
| 2274 | 2268 | if(err == DD_OK)
|
| 2275 | 2269 | {
|
| 2276 | 2270 | lpDDS7->QueryInterface(IID_IDirectDrawSurface,(LPVOID*) lplpDDSurface);
|
| — | — | @@ -2497,7 +2491,7 @@ |
| 2498 | 2492 | if(!lpDDSurfaceDesc) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 2499 | 2493 | if(lpDDSurfaceDesc->dwSize < sizeof(DDSURFACEDESC2)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 2500 | 2494 | LPDIRECTDRAWSURFACE7 lpDDS7;
|
| 2501 | | - HRESULT err = glDD7->CreateSurface2((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter,TRUE);
|
| | 2495 | + HRESULT err = glDD7->CreateSurface2((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter,TRUE,4);
|
| 2502 | 2496 | if(err == DD_OK)
|
| 2503 | 2497 | {
|
| 2504 | 2498 | lpDDS7->QueryInterface(IID_IDirectDrawSurface4,(LPVOID*) lplpDDSurface);
|
| Index: ddraw/glDirectDraw.h |
| — | — | @@ -87,7 +87,7 @@ |
| 88 | 88 | ULONG WINAPI Release2();
|
| 89 | 89 | ULONG WINAPI AddRef1();
|
| 90 | 90 | ULONG WINAPI Release1();
|
| 91 | | - HRESULT CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface);
|
| | 91 | + HRESULT CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface, int version);
|
| 92 | 92 | HRESULT CreateClipper2(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter);
|
| 93 | 93 | HRESULT CreatePalette2(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette, IUnknown FAR *pUnkOuter);
|
| 94 | 94 | HRESULT err() { return error; }
|
| Index: ddraw/glDirectDrawSurface.cpp |
| — | — | @@ -37,7 +37,7 @@ |
| 38 | 38 |
|
| 39 | 39 | // DDRAW7 routines
|
| 40 | 40 | glDirectDrawSurface7::glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error,
|
| 41 | | - glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel)
|
| | 41 | + glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version)
|
| 42 | 42 | {
|
| 43 | 43 | TRACE_ENTER(5,14,this,14,lpDD7,14,lpDDSurfaceDesc2,14,error,14,palettein);
|
| 44 | 44 | creator = NULL;
|
| — | — | @@ -60,12 +60,12 @@ |
| 61 | 61 | texture = NULL;
|
| 62 | 62 | clipper = NULL;
|
| 63 | 63 | hdc = NULL;
|
| 64 | | - dds1 = NULL;
|
| 65 | | - dds2 = NULL;
|
| 66 | | - dds3 = NULL;
|
| 67 | | - dds4 = NULL;
|
| 68 | | - d3dt2 = NULL;
|
| 69 | | - d3dt1 = NULL;
|
| | 64 | + dds1 = new glDirectDrawSurface1(this);
|
| | 65 | + dds2 = new glDirectDrawSurface2(this);
|
| | 66 | + dds3 = new glDirectDrawSurface3(this);
|
| | 67 | + dds4 = new glDirectDrawSurface4(this);
|
| | 68 | + d3dt2 = new glDirect3DTexture2(this);
|
| | 69 | + d3dt1 = new glDirect3DTexture1(this);
|
| 70 | 70 | buffer = gdibuffer = NULL;
|
| 71 | 71 | bigbuffer = NULL;
|
| 72 | 72 | zbuffer = NULL;
|
| — | — | @@ -327,7 +327,7 @@ |
| 328 | 328 | newdesc.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
|
| 329 | 329 | newdesc.dwMipMapCount = ddsd.dwMipMapCount - 1;
|
| 330 | 330 | HRESULT miperror;
|
| 331 | | - if(newdesc.dwMipMapCount) miptexture = new glDirectDrawSurface7(lpDD7, &newdesc, &miperror, palette, texture, miplevel + 1);
|
| | 331 | + if(newdesc.dwMipMapCount) miptexture = new glDirectDrawSurface7(lpDD7, &newdesc, &miperror, palette, texture, miplevel + 1, version);
|
| 332 | 332 | }
|
| 333 | 333 |
|
| 334 | 334 | if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
|
| — | — | @@ -339,7 +339,13 @@ |
| 340 | 340 | }
|
| 341 | 341 | if(!bitmapinfo->bmiHeader.biBitCount)
|
| 342 | 342 | bitmapinfo->bmiHeader.biBitCount = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
|
| 343 | | - refcount = 1;
|
| | 343 | + refcount7 = 1;
|
| | 344 | + refcount4 = 0;
|
| | 345 | + refcount3 = 0;
|
| | 346 | + refcount2 = 0;
|
| | 347 | + refcount1 = 0;
|
| | 348 | + refcountgamma = 0;
|
| | 349 | + refcountcolor = 0;
|
| 344 | 350 | *error = DD_OK;
|
| 345 | 351 | backbuffer = NULL;
|
| 346 | 352 | if(ddsd.ddsCaps.dwCaps & DDSCAPS_COMPLEX)
|
| — | — | @@ -354,12 +360,27 @@ |
| 355 | 361 | ddsdBack.dwBackBufferCount--;
|
| 356 | 362 | ddsdBack.ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER;
|
| 357 | 363 | ddsdBack.ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
|
| 358 | | - backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,error,palette,parenttex,miplevel);
|
| | 364 | + backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,error,palette,parenttex,miplevel,version);
|
| 359 | 365 | }
|
| 360 | 366 | else if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT){}
|
| 361 | 367 | else *error = DDERR_INVALIDPARAMS;
|
| 362 | 368 | }
|
| 363 | 369 | }
|
| | 370 | + switch (version)
|
| | 371 | + {
|
| | 372 | + case 1:
|
| | 373 | + case 2:
|
| | 374 | + case 3:
|
| | 375 | + default:
|
| | 376 | + textureparent = this->dds1;
|
| | 377 | + break;
|
| | 378 | + case 4:
|
| | 379 | + textureparent = this->dds4;
|
| | 380 | + break;
|
| | 381 | + case 7:
|
| | 382 | + textureparent = this;
|
| | 383 | + break;
|
| | 384 | + }
|
| 364 | 385 | TRACE_VAR("*error",23,*error);
|
| 365 | 386 | TRACE_EXIT(-1,0);
|
| 366 | 387 | }
|
| — | — | @@ -367,16 +388,18 @@ |
| 368 | 389 | {
|
| 369 | 390 | TRACE_ENTER(1,14,this);
|
| 370 | 391 | AddRef();
|
| 371 | | - if(dds1) dds1->Release();
|
| 372 | | - if(dds2) dds2->Release();
|
| 373 | | - if(dds3) dds3->Release();
|
| 374 | | - if(dds4) dds4->Release();
|
| | 392 | + if (dds1) delete dds1;
|
| | 393 | + if (dds2) delete dds2;
|
| | 394 | + if (dds3) delete dds3;
|
| | 395 | + if (dds4) delete dds4;
|
| | 396 | + if (d3dt1) delete d3dt1;
|
| | 397 | + if (d3dt2) delete d3dt2;
|
| 375 | 398 | if(paltex)
|
| 376 | 399 | {
|
| 377 | 400 | glRenderer_DeleteTexture(ddInterface->renderer, paltex);
|
| 378 | 401 | delete paltex;
|
| 379 | 402 | }
|
| 380 | | - if(texture)
|
| | 403 | + if(texture && !(ddsd.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL))
|
| 381 | 404 | {
|
| 382 | 405 | glRenderer_DeleteTexture(ddInterface->renderer, texture);
|
| 383 | 406 | delete texture;
|
| — | — | @@ -394,7 +417,7 @@ |
| 395 | 418 | if(clipper) glDirectDrawClipper_Release(clipper);
|
| 396 | 419 | if(buffer) free(buffer);
|
| 397 | 420 | if(bigbuffer) free(bigbuffer);
|
| 398 | | - if(zbuffer) zbuffer->Release();
|
| | 421 | + if(zbuffer) zbuffer_iface->Release();
|
| 399 | 422 | if(miptexture) miptexture->Release();
|
| 400 | 423 | if(device) device->Release();
|
| 401 | 424 | ddInterface->DeleteSurface(this);
|
| — | — | @@ -406,7 +429,7 @@ |
| 407 | 430 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| 408 | 431 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 409 | 432 | if(!ppvObj) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 410 | | - if(riid == IID_IUnknown)
|
| | 433 | + if((riid == IID_IUnknown) || (riid == IID_IDirectDrawSurface7))
|
| 411 | 434 | {
|
| 412 | 435 | this->AddRef();
|
| 413 | 436 | *ppvObj = this;
|
| — | — | @@ -414,135 +437,67 @@ |
| 415 | 438 | TRACE_EXIT(23,DD_OK);
|
| 416 | 439 | return DD_OK;
|
| 417 | 440 | }
|
| 418 | | - if(riid == IID_IDirectDrawSurface7)
|
| | 441 | + if(riid == IID_IDirectDrawSurface4)
|
| 419 | 442 | {
|
| 420 | | - this->AddRef();
|
| 421 | | - *ppvObj = this;
|
| | 443 | + this->AddRef4();
|
| | 444 | + *ppvObj = dds4;
|
| 422 | 445 | TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 423 | 446 | TRACE_EXIT(23,DD_OK);
|
| 424 | 447 | return DD_OK;
|
| 425 | 448 | }
|
| 426 | | - if(riid == IID_IDirectDrawSurface4)
|
| 427 | | - {
|
| 428 | | - if(dds4)
|
| 429 | | - {
|
| 430 | | - *ppvObj = dds4;
|
| 431 | | - dds4->AddRef();
|
| 432 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 433 | | - TRACE_EXIT(23,DD_OK);
|
| 434 | | - return DD_OK;
|
| 435 | | - }
|
| 436 | | - else
|
| 437 | | - {
|
| 438 | | - this->AddRef();
|
| 439 | | - *ppvObj = new glDirectDrawSurface4(this);
|
| 440 | | - dds4 = (glDirectDrawSurface4*)*ppvObj;
|
| 441 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 442 | | - TRACE_EXIT(23,DD_OK);
|
| 443 | | - return DD_OK;
|
| 444 | | - }
|
| 445 | | - }
|
| 446 | 449 | if(riid == IID_IDirectDrawSurface3)
|
| 447 | 450 | {
|
| 448 | | - if(dds3)
|
| 449 | | - {
|
| 450 | | - *ppvObj = dds3;
|
| 451 | | - dds3->AddRef();
|
| 452 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 453 | | - TRACE_EXIT(23,DD_OK);
|
| 454 | | - return DD_OK;
|
| 455 | | - }
|
| 456 | | - else
|
| 457 | | - {
|
| 458 | | - this->AddRef();
|
| 459 | | - *ppvObj = new glDirectDrawSurface3(this);
|
| 460 | | - dds3 = (glDirectDrawSurface3*)*ppvObj;
|
| 461 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 462 | | - TRACE_EXIT(23,DD_OK);
|
| 463 | | - return DD_OK;
|
| 464 | | - }
|
| | 451 | + this->AddRef3();
|
| | 452 | + *ppvObj = dds3;
|
| | 453 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 454 | + TRACE_EXIT(23,DD_OK);
|
| | 455 | + return DD_OK;
|
| 465 | 456 | }
|
| 466 | 457 | if(riid == IID_IDirectDrawSurface2)
|
| 467 | 458 | {
|
| 468 | | - if(dds2)
|
| 469 | | - {
|
| 470 | | - *ppvObj = dds2;
|
| 471 | | - dds2->AddRef();
|
| 472 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 473 | | - TRACE_EXIT(23,DD_OK);
|
| 474 | | - return DD_OK;
|
| 475 | | - }
|
| 476 | | - else
|
| 477 | | - {
|
| 478 | | - this->AddRef();
|
| 479 | | - *ppvObj = new glDirectDrawSurface2(this);
|
| 480 | | - dds2 = (glDirectDrawSurface2*)*ppvObj;
|
| 481 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 482 | | - TRACE_EXIT(23,DD_OK);
|
| 483 | | - return DD_OK;
|
| 484 | | - }
|
| | 459 | + this->AddRef2();
|
| | 460 | + *ppvObj = dds2;
|
| | 461 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 462 | + TRACE_EXIT(23,DD_OK);
|
| | 463 | + return DD_OK;
|
| 485 | 464 | }
|
| 486 | 465 | if(riid == IID_IDirectDrawSurface)
|
| 487 | 466 | {
|
| 488 | | - if(dds1)
|
| 489 | | - {
|
| 490 | | - *ppvObj = dds1;
|
| 491 | | - dds1->AddRef();
|
| 492 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 493 | | - TRACE_EXIT(23,DD_OK);
|
| 494 | | - return DD_OK;
|
| 495 | | - }
|
| 496 | | - else
|
| 497 | | - {
|
| 498 | | - this->AddRef();
|
| 499 | | - *ppvObj = new glDirectDrawSurface1(this);
|
| 500 | | - dds1 = (glDirectDrawSurface1*)*ppvObj;
|
| 501 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 502 | | - TRACE_EXIT(23,DD_OK);
|
| 503 | | - return DD_OK;
|
| 504 | | - }
|
| | 467 | + this->AddRef1();
|
| | 468 | + *ppvObj = dds1;
|
| | 469 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 470 | + TRACE_EXIT(23,DD_OK);
|
| | 471 | + return DD_OK;
|
| 505 | 472 | }
|
| 506 | 473 | if(riid == IID_IDirect3DTexture2)
|
| 507 | 474 | {
|
| 508 | | - if(d3dt2)
|
| 509 | | - {
|
| 510 | | - *ppvObj = d3dt2;
|
| 511 | | - d3dt2->AddRef();
|
| 512 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 513 | | - TRACE_EXIT(23,DD_OK);
|
| 514 | | - return DD_OK;
|
| 515 | | - }
|
| 516 | | - else
|
| 517 | | - {
|
| 518 | | - this->AddRef();
|
| 519 | | - *ppvObj = new glDirect3DTexture2(this);
|
| 520 | | - d3dt2 = (glDirect3DTexture2*)*ppvObj;
|
| 521 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 522 | | - TRACE_EXIT(23,DD_OK);
|
| 523 | | - return DD_OK;
|
| 524 | | - }
|
| | 475 | + d3dt2->AddRef();
|
| | 476 | + *ppvObj = d3dt2;
|
| | 477 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 478 | + TRACE_EXIT(23,DD_OK);
|
| | 479 | + return DD_OK;
|
| 525 | 480 | }
|
| 526 | 481 | if(riid == IID_IDirect3DTexture)
|
| 527 | 482 | {
|
| 528 | | - if(d3dt1)
|
| 529 | | - {
|
| 530 | | - *ppvObj = d3dt1;
|
| 531 | | - d3dt1->AddRef();
|
| 532 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 533 | | - TRACE_EXIT(23,DD_OK);
|
| 534 | | - return DD_OK;
|
| 535 | | - }
|
| 536 | | - else
|
| 537 | | - {
|
| 538 | | - this->AddRef();
|
| 539 | | - *ppvObj = new glDirect3DTexture1(this);
|
| 540 | | - d3dt1 = (glDirect3DTexture1*)*ppvObj;
|
| 541 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 542 | | - TRACE_EXIT(23,DD_OK);
|
| 543 | | - return DD_OK;
|
| 544 | | - }
|
| | 483 | + d3dt1->AddRef();
|
| | 484 | + *ppvObj = d3dt1;
|
| | 485 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| | 486 | + TRACE_EXIT(23,DD_OK);
|
| | 487 | + return DD_OK;
|
| 545 | 488 | }
|
| 546 | | - if((riid == IID_IDirect3DDevice) || (riid == IID_IDirect3DHALDevice) || (riid == IID_IDirect3DRGBDevice) ||
|
| | 489 | + if (riid == IID_IDirectDrawGammaControl)
|
| | 490 | + {
|
| | 491 | + FIXME("Add gamma control\n");
|
| | 492 | + TRACE_EXIT(23, E_NOINTERFACE);
|
| | 493 | + ERR(E_NOINTERFACE);
|
| | 494 | + }
|
| | 495 | + if (riid == IID_IDirectDrawColorControl)
|
| | 496 | + {
|
| | 497 | + FIXME("Add color control\n");
|
| | 498 | + TRACE_EXIT(23, E_NOINTERFACE);
|
| | 499 | + ERR(E_NOINTERFACE);
|
| | 500 | + }
|
| | 501 | + if ((riid == IID_IDirect3DDevice) || (riid == IID_IDirect3DHALDevice) || (riid == IID_IDirect3DRGBDevice) ||
|
| 547 | 502 | (riid == IID_IDirect3DRampDevice) || (riid == IID_IDirect3DRefDevice))
|
| 548 | 503 | {
|
| 549 | 504 |
|
| — | — | @@ -582,9 +537,9 @@ |
| 583 | 538 | {
|
| 584 | 539 | TRACE_ENTER(1,14,this);
|
| 585 | 540 | if(!this) TRACE_RET(ULONG,8,0);
|
| 586 | | - refcount++;
|
| 587 | | - TRACE_EXIT(8,refcount);
|
| 588 | | - return refcount;
|
| | 541 | + refcount7++;
|
| | 542 | + TRACE_EXIT(8,refcount7);
|
| | 543 | + return refcount7;
|
| 589 | 544 | }
|
| 590 | 545 | ULONG WINAPI glDirectDrawSurface7::Release()
|
| 591 | 546 | {
|
| — | — | @@ -591,15 +546,160 @@ |
| 592 | 547 | TRACE_ENTER(1,14,this);
|
| 593 | 548 | if(!this) TRACE_RET(ULONG,8,0);
|
| 594 | 549 | ULONG ret;
|
| 595 | | - refcount--;
|
| 596 | | - ret = refcount;
|
| 597 | | - if(refcount == 0) delete this;
|
| | 550 | + if (refcount7 == 0) TRACE_RET(ULONG, 8, 0);
|
| | 551 | + refcount7--;
|
| | 552 | + ret = refcount7;
|
| | 553 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount3 == 0) && (refcount2 == 0) &&
|
| | 554 | + (refcount1 == 0) && (refcountgamma == 0) && (refcountcolor == 0))delete this;
|
| 598 | 555 | TRACE_EXIT(8,ret);
|
| 599 | 556 | return ret;
|
| 600 | 557 | }
|
| | 558 | +ULONG WINAPI glDirectDrawSurface7::AddRef4()
|
| | 559 | +{
|
| | 560 | + TRACE_ENTER(1, 14, this);
|
| | 561 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 562 | + refcount4++;
|
| | 563 | + TRACE_EXIT(8, refcount4);
|
| | 564 | + return refcount4;
|
| | 565 | +}
|
| | 566 | +ULONG WINAPI glDirectDrawSurface7::Release4()
|
| | 567 | +{
|
| | 568 | + TRACE_ENTER(1, 14, this);
|
| | 569 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 570 | + ULONG ret;
|
| | 571 | + if (refcount4 == 0) TRACE_RET(ULONG, 8, 0);
|
| | 572 | + refcount4--;
|
| | 573 | + ret = refcount4;
|
| | 574 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount3 == 0) && (refcount2 == 0) &&
|
| | 575 | + (refcount1 == 0) && (refcountgamma == 0) && (refcountcolor == 0))delete this;
|
| | 576 | + TRACE_EXIT(8, ret);
|
| | 577 | + return ret;
|
| | 578 | +}
|
| | 579 | +ULONG WINAPI glDirectDrawSurface7::AddRef3()
|
| | 580 | +{
|
| | 581 | + TRACE_ENTER(1, 14, this);
|
| | 582 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 583 | + refcount3++;
|
| | 584 | + TRACE_EXIT(8, refcount3);
|
| | 585 | + return refcount3;
|
| | 586 | +}
|
| | 587 | +ULONG WINAPI glDirectDrawSurface7::Release3()
|
| | 588 | +{
|
| | 589 | + TRACE_ENTER(1, 14, this);
|
| | 590 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 591 | + ULONG ret;
|
| | 592 | + if (refcount3 == 0) TRACE_RET(ULONG, 8, 0);
|
| | 593 | + refcount3--;
|
| | 594 | + ret = refcount3;
|
| | 595 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount3 == 0) && (refcount2 == 0) &&
|
| | 596 | + (refcount1 == 0) && (refcountgamma == 0) && (refcountcolor == 0))delete this;
|
| | 597 | + TRACE_EXIT(8, ret);
|
| | 598 | + return ret;
|
| | 599 | +}
|
| | 600 | +ULONG WINAPI glDirectDrawSurface7::AddRef2()
|
| | 601 | +{
|
| | 602 | + TRACE_ENTER(1, 14, this);
|
| | 603 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 604 | + refcount2++;
|
| | 605 | + TRACE_EXIT(8, refcount2);
|
| | 606 | + return refcount2;
|
| | 607 | +}
|
| | 608 | +ULONG WINAPI glDirectDrawSurface7::Release2()
|
| | 609 | +{
|
| | 610 | + TRACE_ENTER(1, 14, this);
|
| | 611 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 612 | + ULONG ret;
|
| | 613 | + if (refcount2 == 0) TRACE_RET(ULONG, 8, 0);
|
| | 614 | + refcount2--;
|
| | 615 | + ret = refcount2;
|
| | 616 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount3 == 0) && (refcount2 == 0) &&
|
| | 617 | + (refcount1 == 0) && (refcountgamma == 0) && (refcountcolor == 0))delete this;
|
| | 618 | + TRACE_EXIT(8, ret);
|
| | 619 | + return ret;
|
| | 620 | +}
|
| | 621 | +ULONG WINAPI glDirectDrawSurface7::AddRef1()
|
| | 622 | +{
|
| | 623 | + TRACE_ENTER(1, 14, this);
|
| | 624 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 625 | + refcount1++;
|
| | 626 | + TRACE_EXIT(8, refcount1);
|
| | 627 | + return refcount1;
|
| | 628 | +}
|
| | 629 | +ULONG WINAPI glDirectDrawSurface7::Release1()
|
| | 630 | +{
|
| | 631 | + TRACE_ENTER(1, 14, this);
|
| | 632 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 633 | + ULONG ret;
|
| | 634 | + if (refcount1 == 0) TRACE_RET(ULONG, 8, 0);
|
| | 635 | + refcount1--;
|
| | 636 | + ret = refcount1;
|
| | 637 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount3 == 0) && (refcount2 == 0) &&
|
| | 638 | + (refcount1 == 0) && (refcountgamma == 0) && (refcountcolor == 0))delete this;
|
| | 639 | + TRACE_EXIT(8, ret);
|
| | 640 | + return ret;
|
| | 641 | +}
|
| | 642 | +ULONG WINAPI glDirectDrawSurface7::AddRefGamma()
|
| | 643 | +{
|
| | 644 | + TRACE_ENTER(1, 14, this);
|
| | 645 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 646 | + refcountgamma++;
|
| | 647 | + TRACE_EXIT(8, refcountgamma);
|
| | 648 | + return refcountgamma;
|
| | 649 | +}
|
| | 650 | +ULONG WINAPI glDirectDrawSurface7::ReleaseGamma()
|
| | 651 | +{
|
| | 652 | + TRACE_ENTER(1, 14, this);
|
| | 653 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 654 | + ULONG ret;
|
| | 655 | + if (refcountgamma == 0) TRACE_RET(ULONG, 8, 0);
|
| | 656 | + refcountgamma--;
|
| | 657 | + ret = refcountgamma;
|
| | 658 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount3 == 0) && (refcount2 == 0) &&
|
| | 659 | + (refcount1 == 0) && (refcountgamma == 0) && (refcountcolor == 0))delete this;
|
| | 660 | + TRACE_EXIT(8, ret);
|
| | 661 | + return ret;
|
| | 662 | +}
|
| | 663 | +ULONG WINAPI glDirectDrawSurface7::AddRefColor()
|
| | 664 | +{
|
| | 665 | + TRACE_ENTER(1, 14, this);
|
| | 666 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 667 | + refcountcolor++;
|
| | 668 | + TRACE_EXIT(8, refcountcolor);
|
| | 669 | + return refcountcolor;
|
| | 670 | +}
|
| | 671 | +ULONG WINAPI glDirectDrawSurface7::ReleaseColor()
|
| | 672 | +{
|
| | 673 | + TRACE_ENTER(1, 14, this);
|
| | 674 | + if (!this) TRACE_RET(ULONG, 8, 0);
|
| | 675 | + ULONG ret;
|
| | 676 | + if (refcountcolor == 0) TRACE_RET(ULONG, 8, 0);
|
| | 677 | + refcountcolor--;
|
| | 678 | + ret = refcountcolor;
|
| | 679 | + if ((refcount7 == 0) && (refcount4 == 0) && (refcount3 == 0) && (refcount2 == 0) &&
|
| | 680 | + (refcount1 == 0) && (refcountgamma == 0) && (refcountcolor == 0))delete this;
|
| | 681 | + TRACE_EXIT(8, ret);
|
| | 682 | + return ret;
|
| | 683 | +}
|
| | 684 | +
|
| 601 | 685 | HRESULT WINAPI glDirectDrawSurface7::AddAttachedSurface(LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface)
|
| 602 | 686 | {
|
| 603 | | - TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
| | 687 | + TRACE_ENTER(2, 14, this, 15, lpDDSAttachedSurface);
|
| | 688 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| | 689 | + if (!lpDDSAttachedSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 690 | + LPDIRECTDRAWSURFACE7 dds7;
|
| | 691 | + HRESULT ret;
|
| | 692 | + ret = ((IUnknown*)lpDDSAttachedSurface)->QueryInterface(IID_IDirectDrawSurface7, (void**)&dds7);
|
| | 693 | + if (ret != S_OK) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 694 | + ret = AddAttachedSurface2(dds7, lpDDSAttachedSurface);
|
| | 695 | + if (ret == DD_OK) ((IUnknown*)lpDDSAttachedSurface)->AddRef();
|
| | 696 | + dds7->Release();
|
| | 697 | + TRACE_RET(HRESULT, 23, ret);
|
| | 698 | + return ret;
|
| | 699 | +}
|
| | 700 | +
|
| | 701 | +HRESULT glDirectDrawSurface7::AddAttachedSurface2(LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface, IUnknown *iface)
|
| | 702 | +{
|
| | 703 | + TRACE_ENTER(3,14,this,14,lpDDSAttachedSurface,iface);
|
| 604 | 704 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 605 | 705 | if(!lpDDSAttachedSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 606 | 706 | if(zbuffer) TRACE_RET(HRESULT,23,DDERR_SURFACEALREADYATTACHED);
|
| — | — | @@ -609,8 +709,8 @@ |
| 610 | 710 | attached->GetSurfaceDesc(&ddsd);
|
| 611 | 711 | if((ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER) || (ddsd.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
|
| 612 | 712 | {
|
| 613 | | - attached->AddRef();
|
| 614 | 713 | zbuffer = attached;
|
| | 714 | + zbuffer_iface = iface;
|
| 615 | 715 | TRACE_EXIT(23,DD_OK);
|
| 616 | 716 | return DD_OK;
|
| 617 | 717 | }
|
| — | — | @@ -750,7 +850,7 @@ |
| 751 | 851 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 752 | 852 | if(lpDDSAttachedSurface == (LPDIRECTDRAWSURFACE7)zbuffer)
|
| 753 | 853 | {
|
| 754 | | - zbuffer->Release();
|
| | 854 | + zbuffer_iface->Release();
|
| 755 | 855 | zbuffer = NULL;
|
| 756 | 856 | TRACE_EXIT(23,DD_OK);
|
| 757 | 857 | return DD_OK;
|
| — | — | @@ -1627,30 +1727,8 @@ |
| 1628 | 1728 | {
|
| 1629 | 1729 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
| 1630 | 1730 | glDDS7 = gl_DDS7;
|
| 1631 | | - refcount = 1;
|
| 1632 | | - attachments = (glDirectDrawSurface1**)malloc(16 * sizeof(glDirectDrawSurface1*));
|
| 1633 | | - attachcount = 0;
|
| 1634 | | - maxattach = 16;
|
| 1635 | | - if (attachments)
|
| 1636 | | - {
|
| 1637 | | - if (attachcount)
|
| 1638 | | - {
|
| 1639 | | - for (int i = 0; i < attachcount; i++)
|
| 1640 | | - {
|
| 1641 | | - if (attachments[i]) attachments[i]->Release();
|
| 1642 | | - }
|
| 1643 | | - }
|
| 1644 | | - free(attachments);
|
| 1645 | | - }
|
| 1646 | 1731 | TRACE_EXIT(-1, 0);
|
| 1647 | 1732 | }
|
| 1648 | | -glDirectDrawSurface1::~glDirectDrawSurface1()
|
| 1649 | | -{
|
| 1650 | | - TRACE_ENTER(1,14,this);
|
| 1651 | | - glDDS7->dds1 = NULL;
|
| 1652 | | - glDDS7->Release();
|
| 1653 | | - TRACE_EXIT(-1,0);
|
| 1654 | | -}
|
| 1655 | 1733 | HRESULT WINAPI glDirectDrawSurface1::QueryInterface(REFIID riid, void** ppvObj)
|
| 1656 | 1734 | {
|
| 1657 | 1735 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -1669,74 +1747,27 @@ |
| 1670 | 1748 | {
|
| 1671 | 1749 | TRACE_ENTER(1,14,this);
|
| 1672 | 1750 | if(!this) TRACE_RET(ULONG,8,0);
|
| 1673 | | - refcount++;
|
| 1674 | | - TRACE_EXIT(8,refcount);
|
| 1675 | | - return refcount;
|
| | 1751 | + TRACE_RET(ULONG, 8, glDDS7->AddRef1());
|
| 1676 | 1752 | }
|
| 1677 | 1753 | ULONG WINAPI glDirectDrawSurface1::Release()
|
| 1678 | 1754 | {
|
| 1679 | 1755 | TRACE_ENTER(1,14,this);
|
| 1680 | 1756 | if(!this) TRACE_RET(ULONG,8,0);
|
| 1681 | | - ULONG ret;
|
| 1682 | | - refcount--;
|
| 1683 | | - ret = refcount;
|
| 1684 | | - if(refcount == 0) delete this;
|
| 1685 | | - TRACE_EXIT(8,ret);
|
| 1686 | | - return ret;
|
| | 1757 | + TRACE_RET(ULONG, 8, glDDS7->Release1());
|
| 1687 | 1758 | }
|
| 1688 | | -void glDirectDrawSurface1::AddAttach(glDirectDrawSurface1 *attach)
|
| 1689 | | -{
|
| 1690 | | - bool emptyspace = false;
|
| 1691 | | - int index;
|
| 1692 | | - for (int i = 0; i < attachcount; i++)
|
| 1693 | | - {
|
| 1694 | | - if (!attachments[i])
|
| 1695 | | - {
|
| 1696 | | - emptyspace = true;
|
| 1697 | | - index = i;
|
| 1698 | | - break;
|
| 1699 | | - }
|
| 1700 | | - }
|
| 1701 | | - if (emptyspace) attachments[index] = attach;
|
| 1702 | | - else
|
| 1703 | | - {
|
| 1704 | | - attachcount++;
|
| 1705 | | - if (attachcount >= maxattach)
|
| 1706 | | - {
|
| 1707 | | - glDirectDrawSurface1 **newattach = (glDirectDrawSurface1**)realloc(attachments,
|
| 1708 | | - (maxattach + 16)*sizeof(glDirectDrawSurface1*));
|
| 1709 | | - if (newattach)
|
| 1710 | | - {
|
| 1711 | | - maxattach += 16;
|
| 1712 | | - attachments = newattach;
|
| 1713 | | - }
|
| 1714 | | - }
|
| 1715 | | - attachments[attachcount-1] = attach;
|
| 1716 | | - }
|
| 1717 | | - attach->AddRef();
|
| 1718 | | -}
|
| 1719 | | -void glDirectDrawSurface1::DeleteAttach(glDirectDrawSurface1 *attach)
|
| 1720 | | -{
|
| 1721 | | - if (!attachcount) return;
|
| 1722 | | - for (int i = 0; i < attachcount; i++)
|
| 1723 | | - {
|
| 1724 | | - if (attachments[i] == attach)
|
| 1725 | | - {
|
| 1726 | | - attach->Release();
|
| 1727 | | - attachments[i] = NULL;
|
| 1728 | | - return;
|
| 1729 | | - }
|
| 1730 | | - }
|
| 1731 | | -}
|
| 1732 | 1759 | HRESULT WINAPI glDirectDrawSurface1::AddAttachedSurface(LPDIRECTDRAWSURFACE lpDDSAttachedSurface)
|
| 1733 | 1760 | {
|
| 1734 | | - TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
| 1735 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 1736 | | - if(!lpDDSAttachedSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 1737 | | - HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface1*)lpDDSAttachedSurface)->GetDDS7());
|
| 1738 | | - if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 1739 | | - AddAttach((glDirectDrawSurface1*)lpDDSAttachedSurface);
|
| 1740 | | - TRACE_EXIT(23, ret);
|
| | 1761 | + TRACE_ENTER(2, 14, this, 15, lpDDSAttachedSurface);
|
| | 1762 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| | 1763 | + if (!lpDDSAttachedSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 1764 | + LPDIRECTDRAWSURFACE7 dds7;
|
| | 1765 | + HRESULT ret;
|
| | 1766 | + ret = ((IUnknown*)lpDDSAttachedSurface)->QueryInterface(IID_IDirectDrawSurface7, (void**)&dds7);
|
| | 1767 | + if (ret != S_OK) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 1768 | + ret = glDDS7->AddAttachedSurface2(dds7, lpDDSAttachedSurface);
|
| | 1769 | + if (ret == DD_OK) ((IUnknown*)lpDDSAttachedSurface)->AddRef();
|
| | 1770 | + dds7->Release();
|
| | 1771 | + TRACE_RET(HRESULT, 23, ret);
|
| 1741 | 1772 | return ret;
|
| 1742 | 1773 | }
|
| 1743 | 1774 | HRESULT WINAPI glDirectDrawSurface1::AddOverlayDirtyRect(LPRECT lpRect)
|
| — | — | @@ -1784,7 +1815,6 @@ |
| 1785 | 1816 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 1786 | 1817 | HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface1*)lpDDSAttachedSurface)->GetDDS7());
|
| 1787 | 1818 | if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 1788 | | - DeleteAttach((glDirectDrawSurface1*)lpDDSAttachedSurface);
|
| 1789 | 1819 | TRACE_EXIT(23, ret);
|
| 1790 | 1820 | return ret;
|
| 1791 | 1821 | }
|
| — | — | @@ -2003,30 +2033,8 @@ |
| 2004 | 2034 | {
|
| 2005 | 2035 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
| 2006 | 2036 | glDDS7 = gl_DDS7;
|
| 2007 | | - refcount = 1;
|
| 2008 | | - attachments = (glDirectDrawSurface2**)malloc(16 * sizeof(glDirectDrawSurface2*));
|
| 2009 | | - attachcount = 0;
|
| 2010 | | - maxattach = 16;
|
| 2011 | 2037 | TRACE_EXIT(-1, 0);
|
| 2012 | 2038 | }
|
| 2013 | | -glDirectDrawSurface2::~glDirectDrawSurface2()
|
| 2014 | | -{
|
| 2015 | | - TRACE_ENTER(1,14,this);
|
| 2016 | | - glDDS7->dds2 = NULL;
|
| 2017 | | - glDDS7->Release();
|
| 2018 | | - if (attachments)
|
| 2019 | | - {
|
| 2020 | | - if (attachcount)
|
| 2021 | | - {
|
| 2022 | | - for (int i = 0; i < attachcount; i++)
|
| 2023 | | - {
|
| 2024 | | - if (attachments[i]) attachments[i]->Release();
|
| 2025 | | - }
|
| 2026 | | - }
|
| 2027 | | - free(attachments);
|
| 2028 | | - }
|
| 2029 | | - TRACE_EXIT(-1, 0);
|
| 2030 | | -}
|
| 2031 | 2039 | HRESULT WINAPI glDirectDrawSurface2::QueryInterface(REFIID riid, void** ppvObj)
|
| 2032 | 2040 | {
|
| 2033 | 2041 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -2044,74 +2052,27 @@ |
| 2045 | 2053 | {
|
| 2046 | 2054 | TRACE_ENTER(1,14,this);
|
| 2047 | 2055 | if(!this) TRACE_RET(ULONG,8,0);
|
| 2048 | | - refcount++;
|
| 2049 | | - TRACE_EXIT(8,refcount);
|
| 2050 | | - return refcount;
|
| | 2056 | + TRACE_RET(ULONG, 8, glDDS7->AddRef2());
|
| 2051 | 2057 | }
|
| 2052 | 2058 | ULONG WINAPI glDirectDrawSurface2::Release()
|
| 2053 | 2059 | {
|
| 2054 | 2060 | TRACE_ENTER(1,14,this);
|
| 2055 | 2061 | if(!this) TRACE_RET(ULONG,8,0);
|
| 2056 | | - ULONG ret;
|
| 2057 | | - refcount--;
|
| 2058 | | - ret = refcount;
|
| 2059 | | - if(refcount == 0) delete this;
|
| 2060 | | - TRACE_EXIT(8,ret);
|
| 2061 | | - return ret;
|
| | 2062 | + TRACE_RET(ULONG, 8, glDDS7->Release2());
|
| 2062 | 2063 | }
|
| 2063 | | -void glDirectDrawSurface2::AddAttach(glDirectDrawSurface2 *attach)
|
| 2064 | | -{
|
| 2065 | | - bool emptyspace = false;
|
| 2066 | | - int index;
|
| 2067 | | - for (int i = 0; i < attachcount; i++)
|
| 2068 | | - {
|
| 2069 | | - if (!attachments[i])
|
| 2070 | | - {
|
| 2071 | | - emptyspace = true;
|
| 2072 | | - index = i;
|
| 2073 | | - break;
|
| 2074 | | - }
|
| 2075 | | - }
|
| 2076 | | - if (emptyspace) attachments[index] = attach;
|
| 2077 | | - else
|
| 2078 | | - {
|
| 2079 | | - attachcount++;
|
| 2080 | | - if (attachcount >= maxattach)
|
| 2081 | | - {
|
| 2082 | | - glDirectDrawSurface2 **newattach = (glDirectDrawSurface2**)realloc(attachments,
|
| 2083 | | - (maxattach + 16)*sizeof(glDirectDrawSurface2*));
|
| 2084 | | - if (newattach)
|
| 2085 | | - {
|
| 2086 | | - maxattach += 16;
|
| 2087 | | - attachments = newattach;
|
| 2088 | | - }
|
| 2089 | | - }
|
| 2090 | | - attachments[attachcount-1] = attach;
|
| 2091 | | - }
|
| 2092 | | - attach->AddRef();
|
| 2093 | | -}
|
| 2094 | | -void glDirectDrawSurface2::DeleteAttach(glDirectDrawSurface2 *attach)
|
| 2095 | | -{
|
| 2096 | | - if (!attachcount) return;
|
| 2097 | | - for (int i = 0; i < attachcount; i++)
|
| 2098 | | - {
|
| 2099 | | - if (attachments[i] == attach)
|
| 2100 | | - {
|
| 2101 | | - attach->Release();
|
| 2102 | | - attachments[i] = NULL;
|
| 2103 | | - return;
|
| 2104 | | - }
|
| 2105 | | - }
|
| 2106 | | -}
|
| 2107 | 2064 | HRESULT WINAPI glDirectDrawSurface2::AddAttachedSurface(LPDIRECTDRAWSURFACE2 lpDDSAttachedSurface)
|
| 2108 | 2065 | {
|
| 2109 | | - TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
| 2110 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 2111 | | - if(!lpDDSAttachedSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 2112 | | - HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface2*)lpDDSAttachedSurface)->GetDDS7());
|
| 2113 | | - if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2114 | | - AddAttach((glDirectDrawSurface2*)lpDDSAttachedSurface);
|
| 2115 | | - TRACE_EXIT(23, ret);
|
| | 2066 | + TRACE_ENTER(2, 14, this, 15, lpDDSAttachedSurface);
|
| | 2067 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| | 2068 | + if (!lpDDSAttachedSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 2069 | + LPDIRECTDRAWSURFACE7 dds7;
|
| | 2070 | + HRESULT ret;
|
| | 2071 | + ret = ((IUnknown*)lpDDSAttachedSurface)->QueryInterface(IID_IDirectDrawSurface7, (void**)&dds7);
|
| | 2072 | + if (ret != S_OK) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 2073 | + ret = glDDS7->AddAttachedSurface2(dds7, lpDDSAttachedSurface);
|
| | 2074 | + if (ret == DD_OK) ((IUnknown*)lpDDSAttachedSurface)->AddRef();
|
| | 2075 | + dds7->Release();
|
| | 2076 | + TRACE_RET(HRESULT, 23, ret);
|
| 2116 | 2077 | return ret;
|
| 2117 | 2078 | }
|
| 2118 | 2079 | HRESULT WINAPI glDirectDrawSurface2::AddOverlayDirtyRect(LPRECT lpRect)
|
| — | — | @@ -2159,7 +2120,6 @@ |
| 2160 | 2121 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 2161 | 2122 | HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface2*)lpDDSAttachedSurface)->GetDDS7());
|
| 2162 | 2123 | if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2163 | | - DeleteAttach((glDirectDrawSurface2*)lpDDSAttachedSurface);
|
| 2164 | 2124 | TRACE_EXIT(23, ret);
|
| 2165 | 2125 | return ret;
|
| 2166 | 2126 | }
|
| — | — | @@ -2401,30 +2361,8 @@ |
| 2402 | 2362 | {
|
| 2403 | 2363 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
| 2404 | 2364 | glDDS7 = gl_DDS7;
|
| 2405 | | - refcount = 1;
|
| 2406 | | - attachments = (glDirectDrawSurface3**)malloc(16 * sizeof(glDirectDrawSurface3*));
|
| 2407 | | - attachcount = 0;
|
| 2408 | | - maxattach = 16;
|
| 2409 | 2365 | TRACE_EXIT(-1, 0);
|
| 2410 | 2366 | }
|
| 2411 | | -glDirectDrawSurface3::~glDirectDrawSurface3()
|
| 2412 | | -{
|
| 2413 | | - TRACE_ENTER(1,14,this);
|
| 2414 | | - glDDS7->dds3 = NULL;
|
| 2415 | | - glDDS7->Release();
|
| 2416 | | - if (attachments)
|
| 2417 | | - {
|
| 2418 | | - if (attachcount)
|
| 2419 | | - {
|
| 2420 | | - for (int i = 0; i < attachcount; i++)
|
| 2421 | | - {
|
| 2422 | | - if (attachments[i]) attachments[i]->Release();
|
| 2423 | | - }
|
| 2424 | | - }
|
| 2425 | | - free(attachments);
|
| 2426 | | - }
|
| 2427 | | - TRACE_EXIT(-1, 0);
|
| 2428 | | -}
|
| 2429 | 2367 | HRESULT WINAPI glDirectDrawSurface3::QueryInterface(REFIID riid, void** ppvObj)
|
| 2430 | 2368 | {
|
| 2431 | 2369 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -2442,75 +2380,28 @@ |
| 2443 | 2381 | ULONG WINAPI glDirectDrawSurface3::AddRef()
|
| 2444 | 2382 | {
|
| 2445 | 2383 | TRACE_ENTER(1,14,this);
|
| 2446 | | - if(!this) return 0;
|
| 2447 | | - refcount++;
|
| 2448 | | - TRACE_EXIT(23,refcount);
|
| 2449 | | - return refcount;
|
| | 2384 | + if (!this) TRACE_RET(ULONG,8,0);
|
| | 2385 | + TRACE_RET(ULONG, 8, glDDS7->AddRef3());
|
| 2450 | 2386 | }
|
| 2451 | 2387 | ULONG WINAPI glDirectDrawSurface3::Release()
|
| 2452 | 2388 | {
|
| 2453 | 2389 | TRACE_ENTER(1,14,this);
|
| 2454 | 2390 | if(!this) TRACE_RET(ULONG,8,0);
|
| 2455 | | - ULONG ret;
|
| 2456 | | - refcount--;
|
| 2457 | | - ret = refcount;
|
| 2458 | | - if(refcount == 0) delete this;
|
| 2459 | | - TRACE_EXIT(8,ret);
|
| 2460 | | - return ret;
|
| | 2391 | + TRACE_RET(ULONG, 8, glDDS7->Release3());
|
| 2461 | 2392 | }
|
| 2462 | | -void glDirectDrawSurface3::AddAttach(glDirectDrawSurface3 *attach)
|
| 2463 | | -{
|
| 2464 | | - bool emptyspace = false;
|
| 2465 | | - int index;
|
| 2466 | | - for (int i = 0; i < attachcount; i++)
|
| 2467 | | - {
|
| 2468 | | - if (!attachments[i])
|
| 2469 | | - {
|
| 2470 | | - emptyspace = true;
|
| 2471 | | - index = i;
|
| 2472 | | - break;
|
| 2473 | | - }
|
| 2474 | | - }
|
| 2475 | | - if (emptyspace) attachments[index] = attach;
|
| 2476 | | - else
|
| 2477 | | - {
|
| 2478 | | - attachcount++;
|
| 2479 | | - if (attachcount >= maxattach)
|
| 2480 | | - {
|
| 2481 | | - glDirectDrawSurface3 **newattach = (glDirectDrawSurface3**)realloc(attachments,
|
| 2482 | | - (maxattach + 16)*sizeof(glDirectDrawSurface3*));
|
| 2483 | | - if (newattach)
|
| 2484 | | - {
|
| 2485 | | - maxattach += 16;
|
| 2486 | | - attachments = newattach;
|
| 2487 | | - }
|
| 2488 | | - }
|
| 2489 | | - attachments[attachcount-1] = attach;
|
| 2490 | | - }
|
| 2491 | | - attach->AddRef();
|
| 2492 | | -}
|
| 2493 | | -void glDirectDrawSurface3::DeleteAttach(glDirectDrawSurface3 *attach)
|
| 2494 | | -{
|
| 2495 | | - if (!attachcount) return;
|
| 2496 | | - for (int i = 0; i < attachcount; i++)
|
| 2497 | | - {
|
| 2498 | | - if (attachments[i] == attach)
|
| 2499 | | - {
|
| 2500 | | - attach->Release();
|
| 2501 | | - attachments[i] = NULL;
|
| 2502 | | - return;
|
| 2503 | | - }
|
| 2504 | | - }
|
| 2505 | | -}
|
| 2506 | 2393 | HRESULT WINAPI glDirectDrawSurface3::AddAttachedSurface(LPDIRECTDRAWSURFACE3 lpDDSAttachedSurface)
|
| 2507 | 2394 | {
|
| 2508 | | - TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
| 2509 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 2510 | | - if(!lpDDSAttachedSurface) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 2511 | | - HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface3*)lpDDSAttachedSurface)->GetDDS7());
|
| 2512 | | - if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2513 | | - AddAttach((glDirectDrawSurface3*)lpDDSAttachedSurface);
|
| 2514 | | - TRACE_EXIT(23, ret);
|
| | 2395 | + TRACE_ENTER(2, 14, this, 15, lpDDSAttachedSurface);
|
| | 2396 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| | 2397 | + if (!lpDDSAttachedSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 2398 | + LPDIRECTDRAWSURFACE7 dds7;
|
| | 2399 | + HRESULT ret;
|
| | 2400 | + ret = ((IUnknown*)lpDDSAttachedSurface)->QueryInterface(IID_IDirectDrawSurface7, (void**)&dds7);
|
| | 2401 | + if (ret != S_OK) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 2402 | + ret = glDDS7->AddAttachedSurface2(dds7, lpDDSAttachedSurface);
|
| | 2403 | + if (ret == DD_OK) ((IUnknown*)lpDDSAttachedSurface)->AddRef();
|
| | 2404 | + dds7->Release();
|
| | 2405 | + TRACE_RET(HRESULT, 23, ret);
|
| 2515 | 2406 | return ret;
|
| 2516 | 2407 | }
|
| 2517 | 2408 | HRESULT WINAPI glDirectDrawSurface3::AddOverlayDirtyRect(LPRECT lpRect)
|
| — | — | @@ -2558,7 +2449,6 @@ |
| 2559 | 2450 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 2560 | 2451 | HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface3*)lpDDSAttachedSurface)->GetDDS7());
|
| 2561 | 2452 | if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2562 | | - DeleteAttach((glDirectDrawSurface3*)lpDDSAttachedSurface);
|
| 2563 | 2453 | TRACE_EXIT(23, ret);
|
| 2564 | 2454 | return ret;
|
| 2565 | 2455 | }
|
| — | — | @@ -2807,30 +2697,8 @@ |
| 2808 | 2698 | {
|
| 2809 | 2699 | TRACE_ENTER(2,14,this,14,gl_DDS7);
|
| 2810 | 2700 | glDDS7 = gl_DDS7;
|
| 2811 | | - refcount = 1;
|
| 2812 | | - attachments = (glDirectDrawSurface4**)malloc(16 * sizeof(glDirectDrawSurface4*));
|
| 2813 | | - attachcount = 0;
|
| 2814 | | - maxattach = 16;
|
| 2815 | 2701 | TRACE_EXIT(-1, 0);
|
| 2816 | 2702 | }
|
| 2817 | | -glDirectDrawSurface4::~glDirectDrawSurface4()
|
| 2818 | | -{
|
| 2819 | | - TRACE_ENTER(1,14,this);
|
| 2820 | | - glDDS7->dds4 = NULL;
|
| 2821 | | - glDDS7->Release();
|
| 2822 | | - if (attachments)
|
| 2823 | | - {
|
| 2824 | | - if (attachcount)
|
| 2825 | | - {
|
| 2826 | | - for (int i = 0; i < attachcount; i++)
|
| 2827 | | - {
|
| 2828 | | - if (attachments[i]) attachments[i]->Release();
|
| 2829 | | - }
|
| 2830 | | - }
|
| 2831 | | - free(attachments);
|
| 2832 | | - }
|
| 2833 | | - TRACE_EXIT(-1,0);
|
| 2834 | | -}
|
| 2835 | 2703 | HRESULT WINAPI glDirectDrawSurface4::QueryInterface(REFIID riid, void** ppvObj)
|
| 2836 | 2704 | {
|
| 2837 | 2705 | TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
| — | — | @@ -2849,73 +2717,27 @@ |
| 2850 | 2718 | {
|
| 2851 | 2719 | TRACE_ENTER(1,14,this);
|
| 2852 | 2720 | if(!this) TRACE_RET(ULONG,8,0);
|
| 2853 | | - refcount++;
|
| 2854 | | - TRACE_EXIT(8,refcount);
|
| 2855 | | - return refcount;
|
| | 2721 | + TRACE_RET(ULONG, 8, glDDS7->AddRef4());
|
| 2856 | 2722 | }
|
| 2857 | 2723 | ULONG WINAPI glDirectDrawSurface4::Release()
|
| 2858 | 2724 | {
|
| 2859 | 2725 | TRACE_ENTER(1,14,this);
|
| 2860 | 2726 | if(!this) TRACE_RET(ULONG,8,0);
|
| 2861 | | - ULONG ret;
|
| 2862 | | - refcount--;
|
| 2863 | | - ret = refcount;
|
| 2864 | | - if(refcount == 0) delete this;
|
| 2865 | | - TRACE_EXIT(8,ret);
|
| 2866 | | - return ret;
|
| | 2727 | + TRACE_RET(ULONG, 8, glDDS7->Release4());
|
| 2867 | 2728 | }
|
| 2868 | | -void glDirectDrawSurface4::AddAttach(glDirectDrawSurface4 *attach)
|
| 2869 | | -{
|
| 2870 | | - bool emptyspace = false;
|
| 2871 | | - int index;
|
| 2872 | | - for (int i = 0; i < attachcount; i++)
|
| 2873 | | - {
|
| 2874 | | - if (!attachments[i])
|
| 2875 | | - {
|
| 2876 | | - emptyspace = true;
|
| 2877 | | - index = i;
|
| 2878 | | - break;
|
| 2879 | | - }
|
| 2880 | | - }
|
| 2881 | | - if (emptyspace) attachments[index] = attach;
|
| 2882 | | - else
|
| 2883 | | - {
|
| 2884 | | - attachcount++;
|
| 2885 | | - if (attachcount >= maxattach)
|
| 2886 | | - {
|
| 2887 | | - glDirectDrawSurface4 **newattach = (glDirectDrawSurface4**)realloc(attachments,
|
| 2888 | | - (maxattach + 16)*sizeof(glDirectDrawSurface4*));
|
| 2889 | | - if (newattach)
|
| 2890 | | - {
|
| 2891 | | - maxattach += 16;
|
| 2892 | | - attachments = newattach;
|
| 2893 | | - }
|
| 2894 | | - }
|
| 2895 | | - attachments[attachcount-1] = attach;
|
| 2896 | | - }
|
| 2897 | | - attach->AddRef();
|
| 2898 | | -}
|
| 2899 | | -void glDirectDrawSurface4::DeleteAttach(glDirectDrawSurface4 *attach)
|
| 2900 | | -{
|
| 2901 | | - if (!attachcount) return;
|
| 2902 | | - for (int i = 0; i < attachcount; i++)
|
| 2903 | | - {
|
| 2904 | | - if (attachments[i] == attach)
|
| 2905 | | - {
|
| 2906 | | - attach->Release();
|
| 2907 | | - attachments[i] = NULL;
|
| 2908 | | - return;
|
| 2909 | | - }
|
| 2910 | | - }
|
| 2911 | | -}
|
| 2912 | 2729 | HRESULT WINAPI glDirectDrawSurface4::AddAttachedSurface(LPDIRECTDRAWSURFACE4 lpDDSAttachedSurface)
|
| 2913 | 2730 | {
|
| 2914 | | - TRACE_ENTER(2,14,this,14,lpDDSAttachedSurface);
|
| 2915 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 2916 | | - HRESULT ret = glDDS7->AddAttachedSurface(((glDirectDrawSurface4*)lpDDSAttachedSurface)->GetDDS7());
|
| 2917 | | - if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2918 | | - AddAttach((glDirectDrawSurface4*)lpDDSAttachedSurface);
|
| 2919 | | - TRACE_EXIT(23, ret);
|
| | 2731 | + TRACE_ENTER(2, 14, this, 15, lpDDSAttachedSurface);
|
| | 2732 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| | 2733 | + if (!lpDDSAttachedSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 2734 | + LPDIRECTDRAWSURFACE7 dds7;
|
| | 2735 | + HRESULT ret;
|
| | 2736 | + ret = ((IUnknown*)lpDDSAttachedSurface)->QueryInterface(IID_IDirectDrawSurface7, (void**)&dds7);
|
| | 2737 | + if (ret != S_OK) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| | 2738 | + ret = glDDS7->AddAttachedSurface2(dds7, lpDDSAttachedSurface);
|
| | 2739 | + if (ret == DD_OK) ((IUnknown*)lpDDSAttachedSurface)->AddRef();
|
| | 2740 | + dds7->Release();
|
| | 2741 | + TRACE_RET(HRESULT, 23, ret);
|
| 2920 | 2742 | return ret;
|
| 2921 | 2743 | }
|
| 2922 | 2744 | HRESULT WINAPI glDirectDrawSurface4::AddOverlayDirtyRect(LPRECT lpRect)
|
| — | — | @@ -2963,7 +2785,6 @@ |
| 2964 | 2786 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 2965 | 2787 | HRESULT ret = glDDS7->DeleteAttachedSurface(dwFlags, ((glDirectDrawSurface4*)lpDDSAttachedSurface)->GetDDS7());
|
| 2966 | 2788 | if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
|
| 2967 | | - DeleteAttach((glDirectDrawSurface4*)lpDDSAttachedSurface);
|
| 2968 | 2789 | TRACE_EXIT(23, ret);
|
| 2969 | 2790 | return ret;
|
| 2970 | 2791 | }
|
| Index: ddraw/glDirectDrawSurface.h |
| — | — | @@ -39,7 +39,7 @@ |
| 40 | 40 | class glDirectDrawSurface7 : public IDirectDrawSurface7
|
| 41 | 41 | {
|
| 42 | 42 | public:
|
| 43 | | - glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel);
|
| | 43 | + glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version);
|
| 44 | 44 | virtual ~glDirectDrawSurface7();
|
| 45 | 45 | // ddraw 1+ api
|
| 46 | 46 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| — | — | @@ -96,6 +96,18 @@ |
| 97 | 97 | HRESULT WINAPI SetLOD(DWORD dwMaxLOD);
|
| 98 | 98 | HRESULT WINAPI GetLOD(LPDWORD lpdwMaxLOD);
|
| 99 | 99 | // internal functions
|
| | 100 | + ULONG WINAPI AddRef4();
|
| | 101 | + ULONG WINAPI Release4();
|
| | 102 | + ULONG WINAPI AddRef3();
|
| | 103 | + ULONG WINAPI Release3();
|
| | 104 | + ULONG WINAPI AddRef2();
|
| | 105 | + ULONG WINAPI Release2();
|
| | 106 | + ULONG WINAPI AddRef1();
|
| | 107 | + ULONG WINAPI Release1();
|
| | 108 | + ULONG WINAPI AddRefGamma();
|
| | 109 | + ULONG WINAPI ReleaseGamma();
|
| | 110 | + ULONG WINAPI AddRefColor();
|
| | 111 | + ULONG WINAPI ReleaseColor();
|
| 100 | 112 | void SetFilter(int level, GLint mag, GLint min, glExtensions *ext, TextureManager *texman);
|
| 101 | 113 | TEXTURE *GetTexture(){
|
| 102 | 114 | return texture;
|
| — | — | @@ -102,7 +114,8 @@ |
| 103 | 115 | }
|
| 104 | 116 | void Restore2();
|
| 105 | 117 | HRESULT Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags);
|
| 106 | | - void SetTexture(TEXTURE *newtexture){texture = newtexture;};
|
| | 118 | + HRESULT AddAttachedSurface2(LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface, IUnknown *iface);
|
| | 119 | + void SetTexture(TEXTURE *newtexture){ texture = newtexture; };
|
| 107 | 120 | glDirectDrawSurface7 *GetBackbuffer(){return backbuffer;};
|
| 108 | 121 | glDirectDrawSurface7 *GetZBuffer(){return zbuffer;};
|
| 109 | 122 | void RenderScreen(TEXTURE *texture, glDirectDrawSurface7 *surface, int vsync);
|
| — | — | @@ -128,7 +141,6 @@ |
| 129 | 142 | TEXTURE *stencil;
|
| 130 | 143 | bool hasstencil;
|
| 131 | 144 | DWORD miplevel;
|
| 132 | | - glDirectDrawSurface7 *miptexture;
|
| 133 | 145 | char *buffer;
|
| 134 | 146 | char *bigbuffer;
|
| 135 | 147 | char *gdibuffer;
|
| — | — | @@ -135,15 +147,19 @@ |
| 136 | 148 | DDSURFACEDESC2 ddsd;
|
| 137 | 149 | glDirectDrawPalette *palette;
|
| 138 | 150 | HGLRC hRC;
|
| 139 | | - glDirectDrawSurface7 *zbuffer;
|
| 140 | 151 | D3DMATERIALHANDLE handle;
|
| 141 | 152 | FBO fbo;
|
| 142 | 153 | FBO stencilfbo;
|
| 143 | 154 | glDirectDrawClipper *clipper;
|
| 144 | 155 | IUnknown *creator;
|
| | 156 | + IUnknown *textureparent;
|
| | 157 | + glDirectDrawSurface7 *zbuffer;
|
| | 158 | + glDirectDrawSurface7 *miptexture;
|
| | 159 | + glDirectDrawSurface7 *backbuffer;
|
| 145 | 160 | private:
|
| 146 | 161 | int swapinterval;
|
| 147 | | - ULONG refcount;
|
| | 162 | + ULONG refcount7, refcount4, refcount3, refcount2, refcount1;
|
| | 163 | + ULONG refcountgamma, refcountcolor;
|
| 148 | 164 | int locked;
|
| 149 | 165 | HDC hdc;
|
| 150 | 166 | HBITMAP hbitmap;
|
| — | — | @@ -150,11 +166,11 @@ |
| 151 | 167 | BITMAPINFO *bitmapinfo;
|
| 152 | 168 | glDirectDraw7 *ddInterface;
|
| 153 | 169 | int surfacetype; // 0-generic memory, 1-GDI surface, 2-OpenGL Texture
|
| 154 | | - glDirectDrawSurface7 *backbuffer;
|
| 155 | 170 | int pagelocked;
|
| 156 | 171 | GLint magfilter,minfilter;
|
| 157 | 172 | glDirect3DDevice7 *device;
|
| 158 | 173 | bool overlay;
|
| | 174 | + IUnknown *zbuffer_iface;
|
| 159 | 175 | };
|
| 160 | 176 |
|
| 161 | 177 | // Legacy DDRAW Interfaces
|
| — | — | @@ -162,7 +178,6 @@ |
| 163 | 179 | {
|
| 164 | 180 | public:
|
| 165 | 181 | glDirectDrawSurface1(glDirectDrawSurface7 *gl_DDS7);
|
| 166 | | - virtual ~glDirectDrawSurface1();
|
| 167 | 182 | // ddraw 1+ api
|
| 168 | 183 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 169 | 184 | ULONG WINAPI AddRef();
|
| — | — | @@ -201,20 +216,13 @@ |
| 202 | 217 | HRESULT WINAPI UpdateOverlayDisplay(DWORD dwFlags);
|
| 203 | 218 | HRESULT WINAPI UpdateOverlayZOrder(DWORD dwFlags, LPDIRECTDRAWSURFACE lpDDSReference);
|
| 204 | 219 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 205 | | - void AddAttach(glDirectDrawSurface1 *attach);
|
| 206 | | - void DeleteAttach(glDirectDrawSurface1 *attach);
|
| 207 | 220 | private:
|
| 208 | | - UINT refcount;
|
| 209 | 221 | glDirectDrawSurface7 *glDDS7;
|
| 210 | | - glDirectDrawSurface1 **attachments;
|
| 211 | | - int attachcount;
|
| 212 | | - int maxattach;
|
| 213 | 222 | };
|
| 214 | 223 | class glDirectDrawSurface2 : public IDirectDrawSurface2
|
| 215 | 224 | {
|
| 216 | 225 | public:
|
| 217 | 226 | glDirectDrawSurface2(glDirectDrawSurface7 *gl_DDS7);
|
| 218 | | - virtual ~glDirectDrawSurface2();
|
| 219 | 227 | // ddraw 1+ api
|
| 220 | 228 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 221 | 229 | ULONG WINAPI AddRef();
|
| — | — | @@ -257,20 +265,13 @@ |
| 258 | 266 | HRESULT WINAPI PageLock(DWORD dwFlags);
|
| 259 | 267 | HRESULT WINAPI PageUnlock(DWORD dwFlags);
|
| 260 | 268 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 261 | | - void AddAttach(glDirectDrawSurface2 *attach);
|
| 262 | | - void DeleteAttach(glDirectDrawSurface2 *attach);
|
| 263 | 269 | private:
|
| 264 | | - UINT refcount;
|
| 265 | 270 | glDirectDrawSurface7 *glDDS7;
|
| 266 | | - glDirectDrawSurface2 **attachments;
|
| 267 | | - int attachcount;
|
| 268 | | - int maxattach;
|
| 269 | 271 | };
|
| 270 | 272 | class glDirectDrawSurface3 : public IDirectDrawSurface3
|
| 271 | 273 | {
|
| 272 | 274 | public:
|
| 273 | 275 | glDirectDrawSurface3(glDirectDrawSurface7 *gl_DDS7);
|
| 274 | | - virtual ~glDirectDrawSurface3();
|
| 275 | 276 | // ddraw 1+ api
|
| 276 | 277 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 277 | 278 | ULONG WINAPI AddRef();
|
| — | — | @@ -315,20 +316,13 @@ |
| 316 | 317 | // ddraw 3+ api
|
| 317 | 318 | HRESULT WINAPI SetSurfaceDesc(LPDDSURFACEDESC lpddsd2, DWORD dwFlags);
|
| 318 | 319 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 319 | | - void AddAttach(glDirectDrawSurface3 *attach);
|
| 320 | | - void DeleteAttach(glDirectDrawSurface3 *attach);
|
| 321 | 320 | private:
|
| 322 | | - UINT refcount;
|
| 323 | 321 | glDirectDrawSurface7 *glDDS7;
|
| 324 | | - glDirectDrawSurface3 **attachments;
|
| 325 | | - int attachcount;
|
| 326 | | - int maxattach;
|
| 327 | 322 | };
|
| 328 | 323 | class glDirectDrawSurface4 : public IDirectDrawSurface4
|
| 329 | 324 | {
|
| 330 | 325 | public:
|
| 331 | 326 | glDirectDrawSurface4(glDirectDrawSurface7 *gl_DDS7);
|
| 332 | | - virtual ~glDirectDrawSurface4();
|
| 333 | 327 | // ddraw 1+ api
|
| 334 | 328 | HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
| 335 | 329 | ULONG WINAPI AddRef();
|
| — | — | @@ -379,13 +373,7 @@ |
| 380 | 374 | HRESULT WINAPI GetUniquenessValue(LPDWORD lpValue);
|
| 381 | 375 | HRESULT WINAPI ChangeUniquenessValue();
|
| 382 | 376 | glDirectDrawSurface7 *GetDDS7() {return glDDS7;};
|
| 383 | | - void AddAttach(glDirectDrawSurface4 *attach);
|
| 384 | | - void DeleteAttach(glDirectDrawSurface4 *attach);
|
| 385 | 377 | private:
|
| 386 | | - UINT refcount;
|
| 387 | 378 | glDirectDrawSurface7 *glDDS7;
|
| 388 | | - glDirectDrawSurface4 **attachments;
|
| 389 | | - int attachcount;
|
| 390 | | - int maxattach;
|
| 391 | 379 | };
|
| 392 | 380 | #endif //_GLDIRECTDRAWSURFACE_H
|