mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibGUI: Use new Bitmap::minimum_pitch method
Also, make sure that the painter actually draws on a RGB(A) bitmap. Closes #3460.
This commit is contained in:
parent
568d53c9b1
commit
e3101c74c6
Notes:
sideshowbarker
2024-07-19 02:44:37 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/e3101c74c64 Pull-request: https://github.com/SerenityOS/serenity/pull/3462 Issue: https://github.com/SerenityOS/serenity/issues/3460
@ -635,7 +635,7 @@ RefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::BitmapFormat format, const
|
||||
{
|
||||
ASSERT(WindowServerConnection::the().server_pid());
|
||||
ASSERT(!size.is_empty());
|
||||
size_t pitch = round_up_to_power_of_two(size.width() * sizeof(Gfx::RGBA32), 16);
|
||||
size_t pitch = Gfx::Bitmap::minimum_pitch(size.width(), format);
|
||||
size_t size_in_bytes = size.height() * pitch;
|
||||
auto shared_buffer = SharedBuffer::create_with_size(size_in_bytes);
|
||||
ASSERT(shared_buffer);
|
||||
|
@ -68,6 +68,7 @@ ALWAYS_INLINE Color get_pixel(const Gfx::Bitmap& bitmap, int x, int y)
|
||||
Painter::Painter(Gfx::Bitmap& bitmap)
|
||||
: m_target(bitmap)
|
||||
{
|
||||
ASSERT(bitmap.format() == Gfx::BitmapFormat::RGB32 || bitmap.format() == Gfx::BitmapFormat::RGBA32);
|
||||
m_state_stack.append(State());
|
||||
state().font = &Font::default_font();
|
||||
state().clip_rect = { { 0, 0 }, bitmap.size() };
|
||||
|
Loading…
Reference in New Issue
Block a user