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