From 9772afcd293345eed90540508ff7a66a8f42ca5c Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 18 Sep 2024 19:02:00 +0200 Subject: [PATCH] LibGfx: Remove unused Bitmap::fill() --- Tests/LibGfx/CMakeLists.txt | 1 - Tests/LibGfx/TestPainter.cpp | 55 ---------------------------- Userland/Libraries/LibGfx/Bitmap.cpp | 8 ---- Userland/Libraries/LibGfx/Bitmap.h | 2 - 4 files changed, 66 deletions(-) delete mode 100644 Tests/LibGfx/TestPainter.cpp diff --git a/Tests/LibGfx/CMakeLists.txt b/Tests/LibGfx/CMakeLists.txt index b8a36c8c489..333d151007e 100644 --- a/Tests/LibGfx/CMakeLists.txt +++ b/Tests/LibGfx/CMakeLists.txt @@ -7,7 +7,6 @@ set(TEST_SOURCES TestImageDecoder.cpp TestImageWriter.cpp TestMedianCut.cpp - TestPainter.cpp TestRect.cpp TestWOFF.cpp TestWOFF2.cpp diff --git a/Tests/LibGfx/TestPainter.cpp b/Tests/LibGfx/TestPainter.cpp deleted file mode 100644 index d8dcc9f6e95..00000000000 --- a/Tests/LibGfx/TestPainter.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2024, Nico Weber - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -#include - -TEST_CASE(draw_scaled_bitmap_with_transform) -{ - auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 40, 30 })); - bitmap->fill(Gfx::Color::White); - Gfx::DeprecatedPainter painter(bitmap); - - auto source_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 1, 1 })); - source_bitmap->fill(Gfx::Color::Black); - - auto dest_rect = source_bitmap->rect(); - auto source_rect = source_bitmap->rect().to_rounded(); - - // Identity transform: Lower left pixel is black, rest stays white. - Gfx::AffineTransform transform; - painter.draw_scaled_bitmap_with_transform(dest_rect, source_bitmap, source_rect, transform); - for (int y = 0; y < bitmap->height(); ++y) { - for (int x = 0; x < bitmap->width(); ++x) { - if (x == 0 && y == 0) - EXPECT_EQ(bitmap->get_pixel(x, y), Color::Black); - else - EXPECT_EQ(bitmap->get_pixel(x, y), Color::White); - } - } - - // Scale up 1x1 source bitmap 10x in x and 5x in y and paint at 10, 20. Should fill that rect: - bitmap->fill(Gfx::Color::White); - transform = transform.translate(10, 20).scale(10, 5); - painter.draw_scaled_bitmap_with_transform(dest_rect, source_bitmap, source_rect, transform); - for (int y = 0; y < bitmap->height(); ++y) { - for (int x = 0; x < bitmap->width(); ++x) { - if (x >= 10 && x < 10 + 10 && y >= 20 && y < 20 + 5) - EXPECT_EQ(bitmap->get_pixel(x, y), Color::Black); - else - EXPECT_EQ(bitmap->get_pixel(x, y), Color::White); - } - } -} - -TEST_CASE(draw_rect_rough_bounds) -{ - auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, { 10, 10 })); - Gfx::DeprecatedPainter painter(*bitmap); - painter.draw_rect(Gfx::IntRect(0, 0, 1, 1), Color::Black, true); - painter.draw_rect(Gfx::IntRect(9, 9, 1, 1), Color::Black, true); -} diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 2a371dc901a..8d126fdafff 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -237,14 +237,6 @@ void Bitmap::strip_alpha_channel() m_format = BitmapFormat::BGRx8888; } -void Bitmap::fill(Color color) -{ - for (int y = 0; y < height(); ++y) { - auto* scanline = this->scanline(y); - fast_u32_fill(scanline, color.value(), width()); - } -} - Gfx::ShareableBitmap Bitmap::to_shareable_bitmap() const { auto bitmap_or_error = to_bitmap_backed_by_anonymous_buffer(); diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index b3751b562d0..3e98e837f56 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -130,8 +130,6 @@ public: return bpp_for_format(m_format); } - void fill(Color); - [[nodiscard]] bool has_alpha_channel() const { return m_format == BitmapFormat::BGRA8888 || m_format == BitmapFormat::RGBA8888; } [[nodiscard]] BitmapFormat format() const { return m_format; }