mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibGfx: Add const hack in Bitmap::to_bitmap_backed_by_anonymous_buffer()
This commit is contained in:
parent
8bf248a046
commit
2530b301db
Notes:
sideshowbarker
2024-07-17 05:23:40 +09:00
Author: https://github.com/awesomekling
Commit: 2530b301db
Pull-request: https://github.com/SerenityOS/serenity/pull/17557
Reviewed-by: https://github.com/linusg
1 changed files with 4 additions and 2 deletions
|
@ -468,8 +468,10 @@ ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::cropped(Gfx::IntRect crop, Optional<
|
|||
|
||||
ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::to_bitmap_backed_by_anonymous_buffer() const
|
||||
{
|
||||
if (m_buffer.is_valid())
|
||||
return NonnullRefPtr { *this };
|
||||
if (m_buffer.is_valid()) {
|
||||
// FIXME: The const_cast here is awkward.
|
||||
return NonnullRefPtr { const_cast<Bitmap&>(*this) };
|
||||
}
|
||||
auto buffer = TRY(Core::AnonymousBuffer::create_with_size(round_up_to_power_of_two(size_in_bytes(), PAGE_SIZE)));
|
||||
auto bitmap = TRY(Bitmap::create_with_anonymous_buffer(m_format, move(buffer), size(), scale(), palette_to_vector()));
|
||||
memcpy(bitmap->scanline(0), scanline(0), size_in_bytes());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue