For a reason unknown to me, cairo_format_t is much more limited than the many options Pixman supports. The _cairo_image_surface_create_with_pixman_format function does let the user choose a format, but it is not normally exposed. I can think of many use cases. In particular, my issue was interaction with OpenGL ES 2.0: I am using Cairo to write to byte arrays which I later turn into GL textures. However, OpenGL ES 2.0 only support GL_RGBA, whereas Cairo's CAIRO_FORMAT_ARGB32 is equivalent to PIXMAN_a8r8g8b8. What I really need is PIXMAN_a8b8g8r8. Can this API be made public?
My simple patch, for those needing this feature: Edit cairo-image-surface.c, and add the following: cairo_surface_t *cairo_image_surface_create_with_pixman_format(unsigned char *data, pixman_format_code_t pixman_format, int width, int height, int stride) { return _cairo_image_surface_create_with_pixman_format(data, pixman_format, width, height, stride); } An example of calling the newly-exposed API: #include "cairo/cairo.h" #include "pixman.h" cairo_surface_t *cairo_image_surface_create_with_pixman_format(unsigned char *data, pixman_format_code_t pixman_format, int width, int height, int stride); cairo_surface_t *surface = cairo_image_surface_create_with_pixman_format(NULL, PIXMAN_a8b8g8r8, width, height, -1);
Patch from 2012 available at (but also look at the following discussion!): http://lists.cairographics.org/archives/cairo/2012-March/022852.html
I'm confused as to why exposing the internal APIs is a problem. If it's a matter of hiding Pixman from Cairo users, then these "advanced" features could potentially be enabled by including an extra header file, "cairo/cairopixman.h" or something of the sort. Is there any roadmap for solving this? In the meantime, I have to patch Cairo.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/45.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.