21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_WINDOWS
28 #ifndef CDS_FULLSCREEN
29 #define CDS_FULLSCREEN 0
41 (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
44 if (
index == ENUM_CURRENT_SETTINGS
46 char bmi_data[
sizeof(BITMAPINFOHEADER) + 256 *
sizeof(RGBQUAD)];
49 int logical_width = GetDeviceCaps( hdc, HORZRES );
50 int logical_height = GetDeviceCaps( hdc, VERTRES );
52 mode->w = logical_width;
53 mode->h = logical_height;
56 bmi = (LPBITMAPINFO) bmi_data;
57 bmi->bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
59 hbm = CreateCompatibleBitmap(hdc, 1, 1);
60 GetDIBits(hdc, hbm, 0, 1,
NULL, bmi, DIB_RGB_COLORS);
61 GetDIBits(hdc, hbm, 0, 1,
NULL, bmi, DIB_RGB_COLORS);
65 switch (*(
Uint32 *) bmi->bmiColors) {
79 }
else if (bmi->bmiHeader.biBitCount == 8) {
81 }
else if (bmi->bmiHeader.biBitCount == 4) {
86 if ((
data->DeviceMode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
87 switch (
data->DeviceMode.dmBitsPerPel) {
117 devmode.dmSize =
sizeof(devmode);
118 devmode.dmDriverExtra = 0;
119 if (!EnumDisplaySettings(deviceName,
index, &devmode)) {
129 data->DeviceMode = devmode;
132 mode->w =
data->DeviceMode.dmPelsWidth;
133 mode->h =
data->DeviceMode.dmPelsHeight;
134 mode->refresh_rate =
data->DeviceMode.dmDisplayFrequency;
142 WIN_AddDisplay(
_THIS, HMONITOR hMonitor,
const MONITORINFOEXW *info,
SDL_bool send_event)
154 if (!WIN_GetDisplayMode(
_this, info->szDevice, ENUM_CURRENT_SETTINGS, &
mode)) {
181 if (EnumDisplayDevices(info->szDevice, 0, &
device, 0)) {
192 typedef struct _WIN_AddDisplaysData {
196 } WIN_AddDisplaysData;
199 WIN_AddDisplaysCallback(HMONITOR hMonitor,
204 WIN_AddDisplaysData *
data = (WIN_AddDisplaysData*)dwData;
208 info.cbSize =
sizeof(info);
210 if (GetMonitorInfoW(hMonitor, (LPMONITORINFO)&info) != 0) {
211 const SDL_bool is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY);
213 if (is_primary ==
data->want_primary) {
214 WIN_AddDisplay(
data->video_device, hMonitor, &info,
data->send_event);
255 minfo.cbSize =
sizeof(MONITORINFO);
256 rc = GetMonitorInfo(
data->MonitorHandle, &minfo);
262 rect->
x = minfo.rcMonitor.left;
263 rect->
y = minfo.rcMonitor.top;
264 rect->
w = minfo.rcMonitor.right - minfo.rcMonitor.left;
265 rect->
h = minfo.rcMonitor.bottom - minfo.rcMonitor.top;
275 float hdpi = 0, vdpi = 0, ddpi = 0;
277 if (videodata->GetDpiForMonitor) {
278 UINT hdpi_uint, vdpi_uint;
282 hdpi = (float)hdpi_uint;
283 vdpi = (float)hdpi_uint;
284 ddpi = (float)hdpi_uint;
291 int hdpi_int, vdpi_int, hpoints, vpoints, hpix, vpix;
292 float hinches, vinches;
298 hdpi_int = GetDeviceCaps(hdc, LOGPIXELSX);
299 vdpi_int = GetDeviceCaps(hdc, LOGPIXELSY);
300 ReleaseDC(
NULL, hdc);
302 hpoints = GetSystemMetrics(SM_CXVIRTUALSCREEN);
303 vpoints = GetSystemMetrics(SM_CYVIRTUALSCREEN);
305 hpix = MulDiv(hpoints, hdpi_int, 96);
306 vpix = MulDiv(vpoints, vdpi_int, 96);
308 hinches = (float)hpoints / 96.0f;
309 vinches = (float)vpoints / 96.0f;
311 hdpi = (float)hdpi_int;
312 vdpi = (float)vdpi_int;
326 return ddpi != 0.0f ? 0 :
SDL_SetError(
"Couldn't get DPI");
337 minfo.cbSize =
sizeof(MONITORINFO);
338 rc = GetMonitorInfo(
data->MonitorHandle, &minfo);
344 rect->
x = minfo.rcWork.left;
345 rect->
y = minfo.rcWork.top;
346 rect->
w = minfo.rcWork.right - minfo.rcWork.left;
347 rect->
h = minfo.rcWork.bottom - minfo.rcWork.top;
390 if (status != DISP_CHANGE_SUCCESSFUL) {
391 const char *reason =
"Unknown reason";
393 case DISP_CHANGE_BADFLAGS:
394 reason =
"DISP_CHANGE_BADFLAGS";
396 case DISP_CHANGE_BADMODE:
397 reason =
"DISP_CHANGE_BADMODE";
399 case DISP_CHANGE_BADPARAM:
400 reason =
"DISP_CHANGE_BADPARAM";
402 case DISP_CHANGE_FAILED:
403 reason =
"DISP_CHANGE_FAILED";
406 return SDL_SetError(
"ChangeDisplaySettingsEx() failed: %s", reason);
408 EnumDisplaySettings(displaydata->
DeviceName, ENUM_CURRENT_SETTINGS, &
data->DeviceMode);
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define SDL_ISPIXELFORMAT_INDEXED(format)
@ SDL_PIXELFORMAT_INDEX4LSB
@ SDL_PIXELFORMAT_UNKNOWN
void SDL_DelVideoDisplay(int index)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display, SDL_bool send_event)
float SDL_ComputeDiagonalDPI(int hpix, int vpix, float hinches, float vinches)
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
static SDL_VideoDevice * _this
#define WIN_StringToUTF8(S)
int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
void WIN_QuitModes(_THIS)
int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
void WIN_RefreshDisplays(_THIS)
void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
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)
static SDL_AudioDeviceID device
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 skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
The structure that defines a display mode.
A rectangle, with the origin at the upper left (integer).
SDL_VideoDisplay * displays
SDL_DisplayMode desktop_mode
SDL_DisplayMode current_mode