-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1c42ca7
Showing
241 changed files
with
128,444 additions
and
0 deletions.
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
0000-pending-mrs-and-backports/0001-ps5512-win32u-Fix-calculating-viewport-size.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
From 3cc82e6ef9adc0c9921c1bc77abdc80e276e6273 Mon Sep 17 00:00:00 2001 | ||
From: Haoyang Chen <[email protected]> | ||
Date: Tue, 21 Nov 2023 16:24:56 +0800 | ||
Subject: [PATCH 1/2] win32u: Fix calculating viewport size incorrectly. | ||
|
||
Calling either SetViewportExtEx or SetWindowExtEx | ||
fixes the viewport(MAPPING_FixIsotropic), but if both are called then it is fixed twice. | ||
Then the mapping matrix will be incorrect and will not be calculated | ||
using the values of viewport and wnd. | ||
--- | ||
dlls/gdi32/dc.c | 3 +++ | ||
dlls/win32u/mapping.c | 24 ++++++++++++++++++++---- | ||
include/ntgdi.h | 4 ++++ | ||
3 files changed, 27 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c | ||
index 0a57d74485e..c999ff95e15 100644 | ||
--- a/dlls/gdi32/dc.c | ||
+++ b/dlls/gdi32/dc.c | ||
@@ -1171,6 +1171,7 @@ BOOL WINAPI SetWindowExtEx( HDC hdc, INT x, INT y, SIZE *size ) | ||
if (!x || !y) return FALSE; | ||
dc_attr->wnd_ext.cx = x; | ||
dc_attr->wnd_ext.cy = y; | ||
+ dc_attr->vp_wnd_bits |= NTGDI_SETWND; | ||
return NtGdiComputeXformCoefficients( hdc ); | ||
} | ||
|
||
@@ -1226,6 +1227,7 @@ BOOL WINAPI GetViewportExtEx( HDC hdc, SIZE *size ) | ||
{ | ||
DC_ATTR *dc_attr; | ||
if (!(dc_attr = get_dc_attr( hdc ))) return FALSE; | ||
+ if (0 != dc_attr->vp_wnd_bits) NtGdiComputeXformCoefficients( hdc ); | ||
*size = dc_attr->vport_ext; | ||
return TRUE; | ||
} | ||
@@ -1246,6 +1248,7 @@ BOOL WINAPI SetViewportExtEx( HDC hdc, INT x, INT y, LPSIZE size ) | ||
if (!x || !y) return FALSE; | ||
dc_attr->vport_ext.cx = x; | ||
dc_attr->vport_ext.cy = y; | ||
+ dc_attr->vp_wnd_bits |= NTGDI_SETVIEWPORT; | ||
return NtGdiComputeXformCoefficients( hdc ); | ||
} | ||
|
||
diff --git a/dlls/win32u/mapping.c b/dlls/win32u/mapping.c | ||
index 65f276e853f..7a5c729854f 100644 | ||
--- a/dlls/win32u/mapping.c | ||
+++ b/dlls/win32u/mapping.c | ||
@@ -90,10 +90,22 @@ static void MAPPING_FixIsotropic( DC * dc ) | ||
{ | ||
SIZE virtual_size = get_dc_virtual_size( dc ); | ||
SIZE virtual_res = get_dc_virtual_res( dc ); | ||
- double xdim = fabs((double)dc->attr->vport_ext.cx * virtual_size.cx / | ||
- (virtual_res.cx * dc->attr->wnd_ext.cx)); | ||
- double ydim = fabs((double)dc->attr->vport_ext.cy * virtual_size.cy / | ||
- (virtual_res.cy * dc->attr->wnd_ext.cy)); | ||
+ double xdim, ydim; | ||
+ | ||
+ if ((NTGDI_SETVIEWPORT | NTGDI_SETWND) == dc->attr->vp_wnd_bits) | ||
+ { | ||
+ xdim = fabs((double)dc->attr->old_vport_ext.cx / dc->attr->wnd_ext.cx); | ||
+ ydim = fabs((double)dc->attr->old_vport_ext.cy / dc->attr->wnd_ext.cy); | ||
+ dc->attr->vport_ext = dc->attr->old_vport_ext; | ||
+ } | ||
+ else | ||
+ { | ||
+ xdim = fabs((double)dc->attr->vport_ext.cx * virtual_size.cx / | ||
+ (virtual_res.cx * dc->attr->wnd_ext.cx)); | ||
+ ydim = fabs((double)dc->attr->vport_ext.cy * virtual_size.cy / | ||
+ (virtual_res.cy * dc->attr->wnd_ext.cy)); | ||
+ dc->attr->old_vport_ext = dc->attr->vport_ext; | ||
+ } | ||
|
||
if (xdim > ydim) | ||
{ | ||
@@ -107,6 +119,9 @@ static void MAPPING_FixIsotropic( DC * dc ) | ||
dc->attr->vport_ext.cy = GDI_ROUND( dc->attr->vport_ext.cy * xdim / ydim ); | ||
if (!dc->attr->vport_ext.cy) dc->attr->vport_ext.cy = mincy; | ||
} | ||
+ | ||
+ if (NTGDI_SETWND & dc->attr->vp_wnd_bits) | ||
+ dc->attr->vp_wnd_bits = 0; | ||
} | ||
|
||
|
||
@@ -133,6 +148,7 @@ BOOL set_map_mode( DC *dc, int mode ) | ||
dc->attr->wnd_ext.cy = virtual_size.cy * 10; | ||
dc->attr->vport_ext.cx = virtual_res.cx; | ||
dc->attr->vport_ext.cy = -virtual_res.cy; | ||
+ dc->attr->vp_wnd_bits = 0; | ||
break; | ||
case MM_HIMETRIC: | ||
virtual_size = get_dc_virtual_size( dc ); | ||
diff --git a/include/ntgdi.h b/include/ntgdi.h | ||
index 50973535c7a..9f9f852bc6b 100644 | ||
--- a/include/ntgdi.h | ||
+++ b/include/ntgdi.h | ||
@@ -171,6 +171,8 @@ enum | ||
/* structs not compatible with native Windows */ | ||
#ifdef __WINESRC__ | ||
|
||
+#define NTGDI_SETVIEWPORT 0x01 | ||
+#define NTGDI_SETWND 0x02 | ||
typedef struct DC_ATTR | ||
{ | ||
UINT hdc; /* handle to self */ | ||
@@ -198,8 +200,10 @@ typedef struct DC_ATTR | ||
POINT brush_org; /* brush origin */ | ||
POINT wnd_org; /* window origin */ | ||
SIZE wnd_ext; /* window extent */ | ||
+ SIZE old_vport_ext; /* last viewport extent */ | ||
POINT vport_org; /* viewport origin */ | ||
SIZE vport_ext; /* viewport extent */ | ||
+ WORD vp_wnd_bits; /* According to msdn, SetWindowExtEx and SetViewportExtEx need to be used together */ | ||
SIZE virtual_res; | ||
SIZE virtual_size; | ||
UINT font_code_page; | ||
-- | ||
GitLab | ||
|
||
|
||
From 08cc00cd6bd7695d9216bbd57ea94d2a1821377d Mon Sep 17 00:00:00 2001 | ||
From: Haoyang Chen <[email protected]> | ||
Date: Tue, 21 Nov 2023 16:35:10 +0800 | ||
Subject: [PATCH 2/2] gdi32/tests: Add some tests for SetWindowExtEx and | ||
SetViewportExtEx. | ||
|
||
--- | ||
dlls/gdi32/tests/mapping.c | 24 ++++++++++++++++++++++++ | ||
1 file changed, 24 insertions(+) | ||
|
||
diff --git a/dlls/gdi32/tests/mapping.c b/dlls/gdi32/tests/mapping.c | ||
index 78c83907a7e..192c87c33b6 100644 | ||
--- a/dlls/gdi32/tests/mapping.c | ||
+++ b/dlls/gdi32/tests/mapping.c | ||
@@ -487,6 +487,23 @@ static void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, | ||
viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y); | ||
} | ||
|
||
+static void test_SetWindowExtEx(INT vp_cx, INT vp_cy, INT cx, INT cy, INT expect_cx, INT expect_cy) | ||
+{ | ||
+ SIZE viewportExt = {0}; | ||
+ HDC hdc = GetDC(0); | ||
+ | ||
+ SetMapMode(hdc, MM_ISOTROPIC); | ||
+ | ||
+ SetViewportExtEx(hdc, vp_cx, vp_cy, NULL); | ||
+ SetWindowExtEx(hdc, cx, cy, NULL); | ||
+ GetViewportExtEx(hdc, &viewportExt); | ||
+ | ||
+ ok(viewportExt.cx == expect_cx && viewportExt.cy == expect_cy, "Expected %dx%d got %ldx%ld\n", | ||
+ expect_cx, expect_cy, viewportExt.cx, viewportExt.cy); | ||
+ | ||
+ ReleaseDC(0, hdc); | ||
+} | ||
+ | ||
static void test_isotropic_mapping(void) | ||
{ | ||
SIZE win, vp; | ||
@@ -524,6 +541,13 @@ static void test_isotropic_mapping(void) | ||
test_SetWindowExt(hdc, 4 * win.cx, -4 * win.cy, -vp.cx, -vp.cy); | ||
|
||
ReleaseDC(0, hdc); | ||
+ | ||
+ test_SetWindowExtEx(400, 600, 400*2, 600*2, 400, 600); | ||
+ test_SetWindowExtEx(500, 500, 1234, 4567, 500*1234/4567, 500); | ||
+ test_SetWindowExtEx(500, 500, 1234, 600, 500, 500*600/1234); | ||
+ test_SetWindowExtEx(500, 500, 1234, 1234, 500, 500); | ||
+ test_SetWindowExtEx(-500, 500, 111, 111, -500, 500); | ||
+ test_SetWindowExtEx(500, -500, 1500, 1500, 500, -500); | ||
} | ||
|
||
static void test_setvirtualresolution(void) | ||
-- | ||
GitLab | ||
|
82 changes: 82 additions & 0 deletions
82
...ackports/0001-vulkan-OPWR/0001-win32u-Introduce-a-new-vulkan-offscreen-surfaces-lis.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
From d79d1cbbea92d26dcd679be2da4828b887c783bb Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <[email protected]> | ||
Date: Wed, 24 Apr 2024 11:12:31 +0200 | ||
Subject: [PATCH 01/10] win32u: Introduce a new vulkan offscreen surfaces list. | ||
|
||
--- | ||
dlls/win32u/vulkan.c | 28 ++++++++++++++++++++-------- | ||
1 file changed, 20 insertions(+), 8 deletions(-) | ||
|
||
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c | ||
index 5b128afe3cb..91cfa237a61 100644 | ||
--- a/dlls/win32u/vulkan.c | ||
+++ b/dlls/win32u/vulkan.c | ||
@@ -45,6 +45,10 @@ static void *vulkan_handle; | ||
static const struct vulkan_driver_funcs *driver_funcs; | ||
static struct vulkan_funcs vulkan_funcs; | ||
|
||
+/* list of surfaces attached to other processes / desktop windows */ | ||
+static struct list offscreen_surfaces = LIST_INIT(offscreen_surfaces); | ||
+static pthread_mutex_t vulkan_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
+ | ||
static void (*p_vkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *); | ||
static VkResult (*p_vkQueuePresentKHR)(VkQueue, const VkPresentInfoKHR *); | ||
static void *(*p_vkGetDeviceProcAddr)(VkDevice, const char *); | ||
@@ -71,6 +75,7 @@ static inline VkSurfaceKHR surface_to_handle( struct surface *surface ) | ||
static VkResult win32u_vkCreateWin32SurfaceKHR( VkInstance instance, const VkWin32SurfaceCreateInfoKHR *info, | ||
const VkAllocationCallbacks *allocator, VkSurfaceKHR *handle ) | ||
{ | ||
+ HWND toplevel = NtUserGetAncestor( info->hwnd, GA_ROOT ); | ||
struct surface *surface; | ||
VkResult res; | ||
WND *win; | ||
@@ -85,8 +90,12 @@ static VkResult win32u_vkCreateWin32SurfaceKHR( VkInstance instance, const VkWin | ||
return res; | ||
} | ||
|
||
- if (!(win = get_win_ptr( info->hwnd )) || win == WND_DESKTOP || win == WND_OTHER_PROCESS) | ||
- list_init( &surface->entry ); | ||
+ if (!(win = get_win_ptr( toplevel )) || win == WND_DESKTOP || win == WND_OTHER_PROCESS) | ||
+ { | ||
+ pthread_mutex_lock( &vulkan_mutex ); | ||
+ list_add_tail( &offscreen_surfaces, &surface->entry ); | ||
+ pthread_mutex_unlock( &vulkan_mutex ); | ||
+ } | ||
else | ||
{ | ||
list_add_tail( &win->vulkan_surfaces, &surface->entry ); | ||
@@ -105,7 +114,10 @@ static void win32u_vkDestroySurfaceKHR( VkInstance instance, VkSurfaceKHR handle | ||
TRACE( "instance %p, handle 0x%s, allocator %p\n", instance, wine_dbgstr_longlong(handle), allocator ); | ||
if (allocator) FIXME( "Support for allocation callbacks not implemented yet\n" ); | ||
|
||
+ pthread_mutex_lock( &vulkan_mutex ); | ||
list_remove( &surface->entry ); | ||
+ pthread_mutex_unlock( &vulkan_mutex ); | ||
+ | ||
p_vkDestroySurfaceKHR( instance, surface->host_surface, NULL /* allocator */ ); | ||
driver_funcs->p_vulkan_surface_destroy( surface->hwnd, surface->driver_private ); | ||
free( surface ); | ||
@@ -313,14 +325,14 @@ static void vulkan_init(void) | ||
|
||
void vulkan_detach_surfaces( struct list *surfaces ) | ||
{ | ||
- struct surface *surface, *next; | ||
+ struct surface *surface; | ||
|
||
- LIST_FOR_EACH_ENTRY_SAFE( surface, next, surfaces, struct surface, entry ) | ||
- { | ||
+ LIST_FOR_EACH_ENTRY( surface, surfaces, struct surface, entry ) | ||
driver_funcs->p_vulkan_surface_detach( surface->hwnd, surface->driver_private ); | ||
- list_remove( &surface->entry ); | ||
- list_init( &surface->entry ); | ||
- } | ||
+ | ||
+ pthread_mutex_lock( &vulkan_mutex ); | ||
+ list_move_tail( &offscreen_surfaces, surfaces ); | ||
+ pthread_mutex_unlock( &vulkan_mutex ); | ||
} | ||
|
||
/*********************************************************************** | ||
-- | ||
2.45.1 | ||
|
112 changes: 112 additions & 0 deletions
112
...ackports/0001-vulkan-OPWR/0002-win32u-Move-vulkan-surfaces-to-their-new-parent-when.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
From 653a12548c1004e793d9577b8feb1ecbd5b65042 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <[email protected]> | ||
Date: Wed, 24 Apr 2024 11:12:31 +0200 | ||
Subject: [PATCH 02/10] win32u: Move vulkan surfaces to their new parent when | ||
reparenting. | ||
|
||
--- | ||
dlls/win32u/ntuser_private.h | 1 + | ||
dlls/win32u/vulkan.c | 62 ++++++++++++++++++++++++++++++++++++ | ||
dlls/win32u/window.c | 1 + | ||
3 files changed, 64 insertions(+) | ||
|
||
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h | ||
index 11b1a3ff8a1..04396abca72 100644 | ||
--- a/dlls/win32u/ntuser_private.h | ||
+++ b/dlls/win32u/ntuser_private.h | ||
@@ -257,6 +257,7 @@ extern LRESULT system_tray_call( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar | ||
|
||
/* vulkan.c */ | ||
extern void vulkan_detach_surfaces( struct list *surfaces ); | ||
+extern void vulkan_set_parent( HWND hwnd, HWND new_parent, HWND old_parent ); | ||
|
||
/* window.c */ | ||
HANDLE alloc_user_handle( struct user_object *ptr, unsigned int type ); | ||
diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c | ||
index 91cfa237a61..a6255e9bf36 100644 | ||
--- a/dlls/win32u/vulkan.c | ||
+++ b/dlls/win32u/vulkan.c | ||
@@ -335,6 +335,68 @@ void vulkan_detach_surfaces( struct list *surfaces ) | ||
pthread_mutex_unlock( &vulkan_mutex ); | ||
} | ||
|
||
+static void append_window_surfaces( HWND toplevel, struct list *surfaces ) | ||
+{ | ||
+ WND *win; | ||
+ | ||
+ if (!(win = get_win_ptr( toplevel )) || win == WND_DESKTOP || win == WND_OTHER_PROCESS) | ||
+ { | ||
+ pthread_mutex_lock( &vulkan_mutex ); | ||
+ list_move_tail( &offscreen_surfaces, surfaces ); | ||
+ pthread_mutex_unlock( &vulkan_mutex ); | ||
+ } | ||
+ else | ||
+ { | ||
+ list_move_tail( &win->vulkan_surfaces, surfaces ); | ||
+ release_win_ptr( win ); | ||
+ } | ||
+} | ||
+ | ||
+static void enum_window_surfaces( HWND toplevel, HWND hwnd, struct list *surfaces ) | ||
+{ | ||
+ struct list tmp_surfaces = LIST_INIT(tmp_surfaces); | ||
+ struct surface *surface, *next; | ||
+ WND *win; | ||
+ | ||
+ if (!(win = get_win_ptr( toplevel )) || win == WND_DESKTOP || win == WND_OTHER_PROCESS) | ||
+ { | ||
+ pthread_mutex_lock( &vulkan_mutex ); | ||
+ list_move_tail( &tmp_surfaces, &offscreen_surfaces ); | ||
+ pthread_mutex_unlock( &vulkan_mutex ); | ||
+ } | ||
+ else | ||
+ { | ||
+ list_move_tail( &tmp_surfaces, &win->vulkan_surfaces ); | ||
+ release_win_ptr( win ); | ||
+ } | ||
+ | ||
+ LIST_FOR_EACH_ENTRY_SAFE( surface, next, &tmp_surfaces, struct surface, entry ) | ||
+ { | ||
+ if (surface->hwnd != hwnd && !NtUserIsChild( hwnd, surface->hwnd )) continue; | ||
+ list_remove( &surface->entry ); | ||
+ list_add_tail( surfaces, &surface->entry ); | ||
+ } | ||
+ | ||
+ append_window_surfaces( toplevel, &tmp_surfaces ); | ||
+} | ||
+ | ||
+void vulkan_set_parent( HWND hwnd, HWND new_parent, HWND old_parent ) | ||
+{ | ||
+ struct list surfaces = LIST_INIT(surfaces); | ||
+ HWND new_toplevel, old_toplevel; | ||
+ | ||
+ TRACE( "hwnd %p new_parent %p old_parent %p\n", hwnd, new_parent, old_parent ); | ||
+ | ||
+ if (new_parent == NtUserGetDesktopWindow()) new_toplevel = hwnd; | ||
+ else new_toplevel = NtUserGetAncestor( new_parent, GA_ROOT ); | ||
+ if (old_parent == NtUserGetDesktopWindow()) old_toplevel = hwnd; | ||
+ else old_toplevel = NtUserGetAncestor( old_parent, GA_ROOT ); | ||
+ if (old_toplevel == new_toplevel) return; | ||
+ | ||
+ enum_window_surfaces( old_toplevel, hwnd, &surfaces ); | ||
+ append_window_surfaces( new_toplevel, &surfaces ); | ||
+} | ||
+ | ||
/*********************************************************************** | ||
* __wine_get_vulkan_driver (win32u.so) | ||
*/ | ||
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c | ||
index 13dd1c8d80a..f630f107b00 100644 | ||
--- a/dlls/win32u/window.c | ||
+++ b/dlls/win32u/window.c | ||
@@ -463,6 +463,7 @@ HWND WINAPI NtUserSetParent( HWND hwnd, HWND parent ) | ||
context = SetThreadDpiAwarenessContext( get_window_dpi_awareness_context( hwnd )); | ||
|
||
user_driver->pSetParent( full_handle, parent, old_parent ); | ||
+ vulkan_set_parent( full_handle, parent, old_parent ); | ||
|
||
winpos.hwnd = hwnd; | ||
winpos.hwndInsertAfter = HWND_TOP; | ||
-- | ||
2.45.1 | ||
|
Oops, something went wrong.