From 925b9c8ba9492502191f60154e3d7ddd46662812 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 6 Jul 2021 10:43:36 +0900 Subject: [PATCH] sw_engine fill: correct the range of opacity, also some minor code refactors. --- src/lib/sw_engine/tvgSwFill.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/sw_engine/tvgSwFill.cpp b/src/lib/sw_engine/tvgSwFill.cpp index 5ea6cf63..19eda1c1 100644 --- a/src/lib/sw_engine/tvgSwFill.cpp +++ b/src/lib/sw_engine/tvgSwFill.cpp @@ -77,12 +77,11 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, const SwSurface* while (pos < next->offset && i < GRADIENT_STOP_SIZE) { auto t = (pos - curr->offset) * delta; - auto dist = static_cast(256 * t); - auto dist2 = 256 - dist; + auto dist = static_cast(255 * t); + auto dist2 = 255 - dist; auto color = COLOR_INTERPOLATE(rgba, dist2, rgba2, dist); - uint8_t a = color >> 24; - fill->ctable[i] = ALPHA_BLEND(color | 0xff000000, a); + fill->ctable[i] = ALPHA_BLEND((color | 0xff000000), (color >> 24)); ++i; pos += inc; @@ -90,7 +89,7 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, const SwSurface* rgba = rgba2; a = a2; } - rgba = ALPHA_BLEND(rgba | 0xff000000, a); + rgba = ALPHA_BLEND((rgba | 0xff000000), a); for (; i < GRADIENT_STOP_SIZE; ++i) fill->ctable[i] = rgba;