aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlemort2007-11-19 16:19:01 +0000
committerlemort2007-11-19 16:19:01 +0000
commit1e335fc694e93bdc6e6560b20ccd35d712f51b74 (patch)
tree5cbb185dba81fc0725f3e15996ab5b43e3a77907
parent8f95e88041057a292ae2f15737815a668aa6236e (diff)
downloadtkzinc-1e335fc694e93bdc6e6560b20ccd35d712f51b74.zip
tkzinc-1e335fc694e93bdc6e6560b20ccd35d712f51b74.tar.gz
tkzinc-1e335fc694e93bdc6e6560b20ccd35d712f51b74.tar.bz2
tkzinc-1e335fc694e93bdc6e6560b20ccd35d712f51b74.tar.xz
Replace #ifdef GL_DAMAGE statement with a new option (-usedamage) of the TkZinc widget
-rw-r--r--generic/Group.c62
-rw-r--r--generic/WidgetInfo.h1
-rw-r--r--generic/tkZinc.c93
3 files changed, 95 insertions, 61 deletions
diff --git a/generic/Group.c b/generic/Group.c
index 6031811..8a1f668 100644
--- a/generic/Group.c
+++ b/generic/Group.c
@@ -1057,10 +1057,10 @@ Render(ZnItem item)
GroupItem group = (GroupItem) item;
ZnItem current_item;
ZnWInfo *wi = item->wi;
-#ifdef GL_DAMAGE
+//#ifdef GL_DAMAGE
ZnBBox *clip_box;
ZnBBox bbox, old_damaged_area;
-#endif
+//#endif
unsigned char save_alpha = wi->alpha;
unsigned char save_alpha2;
@@ -1074,23 +1074,43 @@ Render(ZnItem item)
PushTransform(item);
PushClip(group, True);
-#ifdef GL_DAMAGE
- if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT) && (group->clip != ZN_NO_ITEM)) {
- old_damaged_area = wi->damaged_area;
- if (ZnCurrentClip(wi, NULL, &clip_box, NULL)) {
- ZnIntersectBBox(&wi->damaged_area, clip_box, &bbox);
- wi->damaged_area = bbox;
+
+ /* Test if we are using damage or not */
+ if (wi->usedamage) {
+ /* Damage is on */
+ if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT) && (group->clip != ZN_NO_ITEM)) {
+ old_damaged_area = wi->damaged_area;
+ if (ZnCurrentClip(wi, NULL, &clip_box, NULL)) {
+ ZnIntersectBBox(&wi->damaged_area, clip_box, &bbox);
+ wi->damaged_area = bbox;
+ }
}
- }
-#endif
+ }
current_item = group->tail;
while (current_item != ZN_NO_ITEM) {
if (ISSET(current_item->flags, ZN_VISIBLE_BIT)) {
-#ifdef GL_DAMAGE
- ZnIntersectBBox(&wi->damaged_area, &current_item->item_bounding_box, &bbox);
- if (!ZnIsEmptyBBox(&bbox) || ISSET(wi->flags, ZN_CONFIGURE_EVENT)) {
-#endif
+ /* test if we are using dmaage or not */
+ if (wi->usedamage) {
+ /* Damage is on */
+ ZnIntersectBBox(&wi->damaged_area, &current_item->item_bounding_box, &bbox);
+ if (!ZnIsEmptyBBox(&bbox) || ISSET(wi->flags, ZN_CONFIGURE_EVENT)) {
+
+ if (current_item->class != ZnGroup) {
+ PushTransform(current_item);
+ if (ISCLEAR(current_item->flags, ZN_COMPOSE_ALPHA_BIT)) {
+ wi->alpha = 100;
+ }
+ }
+ current_item->class->Render(current_item);
+ if (current_item->class != ZnGroup) {
+ PopTransform(current_item);
+ wi->alpha = save_alpha2;
+ }
+ }
+
+ } else {
+ /* Damage is off */
if (current_item->class != ZnGroup) {
PushTransform(current_item);
if (ISCLEAR(current_item->flags, ZN_COMPOSE_ALPHA_BIT)) {
@@ -1102,18 +1122,18 @@ Render(ZnItem item)
PopTransform(current_item);
wi->alpha = save_alpha2;
}
-#ifdef GL_DAMAGE
}
-#endif
+
}
current_item = current_item->previous;
}
-#ifdef GL_DAMAGE
- if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT) && (group->clip != ZN_NO_ITEM)) {
- wi->damaged_area = old_damaged_area;
- }
-#endif
+ /* Test if we are using damage or not */
+ if (wi->usedamage) {
+ if (ISCLEAR(wi->flags, ZN_CONFIGURE_EVENT) && (group->clip != ZN_NO_ITEM)) {
+ wi->damaged_area = old_damaged_area;
+ }
+ }
PopClip(group, True);
PopTransform(item);
diff --git a/generic/WidgetInfo.h b/generic/WidgetInfo.h
index 6851f65..6b34ba7 100644
--- a/generic/WidgetInfo.h
+++ b/generic/WidgetInfo.h
@@ -203,6 +203,7 @@ typedef struct _ZnWInfo {
ZnBool full_reshape; /* Use it on the top level window. */
Window real_top;
int render;
+ ZnBool usedamage; /* Use GL damage (only works if render is to 1 ie if we use GL) */
unsigned char alpha; /* Current composite group alpha. */
ZnItem top_group;
#ifndef PTK_800
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]);
}