mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
PixelPaint: Move Mask::{get, set, to_index} to the header file
They were previously taking up 9% of samples in a profile of PixelPaint while selecting a mask, and as a result of moving them to the header they were inlined, which effectively eliminated them from the profile.
This commit is contained in:
committed by
Andreas Kling
parent
3e592f5959
commit
b41954182a
Notes:
sideshowbarker
2024-07-18 01:56:59 +09:00
Author: https://github.com/Idan-Horowitz 🔰 Commit: https://github.com/SerenityOS/serenity/commit/b41954182ae Pull-request: https://github.com/SerenityOS/serenity/pull/10623
@@ -19,32 +19,6 @@ Mask::Mask(Gfx::IntRect bounding_rect, u8 default_value)
|
||||
}
|
||||
}
|
||||
|
||||
size_t Mask::to_index(int x, int y) const
|
||||
{
|
||||
VERIFY(m_bounding_rect.contains(x, y));
|
||||
|
||||
int dx = x - m_bounding_rect.x();
|
||||
int dy = y - m_bounding_rect.y();
|
||||
return dy * m_bounding_rect.width() + dx;
|
||||
}
|
||||
|
||||
u8 Mask::get(int x, int y) const
|
||||
{
|
||||
if (is_null() || !m_bounding_rect.contains(x, y)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_data[to_index(x, y)];
|
||||
}
|
||||
|
||||
void Mask::set(int x, int y, u8 value)
|
||||
{
|
||||
VERIFY(!is_null());
|
||||
VERIFY(m_bounding_rect.contains(x, y));
|
||||
|
||||
m_data[to_index(x, y)] = value;
|
||||
}
|
||||
|
||||
Mask Mask::with_bounding_rect(Gfx::IntRect inner_rect) const
|
||||
{
|
||||
auto result = Mask::empty(inner_rect);
|
||||
|
||||
Reference in New Issue
Block a user