[cairo] Snapping to pixels in Gecko

Robert O'Callahan rocallahan at gmail.com
Fri Apr 22 13:32:55 PDT 2005


On 4/23/05, Owen Taylor <otaylor at redhat.com> wrote:
> 
> Leaving that question aside, I really think you should be pixel
> snapping coordinates before calling Cairo in what you've shown there...
> 
> (I don't really mean to just round the coordinates immediately before
> calling Pango, I mean to chose coordinates that are properly pixel
> aligned. E.g., if you ask Pango for the underline thickness it always
> gives you an integer value when font hinting is on ... so you don't
> get the smeary underline in your screenshot)


(Actually I think the underline in the screenshot is exactly 1px high. I 
think the problem is that some font-height isn't snapped to an integral 
number of pixels so the underline spans two pixel rows. But that doesn't 
detract from your main point...)

Turning off antialiasing either is going to cause a huge performance
> hit (for FSAA)


Though we'll probably need FSAA anyway to deal with the adjoining edges 
problem.

or going to lose antialiasing.


That would be OK too since we currently don't have it. And if we 
pixel-snapped everything we wouldn't be using it anyway!

Now, maybe you could
> only antialias some things and not others, but in general, if you
> could make that determination easily, you could pixel snap edges
> easily.


We discussed this before and I still don't agree :-). Here are my current 
thoughts.
http://wiki.mozilla.org/Mozilla2:Antialiasing
You're welcome to edit. My issues with the pixel-snapping approach are here:

   - It means that layout of a page inherently depends on device 
   resolution; we'd like layout to be as device-independent as possible. 
   - It is probably not correct according to the CSS spec, which 
   definitely allows for fractional pixel measurements, and does not explicitly 
   allow for rounding. 
   - It will not work if the presentation is scaled or rotated. 
   - It's a huge amount of work to implement in our code base. 

About scaling... we need to be able to zoom in and out with arbitrary scale 
factors without relaying-out the document.

Also, note that Cairo performance will be *much* better for drawing
> rectangles if you pixel snap the edges, as of recently, as it can
> then use rectangle drawing fast paths.


If we turn off antialiasing, similar performance benefits should apply.

Rob
-- 
["Therefore, my dear friends, as you have always obeyed–not only in my
presence, but now much more in my absence–continue to work out your
salvation with fear and trembling, for it is God who works in you to will
and to act according to his good purpose." Philippians 2:12-13.]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/cairo/attachments/20050423/4f864488/attachment.htm


More information about the cairo mailing list