[cairo] Meta surface proposal

Carl Worth cworth at redhat.com
Mon Feb 7 11:34:33 PST 2005


On Sun, 06 Feb 2005 16:22:59 -0500, Owen Taylor wrote:
> Here's some more details about what I was thinking about for doing 
> printer fallbacks.

Owen, Thanks for starting some discussion on this. It looks very
useful.

> cairo_meta_surface_t is a helper surface type that is used for surface
> types where:

The proposed interface for cairo_meta_surface_t looks quite
reasonable. We might want to change one part of it, from:

>  void cairo_meta_surface_create (cairo_format_t format,
>                                  int            width,
>                                  int            height);
> 
>  void cairo_meta_surface_replay (cairo_surface_t *surface,
>                                  cairo_surface_t *target);

to instead be:

void cairo_meta_surface_create (cairo_format_t format,
                                int            width,
                                int            height,
				cairo_surface_t *target);

void cairo_meta_surface_replay (cairo_surface_t *surface);

I'll discuss the reason for this below.

> cairo_win32_composite_trapezoids() would schematically
> look like:
> 
>  /* Determine whether we need to draw the trapezoids as a fallback */
> 
>  if (surface->meta_surface && !surface->replaying) {
>      if (need_fallback)
>          cairo_meta_surface_set_mode (surface, CAIRO_META_MODE_FALLBACK); 
>      else
>          cairo_meta_surface_set_mode (surface, CAIRO_META_MODE_NATIVE); 
> 
>      _cairo_surface_composite_trapezoids (surface->meta_surface, ...)
>  } else {
>      if (need_fallback)
>         return CAIRO_INT_STATUS_UNSUPPORTED:
> 
>      /* Draw trapezoids natively */
>  }

Calling into the same function for such totally different reasons
(replaying vs. not), seems messy here. I think the problem is in
having the real surface own the meta-surface. And the "if" portion of
that statement above looks like its going to be duplicated over and
over in any meta-surface using backend, with only the needs_fallback
condition changing.

I think it would be cleaner to leave the "real" backend functions like
they are now (the else case above), and add the "needs_fallback"
predicates to the backend interface.

That way, the fallback vs. native handling can all be handled internal
to the meta-surface, (so cairo_meta_surface_set_mode wouldn't have to
be exposed).

-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/20050207/8141225a/attachment.pgp


More information about the cairo mailing list