[cairo] A hidden offset for the xlib backend

Kristian Høgsberg krh at bitplanet.net
Thu Jan 6 12:17:15 PST 2005


Carl Worth wrote:
> On Sun, 05 Sep 2004 19:51:21 -0400, Owen Taylor wrote:
> 
>>Though if you really want to kill this slippery slope, of course, you
>>could add something like cairo_set_device_matrix() which set a final
>>matrix that was prepended to the CTM but hidden from the rest of
>>the public API.
> 
> 
> I finally took the time to digest this "hidden offset" thread.
> 
> The suggestion above seems the best to me.
> 
> I know we don't have any use for more than an offset now, but I'm bad
> at predicting the future, so I'd rather throw a whole matrix at it.
> 
> Also, I don't care about making this feature easy to use. In fact, the
> name above is way too simple and might lure people into using it
> improperly. I want something more like:
> 
> 	cairo_set_mysterious_hidden_transform_only_if_you_know_what_you_are_doing
> 
> or such.
> 
> If someone can suggest a name that accurately captures what this
> function does, that would be quite useful. "set_device_matrix" doesn't
> do it for me since it's insufficiently distinct from "set_matrix"
> which does set the user->device transform.
> 
> And, finally, do we want a cairo_function for this, or should we
> restrict it to a cairo_surface function, (cairo_xlib_surface ?). That
> might also help hide the wart away.

For the PDF backend I'm adjusting the PDF CTM so that the PDF user space 
matches the cairo device space.  I do this by outputting a PDF operator 
to change the CTM on each page.  I've been wanting to move this 
transformation into the backend so that the transformation (flipping the 
y-axis and scaling) is done in the cairo backend rather than in the PDF 
viewer.  My plan was to just keep a matrix in the backend and transform 
the coordinates manually before outputting them, but if this "hidden 
offset" was added to cairo, I would get this for free.

To hide this from the user visible API, maybe the function to adjust the 
hidden offset could be an cairo internal function to be used by the 
backends?  For the PDF case, the user shouldn't need to change it, it 
would just be set to the right value in the surface constructor. 
Likewise, as Keith suggests, the Xlib constructor could take extra 
arguments and adjust the hidden matrix internally.

Kristian



More information about the cairo mailing list