[cairo] Dithering

Behdad Esfahbod behdad at behdad.org
Mon Apr 7 14:36:48 PDT 2008


On Tue, 2008-04-01 at 10:54 -0700, Keith Packard wrote:
> On Tue, 2008-04-01 at 03:54 +0400, Behdad Esfahbod wrote:
> 
> > The hard part about dithering in cairo is that compositing requires to
> > read back the drawable contents, compose to it, and put it back.  So if
> > one's not careful, the dithering adjustment can accumulate and show very
> > bad effect.  I "fix" that by subtracting the dithering adjustment when
> > getting the image from the server.  Seems to work fine.
> 
> What i'd like to see is to have the xlib backend just keep a 32-bit
> image on the client side and never fetch bits back from the server, that
> way the dithering would be done only on put-image.

Should this be done in a higher level?  Many (all?) backends can benefit
from that.

When doing such a thing, it would make a lot of sense to take advantage
of cairo_surface_flush().  But then we cannot assume that people are
even calling that function at all, let alone correctly.  Same about
cairo_surface_mark_dirty().  So as we discussed on IRC the other day, we
need some new API, say, cairo_surface_freeze/thaw() or begin/end(), and
do all the optimizations only if frozen.  Then making Gtk+ and firefox
use it correctly is not that hard.

> As a side-effect, drawing without Render would become a lot faster too.
> 
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list