[haiku-development] Re: Text rendering

* Stephan Assmus (superstippi@xxxxxx) wrote:
> Another option is to simply change *the existing* drawing mode 
> implementations to work with subpixel alpha scanlines (so that you don't 
> have to special case text). This would give you LCD subpixel rendering for 
> all vector shapes, not just text. And that would of course seriously rock 
> (no one does that as far as I know), only downside being that it has three 
> times the rendering time. Which might not matter much, since we bypass the 
> vector rendering in most usage cases anyways.
> 

I started coding today, and I think I ended up going with this method
you described above. I have done so far the following:
        * created a scanline_u32 type, exactly as scanline_u8,
          except with a int32u cover. This wastes the 4th word,
          since we only have R/G/B alpha values, but is cleaner
          than working with scanline_u8.
        * typedef'd m_scanline_subpixel to this type.
        * added a glyph_ren_native_subpixel mode.
        * created a decompose_ft_bitmap_subpixel function to
          take the freetype bitmap from FT_RENDER_MODE_LCD and
          put it in a scanline_u32.

I think that's it. I'm getting seriously confused on the font cache
stuff. I don't know where to define a subpixel_adaptor(), renderer and
subpixel_scanline for fFontCache. Heck, I don't even know what the
gray8_adaptor() does, so I don't even know how to approach
subpixel_adaptor() even if I could find where it went.

I know I have to write a blend routine for the r/g/b alpha values, but I
don't know where that'd go. I've been reading the AGG docs, but I'm
still a little confused. As far as the actual blending, I found this on
a post by David Turner:

       dst.r += (src.r - dst.r) * alpha.r;
       dst.g += (src.g - dst.g) * alpha.g;
       dst.b += (src.b - dst.b) * alpha.b;

This seems to do what I need to do.

I'm doing a lot of stuff in headers/libs/agg, which I assume is OK.

So... am I on the right track, or totally off base?

Thanks again!
-Claudio

Other related posts: