diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-04 22:39:47 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-04 22:39:47 +0400 |
commit | 9e51f4b94368a612c5561f20f4b44f858ab5318e (patch) | |
tree | 5cf7c06140dc4828d7523cb022c45fc75370bebd /source/blender/editors/interface | |
parent | 756ac13e3a17e1820c5151f1fff8cb21833a1f0f (diff) |
Optimization of preview widget scaling.
Thanks to Campbell for pointing into issues.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 12187283470..767c6b0353c 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1475,16 +1475,20 @@ static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float zoomx, float zoomy) { ImBuf *scaleibuf; int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy; + const float max_x= ibuf->x-1.0f; + const float max_y= ibuf->y-1.0f; + const float scalex= 1.0f/zoomx; + const float scaley= 1.0f/zoomy; scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect); for(y= 0; y<scaleibuf->y; y++) { for (x= 0; x<scaleibuf->x; x++) { - float src_x= ((float)x)/zoomx; - float src_y= ((float)y)/zoomy; + float src_x= scalex*x; + float src_y= scaley*y; - CLAMP(src_x, 0, ibuf->x-1.0f); - CLAMP(src_y, 0, ibuf->y-1.0f); + CLAMP(src_x, 0, max_x); + CLAMP(src_y, 0, max_y); bilinear_interpolation(ibuf, scaleibuf, src_x, src_y, x, y); } |