With the context manager support for surfaces this also has started to
work for mapped images but finishing a mapped one is undefined.
Add a new __exit__() which unmaps the image instead and makes this valid:
with surface.map_to_image(None) as image:
pass
Instead cast the parsed int explicitly to the enum type which
might be unsigned.
Still not perfect, as the enum type can be smaller, but I don't
think any compiler does that.
This keeps the same API as cairo but adds some additional checks
to prevent crashes. Those cases still are undefined but at least
you get some error messages.
* It adds a new ImageSurface subtype so we can do some type checking.
* It swaps the underlying image surface to a dummy finished one
when it gets unmapped so that operations after unmap
on the wrapper don't crash.
* It checks if the source surface is correct when unmapping.
Turns out the buffer/memoryview API can only be used in implementations
of the buffer protocol of some object and the current approach
worked by accident and for some unknown reason leaked the exporter as
well.
This creates a new Python class implementing the buffer interface,
which takes the buffer information and is only used to keep the
image surface alive and to hand out memory views.
In case the last view dies, the proxy will die and unref the image
surface.
level_to_string() already existed under ps_level_to_string() but the
naming is inconsistend with similar functions.
This just adds another alias and adds a note in the docs.
In case the cairo.Surface got deallocated it took the base object with it, but the surface
could still be referenced from some other place like a cairo.Context/SurfacePattern.
In case the referencing object would then try to use the surface things crash.
Tie the lifetime to the actual object instead using the user_data API.
Add Surface.set_mime_data(), Surface.get_mime_data(),
Surface.supports_mime_type(), HAS_MIME_SURFACE, MIME_TYPE_*.
set_mime_data() takes a buffer and keeps it alive.
get_mime_data() tries to return the same object.
This extends the cairo.Error exception type to have a status attribute
containing the cairo_status_t constants. This is what cairocffi
implements and will also make testing for specific error cases easier.
Also adds an cairo.CairoError alias to be compatible with the default
cairocffi naming.
Switch some functions which raise cairo.Error on programming errors
to ValueError, so we have a valid status value in all cases.
This reverts commit e00cd9d634.
Fedora builds pycairo with xpyb and has some packages depending on it.
So we have to keep it and figure out how to build it.
It's Python 2 only and was never enabled for py2/3 on debian/ubuntu
so this should not change much.
Handle instantiating of XCBSurface like is currently done for
XlibSurface. Getting an instance through the C-API still works.
If support gets added back we should look into xcffib, which is
what cairocffi uses. It also has the advandage that we don't
have to link against it and can use it at runtime.