diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-05 21:27:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-05 21:27:52 +0400 |
commit | 887d517e3b745945d3c8f7e2dc6e1d791067d1e8 (patch) | |
tree | d4c962031f7efb788d7b63705f155f92f4867219 /source/blender/editors | |
parent | dfdfa06c27c6dc44cb3f05e0355279d9e16eab93 (diff) |
use define for 0.375 = GLA_PIXEL_OFS, used all over the interface.
also use M_SQRT1_2 in math_rotation.c
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/anim_draw.c | 6 | ||||
-rw-r--r-- | source/blender/editors/include/BIF_gl.h | 2 | ||||
-rw-r--r-- | source/blender/editors/include/BIF_glutil.h | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 3 |
8 files changed, 16 insertions, 15 deletions
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 0d48bf19c9e..9c9d7f8e34a 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -100,7 +100,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t } else { /* seconds (with pixel offset rounding) */ - seconds = (int)floor(cfra + 0.375f); + seconds = (int)floor(cfra + GLA_PIXEL_OFS); } switch (U.timecode_style) { @@ -150,7 +150,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t /* only show the original seconds display */ /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */ if (power <= 0) sprintf(str, "%.*f", 1 - power, raw_seconds); - else sprintf(str, "%d", (int)floor(raw_seconds + 0.375f)); + else sprintf(str, "%d", (int)floor(raw_seconds + GLA_PIXEL_OFS)); } break; @@ -166,7 +166,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t else { /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */ if (power <= 0) sprintf(str, "%.*f", 1 - power, cfra); - else sprintf(str, "%d", (int)floor(cfra + 0.375f)); + else sprintf(str, "%d", (int)floor(cfra + GLA_PIXEL_OFS)); } } diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h index a5e5d7ce2e0..479e0b65177 100644 --- a/source/blender/editors/include/BIF_gl.h +++ b/source/blender/editors/include/BIF_gl.h @@ -50,5 +50,7 @@ #define glMultMatrixf(x) glMultMatrixf( (float *)(x)) #define glLoadMatrixf(x) glLoadMatrixf( (float *)(x)) +#define GLA_PIXEL_OFS 0.375f + #endif /* #ifdef __BIF_GL_H__ */ diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index b939ae47ead..577113927d1 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -116,8 +116,8 @@ void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y * * \attention This routine makes many assumptions: the rect data * is expected to be in RGBA unsigned byte format, the coordinate - * (0.375, 0.375) is assumed to be within the view frustum, and the - * modelview and projection matrices are assumed to define a + * (GLA_PIXEL_OFS, GLA_PIXEL_OFS) is assumed to be within the view frustum, + * and the modelview and projection matrices are assumed to define a * 1-to-1 mapping to screen space. * \attention Furthermore, in the case of zoomed or unpixel aligned * images extending outside the view frustum, but still within the diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index a693e9eb627..8ae08c08693 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -980,7 +980,7 @@ void UI_view2d_view_ortho(View2D *v2d) rctf curmasked; float xofs, yofs; - /* pixel offsets (-0.375f) are needed to get 1:1 correspondence with pixels for smooth UI drawing, + /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing, * but only applied where requested */ /* XXX brecht: instead of zero at least use a tiny offset, otherwise @@ -1019,12 +1019,12 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis) rctf curmasked; float xofs, yofs; - /* pixel offsets (-0.375f) are needed to get 1:1 correspondence with pixels for smooth UI drawing, + /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing, * but only applied where requested */ /* XXX temp (ton) */ - xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f; - yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f; + xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f; + yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? GLA_PIXEL_OFS : 0.0f; /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 47a086a2779..b4f1f4b3022 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -107,7 +107,7 @@ void ED_region_pixelspace(ARegion *ar) int width = ar->winrct.xmax - ar->winrct.xmin + 1; int height = ar->winrct.ymax - ar->winrct.ymin + 1; - wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f); + wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS); glLoadIdentity(); } diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 5296c8615ab..a534124d2c0 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -674,7 +674,7 @@ void glaDefine2DArea(rcti *screen_rect) glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); - /* The 0.375 magic number is to shift the matrix so that + /* The GLA_PIXEL_OFS magic number is to shift the matrix so that * both raster and vertex integer coordinates fall at pixel * centers properly. For a longer discussion see the OpenGL * Programming Guide, Appendix H, Correctness Tips. @@ -683,7 +683,7 @@ void glaDefine2DArea(rcti *screen_rect) glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, sc_w, 0.0, sc_h, -1, 1); - glTranslatef(0.375, 0.375, 0.0); + glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 7ddee03b08a..9f6d6d0170f 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3025,7 +3025,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) glaDefine2DArea(&ar->winrct); /* ortho at pixel level curarea */ - wmOrtho2(-0.375, ar->winx - 0.375, -0.375, ar->winy - 0.375); + wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS); 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/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 8be5b644afb..6240d174575 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -50,7 +50,6 @@ #include "BKE_suggestions.h" #include "BKE_text.h" - #include "BIF_gl.h" #include "ED_datafiles.h" @@ -1854,7 +1853,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) /* draw other stuff */ draw_brackets(st, ar); draw_markers(st, ar); - glTranslatef(0.375f, 0.375f, 0.0f); /* XXX scroll requires exact pixel space */ + glTranslatef(GLA_PIXEL_OFS, GLA_PIXEL_OFS, 0.0f); /* XXX scroll requires exact pixel space */ draw_textscroll(st, &scroll, &back); draw_documentation(st, ar); draw_suggestion_list(st, ar); |