sw_engine: Correct the color conversion condition.

The color conversion is supposed to take into account the differences between
straight alpha premultiplied color and pre-multiplied alpha color.

The previous logic does not perfectly cover these conditions.

The problem was occured in the thorvg viewer with a jpeg bgra format.
This commit is contained in:
Hermet Park 2023-09-26 18:38:00 +09:00 committed by Hermet Park
parent e8fd7e2b85
commit 5ecd3fb479

View file

@ -2024,11 +2024,11 @@ bool rasterConvertCS(Surface* surface, ColorSpace to)
//TOOD: Support SIMD accelerations
auto from = surface->cs;
if ((from == ColorSpace::ABGR8888 && to == ColorSpace::ARGB8888) || (from == ColorSpace::ABGR8888S && to == ColorSpace::ARGB8888S)) {
if (((from == ColorSpace::ABGR8888) || (from == ColorSpace::ABGR8888S)) && ((to == ColorSpace::ARGB8888) || (to == ColorSpace::ARGB8888S))) {
surface->cs = to;
return cRasterABGRtoARGB(surface);
}
if ((from == ColorSpace::ARGB8888 && to == ColorSpace::ABGR8888) || (from == ColorSpace::ARGB8888S && to == ColorSpace::ABGR8888S)) {
if (((from == ColorSpace::ARGB8888) || (from == ColorSpace::ARGB8888S)) && ((to == ColorSpace::ABGR8888) || (to == ColorSpace::ABGR8888S))) {
surface->cs = to;
return cRasterARGBtoABGR(surface);
}