2 * Copyright (c) 2020-2021 Samsung Electronics Co., Ltd. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 #ifndef _TVG_SVG_LOADER_COMMON_H_
23 #define _TVG_SVG_LOADER_COMMON_H_
25 #include "tvgCommon.h"
29 struct SvgStyleGradient;
31 //NOTE: Please update simpleXmlNodeTypeToString() as well.
32 enum class SvgNodeType
59 enum class SvgLengthType
71 enum class SvgFillFlags
80 enum class SvgStrokeFlags
92 enum class SvgGradientType
98 enum class SvgStyleFlags
107 StrokeLineJoin = 0x80,
108 StrokeLineCap = 0x100,
109 StrokeOpacity = 0x200,
110 StrokeDashArray = 0x400,
117 enum class SvgStopStyleFlags
124 enum class SvgFillRule
130 //Length type to recalculate %, pt, pc, mm, cm etc
131 enum class SvgParserLengthType
135 //In case of, for example, radius of radial gradient
157 Array<SvgStyleGradient*> gradients;
166 struct SvgEllipseNode
212 struct SvgPolygonNode
218 struct SvgCompositeNode
223 struct SvgLinearGradient
235 struct SvgRadialGradient
253 bool applying; //flag for checking circular dependency.
265 SvgStyleGradient* gradient;
277 struct SvgStyleGradient
279 SvgGradientType type = SvgGradientType::Linear;
282 FillSpread spread = FillSpread::Pad;
283 SvgRadialGradient* radial = nullptr;
284 SvgLinearGradient* linear = nullptr;
285 Matrix* transform = nullptr;
286 Array<Fill::ColorStop> stops;
287 bool userSpace = false;
308 struct SvgStyleStroke
310 SvgStrokeFlags flags;
322 struct SvgStyleProperty
325 SvgStyleStroke stroke;
326 SvgComposite clipPath;
338 Array<SvgNode*> child;
340 SvgStyleProperty *style;
347 SvgCircleNode circle;
348 SvgEllipseNode ellipse;
349 SvgPolygonNode polygon;
350 SvgPolygonNode polyline;
355 SvgCompositeNode comp;
364 SvgStyleGradient* styleGrad;
365 Fill::ColorStop gradStop;
366 SvgStopStyleFlags flags;
387 Array<SvgNode *> stack = {nullptr, 0, 0};
388 SvgNode* doc = nullptr;
389 SvgNode* def = nullptr;
390 Array<SvgStyleGradient*> gradients;
391 SvgStyleGradient* latestGradient = nullptr; //For stops
392 SvgParser* svgParse = nullptr;
393 Array<SvgNodeIdPair> cloneNodes;
399 * https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strtof-strtod-l-wcstod-wcstod-l?view=vs-2017
401 * src should be one of the following form :
403 * [whitespace] [sign] {digits [radix digits] | radix digits} [{e | E} [sign] digits]
404 * [whitespace] [sign] {INF | INFINITY}
405 * [whitespace] [sign] NAN [sequence]
407 * No hexadecimal form supported
408 * no sequence supported after NAN
410 float customStrtof(const char *nptr, char **endptr);