1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:07:45 +00:00

LibGfx: Use "try_" prefix for static factory functions

Also mark them as [[nodiscard]].
This commit is contained in:
Andreas Kling 2021-07-21 18:02:15 +02:00
parent f0409081f5
commit c7d891765c
131 changed files with 422 additions and 421 deletions

View file

@ -19,7 +19,7 @@ RefPtr<Layer> Layer::try_create_with_size(Image& image, Gfx::IntSize const& size
if (size.width() > 16384 || size.height() > 16384)
return nullptr;
auto bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, size);
auto bitmap = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, size);
if (!bitmap)
return nullptr;
@ -97,7 +97,7 @@ RefPtr<Gfx::Bitmap> Layer::try_copy_bitmap(Selection const& selection) const
}
auto selection_rect = selection.bounding_rect();
auto result = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, selection_rect.size());
auto result = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, selection_rect.size());
VERIFY(result->has_alpha_channel());
for (int y = selection_rect.top(); y <= selection_rect.bottom(); y++) {