mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
LibGfx: Add early bounds checking to accumulate_non_zero_scanline()
Nonzero fills are much more common (as the default fill rule), so if this does result in any speed-up it makes sense to do it here too.
This commit is contained in:
parent
9a3470c2c5
commit
8988dce93d
Notes:
sideshowbarker
2024-07-17 02:59:43 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/8988dce93d Pull-request: https://github.com/SerenityOS/serenity/pull/24459
|
@ -323,13 +323,15 @@ template<unsigned SamplesPerPixel>
|
|||
auto EdgeFlagPathRasterizer<SamplesPerPixel>::accumulate_non_zero_scanline(EdgeExtent edge_extent, auto init, auto sample_callback)
|
||||
{
|
||||
NonZeroAcc acc = 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) {
|
||||
if (auto edges = m_scanline[x]) {
|
||||
if (auto edges = m_scanline.data()[x]) {
|
||||
// We only need to process the windings when we hit some edges.
|
||||
for (auto y_sub = 0u; y_sub < SamplesPerPixel; y_sub++) {
|
||||
auto subpixel_bit = 1 << y_sub;
|
||||
if (edges & subpixel_bit) {
|
||||
auto winding = m_windings[x].counts[y_sub];
|
||||
auto winding = m_windings.data()[x].counts[y_sub];
|
||||
auto previous_winding_count = acc.winding.counts[y_sub];
|
||||
acc.winding.counts[y_sub] += winding;
|
||||
// Toggle fill on change to/from zero.
|
||||
|
@ -339,8 +341,8 @@ auto EdgeFlagPathRasterizer<SamplesPerPixel>::accumulate_non_zero_scanline(EdgeE
|
|||
}
|
||||
}
|
||||
sample_callback(x, acc.sample);
|
||||
m_scanline[x] = 0;
|
||||
m_windings[x] = {};
|
||||
m_scanline.data()[x] = 0;
|
||||
m_windings.data()[x] = {};
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue