Commit 20414797 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Introduce new add_mode device manager callback.

And use it to enumerate display modes in winex11 and wineandroid.
parent 237778d7
......@@ -288,9 +288,15 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag
.rc_work = monitor_rc_work,
.state_flags = DISPLAY_DEVICE_ACTIVE | DISPLAY_DEVICE_ATTACHED,
};
const DEVMODEW mode =
{
.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY,
.dmBitsPerPel = screen_bpp, .dmPelsWidth = screen_width, .dmPelsHeight = screen_height, .dmDisplayFrequency = 60,
};
device_manager->add_gpu( &gpu, param );
device_manager->add_adapter( &adapter, param );
device_manager->add_monitor( &gdi_monitor, param );
device_manager->add_mode( &mode, param );
force_display_devices_refresh = FALSE;
}
......
......@@ -918,6 +918,73 @@ better:
return ret;
}
static DEVMODEW *display_get_modes(CGDirectDisplayID display_id, int *modes_count)
{
int default_bpp = get_default_bpp(), synth_count = 0, count, i;
BOOL modes_has_8bpp = FALSE, modes_has_16bpp = FALSE;
struct display_mode_descriptor *desc;
DEVMODEW *devmodes;
CFArrayRef modes;
modes = copy_display_modes(display_id, TRUE);
if (!modes)
return NULL;
count = CFArrayGetCount(modes);
for (i = 0; i < count && !(modes_has_8bpp && modes_has_16bpp); i++)
{
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
int bpp = display_mode_bits_per_pixel(mode);
if (bpp == 8)
modes_has_8bpp = TRUE;
else if (bpp == 16)
modes_has_16bpp = TRUE;
}
if (!(devmodes = calloc(count * 3, sizeof(DEVMODEW))))
{
CFRelease(modes);
return NULL;
}
desc = create_original_display_mode_descriptor(display_id);
for (i = 0; i < count; i++)
{
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
display_mode_to_devmode(display_id, mode, devmodes + i);
if (retina_enabled && display_mode_matches_descriptor(mode, desc))
{
devmodes[i].dmPelsWidth *= 2;
devmodes[i].dmPelsHeight *= 2;
}
}
free_display_mode_descriptor(desc);
for (i = 0; !modes_has_16bpp && i < count; i++)
{
/* We only synthesize modes from those having the default bpp. */
if (devmodes[i].dmBitsPerPel != default_bpp) continue;
devmodes[count + synth_count] = devmodes[i];
devmodes[count + synth_count].dmBitsPerPel = 16;
synth_count++;
}
for (i = 0; !modes_has_8bpp && i < count; i++)
{
/* We only synthesize modes from those having the default bpp. */
if (devmodes[i].dmBitsPerPel != default_bpp) continue;
devmodes[count + synth_count] = devmodes[i];
devmodes[count + synth_count].dmBitsPerPel = 8;
synth_count++;
}
CFRelease(modes);
*modes_count = count + synth_count;
return devmodes;
}
/***********************************************************************
* EnumDisplaySettingsEx (MACDRV.@)
*
......@@ -1301,7 +1368,8 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
struct macdrv_adapter *adapters, *adapter;
struct macdrv_monitor *monitors, *monitor;
struct macdrv_gpu *gpus, *gpu;
INT gpu_count, adapter_count, monitor_count;
INT gpu_count, adapter_count, monitor_count, mode_count;
DEVMODEW *mode, *modes;
DWORD len;
if (!force && !force_display_devices_refresh) return TRUE;
......@@ -1359,6 +1427,19 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
device_manager->add_monitor( &gdi_monitor, param );
}
if (!(modes = display_get_modes(adapter->id, &mode_count))) break;
TRACE("adapter: %#x, mode count: %d\n", adapter->id, mode_count);
/* Initialize modes */
for (mode = modes; mode < modes + mode_count; mode++)
{
TRACE("mode: %dx%dx%dbpp @%d Hz, %sstretched %sinterlaced\n", mode->dmPelsWidth, mode->dmPelsHeight,
mode->dmBitsPerPel, mode->dmDisplayFrequency,
mode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un",
mode->dmDisplayFlags & DM_INTERLACED ? "" : "non-");
device_manager->add_mode( mode, param );
}
macdrv_free_monitors(monitors);
}
......
......@@ -1026,6 +1026,8 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
struct gdi_gpu *gpus;
INT gpu_count, adapter_count, monitor_count;
INT gpu, adapter, monitor;
DEVMODEW *modes, *mode;
DWORD mode_count;
if (!force && !force_display_devices_refresh) return TRUE;
force_display_devices_refresh = FALSE;
......@@ -1060,6 +1062,20 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
}
handler->free_monitors(monitors, monitor_count);
if (!settings_handler.get_modes( adapters[adapter].id, EDS_ROTATEDMODE, &modes, &mode_count ))
continue;
qsort( modes, mode_count, sizeof(*modes) + modes[0].dmDriverExtra, mode_compare );
for (mode = modes; mode_count; mode_count--)
{
TRACE( "mode: %p\n", mode );
device_manager->add_mode( mode, param );
mode = (DEVMODEW *)((char *)mode + sizeof(*modes) + modes[0].dmDriverExtra);
}
settings_handler.free_modes( modes );
}
handler->free_adapters(adapters);
......
......@@ -266,6 +266,7 @@ struct gdi_device_manager
void (*add_gpu)( const struct gdi_gpu *gpu, void *param );
void (*add_adapter)( const struct gdi_adapter *adapter, void *param );
void (*add_monitor)( const struct gdi_monitor *monitor, void *param );
void (*add_mode)( const DEVMODEW *mode, void *param );
};
struct tagUPDATELAYEREDWINDOWINFO;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment