LibGfx: Make accumulate_even_odd_scanline() go faster

...by checking scanline vector bounds before entering the loop.
This commit is contained in:
Aliaksandr Kalenik 2024-05-24 10:31:54 +01:00 committed by Andreas Kling
commit 05f9733192
Notes: sideshowbarker 2024-07-18 05:37:06 +09:00

View file

@ -309,10 +309,12 @@ template<unsigned SamplesPerPixel>
auto EdgeFlagPathRasterizer<SamplesPerPixel>::accumulate_even_odd_scanline(EdgeExtent edge_extent, auto init, auto sample_callback)
{
SampleType sample = init;
VERIFY(edge_extent.min_x >= 0);
VERIFY(edge_extent.max_x <= static_cast<int>(m_scanline.size()));
for (int x = edge_extent.min_x; x <= edge_extent.max_x; x += 1) {
sample ^= m_scanline[x];
sample ^= m_scanline.data()[x];
sample_callback(x, sample);
m_scanline[x] = 0;
m_scanline.data()[x] = 0;
}
return sample;
}