mandag den 31. oktober 2011

Rasterizing

Tonight I reviewed the FreeType rasterizer and a couple of other sources. What I found was that the FreeType rasterizer does not handle self-intersecting glyphs (glyphs or outlines, not just contours), but this is not a real problem since glyphs are not supposed to be self-intersecting anyway, and even so, the error that is introduced may not even be noticeable. FreeType supports the Non-Zero Winding Rule as well as the Even-Odd rule.

I shall use an algorithm similar to FreeType, but I am aiming for simplicity, and I shall take a lot of shortcuts compared to the FreeType rasterizer. I believe I shall store cells in arrays rather than linked lists, and include a qsort in the final sweep. A mailing list post seems to indicate that this is what FreeType used to do.

Thinking about it, I might make the buffer large enough for every pixel - this would be a sacrifice of memory for ultimate speed. I will be limiting the band to around 6 lines anyway. Still... 320 times 6 times 8 - 16kbytes... too much yea. Sorry if I am thinking aloud here.

Perhaps a hash table? I think I prefer that to linked lists. To avoid linked lists I would then use open addressing with linear probing. I would have to make sure that the load factor was sufficiently low. No, wait, a hash table is not nice to iterate. Oh dear I am committing a cardinal sin now: premature optimization. I shall have to compare different buffering schemes at various glyph complexities and sizes. A mammoth task.

Ah, all the beautiful code and information that is available by the click on a link.

Ingen kommentarer:

Send en kommentar