wg/gl_engine: standardize shapes closing precision

The sw_engine, when determining the outline, converts
floats to ints by multiplying them x64, resulting in
a comparison precision of 1/64 = 0.015625.
Both gl_engine and wg_engine operate on floats. Before
adding a closing point to a shape, they performed a comparison
to check if the point differed from the starting point:
- wg: with a precision of 1e-3 (using length2, i.e., eps = 1e-6
- gl: used direct == comparison.
Now, consistency has been ensured by introducing a comparison
precision of 1/64 in both wg_engine and gl_engine.

@issue: https://github.com/thorvg/thorvg/issues/2799
@issue: https://github.com/thorvg/thorvg/issues/3235
This commit is contained in:
Mira Grudzinska 2025-02-17 15:24:50 +01:00 committed by Hermet Park
parent 65306d9b66
commit 96be683460
2 changed files with 2 additions and 2 deletions

View file

@ -1746,7 +1746,7 @@ void Stroker::strokeCubicTo(const Point& cnt1, const Point& cnt2, const Point& e
void Stroker::strokeClose()
{
if (mStrokeState.prevPt != mStrokeState.firstPt) {
if (length(mStrokeState.prevPt - mStrokeState.firstPt) > 0.015625f) {
this->strokeLineTo(mStrokeState.firstPt);
}

View file

@ -148,7 +148,7 @@ struct WgVertexBuffer
void close()
{
// check if last point is not to close to the first point
if (!tvg::zero(length2(data[0] - last()))) {
if (length(data[0] - last()) > 0.015625f) {
append(data[0]);
}
closed = true;