[cairo] cairo -> cairo c src backend

Behdad Esfahbod behdad at behdad.org
Fri Sep 22 13:12:10 PDT 2006


On Fri, 2006-09-22 at 11:10 -0700, Carl Worth wrote:
> Yes, I've had this idea at various times. I've never wanted anything
> that would be very complete, (in the cases I've wanted this, I
> wouldn't care to get C code to reconstruct the source surfaces, for
> example), but it would be convenient to be able to grab snippets of
> code or at least some statistics about what operations are being
> performed at various times. 

I also had this other idea of reimplementing the paginated stuff using
the decorator pattern.  Currently paginated is implemented as a single
decorator, while it shouldn't really be.  The concept of a paginated
surface is different from the concept of a surface needing whole-page
analysis.  For example, an animated PNG can be thought of as a paginated
surface, but the current paginated infrastructure doesn't allow that.
What we need is decorators for:

  - paginated
  - analysis
  - logging
  - imagefallback
  - ...

the logging decorator will print out all the operations performed on it
as cairo code to a log file.  It will even have a stack of
enable/disable states, so you can do things like:

void draw (cr)
{
  cairo_surface_t *surface = cairo_get_target (cr);
  cairo_logging_surface_save_logging (surface);
  cairo_logging_surface_set_logging (surface, TRUE);
  ...drawing code...
  cairo_logging_surface_restore_logging (surface);
}

This way, with non-logging surfaces you get no extra functionality, nor
errors, but if the context is connected to a surface which is a logging
decorator, you get the drawing instructions of draw() logged.

Similarly, you should be able to create a paginated surface out of any
surface, by just giving the paginated constructor a surface, a show_page
and a start_page callback, and user data.

Same for analysis.  It can be used to check whether performed operations
are supported on the backend of the surface passed in to the
constructor.

Then there's the imagefallback decorator.  It uses the metasurface and
analysis decorator to implement what we are currently doing in PS and
PDF backends.

Given these, we will be able to construct the PS backend as a paginated
decorator for an imagefallback decorator.


-- 
behdad
http://behdad.org/

"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
        -- Dan Bern, "New American Language"



More information about the cairo mailing list