summaryrefslogtreecommitdiff
path: root/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h')
-rw-r--r--thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h110
1 files changed, 106 insertions, 4 deletions
diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h b/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h
index 3588cabf0b..dec9fadebe 100644
--- a/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h
+++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2020 - 2023 the ThorVG project. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -19,6 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
+
#ifndef _TVG_SVG_LOADER_COMMON_H_
#define _TVG_SVG_LOADER_COMMON_H_
@@ -79,6 +80,16 @@ enum class SvgFillFlags
ClipPath = 0x16
};
+constexpr bool operator &(SvgFillFlags a, SvgFillFlags b)
+{
+ return int(a) & int(b);
+}
+
+constexpr SvgFillFlags operator |(SvgFillFlags a, SvgFillFlags b)
+{
+ return SvgFillFlags(int(a) | int(b));
+}
+
enum class SvgStrokeFlags
{
Paint = 0x1,
@@ -91,6 +102,17 @@ enum class SvgStrokeFlags
Dash = 0x80,
};
+constexpr bool operator &(SvgStrokeFlags a, SvgStrokeFlags b)
+{
+ return int(a) & int(b);
+}
+
+constexpr SvgStrokeFlags operator |(SvgStrokeFlags a, SvgStrokeFlags b)
+{
+ return SvgStrokeFlags(int(a) | int(b));
+}
+
+
enum class SvgGradientType
{
Linear,
@@ -114,9 +136,20 @@ enum class SvgStyleFlags
ClipPath = 0x1000,
Mask = 0x2000,
MaskType = 0x4000,
- Display = 0x8000
+ Display = 0x8000,
+ PaintOrder = 0x10000
};
+constexpr bool operator &(SvgStyleFlags a, SvgStyleFlags b)
+{
+ return int(a) & int(b);
+}
+
+constexpr SvgStyleFlags operator |(SvgStyleFlags a, SvgStyleFlags b)
+{
+ return SvgStyleFlags(int(a) | int(b));
+}
+
enum class SvgStopStyleFlags
{
StopDefault = 0x0,
@@ -124,6 +157,42 @@ enum class SvgStopStyleFlags
StopColor = 0x02
};
+constexpr bool operator &(SvgStopStyleFlags a, SvgStopStyleFlags b)
+{
+ return int(a) & int(b);
+}
+
+constexpr SvgStopStyleFlags operator |(SvgStopStyleFlags a, SvgStopStyleFlags b)
+{
+ return SvgStopStyleFlags(int(a) | int(b));
+}
+
+enum class SvgGradientFlags
+{
+ None = 0x0,
+ GradientUnits = 0x1,
+ SpreadMethod = 0x2,
+ X1 = 0x4,
+ X2 = 0x8,
+ Y1 = 0x10,
+ Y2 = 0x20,
+ Cx = 0x40,
+ Cy = 0x80,
+ R = 0x100,
+ Fx = 0x200,
+ Fy = 0x400
+};
+
+constexpr bool operator &(SvgGradientFlags a, SvgGradientFlags b)
+{
+ return int(a) & int(b);
+}
+
+constexpr SvgGradientFlags operator |(SvgGradientFlags a, SvgGradientFlags b)
+{
+ return SvgGradientFlags(int(a) | int(b));
+}
+
enum class SvgFillRule
{
Winding = 0,
@@ -145,6 +214,31 @@ enum class SvgParserLengthType
Other
};
+enum class SvgViewFlag
+{
+ None = 0x0,
+ Width = 0x01, //viewPort width
+ Height = 0x02, //viewPort height
+ Viewbox = 0x04, //viewBox x,y,w,h - used only if all 4 are correctly set
+ WidthInPercent = 0x08,
+ HeightInPercent = 0x10
+};
+
+constexpr bool operator &(SvgViewFlag a, SvgViewFlag b)
+{
+ return static_cast<int>(a) & static_cast<int>(b);
+}
+
+constexpr SvgViewFlag operator |(SvgViewFlag a, SvgViewFlag b)
+{
+ return SvgViewFlag(int(a) | int(b));
+}
+
+constexpr SvgViewFlag operator ^(SvgViewFlag a, SvgViewFlag b)
+{
+ return SvgViewFlag(int(a) ^ int(b));
+}
+
enum class AspectRatioAlign
{
None,
@@ -167,12 +261,13 @@ enum class AspectRatioMeetOrSlice
struct SvgDocNode
{
- float w;
- float h;
+ float w; //unit: point or in percentage see: SvgViewFlag
+ float h; //unit: point or in percentage see: SvgViewFlag
float vx;
float vy;
float vw;
float vh;
+ SvgViewFlag viewFlag;
SvgNode* defs;
SvgNode* style;
AspectRatioAlign align;
@@ -339,6 +434,7 @@ struct SvgStyleGradient
SvgLinearGradient* linear;
Matrix* transform;
Array<Fill::ColorStop> stops;
+ SvgGradientFlags flags;
bool userSpace;
void clear()
@@ -384,6 +480,7 @@ struct SvgStyleProperty
SvgColor color;
bool curColorSet;
char* cssClass;
+ bool paintOrder; //true if default (fill, stroke), false otherwise
SvgStyleFlags flags;
};
@@ -456,6 +553,11 @@ struct SvgLoaderData
bool style = false;
};
+struct Box
+{
+ float x, y, w, h;
+};
+
/*
* https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strtof-strtod-l-wcstod-wcstod-l?view=vs-2017
*