summaryrefslogtreecommitdiff
path: root/thirdparty/thorvg/src
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/thorvg/src')
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwCommon.h8
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwFill.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwImage.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwMath.cpp4
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwMemPool.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwRaster.cpp11
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterC.h2
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterTexmap.h2
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwRle.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwShape.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/sw_engine/tvgSwStroke.cpp6
-rw-r--r--thirdparty/thorvg/src/lib/tvgAccessor.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/tvgFill.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/tvgLzw.h4
-rw-r--r--thirdparty/thorvg/src/lib/tvgPicture.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/tvgRadialGradient.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/tvgRender.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/tvgScene.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/tvgShape.cpp2
-rw-r--r--thirdparty/thorvg/src/lib/tvgSwCanvas.cpp2
-rw-r--r--thirdparty/thorvg/src/loaders/jpg/tvgJpgLoader.cpp2
-rw-r--r--thirdparty/thorvg/src/loaders/png/tvgLodePng.cpp2
-rw-r--r--thirdparty/thorvg/src/loaders/png/tvgLodePng.h2
-rw-r--r--thirdparty/thorvg/src/loaders/svg/tvgSvgLoader.cpp19
-rw-r--r--thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h3
-rw-r--r--thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp16
-rw-r--r--thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp2
-rw-r--r--thirdparty/thorvg/src/loaders/tvg/tvgTvgBinInterpreter.cpp2
-rw-r--r--thirdparty/thorvg/src/loaders/tvg/tvgTvgCommon.h2
-rw-r--r--thirdparty/thorvg/src/savers/tvg/tvgTvgSaver.cpp2
30 files changed, 75 insertions, 40 deletions
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwCommon.h b/thirdparty/thorvg/src/lib/sw_engine/tvgSwCommon.h
index be7042d6de..47b0cb83f5 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwCommon.h
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwCommon.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -99,9 +99,9 @@ struct SwSize
struct SwOutline
{
SwPoint* pts; //the outline's points
- uint16_t ptsCnt; //number of points in the glyph
- uint16_t reservedPtsCnt;
- uint16_t* cntrs; //the contour end points
+ uint32_t ptsCnt; //number of points in the glyph
+ uint32_t reservedPtsCnt;
+ uint32_t* cntrs; //the contour end points
uint16_t cntrsCnt; //number of contours in glyph
uint16_t reservedCntrsCnt;
uint8_t* types; //curve type
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwFill.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwFill.cpp
index 04014a9ec3..bba6f26a0b 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwFill.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwFill.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwImage.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwImage.cpp
index f24d2d6f27..c02e28b432 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwImage.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwImage.cpp
@@ -46,7 +46,7 @@ static bool _genOutline(SwImage* image, const Matrix* transform, SwMpool* mpool,
if (outline->reservedCntrsCnt < 1) {
outline->reservedCntrsCnt = 1;
- outline->cntrs = static_cast<uint16_t*>(realloc(outline->cntrs, outline->reservedCntrsCnt * sizeof(uint16_t)));
+ outline->cntrs = static_cast<uint32_t*>(realloc(outline->cntrs, outline->reservedCntrsCnt * sizeof(uint32_t)));
outline->closed = static_cast<bool*>(realloc(outline->closed, outline->reservedCntrsCnt * sizeof(bool)));
outline->closed[0] = true;
}
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwMath.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwMath.cpp
index 7f13609525..ced66ae35c 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwMath.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwMath.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -499,4 +499,4 @@ bool mathUpdateOutlineBBox(const SwOutline* outline, const SwBBox& clipRegion, S
renderRegion.max.y = (yMax + 63) >> 6;
}
return mathClipBBox(clipRegion, renderRegion);
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwMemPool.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwMemPool.cpp
index 3ab0b6069e..d2962e6d8d 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwMemPool.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwMemPool.cpp
@@ -153,4 +153,4 @@ bool mpoolTerm(SwMpool* mpool)
free(mpool);
return true;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRaster.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRaster.cpp
index e3deebe24f..810df8d435 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRaster.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRaster.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -19,6 +19,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
+
+#ifdef _WIN32
+ #include <malloc.h>
+#elif defined(__FreeBSD__)
+ #include <stdlib.h>
+#else
+ #include <alloca.h>
+#endif
+
#include "tvgMath.h"
#include "tvgRender.h"
#include "tvgSwCommon.h"
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterC.h b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterC.h
index d479ede15f..de6b35fd64 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterC.h
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterC.h
@@ -61,4 +61,4 @@ static bool inline cRasterTranslucentRect(SwSurface* surface, const SwBBox& regi
}
}
return true;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterTexmap.h b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterTexmap.h
index 1faedd60aa..abb57d7c45 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterTexmap.h
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRasterTexmap.h
@@ -599,4 +599,4 @@ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const
_rasterPolygonImage(surface, image, region, opacity, polygon, blendMethod, aaSpans);
return _apply(surface, aaSpans);
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRle.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRle.cpp
index aa975869e0..63e7fc9447 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwRle.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwRle.cpp
@@ -1040,4 +1040,4 @@ void rleClipRect(SwRleData *rle, const SwBBox* clip)
_replaceClipSpan(rle, spans, spansEnd - spans);
TVGLOG("SW_ENGINE", "Using ClipRect!");
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwShape.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwShape.cpp
index 2a2c6a1da3..e5b540bcc3 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwShape.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwShape.cpp
@@ -64,7 +64,7 @@ static bool _growOutlineContour(SwOutline& outline, uint32_t n)
{
if (outline.reservedCntrsCnt >= outline.cntrsCnt + n) return false;
outline.reservedCntrsCnt = outline.cntrsCnt + n;
- outline.cntrs = static_cast<uint16_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint16_t)));
+ outline.cntrs = static_cast<uint32_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint32_t)));
return true;
}
diff --git a/thirdparty/thorvg/src/lib/sw_engine/tvgSwStroke.cpp b/thirdparty/thorvg/src/lib/sw_engine/tvgSwStroke.cpp
index 04aa9a36ec..be4392740e 100644
--- a/thirdparty/thorvg/src/lib/sw_engine/tvgSwStroke.cpp
+++ b/thirdparty/thorvg/src/lib/sw_engine/tvgSwStroke.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -780,7 +780,7 @@ static void _exportBorderOutline(const SwStroke& stroke, SwOutline* outline, uin
auto src = border->tags;
auto tags = outline->types + outline->ptsCnt;
auto cntrs = outline->cntrs + outline->cntrsCnt;
- uint16_t idx = outline->ptsCnt;
+ auto idx = outline->ptsCnt;
while (cnt > 0) {
@@ -921,7 +921,7 @@ SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid)
outline->reservedPtsCnt = ptsCnt;
}
if (outline->reservedCntrsCnt < cntrsCnt) {
- outline->cntrs = static_cast<uint16_t*>(realloc(outline->cntrs, sizeof(uint16_t) * cntrsCnt));
+ outline->cntrs = static_cast<uint32_t*>(realloc(outline->cntrs, sizeof(uint32_t) * cntrsCnt));
outline->reservedCntrsCnt = cntrsCnt;
}
diff --git a/thirdparty/thorvg/src/lib/tvgAccessor.cpp b/thirdparty/thorvg/src/lib/tvgAccessor.cpp
index 9fd564dd23..092c8b0731 100644
--- a/thirdparty/thorvg/src/lib/tvgAccessor.cpp
+++ b/thirdparty/thorvg/src/lib/tvgAccessor.cpp
@@ -81,4 +81,4 @@ Accessor::Accessor()
unique_ptr<Accessor> Accessor::gen() noexcept
{
return unique_ptr<Accessor>(new Accessor);
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/tvgFill.cpp b/thirdparty/thorvg/src/lib/tvgFill.cpp
index 0c0581a180..eecf239cee 100644
--- a/thirdparty/thorvg/src/lib/tvgFill.cpp
+++ b/thirdparty/thorvg/src/lib/tvgFill.cpp
@@ -112,4 +112,4 @@ Fill* Fill::duplicate() const noexcept
uint32_t Fill::identifier() const noexcept
{
return pImpl->id;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/tvgLzw.h b/thirdparty/thorvg/src/lib/tvgLzw.h
index 1bd5c61fac..8e165bdb34 100644
--- a/thirdparty/thorvg/src/lib/tvgLzw.h
+++ b/thirdparty/thorvg/src/lib/tvgLzw.h
@@ -22,10 +22,12 @@
#ifndef _TVG_LZW_H_
#define _TVG_LZW_H_
+#include <cstdint>
+
namespace tvg
{
uint8_t* lzwEncode(const uint8_t* uncompressed, uint32_t uncompressedSizeBytes, uint32_t* compressedSizeBytes, uint32_t* compressedSizeBits);
uint8_t* lzwDecode(const uint8_t* compressed, uint32_t compressedSizeBytes, uint32_t compressedSizeBits, uint32_t uncompressedSizeBytes);
}
-#endif //_TVG_LZW_H \ No newline at end of file
+#endif //_TVG_LZW_H
diff --git a/thirdparty/thorvg/src/lib/tvgPicture.cpp b/thirdparty/thorvg/src/lib/tvgPicture.cpp
index 1125b1eb58..1e04e25435 100644
--- a/thirdparty/thorvg/src/lib/tvgPicture.cpp
+++ b/thirdparty/thorvg/src/lib/tvgPicture.cpp
@@ -118,4 +118,4 @@ const uint32_t* Picture::data(uint32_t* w, uint32_t* h) const noexcept
}
if (pImpl->surface) return pImpl->surface->buffer;
else return nullptr;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/tvgRadialGradient.cpp b/thirdparty/thorvg/src/lib/tvgRadialGradient.cpp
index 7aba550e48..7f4e1d7e17 100644
--- a/thirdparty/thorvg/src/lib/tvgRadialGradient.cpp
+++ b/thirdparty/thorvg/src/lib/tvgRadialGradient.cpp
@@ -94,4 +94,4 @@ unique_ptr<RadialGradient> RadialGradient::gen() noexcept
uint32_t RadialGradient::identifier() noexcept
{
return TVG_CLASS_ID_RADIAL;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/tvgRender.cpp b/thirdparty/thorvg/src/lib/tvgRender.cpp
index 145f974cee..90f0917e6b 100644
--- a/thirdparty/thorvg/src/lib/tvgRender.cpp
+++ b/thirdparty/thorvg/src/lib/tvgRender.cpp
@@ -70,4 +70,4 @@ RenderTransform::RenderTransform()
RenderTransform::RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs)
{
m = mathMultiply(&lhs->m, &rhs->m);
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/tvgScene.cpp b/thirdparty/thorvg/src/lib/tvgScene.cpp
index ff43d3c881..0beec47b38 100644
--- a/thirdparty/thorvg/src/lib/tvgScene.cpp
+++ b/thirdparty/thorvg/src/lib/tvgScene.cpp
@@ -73,4 +73,4 @@ Result Scene::clear(bool free) noexcept
pImpl->clear(free);
return Result::Success;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/tvgShape.cpp b/thirdparty/thorvg/src/lib/tvgShape.cpp
index 3a3af5f76e..e57f2eafb2 100644
--- a/thirdparty/thorvg/src/lib/tvgShape.cpp
+++ b/thirdparty/thorvg/src/lib/tvgShape.cpp
@@ -424,4 +424,4 @@ Result Shape::fill(FillRule r) noexcept
FillRule Shape::fillRule() const noexcept
{
return pImpl->rule;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/lib/tvgSwCanvas.cpp b/thirdparty/thorvg/src/lib/tvgSwCanvas.cpp
index 8c9de8cb51..b5cae424f7 100644
--- a/thirdparty/thorvg/src/lib/tvgSwCanvas.cpp
+++ b/thirdparty/thorvg/src/lib/tvgSwCanvas.cpp
@@ -102,4 +102,4 @@ unique_ptr<SwCanvas> SwCanvas::gen() noexcept
return unique_ptr<SwCanvas>(new SwCanvas);
#endif
return nullptr;
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/loaders/jpg/tvgJpgLoader.cpp b/thirdparty/thorvg/src/loaders/jpg/tvgJpgLoader.cpp
index 7b90b4aef9..ffdef3004c 100644
--- a/thirdparty/thorvg/src/loaders/jpg/tvgJpgLoader.cpp
+++ b/thirdparty/thorvg/src/loaders/jpg/tvgJpgLoader.cpp
@@ -134,4 +134,4 @@ void JpgLoader::run(unsigned tid)
image = nullptr;
}
image = jpgdDecompress(decoder);
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/loaders/png/tvgLodePng.cpp b/thirdparty/thorvg/src/loaders/png/tvgLodePng.cpp
index 5c01c5a1e2..eaed025c54 100644
--- a/thirdparty/thorvg/src/loaders/png/tvgLodePng.cpp
+++ b/thirdparty/thorvg/src/loaders/png/tvgLodePng.cpp
@@ -2644,4 +2644,4 @@ void lodepng_state_cleanup(LodePNGState* state)
{
lodepng_color_mode_cleanup(&state->info_raw);
lodepng_info_cleanup(&state->info_png);
-} \ No newline at end of file
+}
diff --git a/thirdparty/thorvg/src/loaders/png/tvgLodePng.h b/thirdparty/thorvg/src/loaders/png/tvgLodePng.h
index c9f0e56ab6..0cdac7cbea 100644
--- a/thirdparty/thorvg/src/loaders/png/tvgLodePng.h
+++ b/thirdparty/thorvg/src/loaders/png/tvgLodePng.h
@@ -171,4 +171,4 @@ void lodepng_state_cleanup(LodePNGState* state);
unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h, LodePNGState* state, const unsigned char* in, size_t insize);
unsigned lodepng_inspect(unsigned* w, unsigned* h, LodePNGState* state, const unsigned char* in, size_t insize);
-#endif //_TVG_LODEPNG_H_ \ No newline at end of file
+#endif //_TVG_LODEPNG_H_
diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgLoader.cpp b/thirdparty/thorvg/src/loaders/svg/tvgSvgLoader.cpp
index a842b7fa8b..42bfd4de70 100644
--- a/thirdparty/thorvg/src/loaders/svg/tvgSvgLoader.cpp
+++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgLoader.cpp
@@ -337,7 +337,10 @@ static unsigned char _parserColor(const char* value, char** end)
r = svgUtilStrtof(value, end);
*end = _skipSpace(*end, nullptr);
- if (**end == '%') r = 255 * r / 100;
+ if (**end == '%') {
+ r = 255 * r / 100;
+ (*end)++;
+ }
*end = _skipSpace(*end, nullptr);
if (r < 0 || r > 255) {
@@ -1145,10 +1148,13 @@ static bool _attrParseSymbolNode(void* data, const char* key, const char* value)
if (!strcmp(key, "viewBox")) {
if (!_parseNumber(&value, &symbol->vx) || !_parseNumber(&value, &symbol->vy)) return false;
if (!_parseNumber(&value, &symbol->vw) || !_parseNumber(&value, &symbol->vh)) return false;
+ symbol->hasViewBox = true;
} else if (!strcmp(key, "width")) {
symbol->w = _toFloat(loader->svgParse, value, SvgParserLengthType::Horizontal);
+ symbol->hasWidth = true;
} else if (!strcmp(key, "height")) {
symbol->h = _toFloat(loader->svgParse, value, SvgParserLengthType::Vertical);
+ symbol->hasHeight = true;
} else if (!strcmp(key, "preserveAspectRatio")) {
if (!strcmp(value, "none")) symbol->preserveAspect = false;
} else if (!strcmp(key, "overflow")) {
@@ -1306,6 +1312,12 @@ static SvgNode* _createSymbolNode(SvgLoaderData* loader, SvgNode* parent, const
loader->svgParse->node->node.symbol.preserveAspect = true;
loader->svgParse->node->node.symbol.overflowVisible = false;
+ loader->svgParse->node->node.symbol.hasViewBox = false;
+ loader->svgParse->node->node.symbol.hasWidth = false;
+ loader->svgParse->node->node.symbol.hasHeight = false;
+ loader->svgParse->node->node.symbol.vx = 0.0f;
+ loader->svgParse->node->node.symbol.vy = 0.0f;
+
func(buf, bufLength, _attrParseSymbolNode, loader);
return loader->svgParse->node;
@@ -2722,6 +2734,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
}
/* default value for opacity */
loader->svgParse->gradStop = {0.0f, 0, 0, 0, 255};
+ loader->svgParse->flags = SvgStopStyleFlags::StopDefault;
simpleXmlParseAttributes(attrs, attrsLength, _attrParseStops, loader);
loader->latestGradient->stops.push(loader->svgParse->gradStop);
} else if (!isIgnoreUnsupportedLogElements(tagName)) {
@@ -2865,7 +2878,7 @@ static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const
auto gradList = gradients->data;
for (uint32_t i = 0; i < gradients->count; ++i) {
- if (!strcmp((*gradList)->id, id)) {
+ if ((*gradList)->id && !strcmp((*gradList)->id, id)) {
result = _cloneGradient(*gradList);
break;
}
@@ -2875,7 +2888,7 @@ static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const
if (result && result->ref) {
gradList = gradients->data;
for (uint32_t i = 0; i < gradients->count; ++i) {
- if (!strcmp((*gradList)->id, result->ref)) {
+ if ((*gradList)->id && !strcmp((*gradList)->id, result->ref)) {
if (result->stops.count == 0) _cloneGradStops(result->stops, (*gradList)->stops);
//TODO: Properly inherit other property
break;
diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h b/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h
index 1f25e82adc..dc9ed558c3 100644
--- a/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h
+++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgLoaderCommon.h
@@ -173,6 +173,9 @@ struct SvgSymbolNode
float vx, vy, vw, vh;
bool preserveAspect;
bool overflowVisible;
+ bool hasViewBox;
+ bool hasWidth;
+ bool hasHeight;
};
struct SvgUseNode
diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp b/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp
index 90705f2523..a3f34fd46b 100644
--- a/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp
+++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp
@@ -576,15 +576,17 @@ static unique_ptr<Scene> _useBuildHelper(const SvgNode* node, const Box& vBox, c
if (node->node.use.symbol) {
auto symbol = node->node.use.symbol->node.symbol;
- auto width = symbol.w;
+ auto width = (symbol.hasWidth ? symbol.w : vBox.w);
if (node->node.use.isWidthSet) width = node->node.use.w;
- auto height = symbol.h;
+ auto height = (symbol.hasHeight ? symbol.h : vBox.h);;
if (node->node.use.isHeightSet) height = node->node.use.h;
+ auto vw = (symbol.hasViewBox ? symbol.vw : width);
+ auto vh = (symbol.hasViewBox ? symbol.vh : height);
Matrix mViewBox = {1, 0, 0, 0, 1, 0, 0, 0, 1};
- if ((!mathEqual(width, symbol.vw) || !mathEqual(height, symbol.vh)) && symbol.vw > 0 && symbol.vh > 0) {
- auto sx = width / symbol.vw;
- auto sy = height / symbol.vh;
+ if ((!mathEqual(width, vw) || !mathEqual(height, vh)) && vw > 0 && vh > 0) {
+ auto sx = width / vw;
+ auto sy = height / vh;
if (symbol.preserveAspect) {
if (sx < sy) sy = sx;
else sx = sy;
@@ -592,8 +594,8 @@ static unique_ptr<Scene> _useBuildHelper(const SvgNode* node, const Box& vBox, c
auto tvx = symbol.vx * sx;
auto tvy = symbol.vy * sy;
- auto tvw = symbol.vw * sx;
- auto tvh = symbol.vh * sy;
+ auto tvw = vw * sx;
+ auto tvh = vh * sy;
tvy -= (symbol.h - tvh) * 0.5f;
tvx -= (symbol.w - tvw) * 0.5f;
mViewBox = {sx, 0, -tvx, 0, sy, -tvy, 0, 0, 1};
diff --git a/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp b/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
index a12689c7dd..d7c51bdc30 100644
--- a/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
+++ b/thirdparty/thorvg/src/loaders/svg/tvgXmlParser.cpp
@@ -26,6 +26,8 @@
#ifdef _WIN32
#include <malloc.h>
+#elif defined(__FreeBSD__)
+ #include <stdlib.h>
#else
#include <alloca.h>
#endif
diff --git a/thirdparty/thorvg/src/loaders/tvg/tvgTvgBinInterpreter.cpp b/thirdparty/thorvg/src/loaders/tvg/tvgTvgBinInterpreter.cpp
index 2b85342b2c..66de860aaa 100644
--- a/thirdparty/thorvg/src/loaders/tvg/tvgTvgBinInterpreter.cpp
+++ b/thirdparty/thorvg/src/loaders/tvg/tvgTvgBinInterpreter.cpp
@@ -23,6 +23,8 @@
#ifdef _WIN32
#include <malloc.h>
+#elif defined(__FreeBSD__)
+ #include <stdlib.h>
#else
#include <alloca.h>
#endif
diff --git a/thirdparty/thorvg/src/loaders/tvg/tvgTvgCommon.h b/thirdparty/thorvg/src/loaders/tvg/tvgTvgCommon.h
index 62181605a2..a0762d0fcc 100644
--- a/thirdparty/thorvg/src/loaders/tvg/tvgTvgCommon.h
+++ b/thirdparty/thorvg/src/loaders/tvg/tvgTvgCommon.h
@@ -51,4 +51,4 @@ public:
};
-#endif //_TVG_TVG_COMMON_H_ \ No newline at end of file
+#endif //_TVG_TVG_COMMON_H_
diff --git a/thirdparty/thorvg/src/savers/tvg/tvgTvgSaver.cpp b/thirdparty/thorvg/src/savers/tvg/tvgTvgSaver.cpp
index aa54d21342..fca313b430 100644
--- a/thirdparty/thorvg/src/savers/tvg/tvgTvgSaver.cpp
+++ b/thirdparty/thorvg/src/savers/tvg/tvgTvgSaver.cpp
@@ -28,6 +28,8 @@
#ifdef _WIN32
#include <malloc.h>
+#elif defined(__FreeBSD__)
+ #include <stdlib.h>
#else
#include <alloca.h>
#endif