[5/10] WineD3D: Remove IWineD3DDevice::EnumDisplayModes

Stefan Dösinger stefan at codeweavers.com
Mon Feb 19 08:24:00 CST 2007


-------------- next part --------------
From eff055c1561b825ceb6fccedd1f5dfe094592d9c Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Sun, 18 Feb 2007 20:05:11 +0100
Subject: [PATCH] WineD3D: Remove IWineD3DDevice::EnumDisplayModes

This function was another function I added during the ddraw merge
without knowing that an equivalent already existed. This patch removes
EnumDisplayModes, and DirectDraw uses IWineD3D::EnumAdapterModes instead
---
 dlls/ddraw/ddraw.c               |   99 +++++++++++++++----------------------
 dlls/wined3d/device.c            |   25 ----------
 include/wine/wined3d_interface.h |    9 ----
 3 files changed, 40 insertions(+), 93 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 96b30d3..3270e41 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -1136,50 +1136,6 @@ IDirectDrawImpl_GetGDISurface(IDirectDraw7 *iface,
 }
 
 /*****************************************************************************
- * IDirectDrawImpl_EnumDisplayModesCB
- *
- * Callback function for IDirectDraw7::EnumDisplayModes. Translates
- * the wineD3D values to ddraw values and calls the application callback
- *
- * Params:
- *  device: The IDirectDraw7 interface to the current device
- *  With, Height, Pixelformat, Refresh: Enumerated display mode
- *  context: the context pointer passed to IWineD3DDevice::EnumDisplayModes
- *
- * Returns:
- *  The return value from the application callback
- *
- *****************************************************************************/ 
-static HRESULT WINAPI
-IDirectDrawImpl_EnumDisplayModesCB(IUnknown *pDevice,
-                                   UINT Width,
-                                   UINT Height,
-                                   WINED3DFORMAT Pixelformat,
-                                   FLOAT Refresh,
-                                   void *context)
-{
-    DDSURFACEDESC2 callback_sd;
-    EnumDisplayModesCBS *cbs = (EnumDisplayModesCBS *) context;
-
-    memset(&callback_sd, 0, sizeof(callback_sd));
-    callback_sd.dwSize = sizeof(callback_sd);
-    callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
-
-    callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH;
-    if(Refresh > 0.0)
-    {
-        callback_sd.dwFlags |= DDSD_REFRESHRATE;
-        callback_sd.u2.dwRefreshRate = 60.0;
-    }
-
-    callback_sd.dwHeight = Height;
-    callback_sd.dwWidth = Width;
-
-    PixelFormat_WineD3DtoDD(&callback_sd.u4.ddpfPixelFormat, Pixelformat);
-    return cbs->callback(&callback_sd, cbs->context);
-}
-
-/*****************************************************************************
  * IDirectDraw7::EnumDisplayModes
  *
  * Enumerates the supported Display modes. The modes can be filtered with
@@ -1204,34 +1160,59 @@ IDirectDrawImpl_EnumDisplayModes(IDirectDraw7 *iface,
                                  LPDDENUMMODESCALLBACK2 cb)
 {
     ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw7, iface);
-    UINT Width = 0, Height = 0;
+    unsigned int modenum = 0;
     WINED3DFORMAT pixelformat = WINED3DFMT_UNKNOWN;
-    EnumDisplayModesCBS cbs;
+    WINED3DDISPLAYMODE mode;
+    DDSURFACEDESC2 callback_sd;
 
     TRACE("(%p)->(%p,%p,%p): Relay\n", This, DDSD, Context, cb);
 
     /* This looks sane */
     if(!cb) return DDERR_INVALIDPARAMS;
 
-    /* The private callback structure */
-    cbs.callback = cb;
-    cbs.context = Context;
-
     if(DDSD)
     {
-        if (DDSD->dwFlags & DDSD_WIDTH)
-            Width = DDSD->dwWidth;
-        if (DDSD->dwFlags & DDSD_HEIGHT)
-            Height = DDSD->dwHeight;
         if ((DDSD->dwFlags & DDSD_PIXELFORMAT) && (DDSD->u4.ddpfPixelFormat.dwFlags & DDPF_RGB) )
             pixelformat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
     }
 
-    return IWineD3DDevice_EnumDisplayModes(This->wineD3DDevice,
-                                           Flags,
-                                           Width, Height, pixelformat,
-                                           &cbs,
-                                           IDirectDrawImpl_EnumDisplayModesCB);
+    while(IWineD3D_EnumAdapterModes(This->wineD3D,
+                                    WINED3DADAPTER_DEFAULT,
+                                    pixelformat,
+                                    modenum++,
+                                    &mode) == WINED3D_OK) {
+        if(DDSD)
+        {
+            if(DDSD->dwFlags & DDSD_WIDTH && mode.Width != DDSD->dwWidth) continue;
+            if(DDSD->dwFlags & DDSD_HEIGHT && mode.Height != DDSD->dwHeight) continue;
+        }
+
+        memset(&callback_sd, 0, sizeof(callback_sd));
+        callback_sd.dwSize = sizeof(callback_sd);
+        callback_sd.u4.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
+
+        callback_sd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH;
+        if(Flags & DDEDM_REFRESHRATES)
+        {
+            callback_sd.dwFlags |= DDSD_REFRESHRATE;
+            callback_sd.u2.dwRefreshRate = mode.RefreshRate;
+        }
+
+        callback_sd.dwWidth = mode.Width;
+        callback_sd.dwHeight = mode.Height;
+
+        PixelFormat_WineD3DtoDD(&callback_sd.u4.ddpfPixelFormat, mode.Format);
+
+        TRACE("Enumerating %dx%d@%d\n", callback_sd.dwWidth, callback_sd.dwHeight, callback_sd.u4.ddpfPixelFormat.u1.dwRGBBitCount);
+
+        if(cb(&callback_sd, Context) == DDENUMRET_CANCEL)
+        {
+            TRACE("Application asked to terminate the enumeration\n");
+            return DD_OK;
+        }
+    }
+    TRACE("End of enumeration\n");
+    return DD_OK;
 }
 
 /*****************************************************************************
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 2799ffd..3e66075 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1822,30 +1822,6 @@ static void WINAPI IWineD3DDeviceImpl_SetFullscreen(IWineD3DDevice *iface, BOOL
     This->ddraw_fullscreen = fullscreen;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_EnumDisplayModes(IWineD3DDevice *iface, DWORD Flags, UINT Width, UINT Height, WINED3DFORMAT pixelformat, LPVOID context, D3DCB_ENUMDISPLAYMODESCALLBACK callback) {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-
-    DEVMODEW DevModeW;
-    int i;
-    const PixelFormatDesc *formatDesc  = getFormatDescEntry(pixelformat);
-
-    TRACE("(%p)->(%x,%d,%d,%d,%p,%p)\n", This, Flags, Width, Height, pixelformat, context, callback);
-
-    for (i = 0; EnumDisplaySettingsExW(NULL, i, &DevModeW, 0); i++) {
-        /* Ignore some modes if a description was passed */
-        if ( (Width > 0)  && (Width != DevModeW.dmPelsWidth)) continue;
-        if ( (Height > 0)  && (Height != DevModeW.dmPelsHeight)) continue;
-        if ( (pixelformat != WINED3DFMT_UNKNOWN) && ( formatDesc->bpp != DevModeW.dmBitsPerPel) ) continue;
-
-        TRACE("Enumerating %dx%d@%s\n", DevModeW.dmPelsWidth, DevModeW.dmPelsHeight, debug_d3dformat(pixelformat_for_depth(DevModeW.dmBitsPerPel)));
-
-        if (callback((IUnknown *) This, (UINT) DevModeW.dmPelsWidth, (UINT) DevModeW.dmPelsHeight, pixelformat_for_depth(DevModeW.dmBitsPerPel), 60.0, context) == DDENUMRET_CANCEL)
-            return WINED3D_OK;
-    }
-
-    return WINED3D_OK;
-}
-
 static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, WINED3DDISPLAYMODE* pMode) {
     DEVMODEW devmode;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
@@ -5713,7 +5689,6 @@ const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl =
     IWineD3DDeviceImpl_Init3D,
     IWineD3DDeviceImpl_Uninit3D,
     IWineD3DDeviceImpl_SetFullscreen,
-    IWineD3DDeviceImpl_EnumDisplayModes,
     IWineD3DDeviceImpl_EvictManagedResources,
     IWineD3DDeviceImpl_GetAvailableTextureMem,
     IWineD3DDeviceImpl_GetBackBuffer,
diff --git a/include/wine/wined3d_interface.h b/include/wine/wined3d_interface.h
index 998c84c..3783ebc 100644
--- a/include/wine/wined3d_interface.h
+++ b/include/wine/wined3d_interface.h
@@ -233,13 +233,6 @@ typedef HRESULT WINAPI (*D3DCB_CREATEADDITIONALSWAPCHAIN) (IUnknown *pDevice,
                                                struct IWineD3DSwapChain **pSwapChain
                                                );
 
-typedef HRESULT WINAPI (*D3DCB_ENUMDISPLAYMODESCALLBACK) (IUnknown *pDevice,
-                                                          UINT Width,
-                                                          UINT Height,
-                                                          WINED3DFORMAT Pixelformat,
-                                                          FLOAT Refresh,
-                                                          LPVOID context);
-
 /*****************************************************************************
  * Callback functions for custom implicit object destruction.
  */
@@ -363,7 +356,6 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
     STDMETHOD(Init3D)(THIS_ WINED3DPRESENT_PARAMETERS* pPresentationParameters, D3DCB_CREATEADDITIONALSWAPCHAIN D3DCB_CreateAdditionalSwapChain);
     STDMETHOD(Uninit3D)(THIS, D3DCB_DESTROYSURFACEFN pFn, D3DCB_DESTROYSWAPCHAINFN pFn2);
     STDMETHOD_(void, SetFullscreen)(THIS_ BOOL fullscreen);
-    STDMETHOD(EnumDisplayModes)(THIS_ DWORD Flags, UINT Width, UINT Height, WINED3DFORMAT Format, void *context, D3DCB_ENUMDISPLAYMODESCALLBACK cb) PURE;
     STDMETHOD(EvictManagedResources)(THIS) PURE;
     STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE;
     STDMETHOD(GetBackBuffer)(THIS_ UINT iSwapChain, UINT BackBuffer, WINED3DBACKBUFFER_TYPE, struct IWineD3DSurface** ppBackBuffer) PURE;
@@ -500,7 +492,6 @@ DECLARE_INTERFACE_(IWineD3DDevice,IWineD3DBase)
 #define IWineD3DDevice_Init3D(p, a, b)                          (p)->lpVtbl->Init3D(p, a, b)
 #define IWineD3DDevice_Uninit3D(p, a, b)                        (p)->lpVtbl->Uninit3D(p, a, b)
 #define IWineD3DDevice_SetFullscreen(p, a)                      (p)->lpVtbl->SetFullscreen(p, a)
-#define IWineD3DDevice_EnumDisplayModes(p,a,b,c,d,e,f)          (p)->lpVtbl->EnumDisplayModes(p,a,b,c,d,e,f)
 #define IWineD3DDevice_EvictManagedResources(p)                 (p)->lpVtbl->EvictManagedResources(p)
 #define IWineD3DDevice_GetAvailableTextureMem(p)                (p)->lpVtbl->GetAvailableTextureMem(p)
 #define IWineD3DDevice_GetBackBuffer(p,a,b,c,d)                 (p)->lpVtbl->GetBackBuffer(p,a,b,c,d)
-- 
1.4.4.3



More information about the wine-patches mailing list