From ef57a1b559faba31a173f912c31f2dd16625bab6 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Tue, 27 Feb 2007 10:27:29 +0000 Subject: Fix a segmentation fault when initializing GL (following rotation patch). Fix a dbl buffer pixmap reallocation problem (shown only in the perl flavor but a real bug nonetheless). The symptom was only a small area refreshed. --- generic/tkZinc.c | 111 +++++++++++++++++++++++-------------------------------- 1 file changed, 46 insertions(+), 65 deletions(-) (limited to 'generic') diff --git a/generic/tkZinc.c b/generic/tkZinc.c index c2e481d..e7d6851 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -137,7 +137,6 @@ static GLint ZnGLAttribs[] = { AGL_GREEN_SIZE, 8, AGL_BLUE_SIZE, 8, AGL_STENCIL_SIZE, 8, - AGL_DEPTH_SIZE, 0, AGL_NONE }; #elif !defined(_WIN32) @@ -150,7 +149,6 @@ static int ZnGLAttribs[] = { GLX_BLUE_SIZE, 8, GLX_STENCIL_SIZE, 8, /*GLX_ALPHA_SIZE, 8,*/ - GLX_DEPTH_SIZE, 0, None }; #endif @@ -1604,13 +1602,15 @@ ZincObjCmd(ClientData client_data, /* Main window associated with wi->opt_width, wi->opt_height, Tk_Depth(wi->win)); } -#if defined(GL) && defined(ROTATION) +#ifdef GL else { InitRendering1(wi); +#ifdef ROTATION wi->canvastex = 0; wi->fbo = 0; wi->depthstencil = 0; SET(wi->flags, ZN_UPDATE_CANVASTEX); +#endif } #endif @@ -6925,18 +6925,11 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ return TCL_ERROR; } #ifdef PTK -#ifdef PTK_800 if ((Tk_GetPixels(interp, wi->win, LangString(args2[0]), &wi->scroll_xo) != TCL_OK) || (Tk_GetPixels(interp, wi->win, LangString(args2[1]), &wi->scroll_yo) != TCL_OK) || (Tk_GetPixels(interp, wi->win, LangString(args2[2]), &wi->scroll_xc) != TCL_OK) || (Tk_GetPixels(interp, wi->win, LangString(args2[3]), &wi->scroll_yc) != TCL_OK)) #else - if ((Tk_GetPixelsFromObj(interp, wi->win, args2[0], &wi->scroll_xo) != TCL_OK) || - (Tk_GetPixelsFromObj(interp, wi->win, args2[1], &wi->scroll_yo) != TCL_OK) || - (Tk_GetPixelsFromObj(interp, wi->win, args2[2], &wi->scroll_xc) != TCL_OK) || - (Tk_GetPixelsFromObj(interp, wi->win, args2[3], &wi->scroll_yc) != TCL_OK)) -#endif -#else if ((Tk_GetPixels(interp, wi->win, args2[0], &wi->scroll_xo) != TCL_OK) || (Tk_GetPixels(interp, wi->win, args2[1], &wi->scroll_yo) != TCL_OK) || (Tk_GetPixels(interp, wi->win, args2[2], &wi->scroll_xc) != TCL_OK) || @@ -6975,7 +6968,7 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ return TCL_OK; } -#else +#else /* PTK_800 */ static void TileUpdate(void *client_data) { @@ -7062,18 +7055,10 @@ Configure(Tcl_Interp *interp,/* Used for error reporting. */ if (argc2 != 4) { goto badRegion; } -#ifdef PTK_800 - if ((Tk_GetPixels(interp, wi->win, LangString(args2[0]), &wi->scroll_xo) != TCL_OK) || - (Tk_GetPixels(interp, wi->win, LangString(args2[1]), &wi->scroll_yo) != TCL_OK) || - (Tk_GetPixels(interp, wi->win, LangString(args2[2]), &wi->scroll_xc) != TCL_OK) || - (Tk_GetPixels(interp, wi->win, LangString(args2[3]), &wi->scroll_yc) != TCL_OK)) -#else if ((Tk_GetPixelsFromObj(interp, wi->win, args2[0], &wi->scroll_xo) != TCL_OK) || (Tk_GetPixelsFromObj(interp, wi->win, args2[1], &wi->scroll_yo) != TCL_OK) || (Tk_GetPixelsFromObj(interp, wi->win, args2[2], &wi->scroll_xc) != TCL_OK) || - (Tk_GetPixelsFromObj(interp, wi->win, args2[3], &wi->scroll_yc) != TCL_OK)) -#endif - { + (Tk_GetPixelsFromObj(interp, wi->win, args2[3], &wi->scroll_yc) != TCL_OK)) { goto badRegion; } } @@ -7486,60 +7471,56 @@ Event(ClientData client_data, /* Information about widget. */ int_width = Tk_Width(wi->win); int_height = Tk_Height(wi->win); - if ((wi->opt_width != int_width) || (wi->opt_height != int_height)) { - bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = MAX(wi->opt_width, int_width); - bbox.corner.y = MAX(wi->opt_height, int_height); - wi->opt_width = wi->width = int_width; - wi->opt_height = wi->height = int_height; + bbox.orig.x = bbox.orig.y = 0; + bbox.corner.x = MAX(wi->opt_width, int_width); + bbox.corner.y = MAX(wi->opt_height, int_height); + wi->opt_width = wi->width = int_width; + wi->opt_height = wi->height = int_height; - ZnResetTransformStack(wi); + ZnResetTransformStack(wi); - SET(wi->flags, ZN_UPDATE_SCROLLBARS); - /* - * The call below is needed in order to recenter the view if - * it's confined and the scroll region is smaller than the - * window. - */ - ZnSetOrigin(wi, wi->origin.x, wi->origin.y); + SET(wi->flags, ZN_UPDATE_SCROLLBARS); + /* + * The call below is needed in order to recenter the view if + * it's confined and the scroll region is smaller than the + * window. + */ + ZnSetOrigin(wi, wi->origin.x, wi->origin.y); - ZnDamage(wi, &bbox); - ZnITEM.Invalidate(wi->top_group, ZN_TRANSFO_FLAG); - - /* - * Reallocate the double buffer pixmap/image. - */ - if (!wi->render) { - /*printf("reallocating double buffer\n");*/ - if (wi->draw_buffer) { - Tk_FreePixmap(wi->dpy, wi->draw_buffer); - } - wi->draw_buffer = Tk_GetPixmap(wi->dpy, RootWindowOfScreen(wi->screen), - int_width, int_height, - DefaultDepthOfScreen(wi->screen)); + ZnDamage(wi, &bbox); + ZnITEM.Invalidate(wi->top_group, ZN_TRANSFO_FLAG); + + /* + * Reallocate the double buffer pixmap/image. + */ + if (!wi->render) { + /*printf("reallocating double buffer\n");*/ + if (wi->draw_buffer) { + Tk_FreePixmap(wi->dpy, wi->draw_buffer); } - else { + wi->draw_buffer = Tk_GetPixmap(wi->dpy, RootWindowOfScreen(wi->screen), + int_width, int_height, + DefaultDepthOfScreen(wi->screen)); + } + else { #if defined(GL) #if defined(MAC_OSX_TK) - ZnGLContextEntry *ce = ZnGLMakeCurrent(wi->dpy, wi); - UpdateBufferRect(ce, wi->win); - aglUpdateContext(ce->context); + ZnGLContextEntry *ce = ZnGLMakeCurrent(wi->dpy, wi); + UpdateBufferRect(ce, wi->win); + aglUpdateContext(ce->context); #endif - SET(wi->flags, ZN_UPDATE_CANVASTEX); + SET(wi->flags, ZN_UPDATE_CANVASTEX); #endif - } - } - else { - /* - * In case of a window reconfiguration following a change - * of border size, set the exposed area to force a copy - * of the back buffer to the screen. - */ - bbox.orig.x = bbox.orig.y = 0; - bbox.corner.x = Tk_Width(wi->win); - bbox.corner.y = Tk_Height(wi->win); - ZnAddBBoxToBBox(&wi->exposed_area, &bbox); } + /* + * In case of a window reconfiguration following a change + * of border size, set the exposed area to force a copy + * of the back buffer to the screen. + */ + bbox.orig.x = bbox.orig.y = 0; + bbox.corner.x = Tk_Width(wi->win); + bbox.corner.y = Tk_Height(wi->win); + ZnAddBBoxToBBox(&wi->exposed_area, &bbox); ZnNeedRedisplay(wi); } /* -- cgit v1.1