[cairo] API proposal: cairo_format_from_content and cairo_content_from_format

Radek Doulik rodo at novell.com
Tue Apr 24 14:40:55 PDT 2007


On Tue, 2007-04-24 at 01:35 -0400, Behdad Esfahbod wrote:
> On Tue, 2007-04-24 at 07:54 +0300, Mox Soini wrote:
> > Hi Carl, others.
> > 
> > The function using that conversion in OOo is the OOo's equivalent "get similar":
> > 
> > Surface* Surface::getSimilar( Content aContent, int width, int height );
> > 
> > See:
> > http://go-ooo.org/bonsai/cvsview2.cgi?diff_mode=context&whitespace_mode=show&subdir=gsl/canvas/source/cairo&command=DIFF_FRAMESET&file=cairo_cairo.cxx&rev1=1.4&rev2=1.4.28.1&root=/var/cvsup
> > 
> > That getSimilar boils down to platform specific cairo calls, or a
> > generic one, which are:
> > MACOSX:
> > - cairo_quartz_surface_create( nFormat, width, height ));
> > WIN32:
> > - cairo_win32_surface_.... (... nFormat...);
> > X11:
> > - cairo_xlib_surface_create_with_xrender_format( ... pFormat );
> > GENERIC:
> > - cairo_surface_create_similar( mpSurface, aContent, width, height )
> > 
> > note:
> > nFormat = cairoHelperFormatFromContent(aContent);
> > pFormat = XRenderFindStandardFormat(...
> > cairoHelperX11FormatFromContent(Content aContent)...);
> 
> Ok, so the obvious question would be: why doesn't the generic path work
> for all platforms?

	Because I need the system level drawable to do the text rendering which
unfortunately has to happen in another part of OOo.

	I still use cairo 1.0.x and so it is impossible to get the X11 drawable
(or other system level drawable on the other platforms) from a surface
created with cairo_surface_create_similar.

	Thus I am creating the drawable beforehand and pass it to
cairo_xlib_surface_create_with_xrender_format (similarly on other
platforms)

Cheers
Radek

> > Best Regards,
> > 
> >            Mox
> > 
> > P.S. I have not created the original OOo functions (e.g.
> > getSurface()), just doing porting work for Mac OS X...
> > 
> > On 4/24/07, Carl Worth <cworth at cworth.org> wrote:
> > > On Mon, 23 Apr 2007 17:32:39 -0400, Behdad Esfahbod wrote:
> > > > Given the definition above, it's apparently something image-surface
> > > > centric.  I was ignoring that until Max showed us how OO.o has the two
> > > > following functions implemented:
> > > >
> > > > Format cairoHelperFormatFromContent(Content aContent);
> > > > int cairoHelperX11FormatFromContent(Content aContent);
> > > >
> > > > Now that makes a lot more sense.
> > >
> > > Yeah, that's really the only way it would start making any
> > > sense. Within the context of a given backend, you could want to ask
> > > what format is associated with the surface returned by create_similar
> > > for a particular content value.
> > >
> > > But even then, it still doesn't make a lot of sense. For example, if
> > > you're running an X server with a 565 visual, then doing
> > > create_similar with CAIRO_CONTENT_COLOR will give you a surface
> > > targeting an X11 Pixmap with a 565 visual. But we still don't have any
> > > cairo_format_t to describe that, so I don't see how trying to map a
> > > content to a format in an "xlib aware" fashion would help.
> > >
> > > I guess I still don't see where this would be used. In what sequences
> > > does OO.o find this useful?
> > >
> > > -Carl
> > >
> > > _______________________________________________
> > > cairo mailing list
> > > cairo at cairographics.org
> > > http://cairographics.org/cgi-bin/mailman/listinfo/cairo
> > >
> > >
> > 
> > 



More information about the cairo mailing list