mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 09:25:07 +00:00
LibGfx: Make FastBoxBlurFilter go faster
When entering FastBoxBlurFilter::apply_single_pass(), we VERIFY that the bitmap format is BGRA8888. This invariant allows us to use get_pixel<BGRA8888>() instead of the generic get_pixel() throughout the function. This removes a lot of branches and makes the filter significantly faster. :^)
This commit is contained in:
parent
2432c5264b
commit
1268b39ba0
1 changed files with 4 additions and 4 deletions
|
@ -41,7 +41,7 @@ public:
|
||||||
sum_red = sum_green = sum_blue = sum_alpha = 0;
|
sum_red = sum_green = sum_blue = sum_alpha = 0;
|
||||||
// Setup sliding window
|
// Setup sliding window
|
||||||
for (int i = -radius; i <= radius; i++) {
|
for (int i = -radius; i <= radius; i++) {
|
||||||
auto color_at_px = m_bitmap.get_pixel(clamp(i, 0, width - 1), y);
|
auto color_at_px = m_bitmap.get_pixel<StorageFormat::BGRA8888>(clamp(i, 0, width - 1), y);
|
||||||
sum_red += red_value(color_at_px);
|
sum_red += red_value(color_at_px);
|
||||||
sum_green += green_value(color_at_px);
|
sum_green += green_value(color_at_px);
|
||||||
sum_blue += blue_value(color_at_px);
|
sum_blue += blue_value(color_at_px);
|
||||||
|
@ -57,8 +57,8 @@ public:
|
||||||
auto leftmost_x_coord = max(x - radius, 0);
|
auto leftmost_x_coord = max(x - radius, 0);
|
||||||
auto rightmost_x_coord = min(x + radius + 1, width - 1);
|
auto rightmost_x_coord = min(x + radius + 1, width - 1);
|
||||||
|
|
||||||
auto leftmost_x_color = m_bitmap.get_pixel(leftmost_x_coord, y);
|
auto leftmost_x_color = m_bitmap.get_pixel<StorageFormat::BGRA8888>(leftmost_x_coord, y);
|
||||||
auto rightmost_x_color = m_bitmap.get_pixel(rightmost_x_coord, y);
|
auto rightmost_x_color = m_bitmap.get_pixel<StorageFormat::BGRA8888>(rightmost_x_coord, y);
|
||||||
|
|
||||||
sum_red -= red_value(leftmost_x_color);
|
sum_red -= red_value(leftmost_x_color);
|
||||||
sum_red += red_value(rightmost_x_color);
|
sum_red += red_value(rightmost_x_color);
|
||||||
|
@ -90,7 +90,7 @@ public:
|
||||||
sum_blue / div,
|
sum_blue / div,
|
||||||
sum_alpha / div);
|
sum_alpha / div);
|
||||||
|
|
||||||
m_bitmap.set_pixel(x, y, color);
|
m_bitmap.set_pixel<StorageFormat::BGRA8888>(x, y, color);
|
||||||
|
|
||||||
auto topmost_y_coord = max(y - radius, 0);
|
auto topmost_y_coord = max(y - radius, 0);
|
||||||
auto bottommost_y_coord = min(y + radius + 1, height - 1);
|
auto bottommost_y_coord = min(y + radius + 1, height - 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue