[cairo] Can I tell if cairo_image_surface_create_with_data() was called?

Bill Spitzak spitzak at thefoundry.co.uk
Tue Sep 16 21:24:50 PDT 2008


Actually I am trying to find out if it is ok to copy data into the image 
without it clobbering memory that does not belong to it.

But this brings up another question. If I have some image data in memory 
and I want to draw it, I was assuming it is most efficient if I do 
cairo_image_surface_create_with_data(), then draw it, then destroy it. 
The alternative is to use cairo_image_surface_create(), then memcpy the 
data into it, then draw it. I could see how the second could be more 
efficient if Cairo actually sets up shared memory with the video 
hardware, but somehow I doubt this is true in current versions. So I am 
not using this as a way to write to the memory, just to avoid copying it.

Behdad Esfahbod wrote:
> Bill Spitzak wrote:
>> Is there a way to tell if a cairo_surface_t was created with 
>> cairo_image_surface_create_with_data() as opposed to 
>> cairo_image_surface_create()? Basically I want to know whether it owns 
>> the data.
>>
>> It must know this because the destructor needs to know it so it can free 
>> the data.
> 
> You can schedule a free using the user_data mechanism.
> 
> behdad
> 
>> This call would be somewhat useful and it would keep with the idea of 
>> being able to query all the arguments passed to constructors for all 
>> Cairo objects.


More information about the cairo mailing list