[cairo] Where's the bottleneck in using glitz/cairo/librsvg?

Bill Spitzak spitzak at d2.com
Thu Jun 15 11:14:31 PDT 2006



Alexander Larsson wrote:

> On Thu, 2006-06-15 at 01:28 -0700, Jamey Sharp wrote:
>> It seems to me that run-length encoding a rasterized image will get you
>> almost as compact as a bunch of spanlines. I'd think gzip compression
>> would do as well or better than RLE. If both are true then `ssh -C`
>> should suffice, rather than introducing a new request.
> 
> While that might be true for general images I doubt it is the case for
> e.g. a rasterized one-color polygon. In most case almost all lines in it
> will only be 1 pixel alpha, 1 span opaque color, 1 pixel alpha. The
> server can then composite these spanlines very efficiently against the
> background.

I agree with Jamey. If that polygon was encoded RLE, each line would 
reduce to X,black,R-X,white,EOL. This is hardly much bigger than the X,R 
needed to convey a scanline convex polygon, yet it also allows 
non-convex polygons and antialiasing to be sent.

Using a predictive compression scheme such as png/libz will always 
result in better compression than RLE, but with slower encoding/decoding 
times. A simple version I have had a lot of luck with is to take the 
difference between each pixel, all values between -7 and +7 are encoded 
as 4 bits, all others are encoded as four bits == 8 followed by the 
extra 8 bits (for a total of 12), and strings of zeros are encoded as 
four bits of 8 followed by -7 to +7, add 10 to get how many zeros to repeat.


More information about the cairo mailing list