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

PixelPaint: Always specify a new bounding rect when resizing layers

This commit also removes the other Layer::resize() overloads, as they
are no longer used.
This commit is contained in:
Tim Ledbetter 2023-03-12 14:56:38 +00:00 committed by Andreas Kling
parent c17b32e058
commit 690f3ae43b
2 changed files with 6 additions and 18 deletions

View file

@ -237,12 +237,12 @@ ErrorOr<void> Layer::crop(Gfx::IntRect const& rect, NotifyClients notify_clients
return {}; return {};
} }
ErrorOr<void> Layer::resize(Gfx::IntSize new_size, Gfx::IntPoint new_location, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients) ErrorOr<void> Layer::resize(Gfx::IntRect const& new_rect, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients)
{ {
auto src_rect = Gfx::IntRect(Gfx::IntPoint(0, 0), size()); auto src_rect = Gfx::IntRect({}, size());
auto dst_rect = Gfx::IntRect(Gfx::IntPoint(0, 0), new_size); auto dst_rect = Gfx::IntRect({}, new_rect.size());
auto resized_content_bitmap = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, new_size)); auto resized_content_bitmap = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, new_rect.size()));
{ {
Gfx::Painter painter(resized_content_bitmap); Gfx::Painter painter(resized_content_bitmap);
@ -254,7 +254,7 @@ ErrorOr<void> Layer::resize(Gfx::IntSize new_size, Gfx::IntPoint new_location, G
} }
if (m_mask_bitmap) { if (m_mask_bitmap) {
auto dst = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, new_size)); auto dst = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, new_rect.size()));
Gfx::Painter painter(dst); Gfx::Painter painter(dst);
if (scaling_mode == Gfx::Painter::ScalingMode::None) { if (scaling_mode == Gfx::Painter::ScalingMode::None) {
@ -268,22 +268,12 @@ ErrorOr<void> Layer::resize(Gfx::IntSize new_size, Gfx::IntPoint new_location, G
m_content_bitmap = move(resized_content_bitmap); m_content_bitmap = move(resized_content_bitmap);
set_location(new_location); set_location(new_rect.location());
did_modify_bitmap({}, notify_clients); did_modify_bitmap({}, notify_clients);
return {}; return {};
} }
ErrorOr<void> Layer::resize(Gfx::IntRect const& new_rect, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients)
{
return resize(new_rect.size(), new_rect.location(), scaling_mode, notify_clients);
}
ErrorOr<void> Layer::resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients)
{
return resize(new_size, location(), scaling_mode, notify_clients);
}
void Layer::update_cached_bitmap() void Layer::update_cached_bitmap()
{ {
if (!is_masked()) { if (!is_masked()) {

View file

@ -67,9 +67,7 @@ public:
ErrorOr<void> flip(Gfx::Orientation orientation, NotifyClients notify_clients = NotifyClients::Yes); ErrorOr<void> flip(Gfx::Orientation orientation, NotifyClients notify_clients = NotifyClients::Yes);
ErrorOr<void> rotate(Gfx::RotationDirection direction, NotifyClients notify_clients = NotifyClients::Yes); ErrorOr<void> rotate(Gfx::RotationDirection direction, NotifyClients notify_clients = NotifyClients::Yes);
ErrorOr<void> crop(Gfx::IntRect const& rect, NotifyClients notify_clients = NotifyClients::Yes); ErrorOr<void> crop(Gfx::IntRect const& rect, NotifyClients notify_clients = NotifyClients::Yes);
ErrorOr<void> resize(Gfx::IntSize new_size, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients = NotifyClients::Yes);
ErrorOr<void> resize(Gfx::IntRect const& new_rect, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients = NotifyClients::Yes); ErrorOr<void> resize(Gfx::IntRect const& new_rect, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients = NotifyClients::Yes);
ErrorOr<void> resize(Gfx::IntSize new_size, Gfx::IntPoint new_location, Gfx::Painter::ScalingMode scaling_mode, NotifyClients notify_clients = NotifyClients::Yes);
Optional<Gfx::IntRect> nonempty_content_bounding_rect() const; Optional<Gfx::IntRect> nonempty_content_bounding_rect() const;