From 1e335fc694e93bdc6e6560b20ccd35d712f51b74 Mon Sep 17 00:00:00 2001 From: lemort Date: Mon, 19 Nov 2007 16:19:01 +0000 Subject: Replace #ifdef GL_DAMAGE statement with a new option (-usedamage) of the TkZinc widget --- generic/tkZinc.c | 93 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 40 deletions(-) (limited to 'generic/tkZinc.c') diff --git a/generic/tkZinc.c b/generic/tkZinc.c index df3aeb6..f9e9193 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -421,7 +421,9 @@ static Tk_ConfigSpec config_specs[] = { {TK_CONFIG_DOUBLE, "-screenrotation", "screenRotation", "ScreenRotation", "0", Tk_Offset(ZnWInfo, screen_rotation), 0, NULL}, #endif - + /* Use damage option (only used if -render is set to 1 ie if we use GL */ + {TK_CONFIG_BOOLEAN, "-usedamage", "useDamage", "UseDamage", + "0", Tk_Offset(ZnWInfo, usedamage), 0, NULL}, {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; #else @@ -536,7 +538,9 @@ static Tk_OptionSpec option_specs[] = { {TK_OPTION_DOUBLE, "-screenrotation", "screenRotation", "ScreenRotation", "0", -1, Tk_Offset(ZnWInfo, screen_rotation), 0, NULL, CONFIG_ROTATION}, #endif - + /* Use damage option (only used if -render is set to 1 ie if we use GL */ + {TK_OPTION_BOOLEAN, "-usedamage", "useDamage", "UseDamage", + "0", -1, Tk_Offset(ZnWInfo, usedamage), 0, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; #endif @@ -8783,18 +8787,21 @@ Repair(ZnWInfo *wi) ZnGetDeferredGLGlyphs(); ZnGLWaitX(); -#ifdef GL_DAMAGE - if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT)) { - ClampDamageArea(wi); - /* - * Merge the exposed area. - */ - ZnAddBBoxToBBox(&wi->damaged_area, &wi->exposed_area); - if (ZnIsEmptyBBox(&wi->damaged_area)) { - return; + + /* Test if we must use damage or not */ + if (wi->usedamage) { + if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT)) { + ClampDamageArea(wi); + /* + * Merge the exposed area. + */ + ZnAddBBoxToBBox(&wi->damaged_area, &wi->exposed_area); + if (ZnIsEmptyBBox(&wi->damaged_area)) { + return; + } } } -#endif + //printf("Repair, scissors: %d\n", ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT)); ce = ZnGLMakeCurrent(wi->dpy, wi); @@ -8830,29 +8837,33 @@ Repair(ZnWInfo *wi) */ wi->alpha = 100; -#ifdef GL_DAMAGE - if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT)) { + /* Test if we must use damage or not */ + if (wi->usedamage) { + if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT)) { + /* + * Set the damaged area as the viewport area. + */ + darea_x1 = (int) ZnNearestInt(wi->damaged_area.orig.x); + darea_y1 = (int) ZnNearestInt(wi->damaged_area.orig.y); + darea_x2 = (int) ZnNearestInt(wi->damaged_area.corner.x); + darea_y2 = (int) ZnNearestInt(wi->damaged_area.corner.y); + } + else { + darea_x1 = darea_y1 = wi->damaged_area.orig.x = wi->damaged_area.orig.y = 0; + darea_x2 = wi->damaged_area.corner.x = wi->width; + darea_y2 = wi->damaged_area.corner.y = wi->height; + } + + } else { /* - * Set the damaged area as the viewport area. - */ - darea_x1 = (int) ZnNearestInt(wi->damaged_area.orig.x); - darea_y1 = (int) ZnNearestInt(wi->damaged_area.orig.y); - darea_x2 = (int) ZnNearestInt(wi->damaged_area.corner.x); - darea_y2 = (int) ZnNearestInt(wi->damaged_area.corner.y); - } - else { + * We do not use the damaged area set it to the whole area. + */ darea_x1 = darea_y1 = wi->damaged_area.orig.x = wi->damaged_area.orig.y = 0; darea_x2 = wi->damaged_area.corner.x = wi->width; darea_y2 = wi->damaged_area.corner.y = wi->height; - } -#else - /* - * We do not use the damaged area set it to the whole area. - */ - darea_x1 = darea_y1 = wi->damaged_area.orig.x = wi->damaged_area.orig.y = 0; - darea_x2 = wi->damaged_area.corner.x = wi->width; - darea_y2 = wi->damaged_area.corner.y = wi->height; -#endif + } + + // // glViewport and glOrtho must always be used together with // matching parameters to keep the mapping straight (no distorsion). @@ -8899,13 +8910,15 @@ Repair(ZnWInfo *wi) if ((wi->border_width > 0) || (wi->highlight_width > 0)) { unsigned short alpha; -#ifdef GL_DAMAGE - glViewport(0, 0, wi->opt_width, wi->opt_height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, wi->opt_width, wi->opt_height, 0.0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); -#endif + /* Test if we are using damage or not */ + if (wi->usedamage) { + glViewport(0, 0, wi->opt_width, wi->opt_height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, wi->opt_width, wi->opt_height, 0.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + } + if (wi->highlight_width > 0) { color = ZnGetGradientColor(ISSET(wi->flags, ZN_GOT_FOCUS)?wi->highlight_color: wi->highlight_bg_color, 0.0, &alpha); @@ -9227,7 +9240,7 @@ ZnTessBegin(GLenum type, tristrips->num_strips * sizeof(ZnStrip)); tristrips->strips[tristrips->num_strips-1].fan = (type==GL_TRIANGLE_FAN); } - //printf("Début de fragment de type: %s\n", + //printf("Debut de fragment de type: %s\n", //(type == GL_TRIANGLE_FAN) ? "FAN" : //(type == GL_TRIANGLE_STRIP) ? "STRIP" : //(type == GL_TRIANGLES) ? "TRIANGLES" : @@ -9307,7 +9320,7 @@ ZnTessCombine(GLdouble coords[3], ZnTesselator.combine_list = cdata; *out_data = &cdata->v; ZnTesselator.combine_length++; - //printf("Création d'un nouveau sommet en %g %g\n", + //printf("Creation d'un nouveau sommet en %g %g\n", //cdata->v[0], cdata->v[1]); } -- cgit v1.1