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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-10-25 13:37:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-10-25 13:37:52 +0400
commit86b38473a16a0d9f135a37e0800ed478309df187 (patch)
treed265f388e536b448df485251501c04612fa9e24c /source/blender/src/drawimage.c
parentcbcaa319093f92c0d86fd05e8a8cbdb946b9b6a7 (diff)
checkers being drawn as many glRects is slow when zoomed in, use
glPolygonStipple draw checkers.
Diffstat (limited to 'source/blender/src/drawimage.c')
-rw-r--r--source/blender/src/drawimage.c67
1 files changed, 18 insertions, 49 deletions
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index 789e33964fc..85be4298922 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -1704,61 +1704,30 @@ static void imagespace_grid(SpaceImage *sima)
}
-#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)