diff options
Diffstat (limited to 'xlib')
-rw-r--r-- | xlib/xgc.c | 45 | ||||
-rw-r--r-- | xlib/xutil.c | 5 |
2 files changed, 40 insertions, 10 deletions
@@ -5,23 +5,28 @@ * contexts. * * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * Copyright (c) 2002-2007 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright (c) 2002-2009 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright 2008-2009, Apple Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include <tkInt.h> +#include "tkInt.h" #if !defined(MAC_OSX_TK) # include <X11/Xlib.h> -#endif -#ifdef MAC_OSX_TK +# define gcCacheSize 0 +# define TkpInitGCCache(gc) +# define TkpFreeGCCache(gc) +# define TkpGetGCCache(gc) +#else # include <tkMacOSXInt.h> # include <X11/Xlib.h> # include <X11/X.h> # define Cursor XCursor # define Region XRegion +# define gcCacheSize sizeof(TkpGCCache) #endif @@ -45,7 +50,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; if (clip_mask == None) { - clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask)); + clip_mask = ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK } else if (clip_mask->type == TKP_CLIP_REGION) { @@ -78,7 +83,7 @@ static void FreeClipMask(GC gc) { TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); } #endif - ckfree((char*) gc->clip_mask); + ckfree(gc->clip_mask); gc->clip_mask = None; } } @@ -117,7 +122,7 @@ XCreateGC( #define MAX_DASH_LIST_SIZE 10 - gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE); + gp = ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { return None; } @@ -158,10 +163,33 @@ XCreateGC( clip_mask->type = TKP_CLIP_PIXMAP; clip_mask->value.pixmap = values->clip_mask; } + TkpInitGCCache(gp); return gp; } +#ifdef MAC_OSX_TK +/* + *---------------------------------------------------------------------- + * + * TkpGetGCCache -- + * + * Results: + * Pointer to the TkpGCCache at the end of the GC. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +TkpGCCache* +TkpGetGCCache(GC gc) { + return (gc ? (TkpGCCache*)(((char*) gc) + sizeof(XGCValues) + + MAX_DASH_LIST_SIZE) : NULL); +} +#endif + /* *---------------------------------------------------------------------- * @@ -240,7 +268,8 @@ void XFreeGC( { if (gc != None) { FreeClipMask(gc); - ckfree((char *) gc); + TkpFreeGCCache(gc); + ckfree(gc); } } diff --git a/xlib/xutil.c b/xlib/xutil.c index 267a624..0514d7a 100644 --- a/xlib/xutil.c +++ b/xlib/xutil.c @@ -68,7 +68,8 @@ XGetVisualInfo( XVisualInfo *vinfo_template, int *nitems_return) { - XVisualInfo *info = (XVisualInfo *) ckalloc(sizeof(XVisualInfo)); + XVisualInfo *info = ckalloc(sizeof(XVisualInfo)); + info->visual = DefaultVisual(display, 0); info->visualid = info->visual->visualid; info->screen = 0; @@ -99,7 +100,7 @@ XGetVisualInfo( || ((vinfo_mask & VisualBlueMaskMask) && (vinfo_template->blue_mask != info->blue_mask)) ) { - ckfree((char *) info); + ckfree(info); return NULL; } |