[cairo] API proposal: cairo_format_from_content and cairo_content_from_format

Mox Soini mox at iki.fi
Tue Apr 24 12:36:47 PDT 2007


(sorry for spam...)

Is there a way to get struct XRenderPictFormat  (of Xrender.h) from a
cairo surface?

This seems to be needed for OOo's internal processing...

      Mox

On 4/24/07, Mox Soini <mox at iki.fi> wrote:
> > If there is support for this in win32 too, we could simplify the
> > getSimilar code a lot!
> >
> > Could you cairo guys check, if the getThing thing works for win32 backend?
> >
>
> Replying to myself :)
>
> The CWS (i.e. cvs branch) wincairo01 has this piece of code:
> ... = cairo_win32_surface_get_dc(pSurface->mpSurface);
>
> which is used at the same place as Mac OS X's getContext, so win32
> seems to have the requisite code :)
>
> Going further, where Quartz and Win32 have just one variable stored,
> X11 uses actually two:
>   aSystemGraphicsData.hDrawable = pSurface->getPixmap();
>   aSystemGraphicsData.pRenderFormat = pSurface->getRenderFormat();
>
> But since the xlib surface supports also
> cairo_xlib_surface_get_depth() et al., it is no obstacle :)
>
> Hey, this is fun :) I'm gonna do some experiments...
>
>        Mox
>
> > On 4/24/07, Behdad Esfahbod <behdad at behdad.org> wrote:
> > > On Tue, 2007-04-24 at 17:40 -0400, Radek Doulik wrote:
> > > > > 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.
> > >
> > > Ok, makes sense.  But with cairo 1.4.4 already out, isn't it time to
> > > move to 1.2?  1.2 provides cairo_xlib_surface_get_drawable.  I assume
> > > similar API may be missing in other backends, but we will not be able to
> > > magically add it if you don't tell us about it.  Please do so.
> > >
> > >
> > > Thanks,
> > > behdad
> > >
> > > >       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
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > >
> > > > _______________________________________________
> > > > cairo mailing list
> > > > cairo at cairographics.org
> > > > http://cairographics.org/cgi-bin/mailman/listinfo/cairo
> > > --
> > > behdad
> > > http://behdad.org/
> > >
> > > "Those who would give up Essential Liberty to purchase a little
> > >  Temporary Safety, deserve neither Liberty nor Safety."
> > >         -- Benjamin Franklin, 1759
> > >
> > >
> > >
> > >
> >
> >
> > --
> > Mox on G
> >
>
>
> --
> Mox on G
>


-- 
Mox on G


More information about the cairo mailing list