[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12389] trunk/blender/source/blender/src/ drawimage.c: checkers being drawn as many glRects is slow when zoomed in, use
Campbell Barton
cbarton at metavr.com
Thu Oct 25 11:37:52 CEST 2007
Revision: 12389
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12389
Author: campbellbarton
Date: 2007-10-25 11:37:52 +0200 (Thu, 25 Oct 2007)
Log Message:
-----------
checkers being drawn as many glRects is slow when zoomed in, use
glPolygonStipple draw checkers.
Modified Paths:
--------------
trunk/blender/source/blender/src/drawimage.c
Modified: trunk/blender/source/blender/src/drawimage.c
===================================================================
--- trunk/blender/source/blender/src/drawimage.c 2007-10-25 05:46:07 UTC (rev 12388)
+++ trunk/blender/source/blender/src/drawimage.c 2007-10-25 09:37:52 UTC (rev 12389)
@@ -1704,61 +1704,30 @@
}
-#define ALPHA_CHECKSIZE 30
static void sima_draw_alpha_backdrop(SpaceImage *sima, float x1, float y1, float xsize, float ysize)
{
- float tile= ALPHA_CHECKSIZE/2;
- float x, y, maxx, maxy;
- float xstart, ystart;
- int checker_type = 0;
+ GLubyte checker_stipple[32*32/8] =
+ {
+ 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \
+ 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \
+ 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \
+ 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, \
+ 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \
+ 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \
+ 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \
+ 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, \
+ };
+
glColor3ub(100, 100, 100);
glRectf(x1, y1, x1 + sima->zoom*xsize, y1 + sima->zoom*ysize);
glColor3ub(160, 160, 160);
- maxx= x1+sima->zoom*xsize;
- maxy= y1+sima->zoom*ysize;
-
- xstart = fmod((float)sima->xof*sima->zoom, ALPHA_CHECKSIZE);
- ystart = fmod((float)sima->yof*sima->zoom, ALPHA_CHECKSIZE);
-
- if (xstart>0) xstart-=ALPHA_CHECKSIZE;
- if (ystart>0) ystart-=ALPHA_CHECKSIZE;
-
- ystart = ystart/sima->zoom;
- xstart = xstart/sima->zoom;
-
- while (checker_type != 2) {
-
- /* there are only 2 checker_type's - 0 or 1 , offset the quads to make check's second time round */
- if (checker_type==1) {
- xstart -= ALPHA_CHECKSIZE*0.5/sima->zoom;
- ystart -= ALPHA_CHECKSIZE*0.5/sima->zoom;
- }
-
- for(x=xstart; x<xsize; x+=ALPHA_CHECKSIZE/sima->zoom) {
- float fx= x1 + sima->zoom*x;
- if (fx+tile < x1)
- continue;
-
- for(y=ystart; y<ysize; y+=ALPHA_CHECKSIZE/sima->zoom) {
- float fy= y1 + sima->zoom*y;
- float tilex= tile, tiley= tile;
-
- /* skip min values */
- if (fy+tile<y1)
- continue;
-
- /* clip max values */
- if(fx+tile > maxx)
- tilex= maxx-fx;
- if(fy+tile > maxy)
- tiley= maxy-fy;
-
- glRectf(MAX2(fx, x1), MAX2(fy, y1), fx + tilex, fy + tiley);
- }
- }
- checker_type++;
- }
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(checker_stipple);
+ glRectf(x1, y1, x1 + sima->zoom*xsize, y1 + sima->zoom*ysize);
+ glEnd();
+ glDisable(GL_POLYGON_STIPPLE);
+ return;
}
static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti)
More information about the Bf-blender-cvs
mailing list