LibGfx: Use ErrorOr<T> for Bitmap::flipped()
This commit is contained in:
parent
69c4614a94
commit
db90b4554e
Notes:
sideshowbarker
2024-07-18 01:24:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/db90b4554ec
4 changed files with 9 additions and 8 deletions
|
@ -47,7 +47,7 @@ void ViewWidget::clear()
|
|||
|
||||
void ViewWidget::flip(Gfx::Orientation orientation)
|
||||
{
|
||||
m_bitmap = m_bitmap->flipped(orientation);
|
||||
m_bitmap = m_bitmap->flipped(orientation).release_value_but_fixme_should_propagate_errors();
|
||||
set_scale(m_scale);
|
||||
|
||||
resize_window();
|
||||
|
|
|
@ -506,8 +506,7 @@ void Image::set_path(String path)
|
|||
void Image::flip(Gfx::Orientation orientation)
|
||||
{
|
||||
for (auto& layer : m_layers) {
|
||||
auto flipped = layer.bitmap().flipped(orientation);
|
||||
VERIFY(flipped);
|
||||
auto flipped = layer.bitmap().flipped(orientation).release_value_but_fixme_should_propagate_errors();
|
||||
layer.set_bitmap(*flipped);
|
||||
layer.did_modify_bitmap(rect());
|
||||
}
|
||||
|
|
|
@ -372,11 +372,13 @@ ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::rotated(Gfx::RotationDirection rotat
|
|||
return new_bitmap.release_nonnull();
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> Bitmap::flipped(Gfx::Orientation orientation) const
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::flipped(Gfx::Orientation orientation) const
|
||||
{
|
||||
auto new_bitmap = Gfx::Bitmap::try_create(this->format(), { width(), height() }, scale());
|
||||
if (!new_bitmap)
|
||||
return nullptr;
|
||||
if (!new_bitmap) {
|
||||
// FIXME: Propagate the *real* error, once we have it.
|
||||
return Error::from_errno(ENOMEM);
|
||||
}
|
||||
|
||||
auto w = this->physical_width();
|
||||
auto h = this->physical_height();
|
||||
|
@ -390,7 +392,7 @@ RefPtr<Gfx::Bitmap> Bitmap::flipped(Gfx::Orientation orientation) const
|
|||
}
|
||||
}
|
||||
|
||||
return new_bitmap;
|
||||
return new_bitmap.release_nonnull();
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> Bitmap::scaled(int sx, int sy) const
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> clone() const;
|
||||
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> rotated(Gfx::RotationDirection) const;
|
||||
[[nodiscard]] RefPtr<Gfx::Bitmap> flipped(Gfx::Orientation) const;
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> flipped(Gfx::Orientation) const;
|
||||
[[nodiscard]] RefPtr<Gfx::Bitmap> scaled(int sx, int sy) const;
|
||||
[[nodiscard]] RefPtr<Gfx::Bitmap> scaled(float sx, float sy) const;
|
||||
[[nodiscard]] RefPtr<Gfx::Bitmap> cropped(Gfx::IntRect) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue