Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-09-10 07:24:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-09-10 07:37:53 +0400
commit1b94b3d49c83db16297bd445b19e7384084386d4 (patch)
tree2e347f03ec89540e43bfbb5ed83a97c95f0692c1
parent5202fca6d51f31fab102d3a925df02efd5c934f5 (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.
-rw-r--r--source/blender/editors/interface/interface.c4
-rw-r--r--source/blender/editors/interface/interface_regions.c2
-rw-r--r--source/blender/editors/screen/area.c5
-rw-r--r--source/blender/editors/space_node/drawnode.c3
-rw-r--r--source/blender/windowmanager/WM_api.h4
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c35
6 files changed, 42 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 695c8866d08..b987f970b9e 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1347,8 +1347,8 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
-
- wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
+
+ wmOrtho2_region_ui(ar);
/* back */
if (block->flag & UI_BLOCK_RADIAL)
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 1960c77bc95..efcbc2ab4d5 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1020,7 +1020,7 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
uiSearchboxData *data = ar->regiondata;
/* pixel space */
- wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
+ wmOrtho2_region_ui(ar);
if (data->noback == false)
ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 05418d8d451..739e7be7328 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -107,10 +107,7 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct)
void ED_region_pixelspace(ARegion *ar)
{
- int width = BLI_rcti_size_x(&ar->winrct) + 1;
- int height = BLI_rcti_size_y(&ar->winrct) + 1;
-
- wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
+ wmOrtho2_region_pixelspace(ar);
glLoadIdentity();
}
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index b760d9f5aa8..0358c1abce2 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3056,7 +3056,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
glaDefine2DArea(&ar->winrct);
/* ortho at pixel level curarea */
- wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
+ /* almost #wmOrtho2_region_pixelspace, but no +1 px */
+ wmOrtho2_pixelspace(ar->winx, ar->winy);
x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 35b7fb4b9c9..e1cd334637a 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -361,6 +361,10 @@ void wmSubWindowScissorSet (struct wmWindow *win, int swinid, const struct rcti
void wmFrustum (float x1, float x2, float y1, float y2, float n, float f);
void wmOrtho (float x1, float x2, float y1, float y2, float n, float f);
void wmOrtho2 (float x1, float x2, float y1, float y2);
+ /* use for conventions (avoid hard-coded offsets all over) */
+void wmOrtho2_region_pixelspace(const struct ARegion *ar);
+void wmOrtho2_region_ui(const struct ARegion *ar);
+void wmOrtho2_pixelspace(const float x, const float y);
/* utilities */
void WM_framebuffer_index_set(int index);
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__