diff --git a/SharedGraphics/GraphicsBitmap.cpp b/SharedGraphics/GraphicsBitmap.cpp index 8a7621e4e6..5d9b85b382 100644 --- a/SharedGraphics/GraphicsBitmap.cpp +++ b/SharedGraphics/GraphicsBitmap.cpp @@ -91,3 +91,12 @@ void GraphicsBitmap::set_mmap_name(const StringView& name) ASSERT(m_needs_munmap); ::set_mmap_name(m_data, size_in_bytes(), name.characters()); } + +void GraphicsBitmap::fill(Color color) +{ + ASSERT(m_format == GraphicsBitmap::Format::RGB32 || m_format == GraphicsBitmap::Format::RGBA32); + for (int y = 0; y < height(); ++y) { + auto* scanline = this->scanline(y); + fast_dword_fill(scanline, color.value(), width()); + } +} diff --git a/SharedGraphics/GraphicsBitmap.h b/SharedGraphics/GraphicsBitmap.h index 9e0a24525a..62e33a0e35 100644 --- a/SharedGraphics/GraphicsBitmap.h +++ b/SharedGraphics/GraphicsBitmap.h @@ -39,6 +39,8 @@ public: size_t pitch() const { return m_pitch; } int shared_buffer_id() const { return m_shared_buffer ? m_shared_buffer->shared_buffer_id() : -1; } + void fill(Color); + bool has_alpha_channel() const { return m_format == Format::RGBA32; } Format format() const { return m_format; }