Freetype's FT_Load_Glyph may return different glyph metrics (in particular, horiAdvance) depending on load target flags (FT_LOAD_TARGET_MONO, FT_LOAD_TARGET_NORMAL ...). Among the consequences of that are: - the size of, e. g, GetTextExtentPoint() doesn't match the size of actually rendered text; - DrawTextW() with DT_CALCRECT flag returns wrong bounding rectangle.
In the core of that is GetGlyphOutline() returning different values for GGO_METRICS format (used in various glyph metrics query functions) and the actual format used during rendering.
It probably make sense to use effective fonts rendering option for GGO_METRICS so that matches. I did some ad-hoc testing on Windows with currently problematic Tahoma font and quite expectedly GetGlyphOutline(GGO_METRICS) always returns the same metrics as other output format options. While all the options also have the same metrics between each other (which is still not the case with Wine). I guess it is not easily possible to make all the face load options match each other with freetype (nor I am sure that is always the case on Windows for all the possible fonts), but making GGO_METRICS return the metrics matching actual gdi device context setup looks more important.
Fixes Idle Spiral being unable to render typed text in save / load dialogs (which is using Winforms from Unity's Mono).
-- v4: fixup! win32u: Use font AA flags when querying glyph outline with GGO_METRICS. fixup! win32u: Use font AA flags when querying glyph outline with GGO_METRICS. (tmp, untested, helps ida) win32u: Don't force GGO_BITMAP for default bitmap in dibdrv_SelectFont(). Revert "winex11: Only request display modes driver data when needed." Revert "win32u: Read / write source modes as a single registry blob." Revert "win32u: Remove now unnecessary reset_display_manager_ctx." Revert "win32u: Use struct pci_id in struct gdi_gpu." Revert "win32u: Remove driver-specific id from struct gdi_gpu." Revert "win32u: Pass gdi_gpu structure members as add_gpu parameters." Revert "win32u: Return STATUS_ALREADY_COMPLETE from UpdateDisplayDevices." win32u: Use font AA flags when querying glyph outline with GGO_METRICS. d3dx9/tests: Make test_ID3DXFont() less dependent on GetGlyphOutlineW(GGO_METRICS) behaviour. win32u: Set all glyph load flags in get_load_flags(). win32u: Store effective AA flags in font_physdev.
From: Paul Gofman pgofman@codeweavers.com
--- dlls/win32u/font.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index 277849ac4d9..f26f4ccb7a2 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -55,6 +55,7 @@ struct font_physdev { struct gdi_physdev dev; struct gdi_font *font; + UINT aa_flags; };
static inline struct font_physdev *get_font_dev( PHYSDEV dev ) @@ -4684,6 +4685,7 @@ static HFONT font_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags ) *aa_flags = font_smoothing; } *aa_flags = font_funcs->get_aa_flags( font, *aa_flags, antialias_fakes ); + physdev->aa_flags = *aa_flags; } TRACE( "%p %s %d aa %x\n", hfont, debugstr_w(lf.lfFaceName), (int)lf.lfHeight, *aa_flags ); pthread_mutex_unlock( &font_lock );
From: Paul Gofman pgofman@codeweavers.com
--- dlls/win32u/freetype.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index 3e640115ab7..3e1e0ecefdd 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -3403,10 +3403,13 @@ static unsigned int get_bezier_glyph_outline(FT_Outline *outline, unsigned int b return needed; }
-static FT_Int get_load_flags( UINT format ) +static FT_Int get_load_flags( UINT format, BOOL vertical_metrics, BOOL force_no_bitmap ) { FT_Int load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
+ if (vertical_metrics) load_flags |= FT_LOAD_VERTICAL_LAYOUT; + if (force_no_bitmap || format != GGO_BITMAP) load_flags |= FT_LOAD_NO_BITMAP; + if (format & GGO_UNHINTED) return load_flags | FT_LOAD_NO_HINTING;
@@ -3446,7 +3449,7 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT FT_Glyph_Metrics metrics; FT_Error err; FT_BBox bbox; - FT_Int load_flags = get_load_flags(format); + FT_Int load_flags; FT_Matrix transform_matrices[3], *matrices = NULL; BOOL vertical_metrics;
@@ -3456,8 +3459,6 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT font->matrix.eM11, font->matrix.eM12, font->matrix.eM21, font->matrix.eM22);
- format &= ~GGO_UNHINTED; - matrices = get_transform_matrices( font, tategaki, lpmat, transform_matrices );
vertical_metrics = (tategaki && FT_HAS_VERTICAL(ft_face)); @@ -3465,9 +3466,7 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT properly scaled and correct in 2.4.0 or greater */ if (vertical_metrics && FT_SimpleVersion < FT_VERSION_VALUE(2, 4, 0)) vertical_metrics = FALSE; - - if (matrices || format != GGO_BITMAP) load_flags |= FT_LOAD_NO_BITMAP; - if (vertical_metrics) load_flags |= FT_LOAD_VERTICAL_LAYOUT; + load_flags = get_load_flags(format, vertical_metrics, !!matrices);
err = pFT_Load_Glyph(ft_face, glyph, load_flags); if (err && !(load_flags & FT_LOAD_NO_HINTING)) @@ -3482,6 +3481,8 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT return GDI_ERROR; }
+ format &= ~GGO_UNHINTED; + metrics = ft_face->glyph->metrics; if(font->fake_bold) { if (!get_bold_glyph_outline(ft_face->glyph, font->ppem, &metrics) && metrics.width)
From: Paul Gofman pgofman@codeweavers.com
--- dlls/d3dx9_36/tests/core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index c3b80028f43..5b07fcd5ef7 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -356,7 +356,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) IDirect3DTexture9 *texture; D3DSURFACE_DESC surf_desc; IDirect3DDevice9 *bufdev; - GLYPHMETRICS glyph_metrics; + GLYPHMETRICS glyph_metrics, gm_grayscale; D3DXFONT_DESCA desc; ID3DXSprite *sprite; RECT rect, blackbox; @@ -605,15 +605,27 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) count = GetGlyphOutlineW(hdc, glyph, GGO_GLYPH_INDEX | GGO_METRICS, &glyph_metrics, 0, NULL, &mat); ok(count != GDI_ERROR, "Unexpected count %#lx.\n", count);
+ count = GetGlyphOutlineW(hdc, glyph, GGO_GLYPH_INDEX | GGO_GRAY8_BITMAP, &gm_grayscale, 0, NULL, &mat); + ok(count != GDI_ERROR, "Unexpected count %#lx.\n", count); + ret = ID3DXFont_GetTextMetricsW(font, &tm); ok(ret, "Unexpected ret %#x.\n", ret);
- todo_wine ok(blackbox.right - blackbox.left == glyph_metrics.gmBlackBoxX + 2, "Got %ld, expected %d.\n", + todo_wine_if(blackbox.right - blackbox.left < glyph_metrics.gmBlackBoxX + 2) + ok(blackbox.right - blackbox.left == glyph_metrics.gmBlackBoxX + 2, "Got %ld, expected %d.\n", blackbox.right - blackbox.left, glyph_metrics.gmBlackBoxX + 2); - todo_wine ok(blackbox.bottom - blackbox.top == glyph_metrics.gmBlackBoxY + 2, "Got %ld, expected %d.\n", + + todo_wine_if(blackbox.bottom - blackbox.top < glyph_metrics.gmBlackBoxY + 2) + ok(blackbox.bottom - blackbox.top == glyph_metrics.gmBlackBoxY + 2, "Got %ld, expected %d.\n", blackbox.bottom - blackbox.top, glyph_metrics.gmBlackBoxY + 2); + + todo_wine_if(glyph_metrics.gmptGlyphOrigin.x != gm_grayscale.gmptGlyphOrigin.x + && cellinc.x == gm_grayscale.gmptGlyphOrigin.x - 1) ok(cellinc.x == glyph_metrics.gmptGlyphOrigin.x - 1, "Got %ld, expected %ld.\n", cellinc.x, glyph_metrics.gmptGlyphOrigin.x - 1); + + todo_wine_if(glyph_metrics.gmptGlyphOrigin.y != gm_grayscale.gmptGlyphOrigin.y + && cellinc.y == tm.tmAscent - gm_grayscale.gmptGlyphOrigin.y - 1) ok(cellinc.y == tm.tmAscent - glyph_metrics.gmptGlyphOrigin.y - 1, "Got %ld, expected %ld.\n", cellinc.y, tm.tmAscent - glyph_metrics.gmptGlyphOrigin.y - 1);
From: Paul Gofman pgofman@codeweavers.com
--- dlls/win32u/font.c | 16 ++++++++-------- dlls/win32u/freetype.c | 13 +++++++++++-- dlls/win32u/ntgdi_private.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index f26f4ccb7a2..937340f8d12 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -3846,7 +3846,7 @@ static UINT get_glyph_index_linked( struct gdi_font **font, UINT glyph )
static DWORD get_glyph_outline( struct gdi_font *font, UINT glyph, UINT format, GLYPHMETRICS *gm_ret, ABC *abc_ret, DWORD buflen, void *buf, - const MAT2 *mat ) + const MAT2 *mat, UINT aa_flags ) { GLYPHMETRICS gm; ABC abc; @@ -3880,7 +3880,7 @@ static DWORD get_glyph_outline( struct gdi_font *font, UINT glyph, UINT format, if (format == GGO_METRICS && !mat && get_gdi_font_glyph_metrics( font, index, &gm, &abc )) goto done;
- ret = font_funcs->get_glyph_outline( font, index, format, &gm, &abc, buflen, buf, mat, tategaki ); + ret = font_funcs->get_glyph_outline( font, index, format, &gm, &abc, buflen, buf, mat, tategaki, aa_flags ); if (ret == GDI_ERROR) return ret;
if (format == GGO_METRICS && !mat) @@ -3929,7 +3929,7 @@ static BOOL font_GetCharABCWidths( PHYSDEV dev, UINT first, UINT count, WCHAR *c for (i = 0; i < count; i++) { c = chars ? chars[i] : first + i; - get_glyph_outline( physdev->font, c, GGO_METRICS, NULL, &buffer[i], 0, NULL, NULL ); + get_glyph_outline( physdev->font, c, GGO_METRICS, NULL, &buffer[i], 0, NULL, NULL, physdev->aa_flags ); } pthread_mutex_unlock( &font_lock ); return TRUE; @@ -3955,7 +3955,7 @@ static BOOL font_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *g pthread_mutex_lock( &font_lock ); for (c = 0; c < count; c++, buffer++) get_glyph_outline( physdev->font, gi ? gi[c] : first + c, GGO_METRICS | GGO_GLYPH_INDEX, - NULL, buffer, 0, NULL, NULL ); + NULL, buffer, 0, NULL, NULL, physdev->aa_flags ); pthread_mutex_unlock( &font_lock ); return TRUE; } @@ -3982,7 +3982,7 @@ static BOOL font_GetCharWidth( PHYSDEV dev, UINT first, UINT count, const WCHAR for (i = 0; i < count; i++) { c = chars ? chars[i] : i + first; - if (get_glyph_outline( physdev->font, c, GGO_METRICS, NULL, &abc, 0, NULL, NULL ) == GDI_ERROR) + if (get_glyph_outline( physdev->font, c, GGO_METRICS, NULL, &abc, 0, NULL, NULL, physdev->aa_flags ) == GDI_ERROR) buffer[i] = 0; else buffer[i] = abc.abcA + abc.abcB + abc.abcC; @@ -4161,7 +4161,7 @@ static DWORD font_GetGlyphOutline( PHYSDEV dev, UINT glyph, UINT format, return dev->funcs->pGetGlyphOutline( dev, glyph, format, gm, buflen, buf, mat ); } pthread_mutex_lock( &font_lock ); - ret = get_glyph_outline( physdev->font, glyph, format, gm, NULL, buflen, buf, mat ); + ret = get_glyph_outline( physdev->font, glyph, format, gm, NULL, buflen, buf, mat, physdev->aa_flags ); pthread_mutex_unlock( &font_lock ); return ret; } @@ -4341,7 +4341,7 @@ static BOOL font_GetTextExtentExPoint( PHYSDEV dev, const WCHAR *str, INT count, pthread_mutex_lock( &font_lock ); for (i = pos = 0; i < count; i++) { - get_glyph_outline( physdev->font, str[i], GGO_METRICS, NULL, &abc, 0, NULL, NULL ); + get_glyph_outline( physdev->font, str[i], GGO_METRICS, NULL, &abc, 0, NULL, NULL, physdev->aa_flags ); pos += abc.abcA + abc.abcB + abc.abcC; dxs[i] = pos; } @@ -4371,7 +4371,7 @@ static BOOL font_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT co for (i = pos = 0; i < count; i++) { get_glyph_outline( physdev->font, indices[i], GGO_METRICS | GGO_GLYPH_INDEX, - NULL, &abc, 0, NULL, NULL ); + NULL, &abc, 0, NULL, NULL, physdev->aa_flags ); pos += abc.abcA + abc.abcB + abc.abcC; dxs[i] = pos; } diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index 3e1e0ecefdd..e3b98c3f6ff 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -3442,7 +3442,7 @@ static FT_Int get_load_flags( UINT format, BOOL vertical_metrics, BOOL force_no_ */ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT format, GLYPHMETRICS *lpgm, ABC *abc, UINT buflen, void *buf, - const MAT2 *lpmat, BOOL tategaki ) + const MAT2 *lpmat, BOOL tategaki, UINT aa_flags ) { struct gdi_font *base_font = font->base_font ? font->base_font : font; FT_Face ft_face = get_ft_face( font ); @@ -3452,6 +3452,7 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT FT_Int load_flags; FT_Matrix transform_matrices[3], *matrices = NULL; BOOL vertical_metrics; + UINT effective_format = format;
TRACE("%p, %04x, %08x, %p, %08x, %p, %p\n", font, glyph, format, lpgm, buflen, buf, lpmat);
@@ -3461,14 +3462,22 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT
matrices = get_transform_matrices( font, tategaki, lpmat, transform_matrices );
+ if (aa_flags && (format & ~GGO_GLYPH_INDEX) == GGO_METRICS) + effective_format = aa_flags | (format & GGO_GLYPH_INDEX); vertical_metrics = (tategaki && FT_HAS_VERTICAL(ft_face)); /* there is a freetype bug where vertical metrics are only properly scaled and correct in 2.4.0 or greater */ if (vertical_metrics && FT_SimpleVersion < FT_VERSION_VALUE(2, 4, 0)) vertical_metrics = FALSE; - load_flags = get_load_flags(format, vertical_metrics, !!matrices); + load_flags = get_load_flags(effective_format, vertical_metrics, !!matrices);
err = pFT_Load_Glyph(ft_face, glyph, load_flags); + if (err && format != effective_format) + { + WARN("Failed to load glyph %#x, retrying with GGO_METRICS. Error %#x.\n", glyph, err); + load_flags = get_load_flags(effective_format, vertical_metrics, !!matrices); + err = pFT_Load_Glyph(ft_face, glyph, load_flags); + } if (err && !(load_flags & FT_LOAD_NO_HINTING)) { WARN("Failed to load glyph %#x, retrying without hinting. Error %#x.\n", glyph, err); diff --git a/dlls/win32u/ntgdi_private.h b/dlls/win32u/ntgdi_private.h index 5c4f8279c87..eb82df750ba 100644 --- a/dlls/win32u/ntgdi_private.h +++ b/dlls/win32u/ntgdi_private.h @@ -327,7 +327,7 @@ struct font_backend_funcs UINT (*get_default_glyph)( struct gdi_font *gdi_font ); UINT (*get_glyph_outline)( struct gdi_font *font, UINT glyph, UINT format, GLYPHMETRICS *gm, ABC *abc, UINT buflen, void *buf, - const MAT2 *mat, BOOL tategaki ); + const MAT2 *mat, BOOL tategaki, UINT aa_flags ); UINT (*get_unicode_ranges)( struct gdi_font *font, GLYPHSET *gs ); BOOL (*get_char_width_info)( struct gdi_font *font, struct char_width_info *info ); BOOL (*set_outline_text_metrics)( struct gdi_font *font );
From: Paul Gofman pgofman@codeweavers.com
This reverts commit 9c93676d0c2a3e33dfdeaba2b3f9ce06226e3f9d. --- dlls/win32u/driver.c | 6 +++--- dlls/win32u/sysparams.c | 21 +++++++++------------ dlls/wineandroid.drv/init.c | 6 ++---- dlls/winemac.drv/display.c | 8 ++++---- dlls/winemac.drv/macdrv.h | 2 +- dlls/winewayland.drv/display.c | 8 +++----- dlls/winewayland.drv/waylanddrv.h | 2 +- dlls/winex11.drv/display.c | 11 ++++------- dlls/winex11.drv/x11drv.h | 2 +- include/wine/gdi_driver.h | 2 +- 10 files changed, 29 insertions(+), 39 deletions(-)
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 7c694d20a3c..e22a457d6d6 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -761,9 +761,9 @@ static INT nulldrv_GetDisplayDepth( LPCWSTR name, BOOL is_primary ) return -1; /* use default implementation */ }
-static UINT nulldrv_UpdateDisplayDevices( const struct gdi_device_manager *manager, BOOL force, void *param ) +static BOOL nulldrv_UpdateDisplayDevices( const struct gdi_device_manager *manager, BOOL force, void *param ) { - return STATUS_NOT_IMPLEMENTED; + return FALSE; }
static BOOL nulldrv_CreateDesktop( const WCHAR *name, UINT width, UINT height ) @@ -1166,7 +1166,7 @@ static void loaderdrv_UpdateClipboard(void) load_driver()->pUpdateClipboard(); }
-static UINT loaderdrv_UpdateDisplayDevices( const struct gdi_device_manager *manager, BOOL force, void *param ) +static BOOL loaderdrv_UpdateDisplayDevices( const struct gdi_device_manager *manager, BOOL force, void *param ) { return load_driver()->pUpdateDisplayDevices( manager, force, param ); } diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index e7262cd33f6..ff8cc0edb73 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1888,7 +1888,7 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) if (!write_source_to_registry( &virtual_source, &ctx->source_key )) { WARN( "Failed to write source to registry\n" ); - return STATUS_UNSUCCESSFUL; + return FALSE; }
ctx->source = virtual_source; @@ -1916,21 +1916,18 @@ static BOOL add_virtual_source( struct device_manager_ctx *ctx ) add_monitor( &monitor, ctx ); add_virtual_modes( ctx, ¤t, &initial, &maximum );
- return STATUS_SUCCESS; + return TRUE; }
-static UINT update_display_devices( BOOL force, struct device_manager_ctx *ctx ) +static BOOL update_display_devices( BOOL force, struct device_manager_ctx *ctx ) { - UINT status; - - if (!(status = user_driver->pUpdateDisplayDevices( &device_manager, force, ctx ))) + if (user_driver->pUpdateDisplayDevices( &device_manager, force, ctx )) { if (ctx->source_count && is_virtual_desktop()) return add_virtual_source( ctx ); - return status; + return TRUE; }
- if (status == STATUS_NOT_IMPLEMENTED) return default_update_display_devices( force, ctx ); - return status; + return default_update_display_devices( force, ctx ); }
BOOL update_display_cache( BOOL force ) @@ -1939,7 +1936,7 @@ BOOL update_display_cache( BOOL force ) {'_','_','w','i','n','e','s','e','r','v','i','c','e','_','w','i','n','s','t','a','t','i','o','n',0}; HWINSTA winstation = NtUserGetProcessWindowStation(); struct device_manager_ctx ctx = {0}; - UINT status; + BOOL ret; WCHAR name[MAX_PATH];
/* services do not have any adapters, only a virtual monitor */ @@ -1953,10 +1950,10 @@ BOOL update_display_cache( BOOL force ) return TRUE; }
- status = update_display_devices( force, &ctx ); + ret = update_display_devices( force, &ctx );
release_display_manager_ctx( &ctx ); - if (status && status != STATUS_ALREADY_COMPLETE) WARN( "Failed to update display devices, status %#x\n", status ); + if (!ret) WARN( "Failed to update display devices\n" );
if (!update_display_cache_from_registry()) { diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index c8d997b7aa4..264bd6a7908 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -269,7 +269,7 @@ LONG ANDROID_ChangeDisplaySettings( LPDEVMODEW displays, LPCWSTR primary_name, H /*********************************************************************** * ANDROID_UpdateDisplayDevices */ -UINT ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) +BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) { if (force || force_display_devices_refresh) { @@ -295,11 +295,9 @@ UINT ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag current.dmFields |= DM_POSITION; device_manager->add_modes( ¤t, 1, &mode, param ); force_display_devices_refresh = FALSE; - - return STATUS_SUCCESS; }
- return STATUS_ALREADY_COMPLETE; + return TRUE; }
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index edf740b260e..78019d43de9 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1110,7 +1110,7 @@ static BOOL is_same_devmode(const DEVMODEW *a, const DEVMODEW *b) a->dmDisplayFrequency == b->dmDisplayFrequency; }
-UINT macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) +BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) { struct macdrv_adapter *adapters, *adapter; struct macdrv_monitor *monitors, *monitor; @@ -1120,7 +1120,7 @@ UINT macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage DEVMODEW *mode, *modes; DWORD len;
- if (!force && !force_display_devices_refresh) return STATUS_ALREADY_COMPLETE; + if (!force && !force_display_devices_refresh) return TRUE; force_display_devices_refresh = FALSE;
if (macdrv_get_displays(&displays, &display_count)) @@ -1133,7 +1133,7 @@ UINT macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage if (macdrv_get_gpus(&gpus, &gpu_count)) { ERR("could not get GPUs\n"); - return STATUS_UNSUCCESSFUL; + return FALSE; } TRACE("GPU count: %d\n", gpu_count);
@@ -1198,7 +1198,7 @@ UINT macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
macdrv_free_gpus(gpus); macdrv_free_displays(displays); - return STATUS_SUCCESS; + return TRUE; }
/*********************************************************************** diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 19efc4dc7d4..b8d54222a47 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -129,7 +129,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect) extern BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode); extern INT macdrv_GetDisplayDepth(LPCWSTR name, BOOL is_primary); extern LRESULT macdrv_ClipboardWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); -extern UINT macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, +extern BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ); extern BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); extern BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp); diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index a1dc925a183..3b961476797 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -24,8 +24,6 @@
#include "config.h"
-#include "ntstatus.h" -#define WIN32_NO_STATUS #include "waylanddrv.h"
#include "wine/debug.h" @@ -277,7 +275,7 @@ static void wayland_add_device_modes(const struct gdi_device_manager *device_man /*********************************************************************** * UpdateDisplayDevices (WAYLAND.@) */ -UINT WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, +BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, BOOL force, void *param) { struct wayland_output *output; @@ -285,7 +283,7 @@ UINT WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage struct wl_array output_info_array; struct output_info *output_info;
- if (!force && !force_display_devices_refresh) return STATUS_ALREADY_COMPLETE; + if (!force && !force_display_devices_refresh) return TRUE;
TRACE("force=%d force_refresh=%d\n", force, force_display_devices_refresh);
@@ -320,5 +318,5 @@ UINT WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manage
pthread_mutex_unlock(&process_wayland.output_mutex);
- return STATUS_SUCCESS; + return TRUE; } diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 7852c23b690..595a2e64430 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -332,7 +332,7 @@ void WAYLAND_DestroyWindow(HWND hwnd); void WAYLAND_SetCursor(HWND hwnd, HCURSOR hcursor); void WAYLAND_SetWindowText(HWND hwnd, LPCWSTR text); LRESULT WAYLAND_SysCommand(HWND hwnd, WPARAM wparam, LPARAM lparam); -UINT WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, +BOOL WAYLAND_UpdateDisplayDevices(const struct gdi_device_manager *device_manager, BOOL force, void *param); LRESULT WAYLAND_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp); void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags, diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 861146d3e90..15e7d65c7d1 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -23,9 +23,6 @@ #endif
#include "config.h" - -#include "ntstatus.h" -#define WIN32_NO_STATUS #include "x11drv.h" #include "wine/debug.h"
@@ -496,7 +493,7 @@ BOOL X11DRV_DisplayDevices_SupportEventHandlers(void)
static BOOL force_display_devices_refresh;
-UINT X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) +BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ) { struct x11drv_adapter *adapters; struct gdi_monitor *monitors; @@ -506,13 +503,13 @@ UINT X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage DEVMODEW *modes; UINT mode_count;
- if (!force && !force_display_devices_refresh) return STATUS_ALREADY_COMPLETE; + if (!force && !force_display_devices_refresh) return TRUE; force_display_devices_refresh = FALSE;
TRACE( "via %s\n", debugstr_a(host_handler.name) );
/* Initialize GPUs */ - if (!host_handler.get_gpus( &gpus, &gpu_count, TRUE )) return STATUS_UNSUCCESSFUL; + if (!host_handler.get_gpus( &gpus, &gpu_count, TRUE )) return FALSE; TRACE("GPU count: %d\n", gpu_count);
for (gpu = 0; gpu < gpu_count; gpu++) @@ -561,7 +558,7 @@ UINT X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage }
host_handler.free_gpus( gpus, gpu_count ); - return STATUS_SUCCESS; + return TRUE; }
void X11DRV_DisplayDevices_Init(BOOL force) diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 5c9592705b8..628a0e0f720 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -217,7 +217,7 @@ extern BOOL X11DRV_SystrayDockRemove( HWND hwnd ); extern LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, LPCWSTR primary_name, HWND hwnd, DWORD flags, LPVOID lpvoid ); extern BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode ); extern INT X11DRV_GetDisplayDepth( LPCWSTR name, BOOL is_primary ); -extern UINT X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, +extern BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, BOOL force, void *param ); extern BOOL X11DRV_CreateDesktop( const WCHAR *name, UINT width, UINT height ); extern BOOL X11DRV_CreateWindow( HWND hwnd ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index c299dc2ae42..a8680e2d758 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -306,7 +306,7 @@ struct user_driver_funcs LONG (*pChangeDisplaySettings)(LPDEVMODEW,LPCWSTR,HWND,DWORD,LPVOID); BOOL (*pGetCurrentDisplaySettings)(LPCWSTR,BOOL,LPDEVMODEW); INT (*pGetDisplayDepth)(LPCWSTR,BOOL); - UINT (*pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*); + BOOL (*pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*); /* windowing functions */ BOOL (*pCreateDesktop)(const WCHAR *,UINT,UINT); BOOL (*pCreateWindow)(HWND);
From: Paul Gofman pgofman@codeweavers.com
This reverts commit d525da59075fc4baba95e19125ad23f0d96e6157. --- dlls/win32u/sysparams.c | 17 ++++++++--------- dlls/wineandroid.drv/init.c | 4 ++-- dlls/winemac.drv/display.c | 16 ++++++++++------ dlls/winewayland.drv/display.c | 8 +++++--- dlls/winex11.drv/display.c | 16 +++++++++++----- dlls/winex11.drv/x11drv.h | 4 ++-- dlls/winex11.drv/xinerama.c | 7 ++++--- dlls/winex11.drv/xrandr.c | 16 ++++++++++------ include/wine/gdi_driver.h | 10 +++++++++- 9 files changed, 61 insertions(+), 37 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index ff8cc0edb73..8bda17f2892 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1183,17 +1183,16 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p return TRUE; }
-static void add_gpu( const char *name, const struct pci_id *pci_id, const GUID *vulkan_uuid, - ULONGLONG memory_size, void *param ) +static void add_gpu( const struct gdi_gpu *gpu, void *param ) { + const struct pci_id *pci_id = &gpu->pci_id; struct device_manager_ctx *ctx = param; char buffer[4096]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; unsigned int i; HKEY hkey, subkey; - DWORD len;
- TRACE( "%s %04X %04X %08X %02X\n", debugstr_a( name ), pci_id->vendor, pci_id->device, + TRACE( "%s %04X %04X %08X %02X\n", debugstr_w( gpu->name ), pci_id->vendor, pci_id->device, pci_id->subsystem, pci_id->revision );
if (!enum_key && !(enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL ))) @@ -1208,8 +1207,8 @@ static void add_gpu( const char *name, const struct pci_id *pci_id, const GUID *
memset( &ctx->gpu, 0, sizeof(ctx->gpu) ); ctx->gpu.index = ctx->gpu_count; - if (vulkan_uuid) ctx->gpu.vulkan_uuid = *vulkan_uuid; - if (name) RtlUTF8ToUnicodeN( ctx->gpu.name, sizeof(ctx->gpu.name) - sizeof(WCHAR), &len, name, strlen( name ) ); + lstrcpyW( ctx->gpu.name, gpu->name ); + ctx->gpu.vulkan_uuid = gpu->vulkan_uuid;
snprintf( ctx->gpu.path, sizeof(ctx->gpu.path), "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\%08X", pci_id->vendor, pci_id->device, pci_id->subsystem, pci_id->revision, ctx->gpu.index ); @@ -1252,7 +1251,7 @@ static void add_gpu( const char *name, const struct pci_id *pci_id, const GUID *
NtClose( hkey );
- if (!write_gpu_to_registry( &ctx->gpu, pci_id, memory_size )) + if (!write_gpu_to_registry( &ctx->gpu, pci_id, gpu->memory_size )) WARN( "Failed to write gpu to registry\n" ); else ctx->gpu_count++; @@ -1732,13 +1731,13 @@ static BOOL default_update_display_devices( BOOL force, struct device_manager_ct .dmBitsPerPel = 16, .dmPelsWidth = 1024, .dmPelsHeight = 768, .dmDisplayFrequency = 60, }, }; static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; - struct pci_id pci_id = {0}; + static const struct gdi_gpu gpu; struct gdi_monitor monitor = {0}; DEVMODEW mode = {{0}};
if (!force) return TRUE;
- add_gpu( "Default GPU", &pci_id, NULL, 0, ctx ); + add_gpu( &gpu, ctx ); add_source( "Default", source_flags, ctx );
if (!read_source_mode( ctx->source_key, ENUM_CURRENT_SETTINGS, &mode )) diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 264bd6a7908..d1894535bfb 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -274,7 +274,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag if (force || force_display_devices_refresh) { static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; - struct pci_id pci_id = {0}; + static const struct gdi_gpu gpu; struct gdi_monitor gdi_monitor = { .rc_monitor = virtual_screen_rect, @@ -288,7 +288,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag }; DEVMODEW current = mode;
- device_manager->add_gpu( "Android GPU", &pci_id, NULL, 0, param ); + device_manager->add_gpu( &gpu, param ); device_manager->add_source( "Default", source_flags, param ); device_manager->add_monitor( &gdi_monitor, param );
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 78019d43de9..fc2e680ca88 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1139,14 +1139,18 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (gpu = gpus; gpu < gpus + gpu_count; gpu++) { - struct pci_id pci_id = + struct gdi_gpu gdi_gpu = { - .vendor = gpu->vendor_id, - .device = gpu->device_id, - .subsystem = gpu->subsys_id, - .revision = gpu->revision_id, + .pci_id = + { + .vendor = gpu->vendor_id, + .device = gpu->device_id, + .subsystem = gpu->subsys_id, + .revision = gpu->revision_id, + }, }; - device_manager->add_gpu(gpu->name, &pci_id, NULL, 0, param); + RtlUTF8ToUnicodeN(gdi_gpu.name, sizeof(gdi_gpu.name), &len, gpu->name, strlen(gpu->name)); + device_manager->add_gpu(&gdi_gpu, param);
/* Initialize adapters */ if (macdrv_get_adapters(gpu->id, &adapters, &adapter_count)) break; diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 3b961476797..efe5683d4eb 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -200,11 +200,13 @@ static void output_info_array_arrange_physical_coords(struct wl_array *output_in static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager, void *param) { - struct pci_id pci_id = {0}; + static const WCHAR wayland_gpuW[] = {'W','a','y','l','a','n','d','G','P','U',0}; + struct gdi_gpu gpu = {0}; + lstrcpyW(gpu.name, wayland_gpuW);
- TRACE("\n"); + TRACE("name=%s\n", wine_dbgstr_w(gpu.name));
- device_manager->add_gpu("Wayland GPU", &pci_id, NULL, 0, param); + device_manager->add_gpu(&gpu, param); }
static void wayland_add_device_source(const struct gdi_device_manager *device_manager, diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 15e7d65c7d1..d64f6bb92d6 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -406,7 +406,7 @@ RECT get_host_primary_monitor_rect(void) host_handler.get_monitors(adapters[0].id, &monitors, &monitor_count) && monitor_count) rect = monitors[0].rc_monitor;
- if (gpus) host_handler.free_gpus( gpus, gpu_count ); + if (gpus) host_handler.free_gpus(gpus); if (adapters) host_handler.free_adapters(adapters); if (monitors) host_handler.free_monitors(monitors, monitor_count); return rect; @@ -514,12 +514,18 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (gpu = 0; gpu < gpu_count; gpu++) { - device_manager->add_gpu( gpus[gpu].name, &gpus[gpu].pci_id, &gpus[gpu].vulkan_uuid, - gpus[gpu].memory_size, param ); + struct gdi_gpu gdi_gpu = + { + .pci_id = gpus[gpu].pci_id, + .vulkan_uuid = gpus[gpu].vulkan_uuid, + .memory_size = gpus[gpu].memory_size, + }; + memcpy( gdi_gpu.name, gpus[gpu].name, sizeof(gdi_gpu.name) ); + device_manager->add_gpu( &gdi_gpu, param );
/* Initialize adapters */ if (!host_handler.get_adapters( gpus[gpu].id, &adapters, &adapter_count )) break; - TRACE( "GPU: %#lx %s, adapter count: %d\n", gpus[gpu].id, debugstr_a( gpus[gpu].name ), adapter_count ); + TRACE("GPU: %#lx %s, adapter count: %d\n", gpus[gpu].id, wine_dbgstr_w(gpus[gpu].name), adapter_count);
for (adapter = 0; adapter < adapter_count; adapter++) { @@ -557,7 +563,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage host_handler.free_adapters( adapters ); }
- host_handler.free_gpus( gpus, gpu_count ); + host_handler.free_gpus( gpus ); return TRUE; }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 628a0e0f720..b4e63f1fbce 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -767,7 +767,7 @@ void init_user_driver(void); struct x11drv_gpu { ULONG_PTR id; - char *name; + WCHAR name[128]; struct pci_id pci_id; GUID vulkan_uuid; ULONGLONG memory_size; @@ -806,7 +806,7 @@ struct x11drv_display_device_handler BOOL (*get_monitors)(ULONG_PTR adapter_id, struct gdi_monitor **monitors, int *count);
/* free_gpus will be called to free a GPU list from get_gpus */ - void (*free_gpus)(struct x11drv_gpu *gpus, int count); + void (*free_gpus)(struct x11drv_gpu *gpus);
/* free_adapters will be called to free an adapter list from get_adapters */ void (*free_adapters)(struct x11drv_adapter *adapters); diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index c394c8a49b4..5f489feb59d 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -192,6 +192,7 @@ done:
static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties ) { + static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; struct x11drv_gpu *gpus;
/* Xinerama has no support for GPU, faking one */ @@ -199,16 +200,16 @@ static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge if (!gpus) return FALSE;
- gpus[0].name = strdup( "Xinerama GPU" ); + lstrcpyW( gpus[0].name, wine_adapterW ); + *new_gpus = gpus; *count = 1;
return TRUE; }
-static void xinerama_free_gpus( struct x11drv_gpu *gpus, int count ) +static void xinerama_free_gpus( struct x11drv_gpu *gpus ) { - while (count--) free( gpus[count].name ); free( gpus ); }
diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 885c23a09a0..51b316e71bd 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -653,6 +653,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro VkPhysicalDeviceIDProperties id; VkInstance vk_instance = NULL; VkDisplayKHR vk_display; + DWORD len; BOOL ret = FALSE; VkResult vr;
@@ -739,7 +740,8 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro gpu->pci_id.vendor = properties2.properties.vendorID; gpu->pci_id.device = properties2.properties.deviceID; } - gpu->name = strdup( properties2.properties.deviceName ); + RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len, properties2.properties.deviceName, + strlen( properties2.properties.deviceName ) + 1 );
pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx], &mem_properties ); for (heap_idx = 0; heap_idx < mem_properties.memoryHeapCount; heap_idx++) @@ -768,6 +770,7 @@ done: * not needed to avoid unnecessary querying */ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties ) { + static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; struct x11drv_gpu *gpus = NULL; XRRScreenResources *screen_resources = NULL; XRRProviderResources *provider_resources = NULL; @@ -776,6 +779,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge INT primary_provider = -1; RECT primary_rect; BOOL ret = FALSE; + DWORD len; INT i, j;
screen_resources = xrandr_get_screen_resources(); @@ -795,7 +799,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge if (!provider_resources->nproviders) { WARN("XRandR implementation doesn't report any providers, faking one.\n"); - gpus[0].name = strdup( "Xrandr GPU" ); + lstrcpyW( gpus[0].name, wine_adapterW ); *new_gpus = gpus; *count = 1; ret = TRUE; @@ -830,7 +834,8 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge if (get_properties) { if (!get_gpu_properties_from_vulkan( &gpus[i], provider_info, gpus, i )) - gpus[i].name = strdup( provider_info->name ); + RtlUTF8ToUnicodeN( gpus[i].name, sizeof(gpus[i].name), &len, provider_info->name, + strlen( provider_info->name ) + 1 ); /* FIXME: Add an alternate method of getting PCI IDs, for systems that don't support Vulkan */ } pXRRFreeProviderInfo( provider_info ); @@ -860,9 +865,8 @@ done: return ret; }
-static void xrandr14_free_gpus( struct x11drv_gpu *gpus, int count ) +static void xrandr14_free_gpus( struct x11drv_gpu *gpus ) { - while (count--) free( gpus[count].name ); free( gpus ); }
@@ -1290,7 +1294,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s new_current_mode_count += adapter_count; xrandr14_free_adapters( adapters ); } - xrandr14_free_gpus( gpus, gpu_count ); + xrandr14_free_gpus( gpus );
if (new_current_modes) { diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index a8680e2d758..714db83e89c 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -245,6 +245,14 @@ struct pci_id UINT16 revision; };
+struct gdi_gpu +{ + WCHAR name[128]; + struct pci_id pci_id; + GUID vulkan_uuid; /* Vulkan device UUID */ + ULONGLONG memory_size; +}; + struct gdi_monitor { RECT rc_monitor; /* RcMonitor in MONITORINFO struct */ @@ -255,7 +263,7 @@ struct gdi_monitor
struct gdi_device_manager { - void (*add_gpu)( const char *name, const struct pci_id *pci_id, const GUID *vulkan_uuid, ULONGLONG memory_size, void *param ); + void (*add_gpu)( const struct gdi_gpu *gpu, void *param ); void (*add_source)( const char *name, UINT state_flags, void *param ); void (*add_monitor)( const struct gdi_monitor *monitor, void *param ); void (*add_modes)( const DEVMODEW *current, UINT modes_count, const DEVMODEW *modes, void *param );
From: Paul Gofman pgofman@codeweavers.com
This reverts commit 0300016ac54502200b37dd9bd8e4a97cfa41cc10. --- dlls/winemac.drv/display.c | 1 + dlls/winewayland.drv/display.c | 3 ++- dlls/winex11.drv/display.c | 13 +++---------- dlls/winex11.drv/x11drv.h | 13 ++----------- dlls/winex11.drv/xinerama.c | 6 +++--- dlls/winex11.drv/xrandr.c | 14 +++++++------- include/wine/gdi_driver.h | 1 + 7 files changed, 19 insertions(+), 32 deletions(-)
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index fc2e680ca88..b52bb39c0f6 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1141,6 +1141,7 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage { struct gdi_gpu gdi_gpu = { + .id = gpu->id, .pci_id = { .vendor = gpu->vendor_id, diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index efe5683d4eb..535a3c80ce3 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -204,7 +204,8 @@ static void wayland_add_device_gpu(const struct gdi_device_manager *device_manag struct gdi_gpu gpu = {0}; lstrcpyW(gpu.name, wayland_gpuW);
- TRACE("name=%s\n", wine_dbgstr_w(gpu.name)); + TRACE("id=0x%s name=%s\n", + wine_dbgstr_longlong(gpu.id), wine_dbgstr_w(gpu.name));
device_manager->add_gpu(&gpu, param); } diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index d64f6bb92d6..3ec20743f66 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -395,7 +395,7 @@ POINT root_to_virtual_screen(INT x, INT y) RECT get_host_primary_monitor_rect(void) { INT gpu_count, adapter_count, monitor_count; - struct x11drv_gpu *gpus = NULL; + struct gdi_gpu *gpus = NULL; struct x11drv_adapter *adapters = NULL; struct gdi_monitor *monitors = NULL; RECT rect = {0}; @@ -497,7 +497,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage { struct x11drv_adapter *adapters; struct gdi_monitor *monitors; - struct x11drv_gpu *gpus; + struct gdi_gpu *gpus; INT gpu_count, adapter_count, monitor_count; INT gpu, adapter, monitor; DEVMODEW *modes; @@ -514,14 +514,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (gpu = 0; gpu < gpu_count; gpu++) { - struct gdi_gpu gdi_gpu = - { - .pci_id = gpus[gpu].pci_id, - .vulkan_uuid = gpus[gpu].vulkan_uuid, - .memory_size = gpus[gpu].memory_size, - }; - memcpy( gdi_gpu.name, gpus[gpu].name, sizeof(gdi_gpu.name) ); - device_manager->add_gpu( &gdi_gpu, param ); + device_manager->add_gpu( &gpus[gpu], param );
/* Initialize adapters */ if (!host_handler.get_adapters( gpus[gpu].id, &adapters, &adapter_count )) break; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index b4e63f1fbce..384074becad 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -764,15 +764,6 @@ void init_user_driver(void);
/* X11 display device handler. Used to initialize display device registry data */
-struct x11drv_gpu -{ - ULONG_PTR id; - WCHAR name[128]; - struct pci_id pci_id; - GUID vulkan_uuid; - ULONGLONG memory_size; -}; - struct x11drv_adapter { ULONG_PTR id; @@ -791,7 +782,7 @@ struct x11drv_display_device_handler /* get_gpus will be called to get a list of GPUs. First GPU has to be where the primary adapter is. * * Return FALSE on failure with parameters unchanged */ - BOOL (*get_gpus)(struct x11drv_gpu **gpus, int *count, BOOL get_properties); + BOOL (*get_gpus)(struct gdi_gpu **gpus, int *count, BOOL get_properties);
/* get_adapters will be called to get a list of adapters in EnumDisplayDevices context under a GPU. * The first adapter has to be primary if GPU is primary. @@ -806,7 +797,7 @@ struct x11drv_display_device_handler BOOL (*get_monitors)(ULONG_PTR adapter_id, struct gdi_monitor **monitors, int *count);
/* free_gpus will be called to free a GPU list from get_gpus */ - void (*free_gpus)(struct x11drv_gpu *gpus); + void (*free_gpus)(struct gdi_gpu *gpus);
/* free_adapters will be called to free an adapter list from get_adapters */ void (*free_adapters)(struct x11drv_adapter *adapters); diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index 5f489feb59d..fbf80819204 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -190,10 +190,10 @@ done: return ret; }
-static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties ) +static BOOL xinerama_get_gpus( struct gdi_gpu **new_gpus, int *count, BOOL get_properties ) { static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; - struct x11drv_gpu *gpus; + struct gdi_gpu *gpus;
/* Xinerama has no support for GPU, faking one */ gpus = calloc( 1, sizeof(*gpus) ); @@ -208,7 +208,7 @@ static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge return TRUE; }
-static void xinerama_free_gpus( struct x11drv_gpu *gpus ) +static void xinerama_free_gpus( struct gdi_gpu *gpus ) { free( gpus ); } diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 51b316e71bd..e183501b23f 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -627,8 +627,8 @@ static BOOL is_crtc_primary( RECT primary, const XRRCrtcInfo *crtc )
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR)
-static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRProviderInfo *provider_info, - struct x11drv_gpu *prev_gpus, int prev_gpu_count ) +static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProviderInfo *provider_info, + struct gdi_gpu *prev_gpus, int prev_gpu_count ) { static const char *extensions[] = { @@ -768,10 +768,10 @@ done:
/* Get a list of GPUs reported by XRandR 1.4. Set get_properties to FALSE if GPU properties are * not needed to avoid unnecessary querying */ -static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties ) +static BOOL xrandr14_get_gpus( struct gdi_gpu **new_gpus, int *count, BOOL get_properties ) { static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; - struct x11drv_gpu *gpus = NULL; + struct gdi_gpu *gpus = NULL; XRRScreenResources *screen_resources = NULL; XRRProviderResources *provider_resources = NULL; XRRProviderInfo *provider_info = NULL; @@ -844,7 +844,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge /* Make primary GPU the first */ if (primary_provider > 0) { - struct x11drv_gpu tmp = gpus[0]; + struct gdi_gpu tmp = gpus[0]; gpus[0] = gpus[primary_provider]; gpus[primary_provider] = tmp; } @@ -865,7 +865,7 @@ done: return ret; }
-static void xrandr14_free_gpus( struct x11drv_gpu *gpus ) +static void xrandr14_free_gpus( struct gdi_gpu *gpus ) { free( gpus ); } @@ -1253,7 +1253,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s INT gpu_count, adapter_count, new_current_mode_count = 0; INT gpu_idx, adapter_idx, display_idx; struct x11drv_adapter *adapters; - struct x11drv_gpu *gpus; + struct gdi_gpu *gpus; WCHAR *end;
/* Parse \.\DISPLAY%d */ diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 714db83e89c..447b5a86988 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -247,6 +247,7 @@ struct pci_id
struct gdi_gpu { + ULONG_PTR id; WCHAR name[128]; struct pci_id pci_id; GUID vulkan_uuid; /* Vulkan device UUID */
From: Paul Gofman pgofman@codeweavers.com
This reverts commit 62c60a9e10cdd73bda2b27eb048f4295bae7babb. --- dlls/win32u/sysparams.c | 24 +++++++++++++++++++----- dlls/winemac.drv/display.c | 11 ++++------- dlls/winex11.drv/xrandr.c | 4 ++-- include/wine/gdi_driver.h | 15 +++++---------- 4 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 8bda17f2892..9ebd6e26fc4 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -85,6 +85,14 @@ static const char guid_devinterface_monitorA[] = "{E6F07B5F-EE97-4A90-B076-33F57
#define NEXT_DEVMODEW(mode) ((DEVMODEW *)((char *)((mode) + 1) + (mode)->dmDriverExtra))
+struct pci_id +{ + UINT16 vendor; + UINT16 device; + UINT16 subsystem; + UINT16 revision; +}; + struct gpu { LONG refcount; @@ -1185,15 +1193,21 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p
static void add_gpu( const struct gdi_gpu *gpu, void *param ) { - const struct pci_id *pci_id = &gpu->pci_id; + const struct pci_id pci_id = + { + .vendor = gpu->vendor_id, + .device = gpu->device_id, + .subsystem = gpu->subsys_id, + .revision = gpu->revision_id, + }; struct device_manager_ctx *ctx = param; char buffer[4096]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; unsigned int i; HKEY hkey, subkey;
- TRACE( "%s %04X %04X %08X %02X\n", debugstr_w( gpu->name ), pci_id->vendor, pci_id->device, - pci_id->subsystem, pci_id->revision ); + TRACE( "%s %04X %04X %08X %02X\n", debugstr_w(gpu->name), + gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id );
if (!enum_key && !(enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL ))) return; @@ -1211,7 +1225,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) ctx->gpu.vulkan_uuid = gpu->vulkan_uuid;
snprintf( ctx->gpu.path, sizeof(ctx->gpu.path), "PCI\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\%08X", - pci_id->vendor, pci_id->device, pci_id->subsystem, pci_id->revision, ctx->gpu.index ); + gpu->vendor_id, gpu->device_id, gpu->subsys_id, gpu->revision_id, ctx->gpu.index ); if (!(hkey = reg_create_ascii_key( enum_key, ctx->gpu.path, 0, NULL ))) return;
if ((subkey = reg_create_ascii_key( hkey, "Device Parameters", 0, NULL ))) @@ -1251,7 +1265,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
NtClose( hkey );
- if (!write_gpu_to_registry( &ctx->gpu, pci_id, gpu->memory_size )) + if (!write_gpu_to_registry( &ctx->gpu, &pci_id, gpu->memory_size )) WARN( "Failed to write gpu to registry\n" ); else ctx->gpu_count++; diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index b52bb39c0f6..5221f4402fa 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1142,13 +1142,10 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage struct gdi_gpu gdi_gpu = { .id = gpu->id, - .pci_id = - { - .vendor = gpu->vendor_id, - .device = gpu->device_id, - .subsystem = gpu->subsys_id, - .revision = gpu->revision_id, - }, + .vendor_id = gpu->vendor_id, + .device_id = gpu->device_id, + .subsys_id = gpu->subsys_id, + .revision_id = gpu->revision_id, }; RtlUTF8ToUnicodeN(gdi_gpu.name, sizeof(gdi_gpu.name), &len, gpu->name, strlen(gpu->name)); device_manager->add_gpu(&gdi_gpu, param); diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index e183501b23f..89ce2a6a263 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -737,8 +737,8 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid /* Ignore Khronos vendor IDs */ if (properties2.properties.vendorID < 0x10000) { - gpu->pci_id.vendor = properties2.properties.vendorID; - gpu->pci_id.device = properties2.properties.deviceID; + gpu->vendor_id = properties2.properties.vendorID; + gpu->device_id = properties2.properties.deviceID; } RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len, properties2.properties.deviceName, strlen( properties2.properties.deviceName ) + 1 ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 447b5a86988..61c9342d50f 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -237,19 +237,14 @@ static inline ULONG window_surface_release( struct window_surface *surface )
/* display manager interface, used to initialize display device registry data */
-struct pci_id -{ - UINT16 vendor; - UINT16 device; - UINT16 subsystem; - UINT16 revision; -}; - struct gdi_gpu { ULONG_PTR id; - WCHAR name[128]; - struct pci_id pci_id; + WCHAR name[128]; /* name */ + UINT vendor_id; /* PCI ID */ + UINT device_id; + UINT subsys_id; + UINT revision_id; GUID vulkan_uuid; /* Vulkan device UUID */ ULONGLONG memory_size; };
From: Paul Gofman pgofman@codeweavers.com
This reverts commit 79f3573d8feb638c383c4dff4573ccf711d571af. --- dlls/win32u/sysparams.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 9ebd6e26fc4..3211d4e7d8b 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1485,14 +1485,9 @@ static const struct gdi_device_manager device_manager = add_modes, };
-static void release_display_manager_ctx( struct device_manager_ctx *ctx ) +static void reset_display_manager_ctx( struct device_manager_ctx *ctx ) { - if (ctx->mutex) - { - pthread_mutex_unlock( &display_lock ); - release_display_device_init_mutex( ctx->mutex ); - ctx->mutex = 0; - } + HANDLE mutex = ctx->mutex;
if (ctx->source_key) { @@ -1500,6 +1495,20 @@ static void release_display_manager_ctx( struct device_manager_ctx *ctx ) last_query_display_time = 0; } if (ctx->gpu_count) cleanup_devices(); + + memset( ctx, 0, sizeof(*ctx) ); + if ((ctx->mutex = mutex)) prepare_devices(); +} + +static void release_display_manager_ctx( struct device_manager_ctx *ctx ) +{ + if (ctx->mutex) + { + pthread_mutex_unlock( &display_lock ); + release_display_device_init_mutex( ctx->mutex ); + ctx->mutex = 0; + } + reset_display_manager_ctx( ctx ); }
static void clear_display_devices(void)
From: Paul Gofman pgofman@codeweavers.com
This reverts commit 64a7ca75475d00af269c203349bc6fe386f16a22. --- dlls/win32u/sysparams.c | 53 +++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 28 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 3211d4e7d8b..e66ad488486 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -67,7 +67,6 @@ static const WCHAR device_descW[] = {'D','e','v','i','c','e','D','e','s','c',0}; static const WCHAR driver_descW[] = {'D','r','i','v','e','r','D','e','s','c',0}; static const WCHAR yesW[] = {'Y','e','s',0}; static const WCHAR noW[] = {'N','o',0}; -static const WCHAR modesW[] = {'M','o','d','e','s',0}; static const WCHAR mode_countW[] = {'M','o','d','e','C','o','u','n','t',0};
static const char guid_devclass_displayA[] = "{4D36E968-E325-11CE-BFC1-08002BE10318}"; @@ -432,13 +431,10 @@ static const char *debugstr_devmodew( const DEVMODEW *devmode ) static BOOL write_source_mode( HKEY hkey, UINT index, const DEVMODEW *mode ) { WCHAR bufferW[MAX_PATH] = {0}; + char buffer[MAX_PATH];
- assert( index == ENUM_CURRENT_SETTINGS || index == ENUM_REGISTRY_SETTINGS ); - - if (index == ENUM_CURRENT_SETTINGS) asciiz_to_unicode( bufferW, "Current" ); - else if (index == ENUM_REGISTRY_SETTINGS) asciiz_to_unicode( bufferW, "Registry" ); - else return FALSE; - + snprintf( buffer, sizeof(buffer), "Modes\%08X", index ); + asciiz_to_unicode( bufferW, buffer ); return set_reg_value( hkey, bufferW, REG_BINARY, &mode->dmFields, sizeof(*mode) - offsetof(DEVMODEW, dmFields) ); }
@@ -446,15 +442,11 @@ static BOOL read_source_mode( HKEY hkey, UINT index, DEVMODEW *mode ) { char value_buf[offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[sizeof(*mode)])]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)value_buf; - const char *key; - - assert( index == ENUM_CURRENT_SETTINGS || index == ENUM_REGISTRY_SETTINGS ); + char buffer[MAX_PATH];
- if (index == ENUM_CURRENT_SETTINGS) key = "Current"; - else if (index == ENUM_REGISTRY_SETTINGS) key = "Registry"; - else return FALSE; + snprintf( buffer, sizeof(buffer), "Modes\%08X", index ); + if (!query_reg_ascii_value( hkey, buffer, value, sizeof(value_buf) )) return FALSE;
- if (!query_reg_ascii_value( hkey, key, value, sizeof(value_buf) )) return FALSE; memcpy( &mode->dmFields, value->Data, sizeof(*mode) - offsetof(DEVMODEW, dmFields) ); return TRUE; } @@ -628,6 +620,7 @@ static BOOL reade_source_from_registry( unsigned int index, struct source *sourc char buffer[4096]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; WCHAR *value_str = (WCHAR *)value->Data; + DEVMODEW *mode; DWORD i, size; HKEY hkey;
@@ -653,18 +646,19 @@ static BOOL reade_source_from_registry( unsigned int index, struct source *sourc if (query_reg_ascii_value( hkey, "ModeCount", value, sizeof(buffer) ) && value->Type == REG_DWORD) source->mode_count = *(const DWORD *)value->Data;
- /* Modes */ - size = offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data[(source->mode_count + 1) * sizeof(*source->modes)] ); - if (!(value = malloc( size )) || !query_reg_ascii_value( hkey, "Modes", value, size )) free( value ); - else + /* Modes, allocate an extra mode for easier iteration */ + if ((source->modes = calloc( source->mode_count + 1, sizeof(DEVMODEW) ))) { - source->modes = (DEVMODEW *)value; - source->mode_count = value->DataLength / sizeof(*source->modes); - memmove( source->modes, value->Data, value->DataLength ); - memset( source->modes + source->mode_count, 0, sizeof(*source->modes) ); /* extra empty mode for easier iteration */ - qsort( source->modes, source->mode_count, sizeof(*source->modes), mode_compare ); + for (i = 0, mode = source->modes; i < source->mode_count; i++) + { + mode->dmSize = offsetof(DEVMODEW, dmICMMethod); + if (!read_source_mode( hkey, i, mode )) break; + mode = NEXT_DEVMODEW(mode); + } + source->mode_count = i; + + qsort(source->modes, source->mode_count, sizeof(*source->modes) + source->modes->dmDriverExtra, mode_compare); } - value = (void *)buffer;
/* DeviceID */ size = query_reg_ascii_value( hkey, "GPUID", value, sizeof(buffer) ); @@ -1457,6 +1451,7 @@ static void add_monitor( const struct gdi_monitor *gdi_monitor, void *param ) static void add_modes( const DEVMODEW *current, UINT modes_count, const DEVMODEW *modes, void *param ) { struct device_manager_ctx *ctx = param; + const DEVMODEW *mode; DEVMODEW dummy, detached = *current;
TRACE( "current %s, modes_count %u, modes %p, param %p\n", debugstr_devmodew( current ), modes_count, modes, param ); @@ -1471,10 +1466,12 @@ static void add_modes( const DEVMODEW *current, UINT modes_count, const DEVMODEW write_source_mode( ctx->source_key, ENUM_REGISTRY_SETTINGS, current ); write_source_mode( ctx->source_key, ENUM_CURRENT_SETTINGS, current );
- assert( !modes_count || modes->dmDriverExtra == 0 ); - set_reg_value( ctx->source_key, modesW, REG_BINARY, modes, modes_count * sizeof(*modes) ); - set_reg_value( ctx->source_key, mode_countW, REG_DWORD, &modes_count, sizeof(modes_count) ); - ctx->source.mode_count = modes_count; + for (mode = modes; modes_count; mode = NEXT_DEVMODEW(mode), modes_count--) + { + TRACE( "mode: %s\n", debugstr_devmodew( mode ) ); + if (write_source_mode( ctx->source_key, ctx->source.mode_count, mode )) ctx->source.mode_count++; + } + set_reg_value( ctx->source_key, mode_countW, REG_DWORD, &ctx->source.mode_count, sizeof(ctx->source.mode_count) ); }
static const struct gdi_device_manager device_manager =
From: Paul Gofman pgofman@codeweavers.com
This reverts commit f74900ad1a580eda8fd4923cbd4881b42b042733. --- dlls/winex11.drv/display.c | 7 ++++--- dlls/winex11.drv/x11drv.h | 4 +--- dlls/winex11.drv/xrandr.c | 32 ++++++++++++++++---------------- dlls/winex11.drv/xvidmode.c | 14 +++++++------- 4 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 3ec20743f66..b4a2e4b9487 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -71,7 +71,7 @@ static BOOL nores_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_setti return TRUE; }
-static BOOL nores_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count, BOOL full ) +static BOOL nores_get_modes(x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count) { RECT primary = get_host_primary_monitor_rect(); DEVMODEW *modes; @@ -261,7 +261,8 @@ static DEVMODEW *get_full_mode(x11drv_settings_id id, DEVMODEW *dev_mode) if (is_detached_mode(dev_mode)) return dev_mode;
- if (!settings_handler.get_modes( id, EDS_ROTATEDMODE, &modes, &mode_count, TRUE )) return NULL; + if (!settings_handler.get_modes(id, EDS_ROTATEDMODE, &modes, &mode_count)) + return NULL;
for (mode_idx = 0; mode_idx < mode_count; ++mode_idx) { @@ -546,7 +547,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage if (!settings_handler.get_id( devname, is_primary, &settings_id )) break;
settings_handler.get_current_mode( settings_id, ¤t_mode ); - if (settings_handler.get_modes( settings_id, EDS_ROTATEDMODE, &modes, &mode_count, FALSE )) + if (settings_handler.get_modes( settings_id, EDS_ROTATEDMODE, &modes, &mode_count )) { device_manager->add_modes( ¤t_mode, mode_count, modes, param ); settings_handler.free_modes( modes ); diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 384074becad..0ccffecec49 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -726,7 +726,7 @@ struct x11drv_settings_handler * dmDisplayFlags and dmDisplayFrequency * * Return FALSE on failure with parameters unchanged and error code set. Return TRUE on success */ - BOOL (*get_modes)(x11drv_settings_id id, DWORD flags, DEVMODEW **modes, UINT *mode_count, BOOL full); + BOOL (*get_modes)(x11drv_settings_id id, DWORD flags, DEVMODEW **modes, UINT *mode_count);
/* free_modes() will be called to free the mode list returned from get_modes() */ void (*free_modes)(DEVMODEW *modes); @@ -747,8 +747,6 @@ struct x11drv_settings_handler LONG (*set_current_mode)(x11drv_settings_id id, const DEVMODEW *mode); };
-#define NEXT_DEVMODEW(mode) ((DEVMODEW *)((char *)((mode) + 1) + (mode)->dmDriverExtra)) - extern void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *handler);
extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ); diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 89ce2a6a263..c161b119cc9 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -152,10 +152,10 @@ static BOOL xrandr10_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s }
static void add_xrandr10_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD height, - DWORD frequency, SizeID size_id, BOOL full ) + DWORD frequency, SizeID size_id ) { mode->dmSize = sizeof(*mode); - mode->dmDriverExtra = full ? sizeof(SizeID) : 0; + mode->dmDriverExtra = sizeof(SizeID); mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (frequency) @@ -168,10 +168,10 @@ static void add_xrandr10_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD h mode->dmPelsWidth = width; mode->dmPelsHeight = height; mode->dmDisplayFlags = 0; - if (full) memcpy( mode + 1, &size_id, sizeof(size_id) ); + memcpy( (BYTE *)mode + sizeof(*mode), &size_id, sizeof(size_id) ); }
-static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *new_mode_count, BOOL full ) +static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *new_mode_count ) { INT size_idx, depth_idx, rate_idx, mode_idx = 0; INT size_count, rate_count, mode_count = 0; @@ -201,24 +201,24 @@ static BOOL xrandr10_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n return FALSE; }
- for (size_idx = 0, mode = modes; size_idx < size_count; ++size_idx) + for (size_idx = 0; size_idx < size_count; ++size_idx) { for (depth_idx = 0; depth_idx < DEPTH_COUNT; ++depth_idx) { rates = pXRRRates( gdi_display, DefaultScreen( gdi_display ), size_idx, &rate_count ); if (!rate_count) { + mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*mode) + sizeof(SizeID)) * mode_idx++); add_xrandr10_mode( mode, depths[depth_idx], sizes[size_idx].width, - sizes[size_idx].height, 0, size_idx, full ); - mode = NEXT_DEVMODEW( mode ); + sizes[size_idx].height, 0, size_idx ); continue; }
for (rate_idx = 0; rate_idx < rate_count; ++rate_idx) { + mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*mode) + sizeof(SizeID)) * mode_idx++); add_xrandr10_mode( mode, depths[depth_idx], sizes[size_idx].width, - sizes[size_idx].height, rates[rate_idx], size_idx, full ); - mode = NEXT_DEVMODEW( mode ); + sizes[size_idx].height, rates[rate_idx], size_idx ); } } } @@ -1316,10 +1316,10 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s }
static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, DWORD frequency, - DWORD orientation, BOOL full ) + DWORD orientation ) { mode->dmSize = sizeof(*mode); - mode->dmDriverExtra = full ? sizeof(RRMode) : 0; + mode->dmDriverExtra = sizeof(RRMode); mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (frequency) @@ -1340,10 +1340,10 @@ static void add_xrandr14_mode( DEVMODEW *mode, XRRModeInfo *info, DWORD depth, D mode->dmDisplayOrientation = orientation; mode->dmBitsPerPel = depth; mode->dmDisplayFlags = 0; - if (full) memcpy( mode + 1, &info->id, sizeof(info->id) ); + memcpy( (BYTE *)mode + sizeof(*mode), &info->id, sizeof(info->id) ); }
-static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count, BOOL full ) +static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count ) { DWORD frequency, orientation, orientation_count; XRRScreenResources *screen_resources; @@ -1415,7 +1415,7 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n if (!modes) goto done;
- for (i = 0, mode = modes; i < output_info->nmode; ++i) + for (i = 0; i < output_info->nmode; ++i) { for (j = 0; j < screen_resources->nmode; ++j) { @@ -1432,8 +1432,8 @@ static BOOL xrandr14_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **n if (!((1 << orientation) & rotations)) continue;
- add_xrandr14_mode( mode, mode_info, depths[depth_idx], frequency, orientation, full ); - mode = NEXT_DEVMODEW( mode ); + mode = (DEVMODEW *)((BYTE *)modes + (sizeof(*modes) + sizeof(RRMode)) * mode_idx); + add_xrandr14_mode( mode, mode_info, depths[depth_idx], frequency, orientation ); ++mode_idx; } } diff --git a/dlls/winex11.drv/xvidmode.c b/dlls/winex11.drv/xvidmode.c index f5e49409080..fd9b1e7e8b1 100644 --- a/dlls/winex11.drv/xvidmode.c +++ b/dlls/winex11.drv/xvidmode.c @@ -91,10 +91,10 @@ static BOOL xf86vm_get_id(const WCHAR *device_name, BOOL is_primary, x11drv_sett return TRUE; }
-static void add_xf86vm_mode( DEVMODEW *mode, DWORD depth, const XF86VidModeModeInfo *mode_info, BOOL full ) +static void add_xf86vm_mode(DEVMODEW *mode, DWORD depth, const XF86VidModeModeInfo *mode_info) { mode->dmSize = sizeof(*mode); - mode->dmDriverExtra = full ? sizeof(mode_info) : 0; + mode->dmDriverExtra = sizeof(mode_info); mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS; if (mode_info->htotal && mode_info->vtotal) { @@ -106,10 +106,10 @@ static void add_xf86vm_mode( DEVMODEW *mode, DWORD depth, const XF86VidModeModeI mode->dmPelsWidth = mode_info->hdisplay; mode->dmPelsHeight = mode_info->vdisplay; mode->dmDisplayFlags = 0; - if (full) memcpy( mode + 1, &mode_info, sizeof(mode_info) ); + memcpy((BYTE *)mode + sizeof(*mode), &mode_info, sizeof(mode_info)); }
-static BOOL xf86vm_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count, BOOL full ) +static BOOL xf86vm_get_modes(x11drv_settings_id id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count) { INT xf86vm_mode_idx, xf86vm_mode_count; XF86VidModeModeInfo **xf86vm_modes; @@ -139,12 +139,12 @@ static BOOL xf86vm_get_modes( x11drv_settings_id id, DWORD flags, DEVMODEW **new memcpy(ptr, &xf86vm_modes, sizeof(xf86vm_modes)); modes = (DEVMODEW *)(ptr + sizeof(xf86vm_modes));
- for (depth_idx = 0, mode = modes; depth_idx < DEPTH_COUNT; ++depth_idx) + for (depth_idx = 0; depth_idx < DEPTH_COUNT; ++depth_idx) { for (xf86vm_mode_idx = 0; xf86vm_mode_idx < xf86vm_mode_count; ++xf86vm_mode_idx) { - add_xf86vm_mode( mode, depths[depth_idx], xf86vm_modes[xf86vm_mode_idx], full ); - mode = NEXT_DEVMODEW( mode ); + mode = (DEVMODEW *)((BYTE *)modes + (sizeof(DEVMODEW) + sizeof(XF86VidModeModeInfo *)) * mode_idx++); + add_xf86vm_mode(mode, depths[depth_idx], xf86vm_modes[xf86vm_mode_idx]); } }
From: Paul Gofman pgofman@codeweavers.com
--- dlls/win32u/dibdrv/graphics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/win32u/dibdrv/graphics.c b/dlls/win32u/dibdrv/graphics.c index 009143bc2d2..28f640b912b 100644 --- a/dlls/win32u/dibdrv/graphics.c +++ b/dlls/win32u/dibdrv/graphics.c @@ -949,7 +949,7 @@ HFONT dibdrv_SelectFont( PHYSDEV dev, HFONT font, UINT *aa_flags ) DC *dc = get_physdev_dc( dev ); HFONT ret;
- if (pdev->dib.bit_count <= 8) *aa_flags = GGO_BITMAP; /* no anti-aliasing on <= 8bpp */ + if (pdev->dib.bit_count <= 8 && dc->hBitmap != GetStockObject( DEFAULT_BITMAP )) *aa_flags = GGO_BITMAP; /* no anti-aliasing on <= 8bpp */
dev = GET_NEXT_PHYSDEV( dev, pSelectFont ); ret = dev->funcs->pSelectFont( dev, font, aa_flags );
From: Paul Gofman pgofman@codeweavers.com
--- dlls/win32u/freetype.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index e3b98c3f6ff..6fdc547997c 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -3462,8 +3462,7 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT
matrices = get_transform_matrices( font, tategaki, lpmat, transform_matrices );
- if (aa_flags && (format & ~GGO_GLYPH_INDEX) == GGO_METRICS) - effective_format = aa_flags | (format & GGO_GLYPH_INDEX); + if (aa_flags) effective_format = aa_flags | (format & GGO_GLYPH_INDEX); vertical_metrics = (tategaki && FT_HAS_VERTICAL(ft_face)); /* there is a freetype bug where vertical metrics are only properly scaled and correct in 2.4.0 or greater */
From: Paul Gofman pgofman@codeweavers.com
--- dlls/win32u/freetype.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index 6fdc547997c..4d0a4723b88 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -3437,6 +3437,12 @@ static FT_Int get_load_flags( UINT format, BOOL vertical_metrics, BOOL force_no_ return load_flags; }
+static BOOL is_curve_format(UINT format) +{ + format &= ~(GGO_GLYPH_INDEX | GGO_UNHINTED); + return format == GGO_BEZIER || format == GGO_NATIVE; +} + /************************************************************* * freetype_get_glyph_outline */ @@ -3462,7 +3468,7 @@ static UINT freetype_get_glyph_outline( struct gdi_font *font, UINT glyph, UINT
matrices = get_transform_matrices( font, tategaki, lpmat, transform_matrices );
- if (aa_flags) effective_format = aa_flags | (format & GGO_GLYPH_INDEX); + if (aa_flags && !is_curve_format( format )) effective_format = aa_flags | (format & GGO_GLYPH_INDEX); vertical_metrics = (tategaki && FT_HAS_VERTICAL(ft_face)); /* there is a freetype bug where vertical metrics are only properly scaled and correct in 2.4.0 or greater */
This merge request was closed by Paul Gofman.