aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlemort2008-01-15 16:31:46 +0000
committerlemort2008-01-15 16:31:46 +0000
commite5d991bba3fceb7f2a0e2f7a7c98ab41f7412f59 (patch)
treed427fc66698672800421f74c081064b5c02a9da5
parent01cffb44feca63f14616535e0b51eec7f8aad39c (diff)
downloadtkzinc-e5d991bba3fceb7f2a0e2f7a7c98ab41f7412f59.zip
tkzinc-e5d991bba3fceb7f2a0e2f7a7c98ab41f7412f59.tar.gz
tkzinc-e5d991bba3fceb7f2a0e2f7a7c98ab41f7412f59.tar.bz2
tkzinc-e5d991bba3fceb7f2a0e2f7a7c98ab41f7412f59.tar.xz
Integration d'un mecanisme d'optimisation compatible avec les cartes non-Nvidia. Ce mecanisme est plus lent que le mecanisme de GL_DAMAGE mais il demeure plus rapide que le redessin complet de la scene.
Le nouveau mecanisme elimine le souci des traces noires avec les cartes ATI
-rw-r--r--generic/WidgetInfo.h2
-rw-r--r--generic/tkZinc.c62
2 files changed, 55 insertions, 9 deletions
diff --git a/generic/WidgetInfo.h b/generic/WidgetInfo.h
index 6b34ba7..813da14 100644
--- a/generic/WidgetInfo.h
+++ b/generic/WidgetInfo.h
@@ -203,7 +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) */
+ int 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 f9e9193..d6e5215 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -422,7 +422,7 @@ static Tk_ConfigSpec config_specs[] = {
"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",
+ {TK_CONFIG_INT, "-usedamage", "useDamage", "UseDamage",
"0", Tk_Offset(ZnWInfo, usedamage), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -539,7 +539,7 @@ static Tk_OptionSpec option_specs[] = {
"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",
+ {TK_OPTION_INT, "-usedamage", "useDamage", "UseDamage",
"0", -1, Tk_Offset(ZnWInfo, usedamage), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -8867,17 +8867,47 @@ Repair(ZnWInfo *wi)
//
// glViewport and glOrtho must always be used together with
// matching parameters to keep the mapping straight (no distorsion).
- glViewport(darea_x1, wi->height - darea_y2, darea_x2 - darea_x1, darea_y2 - darea_y1);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(darea_x1, darea_x2, darea_y2, darea_y1, -1.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
+ if (wi->usedamage == 2) {
+ // usedamage == 2
+ glViewport(0, 0, wi->width, wi->height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0, wi->width, wi->height, 0, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+ }
+ else {
+ glViewport(darea_x1, wi->height - darea_y2, darea_x2 - darea_x1, darea_y2 - darea_y1);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(darea_x1, darea_x2, darea_y2, darea_y1, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+ }
+
/*
* Clear the GL buffers.
*/
glClear(GL_STENCIL_BUFFER_BIT);
/*
+ * Use clipping if needed (optimization for non-Nvidia cards)
+ */
+ if (wi->usedamage == 2) {
+ // Clip the damaged region
+ // This point array will contain our damage mask coordinates
+ ZnPoint _ptClip [ 2 ];
+ // This triangle strip will contain our specific damage clipping zone.
+ ZnTriStrip tristripClip;
+ _ptClip [0].x = darea_x1;
+ _ptClip [0].y = darea_y1;
+ _ptClip [1].x = darea_x2;
+ _ptClip [1].y = darea_y2;
+
+ ZnTriStrip1(&tristripClip, _ptClip, 2, False);
+ ZnPushClip(wi, &tristripClip, True, True);
+ }
+
+
+ /*
* Setup the background tile or the background color.
*/
if (wi->tile != ZnUnspecifiedImage) {
@@ -8901,6 +8931,15 @@ Repair(ZnWInfo *wi)
wi->top_group->class->Render(wi->top_group);
+
+ /*
+ * Stop clipping if needed (optimizations for non-Nvidia cards)
+ */
+ if (wi->usedamage == 2) {
+ // Stop clipping !
+ ZnPopClip(wi, True);
+ }
+
#if defined(GL) && defined(ROTATION)
if (wi->enable_rotation) {
FinalizeRotation(wi);
@@ -8911,7 +8950,14 @@ Repair(ZnWInfo *wi)
unsigned short alpha;
/* Test if we are using damage or not */
- if (wi->usedamage) {
+ if (wi->usedamage == 2) {
+ glViewport(0, 0, wi->width, wi->height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(0.0, wi->width, wi->height, 0.0, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+ }
+ else {
glViewport(0, 0, wi->opt_width, wi->opt_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();