mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
LibGfx: Painter::blit_filtered should take into account alpha value
If either the destination or calculated source pixel color contains an alpha value, we should blend them together.
This commit is contained in:
parent
dd0833107f
commit
130d48fa13
Notes:
sideshowbarker
2024-07-18 22:26:12 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/130d48fa13e Pull-request: https://github.com/SerenityOS/serenity/pull/5292 Issue: https://github.com/SerenityOS/serenity/issues/5291
@ -590,9 +590,13 @@ void Painter::blit_filtered(const IntPoint& position, const Gfx::Bitmap& source,
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
for (int x = 0; x <= (last_column - first_column); ++x) {
|
||||
u8 alpha = Color::from_rgba(src[x]).alpha();
|
||||
if (alpha == 0xff)
|
||||
dst[x] = filter(Color::from_rgba(src[x])).value();
|
||||
else if (!alpha)
|
||||
if (alpha == 0xff) {
|
||||
auto color = filter(Color::from_rgba(src[x]));
|
||||
if (color.alpha() == 0xff)
|
||||
dst[x] = color.value();
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(color).value();
|
||||
} else if (!alpha)
|
||||
continue;
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(filter(Color::from_rgba(src[x]))).value();
|
||||
@ -605,9 +609,13 @@ void Painter::blit_filtered(const IntPoint& position, const Gfx::Bitmap& source,
|
||||
const RGBA32* src = source.scanline(safe_src_rect.top() + row / s) + safe_src_rect.left() + first_column / s;
|
||||
for (int x = 0; x <= (last_column - first_column); ++x) {
|
||||
u8 alpha = Color::from_rgba(src[x / s]).alpha();
|
||||
if (alpha == 0xff)
|
||||
dst[x] = filter(Color::from_rgba(src[x / s])).value();
|
||||
else if (!alpha)
|
||||
if (alpha == 0xff) {
|
||||
auto color = filter(Color::from_rgba(src[x / s]));
|
||||
if (color.alpha() == 0xff)
|
||||
dst[x] = color.value();
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(color).value();
|
||||
} else if (!alpha)
|
||||
continue;
|
||||
else
|
||||
dst[x] = Color::from_rgba(dst[x]).blend(filter(Color::from_rgba(src[x / s]))).value();
|
||||
|
Loading…
Reference in New Issue
Block a user