LibGfx: Remove redundant bits() method
In all circumstances, this returned exactly the same thing as scanline_u8(), so let's just remove the silly detour. This does not add any new dependency on Bitmap-internals, because that already existed.
This commit is contained in:
parent
25ccd40d5a
commit
d6673b384e
Notes:
sideshowbarker
2024-07-19 02:45:03 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/d6673b384ef Pull-request: https://github.com/SerenityOS/serenity/pull/3398 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/nico
4 changed files with 17 additions and 30 deletions
|
@ -119,7 +119,7 @@ Fire::Fire()
|
|||
|
||||
/* Draw fire "source" on bottom row of pixels */
|
||||
for (int i = 0; i < FIRE_WIDTH; i++)
|
||||
bitmap->bits(bitmap->height() - 1)[i] = FIRE_MAX;
|
||||
bitmap->scanline_u8(bitmap->height() - 1)[i] = FIRE_MAX;
|
||||
|
||||
/* Set off initital paint event */
|
||||
//update();
|
||||
|
@ -157,7 +157,7 @@ void Fire::timer_event(Core::TimerEvent&)
|
|||
int rnd = rand() % 3;
|
||||
|
||||
/* Calculate new pixel value, don't go below 0 */
|
||||
u8 nv = bitmap->bits(py)[px];
|
||||
u8 nv = bitmap->scanline_u8(py)[px];
|
||||
if (nv > 0)
|
||||
nv -= (rnd & 1);
|
||||
|
||||
|
@ -168,7 +168,7 @@ void Fire::timer_event(Core::TimerEvent&)
|
|||
else if (epx > FIRE_WIDTH)
|
||||
epx = FIRE_WIDTH;
|
||||
|
||||
bitmap->bits(py - 1)[epx] = nv;
|
||||
bitmap->scanline_u8(py - 1)[epx] = nv;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,10 +199,10 @@ void Fire::mousemove_event(GUI::MouseEvent& event)
|
|||
if (event.y() >= 2 && event.y() < 398 && event.x() <= 638) {
|
||||
int ypos = event.y() / 2;
|
||||
int xpos = event.x() / 2;
|
||||
bitmap->bits(ypos - 1)[xpos] = FIRE_MAX + 5;
|
||||
bitmap->bits(ypos - 1)[xpos + 1] = FIRE_MAX + 5;
|
||||
bitmap->bits(ypos)[xpos] = FIRE_MAX + 5;
|
||||
bitmap->bits(ypos)[xpos + 1] = FIRE_MAX + 5;
|
||||
bitmap->scanline_u8(ypos - 1)[xpos] = FIRE_MAX + 5;
|
||||
bitmap->scanline_u8(ypos - 1)[xpos + 1] = FIRE_MAX + 5;
|
||||
bitmap->scanline_u8(ypos)[xpos] = FIRE_MAX + 5;
|
||||
bitmap->scanline_u8(ypos)[xpos + 1] = FIRE_MAX + 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ static int ensure_realized_icon(IconContainerType& container)
|
|||
auto shared_buffer = SharedBuffer::create_with_size(container.icon()->size_in_bytes());
|
||||
ASSERT(shared_buffer);
|
||||
auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::BitmapFormat::RGBA32, *shared_buffer, container.icon()->size());
|
||||
memcpy(shared_buffer->data(), container.icon()->bits(0), container.icon()->size_in_bytes());
|
||||
memcpy(shared_buffer->data(), container.icon()->scanline_u8(0), container.icon()->size_in_bytes());
|
||||
shared_buffer->seal();
|
||||
shared_buffer->share_with(WindowServerConnection::the().server_pid());
|
||||
container.set_icon(shared_icon);
|
||||
|
|
|
@ -93,9 +93,6 @@ public:
|
|||
RGBA32* scanline(int y);
|
||||
const RGBA32* scanline(int y) const;
|
||||
|
||||
u8* bits(int y);
|
||||
const u8* bits(int y) const;
|
||||
|
||||
IntRect rect() const { return { {}, m_size }; }
|
||||
IntSize size() const { return m_size; }
|
||||
int width() const { return m_size.width(); }
|
||||
|
@ -250,16 +247,6 @@ inline const RGBA32* Bitmap::scanline(int y) const
|
|||
return reinterpret_cast<const RGBA32*>(scanline_u8(y));
|
||||
}
|
||||
|
||||
inline const u8* Bitmap::bits(int y) const
|
||||
{
|
||||
return reinterpret_cast<const u8*>(scanline(y));
|
||||
}
|
||||
|
||||
inline u8* Bitmap::bits(int y)
|
||||
{
|
||||
return reinterpret_cast<u8*>(scanline(y));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::RGB32>(int x, int y) const
|
||||
{
|
||||
|
@ -275,25 +262,25 @@ inline Color Bitmap::get_pixel<BitmapFormat::RGBA32>(int x, int y) const
|
|||
template<>
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::Indexed1>(int x, int y) const
|
||||
{
|
||||
return Color::from_rgb(m_palette[bits(y)[x]]);
|
||||
return Color::from_rgb(m_palette[scanline_u8(y)[x]]);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::Indexed2>(int x, int y) const
|
||||
{
|
||||
return Color::from_rgb(m_palette[bits(y)[x]]);
|
||||
return Color::from_rgb(m_palette[scanline_u8(y)[x]]);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::Indexed4>(int x, int y) const
|
||||
{
|
||||
return Color::from_rgb(m_palette[bits(y)[x]]);
|
||||
return Color::from_rgb(m_palette[scanline_u8(y)[x]]);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Color Bitmap::get_pixel<BitmapFormat::Indexed8>(int x, int y) const
|
||||
{
|
||||
return Color::from_rgb(m_palette[bits(y)[x]]);
|
||||
return Color::from_rgb(m_palette[scanline_u8(y)[x]]);
|
||||
}
|
||||
|
||||
inline Color Bitmap::get_pixel(int x, int y) const
|
||||
|
|
|
@ -51,13 +51,13 @@ template<BitmapFormat format = BitmapFormat::Invalid>
|
|||
ALWAYS_INLINE Color get_pixel(const Gfx::Bitmap& bitmap, int x, int y)
|
||||
{
|
||||
if constexpr (format == BitmapFormat::Indexed8)
|
||||
return bitmap.palette_color(bitmap.bits(y)[x]);
|
||||
return bitmap.palette_color(bitmap.scanline_u8(y)[x]);
|
||||
if constexpr (format == BitmapFormat::Indexed4)
|
||||
return bitmap.palette_color(bitmap.bits(y)[x]);
|
||||
return bitmap.palette_color(bitmap.scanline_u8(y)[x]);
|
||||
if constexpr (format == BitmapFormat::Indexed2)
|
||||
return bitmap.palette_color(bitmap.bits(y)[x]);
|
||||
return bitmap.palette_color(bitmap.scanline_u8(y)[x]);
|
||||
if constexpr (format == BitmapFormat::Indexed1)
|
||||
return bitmap.palette_color(bitmap.bits(y)[x]);
|
||||
return bitmap.palette_color(bitmap.scanline_u8(y)[x]);
|
||||
if constexpr (format == BitmapFormat::RGB32)
|
||||
return Color::from_rgb(bitmap.scanline(y)[x]);
|
||||
if constexpr (format == BitmapFormat::RGBA32)
|
||||
|
@ -678,7 +678,7 @@ void Painter::blit(const IntPoint& position, const Gfx::Bitmap& source, const In
|
|||
}
|
||||
|
||||
if (Bitmap::is_indexed(source.format())) {
|
||||
const u8* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||
const u8* src = source.scanline_u8(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||
const size_t src_skip = source.pitch();
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
for (int i = 0; i < clipped_rect.width(); ++i)
|
||||
|
|
Loading…
Add table
Reference in a new issue