mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:27:45 +00:00
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
4 changed files with 17 additions and 30 deletions
|
@ -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
Add a link
Reference in a new issue