[haiku-development] Re: Text rendering

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 14 Jun 2007 21:53:18 +0200

Hi,

Claudio Leite wrote (2007-06-14, 20:19:30 [+0200]):
> * 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.

But this looks like you're not doing what I said in above quote, but 
implement subpixel rendering for text only. Which is fine... don't get me 
wrong.

> 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.

Sorry, I have not looked into that closely enough. Maybe you should subscribe 
to the AGG mailing list and ask Maxim directly. He is usually very helpful. 
And you'd probably get some comments from other people as well, since the 
subject is quite interesting and came up in the past without satisfactory 
results. ;-)

> 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 don't really know. All I know is that you have to "filter". This was also 
here in the links that Ryan posted:

<http://www.grc.com/cttech.htm>

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

I think you should copy stuff and then change it. Otherwise we will have a 
hard time upgrading AGG.

Thanks a lot for your work!

Best regards,
-Stephan

Other related posts: