[PATCH 2/5] quartz/vmr9: Pass the already retrieved caps pointer to VMR9_SurfaceAllocator_SetAllocationSettings().

Zebediah Figura zfigura at codeweavers.com
Tue Feb 1 22:37:41 CST 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/quartz/vmr9.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c
index f992f1136c7..78e47bbb908 100644
--- a/dlls/quartz/vmr9.c
+++ b/dlls/quartz/vmr9.c
@@ -2778,21 +2778,15 @@ static ULONG WINAPI VMR9_SurfaceAllocator_Release(IVMRSurfaceAllocator9 *iface)
     return IVMRImagePresenter9_Release(&presenter->IVMRImagePresenter9_iface);
 }
 
-static HRESULT VMR9_SurfaceAllocator_SetAllocationSettings(struct default_presenter *This, VMR9AllocationInfo *allocinfo)
+static void adjust_surface_size(const D3DCAPS9 *caps, VMR9AllocationInfo *allocinfo)
 {
-    D3DCAPS9 caps;
     UINT width, height;
-    HRESULT hr;
 
+    /* There are no restrictions on the size of offscreen surfaces. */
     if (!(allocinfo->dwFlags & VMR9AllocFlag_TextureSurface))
-        /* Only needed for texture surfaces */
-        return S_OK;
+        return;
 
-    hr = IDirect3DDevice9_GetDeviceCaps(This->d3d9_dev, &caps);
-    if (FAILED(hr))
-        return hr;
-
-    if (!(caps.TextureCaps & D3DPTEXTURECAPS_POW2) || (caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY))
+    if (!(caps->TextureCaps & D3DPTEXTURECAPS_POW2) || (caps->TextureCaps & D3DPTEXTURECAPS_SQUAREONLY))
     {
         width = allocinfo->dwWidth;
         height = allocinfo->dwHeight;
@@ -2808,7 +2802,7 @@ static HRESULT VMR9_SurfaceAllocator_SetAllocationSettings(struct default_presen
         FIXME("NPOW2 support missing, not using proper surfaces!\n");
     }
 
-    if (caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
+    if (caps->TextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
     {
         if (height > width)
             width = height;
@@ -2819,8 +2813,6 @@ static HRESULT VMR9_SurfaceAllocator_SetAllocationSettings(struct default_presen
 
     allocinfo->dwHeight = height;
     allocinfo->dwWidth = width;
-
-    return hr;
 }
 
 static UINT d3d9_adapter_from_hwnd(IDirect3D9 *d3d9, HWND hwnd, HMONITOR *mon_out)
@@ -2899,19 +2891,13 @@ static HRESULT WINAPI VMR9_SurfaceAllocator_InitializeDevice(IVMRSurfaceAllocato
     if (!(This->d3d9_surfaces = calloc(*numbuffers, sizeof(IDirect3DSurface9 *))))
         return E_OUTOFMEMORY;
 
-    hr = VMR9_SurfaceAllocator_SetAllocationSettings(This, info);
-    if (FAILED(hr))
-        ERR("Setting allocation settings failed: %08x\n", hr);
-
-    if (SUCCEEDED(hr))
-    {
-        hr = IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper(This->SurfaceAllocatorNotify, info, numbuffers, This->d3d9_surfaces);
-        if (FAILED(hr))
-            ERR("Allocating surfaces failed: %08x\n", hr);
-    }
+    adjust_surface_size(&caps, info);
 
+    hr = IVMRSurfaceAllocatorNotify9_AllocateSurfaceHelper(This->SurfaceAllocatorNotify,
+            info, numbuffers, This->d3d9_surfaces);
     if (FAILED(hr))
     {
+        ERR("Failed to allocate surfaces, hr %#x.\n", hr);
         IVMRSurfaceAllocator9_TerminateDevice(This->pVMR9->allocator, This->pVMR9->cookie);
         return hr;
     }
-- 
2.34.1




More information about the wine-devel mailing list