Esempio n. 1
0
void
XftMemAlloc (int kind, int size)
{
    if (XftDebug() & XFT_DBG_MEMORY)
    {
	XftInUse[kind].alloc_count++;
	XftInUse[kind].alloc_mem += size;
	XftAllocCount++;
	XftAllocMem += size;
	XftAllocNotify += size;
	if (XftAllocNotify > XftMemNotice)
	    XftMemReport ();
    }
}
Esempio n. 2
0
void
XftMemFree (int kind, int size)
{
    if (XftDebug() & XFT_DBG_MEMORY)
    {
	XftInUse[kind].free_count++;
	XftInUse[kind].free_mem += size;
	XftFreeCount++;
	XftFreeMem += size;
	XftFreeNotify += size;
	if (XftFreeNotify > XftMemNotice)
	    XftMemReport ();
    }
}
Esempio n. 3
0
_X_HIDDEN XftDisplayInfo *
_XftDisplayInfoGet (Display *dpy, FcBool createIfNecessary)
{
    XftDisplayInfo	*info, **prev;
    XRenderPictFormat	pf;
    int			i;
    int			event_base, error_base;

    for (prev = &_XftDisplayInfo; (info = *prev); prev = &(*prev)->next)
    {
	if (info->display == dpy)
	{
	    /*
	     * MRU the list
	     */
	    if (prev != &_XftDisplayInfo)
	    {
		*prev = info->next;
		info->next = _XftDisplayInfo;
		_XftDisplayInfo = info;
	    }
	    return info;
	}
    }
    if (!createIfNecessary)
	return NULL;

    info = (XftDisplayInfo *) malloc (sizeof (XftDisplayInfo));
    if (!info)
	goto bail0;
    info->codes = XAddExtension (dpy);
    if (!info->codes)
	goto bail1;
    (void) XESetCloseDisplay (dpy, info->codes->extension, _XftCloseDisplay);

    info->display = dpy;
    info->defaults = NULL;
    info->solidFormat = NULL;
    info->hasRender = (XRenderQueryExtension (dpy, &event_base, &error_base) &&
		       (XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != NULL));
    info->use_free_glyphs = FcTrue;
    if (info->hasRender)
    {
	int major, minor;
	XRenderQueryVersion (dpy, &major, &minor);
	if (major < 0 || (major == 0 && minor <= 2))
	    info->use_free_glyphs = FcFalse;

	pf.type = PictTypeDirect;
	pf.depth = 32;
	pf.direct.redMask = 0xff;
	pf.direct.greenMask = 0xff;
	pf.direct.blueMask = 0xff;
	pf.direct.alphaMask = 0xff;
	info->solidFormat = XRenderFindFormat (dpy,
					       (PictFormatType|
						PictFormatDepth|
						PictFormatRedMask|
						PictFormatGreenMask|
						PictFormatBlueMask|
						PictFormatAlphaMask),
					       &pf,
					       0);
    }
    if (XftDebug () & XFT_DBG_RENDER)
    {
	Visual		    *visual = DefaultVisual (dpy, DefaultScreen (dpy));
	XRenderPictFormat   *format = XRenderFindVisualFormat (dpy, visual);

	printf ("XftDisplayInfoGet Default visual 0x%x ",
		(int) visual->visualid);
	if (format)
	{
	    if (format->type == PictTypeDirect)
	    {
		printf ("format %d,%d,%d,%d\n",
			format->direct.alpha,
			format->direct.red,
			format->direct.green,
			format->direct.blue);
	    }
	    else
	    {
		printf ("format indexed\n");
	    }
	}
	else
	    printf ("No Render format for default visual\n");

	printf ("XftDisplayInfoGet initialized, hasRender set to \"%s\"\n",
		info->hasRender ? "True" : "False");
    }
    for (i = 0; i < XFT_NUM_SOLID_COLOR; i++)
    {
	info->colors[i].screen = -1;
	info->colors[i].pict = 0;
    }
    info->fonts = NULL;

    info->next = _XftDisplayInfo;
    _XftDisplayInfo = info;

    info->glyph_memory = 0;
    info->max_glyph_memory = XftDefaultGetInteger (dpy,
						   XFT_MAX_GLYPH_MEMORY, 0,
						   XFT_DPY_MAX_GLYPH_MEMORY);
    if (XftDebug () & XFT_DBG_CACHE)
	printf ("global max cache memory %ld\n", info->max_glyph_memory);


    info->num_unref_fonts = 0;
    info->max_unref_fonts = XftDefaultGetInteger (dpy,
						  XFT_MAX_UNREF_FONTS, 0,
						  XFT_DPY_MAX_UNREF_FONTS);
    if (XftDebug() & XFT_DBG_CACHE)
	printf ("global max unref fonts %d\n", info->max_unref_fonts);

    memset (info->fontHash, '\0', sizeof (XftFont *) * XFT_NUM_FONT_HASH);
    return info;

bail1:
    free (info);
bail0:
    if (XftDebug () & XFT_DBG_RENDER)
    {
	printf ("XftDisplayInfoGet failed to initialize, Xft unhappy\n");
    }
    return NULL;
}