# Copyright (C) 2022-2023 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

header: <WebCore/PathSegmentData.h>
[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathMoveTo {
    WebCore::FloatPoint point;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathLineTo {
    WebCore::FloatPoint point;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathQuadCurveTo {
    WebCore::FloatPoint controlPoint;
    WebCore::FloatPoint endPoint;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathBezierCurveTo {
    WebCore::FloatPoint controlPoint1;
    WebCore::FloatPoint controlPoint2;
    WebCore::FloatPoint endPoint;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathArcTo {
    WebCore::FloatPoint controlPoint1;
    WebCore::FloatPoint controlPoint2;
    float radius;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathArc {
    WebCore::FloatPoint center;
    float radius;
    float startAngle;
    float endAngle;
    WebCore::RotationDirection direction;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathClosedArc {
    WebCore::PathArc arc;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathEllipse {
    WebCore::FloatPoint center;
    float radiusX;
    float radiusY;
    float rotation;
    float startAngle;
    float endAngle;
    WebCore::RotationDirection direction;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathEllipseInRect {
    WebCore::FloatRect rect;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathRect {
    WebCore::FloatRect rect;
};

[Nested] enum class WebCore::PathRoundedRect::Strategy : uint8_t {
    PreferNative,
    PreferBezier
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathRoundedRect {
    WebCore::FloatRoundedRect roundedRect;
    WebCore::PathRoundedRect::Strategy strategy;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathDataLine {
    WebCore::FloatPoint start;
    WebCore::FloatPoint end;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathDataQuadCurve {
    WebCore::FloatPoint start;
    WebCore::FloatPoint controlPoint;
    WebCore::FloatPoint endPoint;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathDataBezierCurve {
    WebCore::FloatPoint start;
    WebCore::FloatPoint controlPoint1;
    WebCore::FloatPoint controlPoint2;
    WebCore::FloatPoint endPoint;
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathDataArc {
    WebCore::FloatPoint start;
    WebCore::FloatPoint controlPoint1;
    WebCore::FloatPoint controlPoint2;
    float radius;
};

header: <WebCore/PathSegment.h>
[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] struct WebCore::PathCloseSubpath {
};

[AdditionalEncoder=StreamConnectionEncoder, CustomHeader] class WebCore::PathSegment {
    WebCore::PathSegment::Data data();
};

using WebCore::PathSegment::Data = std::variant<WebCore::PathMoveTo, WebCore::PathLineTo, WebCore::PathQuadCurveTo, WebCore::PathBezierCurveTo, WebCore::PathArcTo, WebCore::PathArc, WebCore::PathClosedArc, WebCore::PathEllipse, WebCore::PathEllipseInRect, WebCore::PathRect, WebCore::PathRoundedRect, WebCore::PathDataLine, WebCore::PathDataQuadCurve, WebCore::PathDataBezierCurve, WebCore::PathDataArc, WebCore::PathCloseSubpath>;
