[sugar] Cairo tile engine, and accessing 565 buffers from cairo and C

Carl Worth cworth at redhat.com
Mon Apr 16 16:18:44 EDT 2007

On Mon, 16 Apr 2007 16:03:08 -0400, Dan Williams wrote:
>     source = cairo_surface_create_similar (target,
> 			width, height);
> gives you a 32-bit ARGB surface.

Yes, this is what I described as a likely cause.

Now, are you getting an xlib surface or an image surface from that?

> I can understand why; but in our case it's undesirable.  We'd rather
> have 16bpp, but _some_ kind of alpha.

This is why I asked what the X server provides. Is there some X server
visual that provides that? If so, then it's really trivial to fix
cairo_surface_create_similar to just use that and we're done.

> Ideally we could ask Cairo to create a surface of _any_ type we want,
> either 1555, 4444, 0565, 8888, 0888, 0444, etc.  But cairo can't do that
> AFAIK.  That's why I said "grudgingly supports 565" and "it's native
> format is really 32bpp".  When I say "manually create" a surface, I mean
> telling cairo _exactly_ what format of surface you want.

I still say that's a total mischaracterization of cairo.

Cairo's _image_ backend only accepts 32-bit surfaces. But the xlib
backend is usually much more _native_ anyway, (it's what lets you get
at access to GPU capabilities for example). And when "manually
creating" a surface with cairo's xlib backend you can definitely
create a surface with _exactly_ whatever formats are supported by your
X server.

When I say "manually creating" I mean using cairo_xlib_surface_create
instead of cairo_surface_create_similar. If you want an xlib surface
with a particular format, then you should be asking for it.

The reason to use cairo_surface_create_similar is when you don't
particularly care what kind of surface you want, (you likely don't
know what type the target surface is), and you just want to get the
best possible. And we can still fix the implementation of how cairo
implements "best possible".

But in the meantime, you can absolutely avoid that by just calling
cairo_xlib_surface_create with any X server visual. And cairo won't be
grudging at all.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.laptop.org/pipermail/devel/attachments/20070416/c235bfe5/attachment.sig>

More information about the Devel mailing list