Re: Computing cairo surface dimensions in advance



Am Dienstag, den 12.12.2006, 15:07 -0500 schrieb Behdad Esfahbod: 
> On Mon, 2006-12-11 at 17:35 -0500, Daniel Elstner wrote:
> > 
> > 'Tis ain't pretty.  Is the code above actually correct?  Is there a
> > better to do this kind of thing?
> 
> What you say is basically correct.  Currently you first need to create a
> tiny surface to measure a PangoLayout before you create your final
> surface.  Any suggestions how to improve this?

Tough one, as I don't think I understand all of the implications yet.
It'd help a lot if the documentation of pango_cairo_update_context()
would elaborate a little on when and why it needs to be called, and shed
some light on the corner cases.

For instance, a strict reading of "if you change the transformation or
target surface" would suggest that cairo_translate() and cairo_move_to()
aren't equivalent wrt. pango_cairo_update_context().  In fact even the
cairosimple.c example seems to rely on cairo_move_to() to be safe.  What
happens if I move_to or translate by non-integer coordinates; is there a
difference in behavior?

>From my limited understanding, the update after changing the target
surface is necessary because hinting might be done differently, like
when switching from subpixel AA on the screen to an image surface in
memory with only an alpha channel.  And wrt. transformation, an update
would be in order whenever there are changes to the fractional part of
any used coordinate after transformation.

If these were really the only cases requiring an update then it could be
stated that integer transformations with unchanged surface type are safe
to use without pango_cairo_update_context().  But I reckon that there
are more restrictions necessitating the update.  Still, even if a
blanket statement like that isn't possible it'd be great if the
requirements were stated more clearly.  For instance, right now the
documentation doesn't really allow for changing the target the surface
at all, even if its type stays the same.

Bah, I'm writing way too much again, so that's it for now.  Please tell
me if I'm not making any sense.

Cheers,
--Daniel





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]