[PATCH 1/4] dix: Provide means to report exact sizes of resources.

Alan Coopersmith alan.coopersmith at oracle.com
Fri Oct 29 13:55:18 PDT 2010


Rami Ylimäki wrote:
>  On 10/28/2010 04:48 PM, Alan Coopersmith wrote:
>>> +/**
>>> + * Get the function used to calculate resource size. Extensions and
>>> + * drivers need to be able to determine the current size calculation
>>> + * function if they want to wrap or override it.
>>> + *
>>> + * @param[in] type     Resource type used in size calculations.
>>> + *
>>> + * @return Function to calculate the size of a single
>>> + *                     resource.
>>> + */
>>> +SizeType
>>> +GetResourceTypeSizeFunc(RESTYPE type)
>>> +{
>>> +    return resourceTypes[type&  TypeMask].sizeFunc;
>>> +}
>> Should this add dixPrivatesSize(type) to the result or should the callers
>> like Xresource be doing that?
>>
> 
> The original intention was that Xresource wouldn't do that automatically
> and the functions returned by that getter would calculate the size as
> well as they can. The resourceSize field of ResourceSizeRec should be
> filled with the amount of memory that is freed when the resource doesn't
> exist anymore.
> 
> It's probably best to add sizeof(PixmapRec) and
> dixPrivatesSize(PIXMAP_PRIVATE) to the result in GetPixmapBytes to get
> better estimate for the size and also to make GetPixmapBytes an example
> for other size calculation functions. I can do that in v2 of the patch
> if this change seems sensible to you.

I was thinking more of the other resource types than pixmaps there, though
for most resource types the private size is the same for all resources.
The idea was just better estimating the size after all the extensions have
put their hooks/structs into each type of resource.

I also had a brain fart that morning thinking that the type arguments to
GetResourceTypeSizeFunc & dixPrivatesSize were the same, but they're not
so you'd need to map the resource type to the privates structure type if
you were to do that.

(It really was a question for discussion, not something I was at all sure
 was the right thing to do.)

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list