LibGfx: Replace Bitmap::visually_equals() with ::diff()

This produces more granural information on the actual pixel errors
present between two bitmaps. It now also asserts that both bitmaps are
the same size, since we should never compare two differently sized
bitmaps anyway.
This commit is contained in:
Jelle Raaijmakers 2025-07-16 09:04:19 +02:00 committed by Tim Ledbetter
commit 0f642ecb5c
Notes: github-actions[bot] 2025-07-17 12:00:38 +00:00
3 changed files with 55 additions and 8 deletions

View file

@ -137,7 +137,28 @@ public:
[[nodiscard]] Core::AnonymousBuffer& anonymous_buffer() { return m_buffer; }
[[nodiscard]] Core::AnonymousBuffer const& anonymous_buffer() const { return m_buffer; }
[[nodiscard]] bool visually_equals(Bitmap const&) const;
struct DiffResult {
bool identical { false };
// Cumulative channel differences.
u64 total_red_error { 0 };
u64 total_green_error { 0 };
u64 total_blue_error { 0 };
u64 total_alpha_error { 0 };
u64 total_error { 0 };
// Maximum channel differences.
u8 maximum_red_error { 0 };
u8 maximum_green_error { 0 };
u8 maximum_blue_error { 0 };
u8 maximum_alpha_error { 0 };
u8 maximum_error { 0 };
// Number of pixels with errors.
u64 pixel_error_count { 0 };
};
[[nodiscard]] DiffResult diff(Bitmap const&) const;
[[nodiscard]] AlphaType alpha_type() const { return m_alpha_type; }
void set_alpha_type_destructive(AlphaType);