ultimatepp/uppdev/ScanLine/Rasterizer2.hpp
cxl 5e29501484 New rasterizer finally faster than AGG...
git-svn-id: svn://ultimatepp.org/upp/trunk@828 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2009-01-31 13:40:25 +00:00

42 lines
797 B
C++

#include "ScanLine.h"
inline unsigned Alpha(int area)
{
int cover = area >> 9;
if(cover < 0) cover = -cover;
/* if(evenodd) {
cover &= 511;
if(cover > 256)
cover = 512 - cover;
}*/
if(cover > 255) cover = 255;
return (cover + 1) / 2;
}
template <class Target>
void Rasterizer::Render(int y, Target& g)
{
PAINTER_TIMING("Render");
const Cell *c, *e;
if(!BeginRender(y, c, e))
return;
g.Start(c->x);
int cover = 0;
while(c < e) {
int x = c->x;
int area = c->area;
cover += c->cover;
c++;
while(c < e && c->x == x) {
area += c->area;
cover += c->cover;
c++;
}
if(area) {
g.Render(Alpha((cover << (8 + 1)) - area));
x++;
}
if(c < e && c->x > x)
g.Render(Alpha(cover << (8 + 1)), c->x - x);
}
}