[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42418] branches/soc-2011-tomato/source/ blender/editors/interface/interface_draw.c: Optimization of preview widget scaling.

Sergey Sharybin sergey.vfx at gmail.com
Sun Dec 4 19:39:47 CET 2011


Revision: 42418
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42418
Author:   nazgul
Date:     2011-12-04 18:39:47 +0000 (Sun, 04 Dec 2011)
Log Message:
-----------
Optimization of preview widget scaling.

Thanks to Campbell for pointing into issues.

Modified Paths:
--------------
    branches/soc-2011-tomato/source/blender/editors/interface/interface_draw.c

Modified: branches/soc-2011-tomato/source/blender/editors/interface/interface_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/interface_draw.c	2011-12-04 18:39:19 UTC (rev 42417)
+++ branches/soc-2011-tomato/source/blender/editors/interface/interface_draw.c	2011-12-04 18:39:47 UTC (rev 42418)
@@ -1475,16 +1475,20 @@
 {
 	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);
 		}




More information about the Bf-blender-cvs mailing list