DXGL r539 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r538‎ | r539 | r540 >
Date:14:58, 20 September 2014
Author:admin
Status:new
Tags:
Comment:
Wrap around GetAttachedSurface on flip surfaces.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -968,7 +968,7 @@
969969 ZeroMemory(&surfaces[surfacecountmax], 1024 * sizeof(glDirectDrawSurface7 *));
970970 surfacecountmax += 1024;
971971 }
972 - surfaces[surfacecount - 1] = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version);
 972+ surfaces[surfacecount - 1] = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version, NULL);
973973 if (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
974974 {
975975 primary = surfaces[surfacecount - 1];
@@ -979,7 +979,7 @@
980980 else
981981 {
982982 if (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
983 - *lplpDDSurface = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version);
 983+ *lplpDDSurface = new glDirectDrawSurface7(this, lpDDSurfaceDesc2, &error, NULL, NULL, 0, version, NULL);
984984 }
985985 TRACE_VAR("*lplpDDSurface",14,*lplpDDSurface);
986986 TRACE_EXIT(23,error);
Index: ddraw/glDirectDrawSurface.cpp
@@ -38,7 +38,7 @@
3939
4040 // DDRAW7 routines
4141 glDirectDrawSurface7::glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error,
42 - glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version)
 42+ glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version, glDirectDrawSurface7 *front)
4343 {
4444 TRACE_ENTER(5,14,this,14,lpDD7,14,lpDDSurfaceDesc2,14,error,14,palettein);
4545 this->version = version;
@@ -207,6 +207,7 @@
208208 bitmapinfo->bmiHeader.biHeight = -(signed)ddsd.dwHeight;
209209 bitmapinfo->bmiHeader.biPlanes = 1;
210210 backbuffer = NULL;
 211+ backbufferwraparound = NULL;
211212 if ((ddsd.ddsCaps.dwCaps & DDSCAPS_MIPMAP) && !(ddsd.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL))
212213 {
213214 if (!(ddsd.dwFlags & DDSD_MIPMAPCOUNT))
@@ -332,7 +333,7 @@
333334 newdesc.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
334335 newdesc.dwMipMapCount = ddsd.dwMipMapCount - 1;
335336 HRESULT miperror;
336 - if(newdesc.dwMipMapCount) miptexture = new glDirectDrawSurface7(lpDD7, &newdesc, &miperror, palette, texture, miplevel + 1, version);
 337+ if(newdesc.dwMipMapCount) miptexture = new glDirectDrawSurface7(lpDD7, &newdesc, &miperror, palette, texture, miplevel + 1, version, NULL);
337338 }
338339
339340 if(ddsd.ddpfPixelFormat.dwRGBBitCount > 8)
@@ -367,9 +368,12 @@
368369 ddsdBack.dwBackBufferCount--;
369370 ddsdBack.ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER;
370371 ddsdBack.ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
371 - backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,error,palette,parenttex,miplevel,version);
 372+ backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,error,palette,parenttex,miplevel,version,front?front:this);
372373 }
373 - else if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT){}
 374+ else if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT)
 375+ {
 376+ backbufferwraparound = front;
 377+ }
374378 else *error = DDERR_INVALIDPARAMS;
375379 }
376380 }
@@ -1035,6 +1039,20 @@
10361040 return DD_OK;
10371041 }
10381042 }
 1043+ if (backbufferwraparound)
 1044+ {
 1045+ backbufferwraparound->GetCaps(&ddsComp);
 1046+ memcpy(&comp1, lpDDSCaps, sizeof(unsigned __int64));
 1047+ memcpy(&comp2, &ddsComp, sizeof(unsigned __int64));
 1048+ if ((comp1 & comp2) == comp1)
 1049+ {
 1050+ *lplpDDAttachedSurface = backbufferwraparound;
 1051+ backbufferwraparound->AddRef();
 1052+ TRACE_VAR("*lplpDDAttachedSurface", 14, *lplpDDAttachedSurface);
 1053+ TRACE_EXIT(23, DD_OK);
 1054+ return DD_OK;
 1055+ }
 1056+ }
10391057 if(zbuffer)
10401058 {
10411059 zbuffer->GetCaps(&ddsComp);
Index: ddraw/glDirectDrawSurface.h
@@ -40,7 +40,8 @@
4141 class glDirectDrawSurface7 : public IDirectDrawSurface7
4242 {
4343 public:
44 - glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, glDirectDrawPalette *palettein, TEXTURE *parenttex, DWORD miplevel, int version);
 44+ glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, glDirectDrawPalette *palettein,
 45+ TEXTURE *parenttex, DWORD miplevel, int version, glDirectDrawSurface7 *front);
4546 virtual ~glDirectDrawSurface7();
4647 // ddraw 1+ api
4748 HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
@@ -161,6 +162,7 @@
162163 glDirectDrawSurface7 *zbuffer;
163164 glDirectDrawSurface7 *miptexture;
164165 glDirectDrawSurface7 *backbuffer;
 166+ glDirectDrawSurface7 *backbufferwraparound;
165167 private:
166168 int swapinterval;
167169 ULONG refcount7, refcount4, refcount3, refcount2, refcount1;