mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-27 08:36:59 +00:00
sw_engine fill: correct the range of opacity,
also some minor code refactors.
This commit is contained in:
parent
7a8d7ceac6
commit
925b9c8ba9
1 changed files with 4 additions and 5 deletions
|
@ -77,12 +77,11 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, const SwSurface*
|
||||||
|
|
||||||
while (pos < next->offset && i < GRADIENT_STOP_SIZE) {
|
while (pos < next->offset && i < GRADIENT_STOP_SIZE) {
|
||||||
auto t = (pos - curr->offset) * delta;
|
auto t = (pos - curr->offset) * delta;
|
||||||
auto dist = static_cast<int32_t>(256 * t);
|
auto dist = static_cast<int32_t>(255 * t);
|
||||||
auto dist2 = 256 - dist;
|
auto dist2 = 255 - dist;
|
||||||
|
|
||||||
auto color = COLOR_INTERPOLATE(rgba, dist2, rgba2, dist);
|
auto color = COLOR_INTERPOLATE(rgba, dist2, rgba2, dist);
|
||||||
uint8_t a = color >> 24;
|
fill->ctable[i] = ALPHA_BLEND((color | 0xff000000), (color >> 24));
|
||||||
fill->ctable[i] = ALPHA_BLEND(color | 0xff000000, a);
|
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
pos += inc;
|
pos += inc;
|
||||||
|
@ -90,7 +89,7 @@ static bool _updateColorTable(SwFill* fill, const Fill* fdata, const SwSurface*
|
||||||
rgba = rgba2;
|
rgba = rgba2;
|
||||||
a = a2;
|
a = a2;
|
||||||
}
|
}
|
||||||
rgba = ALPHA_BLEND(rgba | 0xff000000, a);
|
rgba = ALPHA_BLEND((rgba | 0xff000000), a);
|
||||||
|
|
||||||
for (; i < GRADIENT_STOP_SIZE; ++i)
|
for (; i < GRADIENT_STOP_SIZE; ++i)
|
||||||
fill->ctable[i] = rgba;
|
fill->ctable[i] = rgba;
|
||||||
|
|
Loading…
Add table
Reference in a new issue