diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-09-10 07:24:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-09-10 07:37:53 +0400 |
commit | 1b94b3d49c83db16297bd445b19e7384084386d4 (patch) | |
tree | 2e347f03ec89540e43bfbb5ed83a97c95f0692c1 /source/blender/windowmanager/intern/wm_subwindow.c | |
parent | 5202fca6d51f31fab102d3a925df02efd5c934f5 (diff) |
WM: Add utility wmOrtho2_*** funcs
Currently there are inconsistencies with pixel alignment.
but this commit has no functional changes.
- wmOrtho2_region_ui for UI/Text.
- wmOrtho2_region_pixelspace for 2D drawing.
- wmOrtho2_pixelspace - when the region isn't used.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_subwindow.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index db4459b1799..e26bcac9b1a 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -215,7 +215,7 @@ int wm_subwindow_open(wmWindow *win, const rcti *winrct) /* extra service */ wm_swin_size_get(swin, &width, &height); - wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); + wmOrtho2_pixelspace(width, height); glLoadIdentity(); return swin->swinid; @@ -272,7 +272,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct) /* extra service */ wmSubWindowSet(win, swinid); wm_swin_size_get(swin, &width, &height); - wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); + wmOrtho2_pixelspace(width, height); } else { printf("%s: Internal error, bad winid: %d\n", __func__, swinid); @@ -319,7 +319,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, const rcti *srct, bool src else glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height); - wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); + wmOrtho2_pixelspace(width, height); glLoadIdentity(); glFlush(); @@ -358,6 +358,35 @@ void wmOrtho2(float x1, float x2, float y1, float y2) wmOrtho(x1, x2, y1, y2, -100, 100); } +static void wmOrtho2_offset(const float x, const float y, const float ofs) +{ + wmOrtho2(ofs, x + ofs, ofs, y + ofs); +} + +/** + * default pixel alignment. + */ +void wmOrtho2_region_pixelspace(const struct ARegion *ar) +{ + wmOrtho2_offset(ar->winx + 1, ar->winy + 1, -GLA_PIXEL_OFS); +} + +void wmOrtho2_pixelspace(const float x, const float y) +{ + wmOrtho2_offset(x, y, -GLA_PIXEL_OFS); +} + +/** + * use for drawing uiBlock, any UI elements and text. + * \note prevents blurry text with multi-sample (FSAA), see T41749 + */ +void wmOrtho2_region_ui(const ARegion *ar) +{ + /* note, intentionally no '+ 1', + * as with wmOrtho2_region_pixelspace */ + wmOrtho2_offset(ar->winx, ar->winy, -0.01f); +} + /* *************************** Framebuffer color depth, for selection codes ********************** */ #ifdef __APPLE__ |