diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2014-09-30 20:29:32 +0400 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2014-09-30 20:29:32 +0400 |
commit | 6fa46ad315ceb46dbf47d6c6ffdda032d0e885ed (patch) | |
tree | b1454974f24b9d7020ddd26a6c86c0cdc12d454d /source/blender/windowmanager | |
parent | c7684b456a3236549b17e731288365331beec2ed (diff) |
Support for "virtual pixelsize" on 4k screens.
On 4k devices the default pixel size leads to tiny OpenGL drawing
that is hardly usable without doubling the DPI. The retina system
on OSX aims to alleviate this problem by introducing a general 2x
pixel size.
No equivalent feature exists on other platforms so far. However,
to emulate the effect this patch introduces a "virtual" pixel size
factor for OpenGL drawing.
Note that the user currently has to enable this manually by selecting
the "Virtual Pixel Mode" in the user preferences (defaults to native).
All windows of a Blender instance share the same virtual pixel size as well.
It may be possible to handle this on a per-window basis and automate
the selection somewhat (if enabled by the user), so working with
multiple screens becomes more convenient, but technical limitations
make this a bit difficult (on X11 with nvidia drivers the actual screen size
is not reported correctly).
Reviewers: ton, campbellbarton
Differential Revision: https://developer.blender.org/D669
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 19 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_window.h | 2 |
2 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 56e094891f5..ec806fb7c61 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -339,6 +339,19 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) } } +float wm_window_pixelsize(wmWindow *win) +{ + float pixelsize = GHOST_GetNativePixelSize(win->ghostwin); + + switch (U.virtual_pixel) { + default: + case VIRTUAL_PIXEL_NATIVE: + return pixelsize; + case VIRTUAL_PIXEL_DOUBLE: + return 2.0f * pixelsize; + } +} + /* belongs to below */ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) { @@ -397,7 +410,7 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win) /* displays with larger native pixels, like Macbook. Used to scale dpi with */ /* needed here, because it's used before it reads userdef */ - U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); + U.pixelsize = wm_window_pixelsize(win); BKE_userdef_state(); wm_window_swap_buffers(win); @@ -686,7 +699,7 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) GHOST_ActivateWindowDrawingContext(win->ghostwin); /* this can change per window */ - U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); + U.pixelsize = wm_window_pixelsize(win); BKE_userdef_state(); } } @@ -1046,7 +1059,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr case GHOST_kEventNativeResolutionChange: // printf("change, pixel size %f\n", GHOST_GetNativePixelSize(win->ghostwin)); - U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin); + U.pixelsize = wm_window_pixelsize(win); BKE_userdef_state(); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); WM_event_add_notifier(C, NC_WINDOW | NA_EDITED, NULL); diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index e0639b098a8..bf96e020a48 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -61,6 +61,8 @@ void wm_window_swap_buffers (wmWindow *win); void wm_window_set_swap_interval (wmWindow *win, int interval); int wm_window_get_swap_interval (wmWindow *win); +float wm_window_pixelsize(wmWindow *win); + void wm_get_cursor_position (wmWindow *win, int *x, int *y); wmWindow *wm_window_copy (bContext *C, wmWindow *winorig); |