diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-15 03:41:13 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-15 03:41:13 +0400 |
commit | fab5438943a2326d6af391b8fe0e3a3078cc7b85 (patch) | |
tree | f67b16ebe57ce370285bffc26f8b79638427f8f8 /source/blender/editors/interface/view2d.c | |
parent | cc978dc0c128f455145daf6d693ef0e571d22988 (diff) |
Code Cleanup: avoid duplicate calls to WM_window_pixels_x/y
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r-- | source/blender/editors/interface/view2d.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index e88e7e3e7af..06f13c35e0b 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1019,8 +1019,9 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked) void UI_view2d_view_ortho(View2D *v2d) { rctf curmasked; - int sizex = BLI_rcti_size_x(&v2d->mask); - int sizey = BLI_rcti_size_y(&v2d->mask); + const int sizex = BLI_rcti_size_x(&v2d->mask); + const int sizey = BLI_rcti_size_y(&v2d->mask); + const float eps = 0.001f; float xofs = 0.0f, yofs = 0.0f; /* pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1 correspondence with pixels for smooth UI drawing, @@ -1029,9 +1030,9 @@ void UI_view2d_view_ortho(View2D *v2d) /* XXX brecht: instead of zero at least use a tiny offset, otherwise * pixel rounding is effectively random due to float inaccuracy */ if (sizex > 0) - xofs = 0.001f * BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); + xofs = eps * BLI_rctf_size_x(&v2d->cur) / sizex; if (sizey > 0) - yofs = 0.001f * BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); + yofs = eps * BLI_rctf_size_y(&v2d->cur) / sizey; /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */ view2d_map_cur_using_mask(v2d, &curmasked); @@ -1040,12 +1041,12 @@ void UI_view2d_view_ortho(View2D *v2d) /* XXX ton: this flag set by outliner, for icons */ if (v2d->flag & V2D_PIXELOFS_X) { - curmasked.xmin = floorf(curmasked.xmin) - (0.001f + xofs); - curmasked.xmax = floorf(curmasked.xmax) - (0.001f + xofs); + curmasked.xmin = floorf(curmasked.xmin) - (eps + xofs); + curmasked.xmax = floorf(curmasked.xmax) - (eps + xofs); } if (v2d->flag & V2D_PIXELOFS_Y) { - curmasked.ymin = floorf(curmasked.ymin) - (0.001f + yofs); - curmasked.ymax = floorf(curmasked.ymax) - (0.001f + yofs); + curmasked.ymin = floorf(curmasked.ymin) - (eps + yofs); + curmasked.ymax = floorf(curmasked.ymax) - (eps + yofs); } /* set matrix on all appropriate axes */ |