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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-01-15 03:41:13 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-15 03:41:13 +0400
commitfab5438943a2326d6af391b8fe0e3a3078cc7b85 (patch)
treef67b16ebe57ce370285bffc26f8b79638427f8f8 /source
parentcc978dc0c128f455145daf6d693ef0e571d22988 (diff)
Code Cleanup: avoid duplicate calls to WM_window_pixels_x/y
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/view2d.c17
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c14
2 files changed, 19 insertions, 12 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 */
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index 5edc57be40b..b4d29f05e15 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -502,6 +502,9 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float alpha)
{
+ const int winsize_x = WM_window_pixels_x(win);
+ const int winsize_y = WM_window_pixels_y(win);
+
float halfx, halfy, ratiox, ratioy;
int x, y, sizex, sizey, offx, offy;
@@ -509,8 +512,8 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float a
for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
- sizex = (x == triple->nx - 1) ? WM_window_pixels_x(win) - offx : triple->x[x];
- sizey = (y == triple->ny - 1) ? WM_window_pixels_y(win) - offy : triple->y[y];
+ sizex = (x == triple->nx - 1) ? winsize_x - offx : triple->x[x];
+ sizey = (y == triple->ny - 1) ? winsize_y - offy : triple->y[y];
/* wmOrtho for the screen has this same offset */
ratiox = sizex;
@@ -551,12 +554,15 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float a
static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
{
+ const int winsize_x = WM_window_pixels_x(win);
+ const int winsize_y = WM_window_pixels_y(win);
+
int x, y, sizex, sizey, offx, offy;
for (y = 0, offy = 0; y < triple->ny; offy += triple->y[y], y++) {
for (x = 0, offx = 0; x < triple->nx; offx += triple->x[x], x++) {
- sizex = (x == triple->nx - 1) ? WM_window_pixels_x(win) - offx : triple->x[x];
- sizey = (y == triple->ny - 1) ? WM_window_pixels_y(win) - offy : triple->y[y];
+ sizex = (x == triple->nx - 1) ? winsize_x - offx : triple->x[x];
+ sizey = (y == triple->ny - 1) ? winsize_y - offy : triple->y[y];
glBindTexture(triple->target, triple->bind[x + y * triple->nx]);
glCopyTexSubImage2D(triple->target, 0, 0, 0, offx, offy, sizex, sizey);