PS/PDF API Change Proposal: (Re: [cairo] Semantics of transparent objects)

Carl Worth cworth at cworth.org
Wed Jan 18 12:07:17 PST 2006


On Wed, 18 Jan 2006 11:12:43 -0800, Keith Packard wrote:
> 
> Seems like these are more likely associated with the surface and not the
> drawing state.

This isn't as obvious to me, though you may be correct.

> I see something like:
> 
> surface = cairo_ps_surface_create ();
> 
> while (more pages)
> {
> 	set page options (surface);
> 	draw_surface (surface);
> 	cr = cairo_create (surface);
> 	cairo_show_page (cr);
> 	cairo_destroy (cr);
> }

How is that fundamentally "better" than the following?

surface = cairo_ps_surface_create ();
cr = cairo_create (surface);

while (more pages)
{
	set page options (cr);
	draw_surface (cr);
	cairo_show_page (cr);
}

> In this way, draw_surface is independent of the target, and only this
> outer loop "knows" about printing at all.

Isn't that the same in my example? Or is the point that your proposal
would make it harder for the user to violate this model? (which would
require using cairo_get_target within draw_surface).

The question I'm trying to answer is given some imagined
functionality, how do we decide what should be a cairo_surface_t
function and what should be a cairo_t function. (And remember that in
the past there was even debate over whether there should be any object
separation at all.) The fact that once created, a cairo_t cannot be
separated from its target surface does also muddle the issue
sometimes.

What is clear is that functionality for drawing the contents of a
surface, (along with all the necessary state for such drawing),
belongs in cairo_t.

So what's the guiding principle that says where this new functionality
belongs?

One thing that has been mentioned in this thread is that we'll need
per-page size settings. For some existing backends we do already have
functions such as:

	cairo_xlib_surface_set_size

And, as size is something that is generally passed to the
surface_create functions, it certainly makes sense that setting the
surface size is a cairo_surface_t kind of function. (Not to mention
the fact that this is a backend-specific function and while we have
backend-specific cairo_surface functions, we don't have any
backend-specific cairo_t functions).

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060118/51be77b2/attachment.pgp


More information about the cairo mailing list