[Webkit-unassigned] [Bug 265911] New: Simplify conversion of quadratic bezier segments

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 5 15:26:52 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=265911

            Bug ID: 265911
           Summary: Simplify conversion of quadratic bezier segments
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: SVG
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: ahmad.saleem792 at gmail.com
                CC: rbuis at igalia.com, sabouhallawa at apple.com,
                    simon.fraser at apple.com, ysuzuki at apple.com,
                    zimmermann at kde.org

hi Team,

While going through Blink's commits, I came across following simplification commit:

Blink Commit: https://chromium.googlesource.com/chromium/blink/+/a2034c0f6210c1e9f5897340a37e29873575ed2e

WebKit Source: https://searchfox.org/wubkat/rev/1a7afa1ea1ff078e0856c604cc572aa47d35f2eb/Source/WebCore/svg/SVGPathParser.cpp#197 etc.

Locally following compiles:

static FloatPoint blendPoints(const FloatPoint& p1, const FloatPoint& p2)
{
    const float oneOverThree = 1 / 3.f;
    return FloatPoint((p1.x() + 2 * p2.x()) * oneOverThree, (p1.y() + 2 * p2.y()) * oneOverThree);
}

and

static FloatPoint reflectedPoint(const FloatPoint& reflectIn, const FloatPoint& pointToReflect)
{
    return FloatPoint(2 * reflectIn.x() - pointToReflect.x(), 2 * reflectIn.y() - pointToReflect.y());
}

and then following modified:

bool SVGPathParser::parseCurveToQuadraticSmoothSegment()
{
    auto result = m_source.parseCurveToQuadraticSmoothSegment();
    if (!result)
        return false;
    if (m_lastCommand != SVGPathSegType::CurveToQuadraticAbs
        && m_lastCommand != SVGPathSegType::CurveToQuadraticRel
        && m_lastCommand != SVGPathSegType::CurveToQuadraticSmoothAbs
        && m_lastCommand != SVGPathSegType::CurveToQuadraticSmoothRel)
        m_controlPoint = m_currentPoint;
    if (m_pathParsingMode == NormalizedParsing) {
        if (m_mode == RelativeCoordinates) {
            result->targetPoint += m_currentPoint;
        }
        m_controlPoint = reflectedPoint(m_currentPoint, m_controlPoint);
        FloatPoint point1 = blendPoints(m_currentPoint, m_controlPoint);
        FloatPoint point2 = blendPoints(result->targetPoint, m_controlPoint);
        m_consumer.curveToCubic(point1, point2, result->targetPoint, AbsoluteCoordinates);
        m_currentPoint = result->targetPoint;
    } else
        m_consumer.curveToQuadraticSmooth(result->targetPoint, m_mode);

and

bool SVGPathParser::parseCurveToQuadraticSegment()
{
    auto result = m_source.parseCurveToQuadraticSegment();
    if (!result)
        return false;
    if (m_pathParsingMode == NormalizedParsing) {
        m_controlPoint = result->point1;
        if (m_mode == RelativeCoordinates) {
            m_controlPoint += m_currentPoint;
            result->targetPoint += m_currentPoint;
        }
        result->point1 = blendPoints(m_currentPoint, m_controlPoint);
        FloatPoint point2 = blendPoints(result->targetPoint, m_controlPoint);
        m_consumer.curveToCubic(result->point1, point2, result->targetPoint, AbsoluteCoordinates);
        m_currentPoint = result->targetPoint;
    } else
        m_consumer.curveToQuadratic(result->point1, result->targetPoint, m_mode);
    return true;
}

___

Just wanted to raise and ask for input, if it is worth merging.

Thanks!

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20231205/30d81959/attachment-0001.htm>


More information about the webkit-unassigned mailing list