View Full Version : Coverage buffer

01-09-2011, 09:11 PM
In riApp.cpp, renderStroke(), path->stroke() fills in covBuffer[] with coverage values, then calls pixelPipe->pixelPipe() in a loop to plot each pixel with a coverage filter that is effectively a box.

Why doesn't path->stroke() plot the pixels itself without having this covBuffer[] thing?

Modifying the code to do this shows little difference in the appearance of a diagonal 1-pixel wide line, and saves memory from having to allocate covBuffer[].

Ivo Moravec
01-10-2011, 04:16 PM
Firstly, I will say the mandatory:
The reference implementation is not made for speed. It's made for accuracy and picture quality.

In fact, the reference implementation is about 2 orders of magnitude slower than other software only implementations. Deliberately slowly in fact.

That said, it does make sense to calculate coverage first, then paint it. Painting an object with a solid color is trivially easy, and yes, it would benefit from doing the draw in a better way. But what about paint gradients and textures?

In both of these cases, it is common that in the space occupied by a single pixel on the screen, several different color stops or texels are in that pixel. The coverage filter samples the region correctly to give a correct sum of the colors in that pixel. This is a step most implementations skimp on.

If you're looking for fast OpenVG code, do not look at the reference implementation. It's really a tool for people who create faster OpenVG drivers for verifying that their output is correct, that's about it.

01-10-2011, 05:03 PM
I figured it out now. This does an ORing operation to update pixels from previous rasterizations:
r->m_covBuffer[j*clip->w + i] |= (RIuint32)sampleMask;