March 2017
Mo Tu We Th Fr Sa Su
<< >>


Vector Graphics Engine

Posted on Apr 19 2005

Recently I'm writing a Vector Graphics Engine. Is it related to the Poll on mtasc list ? Maybe...

The major problem right now is about quality of SWF rendering. I checked a lot of opensource Flash Players, and as for AA, either they don't do at all, or they do with poor quality. I'm using the Libart library but I am not satisfied with AA. This comes from the SWF file format : when you draw one shape in SWF, you have two fills, one on the left and one on the right. That means that shapes that share a border are not two shapes but one shape with some edges that have both left and right fills.

I managed to extract single colored shapes by duplicating the common edges but when rendering, there is an AA hole between the shapes. That's because some pixels are covered for example at 70% by Shape A (red) and at 30% by Shape B (blue). The final color should then be :

    red * 0.7 + blue * 0.3

But since the shapes are rendered one over the other, you're first applying a 70% alpha red on background color, and then a 30% blue :

    (bgcolor * 0.3 + red * 0.7) * 0.7 + blue * 0.3

Which is not at all what we want. I had then hack into Libart to be able to get at rasterization-time a pointer to some segment custom data that would tell me which fill color there is at the right. Then if the fill is transparent we blend with background color else will blend with adjacent fillcolor. I wrote a line-rasterizer that plugs into libart to test it : this way the quality is better but not perfect yet.

Looking at the quality at AA of Macromdia (now Adobe) Flash Player compared to the speed of the renderer, I now understand they did a great job on the vector engine. Now I have to go back to try some different AA methods than the Exact Pixel Coverage calculation Libart is using : it's quite good but takes too much CPU (50% of Flash Player performances), maybe using fixed point calculations would speed a lot of things, and will open the way to add a 2x2 supersampling for better quality...

0 comment
Name : Email : Website : Message :