DXGL r505 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r504‎ | r505 | r506 >
Date:17:23, 31 August 2014
Author:admin
Status:new
Tags:
Comment:
Add EnumAttachedSurfaces.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDraw.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -849,6 +849,7 @@
850850 if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
851851 if (!lpDDSurfaceDesc2) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
852852 if (pUnkOuter) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 853+ if (!renderer) TRACE_RET(HRESULT, 23, DDERR_NOCOOPERATIVELEVELSET);
853854 if (primary && (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && (renderer->hRC == primary->hRC))
854855 {
855856 if (primarylost)
Index: ddraw/glDirectDraw.h
@@ -230,4 +230,8 @@
231231 ULONG refcount;
232232 glDirectDraw7 *glDD7;
233233 };
 234+
 235+HRESULT WINAPI EnumSurfacesCallback1(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDDSURFACEDESC2 lpDDSD2, LPVOID lpContext);
 236+HRESULT WINAPI EnumSurfacesCallback2(LPDIRECTDRAWSURFACE7 lpDDSurface, LPDDSURFACEDESC2 lpDDSD2, LPVOID lpContext);
 237+
234238 #endif //_GLDIRECTDRAW_H
Index: ddraw/glDirectDrawSurface.cpp
@@ -394,6 +394,7 @@
395395 if(buffer) free(buffer);
396396 if(bigbuffer) free(bigbuffer);
397397 if(zbuffer) zbuffer->Release();
 398+ if(miptexture) miptexture->Release();
398399 if(device) device->Release();
399400 ddInterface->DeleteSurface(this);
400401 TRACE_EXIT(-1,0);
@@ -758,9 +759,26 @@
759760 {
760761 TRACE_ENTER(3,14,this,14,lpContext,14,lpEnumSurfacesCallback);
761762 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
762 - FIXME("glDirectDrawSurface7::EnumAttachedSurfaces: stub\n");
763 - TRACE_EXIT(23,DDERR_GENERIC);
764 - ERR(DDERR_GENERIC);
 763+ HRESULT enumret = DDENUMRET_OK;
 764+ if (backbuffer)
 765+ {
 766+ backbuffer->AddRef();
 767+ enumret = lpEnumSurfacesCallback(backbuffer, &backbuffer->ddsd, lpContext);
 768+ }
 769+ if (enumret == DDENUMRET_CANCEL) TRACE_RET(HRESULT, 23, DD_OK);
 770+ if (zbuffer)
 771+ {
 772+ zbuffer->AddRef();
 773+ enumret = lpEnumSurfacesCallback(zbuffer, &zbuffer->ddsd, lpContext);
 774+ }
 775+ if (enumret == DDENUMRET_CANCEL) TRACE_RET(HRESULT, 23, DD_OK);
 776+ if (miptexture)
 777+ {
 778+ miptexture->AddRef();
 779+ enumret = lpEnumSurfacesCallback(miptexture, &miptexture->ddsd, lpContext);
 780+ }
 781+ TRACE_EXIT(23, DD_OK);
 782+ return DD_OK;
765783 }
766784 HRESULT WINAPI glDirectDrawSurface7::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK7 lpfnCallback)
767785 {
@@ -924,7 +942,7 @@
925943 }
926944
927945 TRACE_EXIT(23,DDERR_NOTFOUND);
928 - ERR(DDERR_NOTFOUND);
 946+ return DDERR_NOTFOUND;
929947 }
930948 HRESULT WINAPI glDirectDrawSurface7::GetBltStatus(DWORD dwFlags)
931949 {
@@ -1772,7 +1790,11 @@
17731791 {
17741792 TRACE_ENTER(3,14,this,14,lpContext,14,lpEnumSurfacesCallback);
17751793 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
1776 - TRACE_RET(HRESULT,23,glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback));
 1794+ if (!lpEnumSurfacesCallback) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 1795+ LPVOID context[2];
 1796+ context[0] = lpEnumSurfacesCallback;
 1797+ context[1] = lpContext;
 1798+ TRACE_RET(HRESULT,23,glDDS7->EnumAttachedSurfaces(context,EnumSurfacesCallback1));
17771799 }
17781800 HRESULT WINAPI glDirectDrawSurface1::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback)
17791801 {
@@ -2143,7 +2165,11 @@
21442166 {
21452167 TRACE_ENTER(3,14,this,14,lpContext,14,lpEnumSurfacesCallback);
21462168 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2147 - TRACE_RET(HRESULT,23,glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback));
 2169+ if (!lpEnumSurfacesCallback) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2170+ LPVOID context[2];
 2171+ context[0] = lpEnumSurfacesCallback;
 2172+ context[1] = lpContext;
 2173+ TRACE_RET(HRESULT, 23, glDDS7->EnumAttachedSurfaces(context, EnumSurfacesCallback1));
21482174 }
21492175 HRESULT WINAPI glDirectDrawSurface2::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback)
21502176 {
@@ -2538,7 +2564,11 @@
25392565 {
25402566 TRACE_ENTER(3,14,this,14,lpContext,14,lpEnumSurfacesCallback);
25412567 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2542 - TRACE_RET(HRESULT,23,glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback));
 2568+ if (!lpEnumSurfacesCallback) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2569+ LPVOID context[2];
 2570+ context[0] = lpEnumSurfacesCallback;
 2571+ context[1] = lpContext;
 2572+ TRACE_RET(HRESULT, 23, glDDS7->EnumAttachedSurfaces(context, EnumSurfacesCallback1));
25432573 }
25442574 HRESULT WINAPI glDirectDrawSurface3::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpfnCallback)
25452575 {
@@ -2939,7 +2969,11 @@
29402970 {
29412971 TRACE_ENTER(3,14,this,14,lpContext,14,lpEnumSurfacesCallback);
29422972 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2943 - TRACE_RET(HRESULT,23,glDDS7->EnumAttachedSurfaces(lpContext,(LPDDENUMSURFACESCALLBACK7)lpEnumSurfacesCallback));
 2973+ if (!lpEnumSurfacesCallback) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2974+ LPVOID context[2];
 2975+ context[0] = lpEnumSurfacesCallback;
 2976+ context[1] = lpContext;
 2977+ TRACE_RET(HRESULT, 23, glDDS7->EnumAttachedSurfaces(context, EnumSurfacesCallback2));
29442978 }
29452979 HRESULT WINAPI glDirectDrawSurface4::EnumOverlayZOrders(DWORD dwFlags, LPVOID lpContext, LPDDENUMSURFACESCALLBACK2 lpfnCallback)
29462980 {