https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b50ef9007cbec00929ebe…
commit b50ef9007cbec00929ebe7c2fba2676657c56f54
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Jan 4 01:48:04 2020 +0100
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Wed Feb 26 18:19:18 2020 +0100
[WINESYNC]d3dx9: Factor out {lock|unlock}_surface() functions.
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 33be8439fc95ca8f005bd3a2b6790c101842c02e by Paul Gofman
<gofmanp(a)gmail.com>
---
dll/directx/wine/d3dx9_36/surface.c | 75 +++++++++++++++++++++++++------------
sdk/tools/winesync/d3dx9.cfg | 36 ++++++++++++++++++
2 files changed, 88 insertions(+), 23 deletions(-)
diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c
index 11a0ee1a2fe..2d00cd1dcdc 100644
--- a/dll/directx/wine/d3dx9_36/surface.c
+++ b/dll/directx/wine/d3dx9_36/surface.c
@@ -199,6 +199,53 @@ static const struct {
{ 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, D3DFMT_X8B8G8R8 },
};
+static HRESULT lock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock,
+ IDirect3DSurface9 **temp_surface)
+{
+ IDirect3DDevice9 *device;
+ D3DSURFACE_DESC desc;
+ HRESULT hr;
+
+ *temp_surface = NULL;
+ if (FAILED(hr = IDirect3DSurface9_LockRect(surface, lock, NULL, D3DLOCK_READONLY)))
+ {
+ IDirect3DSurface9_GetDevice(surface, &device);
+ IDirect3DSurface9_GetDesc(surface, &desc);
+ if (FAILED(hr = IDirect3DDevice9_CreateRenderTarget(device, desc.Width,
desc.Height,
+ desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, temp_surface, NULL)))
+ {
+ IDirect3DDevice9_Release(device);
+ return hr;
+ }
+
+ if (SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, surface, NULL,
*temp_surface, NULL, D3DTEXF_NONE)))
+ hr = IDirect3DSurface9_LockRect(*temp_surface, lock, NULL,
D3DLOCK_READONLY);
+ IDirect3DDevice9_Release(device);
+ if (FAILED(hr))
+ {
+ WARN("Failed to lock surface %p, usage %#x, pool %#x.\n",
+ surface, desc.Usage, desc.Pool);
+ IDirect3DSurface9_Release(*temp_surface);
+ *temp_surface = NULL;
+ return hr;
+ }
+ }
+ return hr;
+}
+
+static HRESULT unlock_surface(IDirect3DSurface9 *surface, D3DLOCKED_RECT *lock,
+ IDirect3DSurface9 *temp_surface)
+{
+ HRESULT hr;
+
+ if (!temp_surface)
+ return IDirect3DSurface9_UnlockRect(surface);
+
+ hr = IDirect3DSurface9_UnlockRect(temp_surface);
+ IDirect3DSurface9_Release(temp_surface);
+ return hr;
+}
+
static D3DFORMAT dds_rgb_to_d3dformat(const struct dds_pixel_format *pixel_format)
{
unsigned int i;
@@ -1924,7 +1971,7 @@ HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9
*dst_surface,
const PALETTEENTRY *dst_palette, const RECT *dst_rect, IDirect3DSurface9
*src_surface,
const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR
color_key)
{
- IDirect3DSurface9 *surface = src_surface;
+ IDirect3DSurface9 *temp_surface;
D3DTEXTUREFILTERTYPE d3d_filter;
IDirect3DDevice9 *device;
D3DSURFACE_DESC src_desc;
@@ -1979,32 +2026,14 @@ HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9
*dst_surface,
src_rect = &s;
}
- if (FAILED(IDirect3DSurface9_LockRect(surface, &lock, NULL, D3DLOCK_READONLY)))
- {
- IDirect3DSurface9_GetDevice(src_surface, &device);
- if (FAILED(IDirect3DDevice9_CreateRenderTarget(device, src_desc.Width,
src_desc.Height,
- src_desc.Format, D3DMULTISAMPLE_NONE, 0, TRUE, &surface, NULL)))
- {
- IDirect3DDevice9_Release(device);
- return D3DXERR_INVALIDDATA;
- }
-
- if (SUCCEEDED(hr = IDirect3DDevice9_StretchRect(device, src_surface, NULL,
surface, NULL, D3DTEXF_NONE)))
- hr = IDirect3DSurface9_LockRect(surface, &lock, NULL, D3DLOCK_READONLY);
- IDirect3DDevice9_Release(device);
- if (FAILED(hr))
- {
- IDirect3DSurface9_Release(surface);
- return D3DXERR_INVALIDDATA;
- }
- }
+ if (FAILED(lock_surface(src_surface, &lock, &temp_surface)))
+ return D3DXERR_INVALIDDATA;
hr = D3DXLoadSurfaceFromMemory(dst_surface, dst_palette, dst_rect, lock.pBits,
src_desc.Format, lock.Pitch, src_palette, src_rect, filter, color_key);
- IDirect3DSurface9_UnlockRect(surface);
- if (surface != src_surface)
- IDirect3DSurface9_Release(surface);
+ if (FAILED(unlock_surface(src_surface, &lock, temp_surface)))
+ return D3DXERR_INVALIDDATA;
return hr;
}
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
new file mode 100644
index 00000000000..ff99278963a
--- /dev/null
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -0,0 +1,36 @@
+directories:
+ dlls/d3dx9_24: dll/directx/wine/d3dx9_24
+ dlls/d3dx9_25: dll/directx/wine/d3dx9_25
+ dlls/d3dx9_26: dll/directx/wine/d3dx9_26
+ dlls/d3dx9_27: dll/directx/wine/d3dx9_27
+ dlls/d3dx9_28: dll/directx/wine/d3dx9_28
+ dlls/d3dx9_29: dll/directx/wine/d3dx9_29
+ dlls/d3dx9_30: dll/directx/wine/d3dx9_30
+ dlls/d3dx9_31: dll/directx/wine/d3dx9_31
+ dlls/d3dx9_32: dll/directx/wine/d3dx9_32
+ dlls/d3dx9_33: dll/directx/wine/d3dx9_33
+ dlls/d3dx9_34: dll/directx/wine/d3dx9_34
+ dlls/d3dx9_35: dll/directx/wine/d3dx9_35
+ dlls/d3dx9_36: dll/directx/wine/d3dx9_36
+ dlls/d3dx9_36/tests: modules/rostests/winetests/d3dx9_36
+ dlls/d3dx9_37: dll/directx/wine/d3dx9_37
+ dlls/d3dx9_38: dll/directx/wine/d3dx9_38
+ dlls/d3dx9_39: dll/directx/wine/d3dx9_39
+ dlls/d3dx9_40: dll/directx/wine/d3dx9_40
+ dlls/d3dx9_41: dll/directx/wine/d3dx9_41
+ dlls/d3dx9_42: dll/directx/wine/d3dx9_42
+ dlls/d3dx9_43: dll/directx/wine/d3dx9_43
+files:
+ include/d3dx9.h: sdk/include/dxsdk/d3dx9.h
+ include/d3dx9anim.h: sdk/include/dxsdk/d3dx9anim.h
+ include/d3dx9core.h: sdk/include/dxsdk/d3dx9core.h
+ include/d3dx9effect.h: sdk/include/dxsdk/d3dx9effect.h
+ include/d3dx9math.h: sdk/include/dxsdk/d3dx9math.h
+ include/d3dx9math.inl: sdk/include/dxsdk/d3dx9math.inl
+ include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h
+ include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h
+ include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h
+ include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h
+ include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h
+tags:
+ wine: 33be8439fc95ca8f005bd3a2b6790c101842c02e