21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_WINDOWS 26 #include "../../../include/SDL_assert.h" 29 #ifndef CDS_FULLSCREEN 30 #define CDS_FULLSCREEN 0 33 typedef struct _WIN_GetMonitorDPIData {
37 } WIN_GetMonitorDPIData;
40 WIN_GetMonitorDPI(HMONITOR hMonitor,
45 WIN_GetMonitorDPIData *
data = (WIN_GetMonitorDPIData*) dwData;
53 data->mode_data->
HorzDPI = (float)hdpi;
54 data->mode_data->VertDPI = (float)vdpi;
57 hsize = data->mode->w / data->mode_data->HorzDPI;
58 vsize = data->mode->h / data->mode_data->VertDPI;
80 data->DeviceMode.dmFields =
81 (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
84 if (index == ENUM_CURRENT_SETTINGS
86 char bmi_data[
sizeof(BITMAPINFOHEADER) + 256 *
sizeof(RGBQUAD)];
89 int logical_width = GetDeviceCaps( hdc, HORZRES );
90 int logical_height = GetDeviceCaps( hdc, VERTRES );
92 data->ScaleX = (float)logical_width / data->DeviceMode.dmPelsWidth;
93 data->ScaleY = (
float)logical_height / data->DeviceMode.dmPelsHeight;
94 mode->
w = logical_width;
95 mode->
h = logical_height;
99 if (vid_data->GetDpiForMonitor) {
100 WIN_GetMonitorDPIData dpi_data;
103 dpi_data.vid_data = vid_data;
104 dpi_data.mode =
mode;
105 dpi_data.mode_data =
data;
106 monitor_rect.left = data->DeviceMode.dmPosition.x;
107 monitor_rect.top = data->DeviceMode.dmPosition.y;
108 monitor_rect.right = monitor_rect.left + 1;
109 monitor_rect.bottom = monitor_rect.top + 1;
110 EnumDisplayMonitors(
NULL, &monitor_rect, WIN_GetMonitorDPI, (LPARAM)&dpi_data);
114 data->HorzDPI = (float)GetDeviceCaps( hdc, LOGPIXELSX );
115 data->VertDPI = (float)GetDeviceCaps( hdc, LOGPIXELSY );
116 if (data->HorzDPI == data->VertDPI) {
117 data->DiagDPI = data->HorzDPI;
121 (
float)GetDeviceCaps( hdc, HORZSIZE ) / 25.4
f,
122 (
float)GetDeviceCaps( hdc, VERTSIZE ) / 25.4
f );
127 bmi = (LPBITMAPINFO) bmi_data;
128 bmi->bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
130 hbm = CreateCompatibleBitmap(hdc, 1, 1);
131 GetDIBits(hdc, hbm, 0, 1,
NULL, bmi, DIB_RGB_COLORS);
132 GetDIBits(hdc, hbm, 0, 1,
NULL, bmi, DIB_RGB_COLORS);
136 switch (*(
Uint32 *) bmi->bmiColors) {
150 }
else if (bmi->bmiHeader.biBitCount == 8) {
152 }
else if (bmi->bmiHeader.biBitCount == 4) {
157 if ((data->DeviceMode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
158 switch (data->DeviceMode.dmBitsPerPel) {
188 devmode.dmSize =
sizeof(devmode);
189 devmode.dmDriverExtra = 0;
190 if (!EnumDisplaySettings(deviceName, index, &devmode)) {
215 WIN_UpdateDisplayMode(
_this, deviceName, index, mode);
220 WIN_AddDisplay(
_THIS, LPTSTR DeviceName)
225 DISPLAY_DEVICE device;
230 if (!WIN_GetDisplayMode(
_this, DeviceName, ENUM_CURRENT_SETTINGS, &mode)) {
242 device.cb =
sizeof(device);
243 if (EnumDisplayDevices(DeviceName, 0, &device, 0)) {
259 DISPLAY_DEVICE device;
261 device.cb =
sizeof(device);
264 for (pass = 0; pass < 2; ++pass) {
266 TCHAR DeviceName[32];
268 if (!EnumDisplayDevices(
NULL, i, &device, 0)) {
271 if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
275 if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) {
279 if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
283 SDL_memcpy(DeviceName, device.DeviceName,
sizeof(DeviceName));
289 if (!EnumDisplayDevices(DeviceName, j, &device, 0)) {
292 if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) {
296 if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) {
300 if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) {
304 count += WIN_AddDisplay(
_this, device.DeviceName);
307 WIN_AddDisplay(
_this, DeviceName);
355 (LONG) (pDevMode->dmPosition.x + (pDevMode->dmPelsWidth / 2)),
356 (LONG) (pDevMode->dmPosition.y + (pDevMode->dmPelsHeight / 2))
358 HMONITOR hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
367 minfo.cbSize =
sizeof (MONITORINFO);
368 rc = GetMonitorInfo(hmon, &minfo);
376 work = &minfo.rcWork;
421 status = ChangeDisplaySettingsEx(displaydata->
DeviceName, &data->DeviceMode,
NULL, CDS_FULLSCREEN,
NULL);
423 if (status != DISP_CHANGE_SUCCESSFUL) {
424 const char *reason =
"Unknown reason";
426 case DISP_CHANGE_BADFLAGS:
427 reason =
"DISP_CHANGE_BADFLAGS";
429 case DISP_CHANGE_BADMODE:
430 reason =
"DISP_CHANGE_BADMODE";
432 case DISP_CHANGE_BADPARAM:
433 reason =
"DISP_CHANGE_BADPARAM";
435 case DISP_CHANGE_FAILED:
436 reason =
"DISP_CHANGE_FAILED";
439 return SDL_SetError(
"ChangeDisplaySettingsEx() failed: %s", reason);
441 EnumDisplaySettings(displaydata->
DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode);
442 WIN_UpdateDisplayMode(
_this, displaydata->
DeviceName, ENUM_CURRENT_SETTINGS, mode);
void WIN_QuitModes(_THIS)
#define SDL_ISPIXELFORMAT_INDEXED(format)
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
The structure that defines a display mode.
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
uint32_t Uint32
An unsigned 32-bit integer type.
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
static SDL_VideoDevice * _this
void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
SDL_DisplayMode current_mode
#define WIN_StringToUTF8(S)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_assert(condition)
SDL_DisplayMode desktop_mode
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
A rectangle, with the origin at the upper left.
int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)