1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:27:43 +00:00

LibGfx: Add Painter::fill_pixels()

This function fills a region of pixels with the result of a callback
function. This is an alternative to a for loop that repeatedly calls
Painter::set_pixel(), which can get very expensive due to the clipping
checks set_pixel() does each call.
This commit is contained in:
MacDue 2022-12-24 14:18:53 +00:00 committed by Andreas Kling
parent 7e701f6256
commit ca01017f32
2 changed files with 30 additions and 1 deletions

View file

@ -1842,7 +1842,14 @@ void Painter::set_pixel(IntPoint p, Color color, bool blend)
// scaling and call set_pixel() -- do not scale the pixel.
if (!clip_rect().contains(point / scale()))
return;
auto& dst = m_target->scanline(point.y())[point.x()];
set_physical_pixel(point, color, blend);
}
void Painter::set_physical_pixel(IntPoint physical_point, Color color, bool blend)
{
// This function should only be called after translation, clipping, etc has been handled elsewhere
// if not use set_pixel().
auto& dst = m_target->scanline(physical_point.y())[physical_point.x()];
if (!blend || color.alpha() == 255)
dst = color.value();
else if (color.alpha())