From 06d8105a172c18cff1eeabd295c743a026bb34d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 18 Jan 2022 12:20:35 +0100 Subject: [PATCH 01/16] build: Add missing includes for MinGW compatibility Change-Id: I046d4bd18604b5b21696f290d75e1aea069bf314 --- src/loaders/svg/tvgSvgLoader.cpp | 1 + src/loaders/svg/tvgSvgPath.cpp | 1 + src/loaders/svg/tvgSvgSceneBuilder.cpp | 1 + src/loaders/svg/tvgSvgUtil.cpp | 1 + src/loaders/svg/tvgXmlParser.cpp | 1 + src/savers/tvg/tvgTvgSaver.cpp | 2 ++ 6 files changed, 7 insertions(+) diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index eb7a0e0..09ed29f 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -51,6 +51,7 @@ #define _USE_MATH_DEFINES //Math Constants are not defined in Standard C/C++. +#include #include #include #include diff --git a/src/loaders/svg/tvgSvgPath.cpp b/src/loaders/svg/tvgSvgPath.cpp index c712b72..a09a279 100644 --- a/src/loaders/svg/tvgSvgPath.cpp +++ b/src/loaders/svg/tvgSvgPath.cpp @@ -50,6 +50,7 @@ #define _USE_MATH_DEFINES //Math Constants are not defined in Standard C/C++. +#include #include #include #include diff --git a/src/loaders/svg/tvgSvgSceneBuilder.cpp b/src/loaders/svg/tvgSvgSceneBuilder.cpp index 0645c32..e9b8f42 100644 --- a/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -49,6 +49,7 @@ */ +#include #include #include "tvgMath.h" #include "tvgSvgLoaderCommon.h" diff --git a/src/loaders/svg/tvgSvgUtil.cpp b/src/loaders/svg/tvgSvgUtil.cpp index 2569202..1f1fe2a 100644 --- a/src/loaders/svg/tvgSvgUtil.cpp +++ b/src/loaders/svg/tvgSvgUtil.cpp @@ -20,6 +20,7 @@ * SOFTWARE. */ +#include #include #include #include "tvgSvgUtil.h" diff --git a/src/loaders/svg/tvgXmlParser.cpp b/src/loaders/svg/tvgXmlParser.cpp index 81b7957..d182bc2 100644 --- a/src/loaders/svg/tvgXmlParser.cpp +++ b/src/loaders/svg/tvgXmlParser.cpp @@ -20,6 +20,7 @@ * SOFTWARE. */ +#include #include #include diff --git a/src/savers/tvg/tvgTvgSaver.cpp b/src/savers/tvg/tvgTvgSaver.cpp index f21219f..aa54d21 100644 --- a/src/savers/tvg/tvgTvgSaver.cpp +++ b/src/savers/tvg/tvgTvgSaver.cpp @@ -24,6 +24,8 @@ #include "tvgTvgSaver.h" #include "tvgLzw.h" +#include + #ifdef _WIN32 #include #else -- 2.7.4 From cd75c1dcdae271000f263ed3376e53770b73aabd Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Tue, 18 Jan 2022 23:59:14 +0100 Subject: [PATCH 02/16] svg_loader: group tags misinterpreted as parent nodes Group tags in a format finds no application to the rest of the svg file and should be skipped. Change-Id: I77f7a5acdccdbb3239670d8cdbf6d0f8e8416d48 --- src/loaders/svg/tvgSvgLoader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index 09ed29f..74e6144 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -2539,6 +2539,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content, if ((method = _findGroupFactory(tagName))) { //Group + if (empty) return; if (!loader->doc) { if (strcmp(tagName, "svg")) return; //Not a valid svg document node = method(loader, nullptr, attrs, attrsLength); -- 2.7.4 From 5c3fac747db096ecb4511463cad2af8fc6e4cc3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 19 Jan 2022 10:59:34 +0100 Subject: [PATCH 03/16] sw_engine: Replace non-portable min/max with tvgMath.h macros This would fail building with Visual Studio 2017, at least downstream in Godot where we undefine old Windows compilers' non-standard `min`/`max` macros (see `minmax.h`/`NOMINMAX`). Change-Id: I593db53fb75b8eaac98f578fb49fa8f923cb7fb9 --- AUTHORS | 2 ++ src/lib/sw_engine/tvgSwRenderer.cpp | 9 +++++---- src/lib/tvgMath.h | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6605723..ec06c49 100644 --- a/AUTHORS +++ b/AUTHORS @@ -13,3 +13,5 @@ Pankaj Kumar Patryk Kaczmarek Michal Maciola Peter Vullings +K. S. Ernest (iFire) Lee +Rémi Verschelde diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index f63cece..49a4b5e 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -23,6 +23,7 @@ #include "tvgSwCommon.h" #include "tvgTaskScheduler.h" #include "tvgSwRenderer.h" +#include "tvgMath.h" /************************************************************************/ /* Internal Class Implementation */ @@ -594,10 +595,10 @@ void* SwRenderer::prepareCommon(SwTask* task, const RenderTransform* transform, task->surface = surface; task->mpool = mpool; task->flags = flags; - task->bbox.min.x = max(static_cast(0), static_cast(vport.x)); - task->bbox.min.y = max(static_cast(0), static_cast(vport.y)); - task->bbox.max.x = min(static_cast(surface->w), static_cast(vport.x + vport.w)); - task->bbox.max.y = min(static_cast(surface->h), static_cast(vport.y + vport.h)); + task->bbox.min.x = mathMax(static_cast(0), static_cast(vport.x)); + task->bbox.min.y = mathMax(static_cast(0), static_cast(vport.y)); + task->bbox.max.x = mathMin(static_cast(surface->w), static_cast(vport.x + vport.w)); + task->bbox.max.y = mathMin(static_cast(surface->h), static_cast(vport.y + vport.h)); if (!task->pushed) { task->pushed = true; diff --git a/src/lib/tvgMath.h b/src/lib/tvgMath.h index da93199..d4d3ad9 100644 --- a/src/lib/tvgMath.h +++ b/src/lib/tvgMath.h @@ -29,6 +29,10 @@ #include "tvgCommon.h" +#define mathMin(x, y) (((x) < (y)) ? (x) : (y)) +#define mathMax(x, y) (((x) > (y)) ? (x) : (y)) + + static inline bool mathZero(float a) { return (fabsf(a) < FLT_EPSILON) ? true : false; @@ -154,4 +158,4 @@ static inline Matrix mathMultiply(const Matrix* lhs, const Matrix* rhs) } -#endif //_TVG_MATH_H_ \ No newline at end of file +#endif //_TVG_MATH_H_ -- 2.7.4 From 2f707c6a0d748a105d412983233c5fa2efc1ae79 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 20 Jan 2022 11:27:28 +0900 Subject: [PATCH 04/16] sw_engine renderer: code refactoring remove unnecessary header inclusion. Change-Id: Ic58763dd5a1f95169208eb09c85929a140c8994d --- src/lib/sw_engine/tvgSwRenderer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index 49a4b5e..c3872f3 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -19,11 +19,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include +#include "tvgMath.h" #include "tvgSwCommon.h" #include "tvgTaskScheduler.h" #include "tvgSwRenderer.h" -#include "tvgMath.h" /************************************************************************/ /* Internal Class Implementation */ -- 2.7.4 From adda399b271a19da834d0b8c4ca7a7c4bf97567b Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 20 Jan 2022 12:04:19 +0900 Subject: [PATCH 05/16] svg_loader: ++robustness Prevent recursive calls by counting just in case. The size is arbitrary value, we can adjust it experimentally. @Issue: https://github.com/Samsung/thorvg/issues/1161 Change-Id: I30571e5de085c65980a240b14c592bc0b47a7860 --- src/loaders/svg/tvgSvgLoader.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index 74e6144..4990c5c 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -1934,8 +1934,15 @@ static void _copyAttr(SvgNode* to, const SvgNode* from) } -static void _cloneNode(SvgNode* from, SvgNode* parent) +static void _cloneNode(SvgNode* from, SvgNode* parent, int depth) { + /* Exception handling: Prevent invalid SVG data input. + The size is the arbitrary value, we need an experimental size. */ + if (depth == 8192) { + TVGERR("SVG", "Infinite recursive call - stopped after %d calls! Svg file may be incorrectly formatted.", depth); + return; + } + SvgNode* newNode; if (!from || !parent || from == parent) return; @@ -1947,7 +1954,7 @@ static void _cloneNode(SvgNode* from, SvgNode* parent) auto child = from->child.data; for (uint32_t i = 0; i < from->child.count; ++i, ++child) { - _cloneNode(*child, newNode); + _cloneNode(*child, newNode, depth + 1); } } @@ -1965,7 +1972,7 @@ static void _clonePostponedNodes(Array* cloneNodes, SvgNode* doc) auto defs = _getDefsNode(nodeIdPair.node); auto nodeFrom = _findChildById(defs, nodeIdPair.id); if (!nodeFrom) nodeFrom = _findChildById(doc, nodeIdPair.id); - _cloneNode(nodeFrom, nodeIdPair.node); + _cloneNode(nodeFrom, nodeIdPair.node, 0); free(nodeIdPair.id); } } @@ -2006,7 +2013,7 @@ static bool _attrParseUseNode(void* data, const char* key, const char* value) defs = _getDefsNode(node); nodeFrom = _findChildById(defs, id); if (nodeFrom) { - _cloneNode(nodeFrom, node); + _cloneNode(nodeFrom, node, 0); free(id); } else { //some svg export software include element at the end of the file -- 2.7.4 From 4bf49c05bf258cb4fe237d25745645e32e2cf048 Mon Sep 17 00:00:00 2001 From: jykeon Date: Mon, 27 Feb 2023 16:53:00 +0900 Subject: [PATCH 06/16] Bump up 0.7.5 Change-Id: I0ce3f00a49467ffd990eeeaf0179171401280177 Signed-off-by: jykeon --- packaging/thorvg.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/thorvg.spec b/packaging/thorvg.spec index a2f5c0d..a53aa64 100644 --- a/packaging/thorvg.spec +++ b/packaging/thorvg.spec @@ -1,6 +1,6 @@ Name: thorvg Summary: Thor Vector Graphics Library -Version: 0.7.4 +Version: 0.7.5 Release: 1 Group: Graphics System/Rendering Engine License: MIT -- 2.7.4 From b86c6e7236df93ae3434d8dde727dfea8cf742d0 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Thu, 20 Jan 2022 13:55:05 +0100 Subject: [PATCH 07/16] sw_engine: float casted on the unsigned int type uint32_t -> int32_t Change-Id: I33a7ba842a19acafc2cbe9bfa4bc8f6f79ba7658 --- src/lib/sw_engine/tvgSwImage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwImage.cpp b/src/lib/sw_engine/tvgSwImage.cpp index 9b57700..f24d2d6 100644 --- a/src/lib/sw_engine/tvgSwImage.cpp +++ b/src/lib/sw_engine/tvgSwImage.cpp @@ -84,8 +84,8 @@ bool imagePrepare(SwImage* image, const Matrix* transform, const SwBBox& clipReg //Fast track: Non-transformed image but just shifted. if (image->direct) { - image->ox = -static_cast(round(transform->e13)); - image->oy = -static_cast(round(transform->e23)); + image->ox = -static_cast(round(transform->e13)); + image->oy = -static_cast(round(transform->e23)); //Figure out the scale factor by transform matrix } else { auto scaleX = sqrtf((transform->e11 * transform->e11) + (transform->e21 * transform->e21)); -- 2.7.4 From 8d4b1c99d7e87f6d98cc39a3c40b8a6a4bfcbd1d Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Fri, 21 Jan 2022 23:45:03 +0100 Subject: [PATCH 08/16] examples: terminate the same engine as was initialized Change-Id: I3e1b3cbee003fa18fdec8b554588d3420473aa08 --- src/examples/AnimateMasking.cpp | 2 +- src/examples/GradientMasking.cpp | 6 +++--- src/examples/GradientStroke.cpp | 2 +- src/examples/InvMasking.cpp | 2 +- src/examples/LumaMasking.cpp | 2 +- src/examples/Masking.cpp | 2 +- src/examples/MultiCanvas.cpp | 6 +++--- src/examples/PictureJpg.cpp | 2 +- src/examples/PicturePng.cpp | 4 ++-- src/examples/PictureRaw.cpp | 2 +- src/examples/Stress.cpp | 2 +- src/examples/Svg.cpp | 2 +- src/examples/Svg2.cpp | 2 +- src/examples/Tvg.cpp | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/examples/AnimateMasking.cpp b/src/examples/AnimateMasking.cpp index 7f1ba23..48cbe70 100644 --- a/src/examples/AnimateMasking.cpp +++ b/src/examples/AnimateMasking.cpp @@ -103,7 +103,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress) You can update only necessary properties of this shape, while retaining other properties. */ - // Translate mask object with its stroke & update + // Translate mask object with its stroke & update pMaskShape->translate(0 , progress * 300); pMask->translate(0 , progress * 300); diff --git a/src/examples/GradientMasking.cpp b/src/examples/GradientMasking.cpp index bafc21a..b8b88ea 100644 --- a/src/examples/GradientMasking.cpp +++ b/src/examples/GradientMasking.cpp @@ -47,7 +47,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) colorStops[1] = {1,255,255,255,255}; fill->colorStops(colorStops,2); shape->fill(move(fill)); - + shape->composite(move(mask), tvg::CompositeMethod::AlphaMask); canvas->push(move(shape)); @@ -79,7 +79,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) colorStops1[1] = {1,1,255,255,255}; fill1->colorStops(colorStops1,2); shape1->fill(move(fill1)); - + shape1->composite(move(mask1), tvg::CompositeMethod::AlphaMask); canvas->push(move(shape1)); @@ -237,7 +237,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/GradientStroke.cpp b/src/examples/GradientStroke.cpp index 8b04aa2..6e2b97e 100644 --- a/src/examples/GradientStroke.cpp +++ b/src/examples/GradientStroke.cpp @@ -77,7 +77,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) if (canvas->push(move(shape1)) != tvg::Result::Success) return; - // radial gradient stroke + duplicate + // radial gradient stroke + duplicate auto shape2 = tvg::Shape::gen(); shape2->appendCircle(600, 175, 100, 60); shape2->stroke(80); diff --git a/src/examples/InvMasking.cpp b/src/examples/InvMasking.cpp index cd4b0a3..4b6eb31 100644 --- a/src/examples/InvMasking.cpp +++ b/src/examples/InvMasking.cpp @@ -212,7 +212,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/LumaMasking.cpp b/src/examples/LumaMasking.cpp index 45b1548..cb32d1b 100644 --- a/src/examples/LumaMasking.cpp +++ b/src/examples/LumaMasking.cpp @@ -208,7 +208,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/Masking.cpp b/src/examples/Masking.cpp index 8b63b0b..88be49a 100644 --- a/src/examples/Masking.cpp +++ b/src/examples/Masking.cpp @@ -212,7 +212,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/MultiCanvas.cpp b/src/examples/MultiCanvas.cpp index 006223f..f622a05 100644 --- a/src/examples/MultiCanvas.cpp +++ b/src/examples/MultiCanvas.cpp @@ -178,7 +178,7 @@ void tvgGlTest(const char* name, const char* path, void* data) objData->name = strdup(name); objData->path = strdup(path); - Eo* win = (Eo*) data; + Eo* win = (Eo*) data; Eo* view = elm_glview_add(win); elm_glview_mode_set(view, ELM_GLVIEW_ALPHA); @@ -189,7 +189,7 @@ void tvgGlTest(const char* name, const char* path, void* data) evas_object_data_set(view, "objdata", reinterpret_cast(objData)); evas_object_event_callback_add(view, EVAS_CALLBACK_DEL, gl_del, objData); evas_object_resize(view, SIZE, SIZE); - evas_object_move(view, (count % NUM_PER_LINE) * SIZE, SIZE * (count / NUM_PER_LINE)); + evas_object_move(view, (count % NUM_PER_LINE) * SIZE, SIZE * (count / NUM_PER_LINE)); evas_object_show(view); } @@ -238,7 +238,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/PictureJpg.cpp b/src/examples/PictureJpg.cpp index df56f3e..c04b34b 100644 --- a/src/examples/PictureJpg.cpp +++ b/src/examples/PictureJpg.cpp @@ -169,7 +169,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { diff --git a/src/examples/PicturePng.cpp b/src/examples/PicturePng.cpp index 0cbaedb..b43926a 100644 --- a/src/examples/PicturePng.cpp +++ b/src/examples/PicturePng.cpp @@ -31,7 +31,7 @@ void tvgDrawCmds(tvg::Canvas* canvas) { if (!canvas) return; - //Background + //Background auto bg = tvg::Shape::gen(); bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0); //x, y, w, h, rx, ry bg->fill(255, 255, 255, 255); //r, g, b, a @@ -175,7 +175,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { diff --git a/src/examples/PictureRaw.cpp b/src/examples/PictureRaw.cpp index dcb86fc..ea6de16 100644 --- a/src/examples/PictureRaw.cpp +++ b/src/examples/PictureRaw.cpp @@ -169,7 +169,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/Stress.cpp b/src/examples/Stress.cpp index 004561b..cd8843d 100644 --- a/src/examples/Stress.cpp +++ b/src/examples/Stress.cpp @@ -236,7 +236,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/Svg.cpp b/src/examples/Svg.cpp index be4f357..53e9502 100644 --- a/src/examples/Svg.cpp +++ b/src/examples/Svg.cpp @@ -181,7 +181,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/Svg2.cpp b/src/examples/Svg2.cpp index a7c97da..011816e 100644 --- a/src/examples/Svg2.cpp +++ b/src/examples/Svg2.cpp @@ -147,7 +147,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; diff --git a/src/examples/Tvg.cpp b/src/examples/Tvg.cpp index 51c6af8..5512f43 100644 --- a/src/examples/Tvg.cpp +++ b/src/examples/Tvg.cpp @@ -181,7 +181,7 @@ int main(int argc, char **argv) elm_shutdown(); //Terminate ThorVG Engine - tvg::Initializer::term(tvg::CanvasEngine::Sw); + tvg::Initializer::term(tvgEngine); } else { cout << "engine is not supported" << endl; -- 2.7.4 From 0dfc931de3b9509ead61d02c8c4a364577a297aa Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Thu, 20 Jan 2022 13:52:57 +0100 Subject: [PATCH 09/16] portability: fixing windows warnings atan2->atan2f Change-Id: Ia7572db01a26e0b7d5a6d3ed610cda407a27375f --- src/lib/sw_engine/tvgSwRasterTexmapInternal.h | 6 +++--- src/lib/tvgMath.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRasterTexmapInternal.h b/src/lib/sw_engine/tvgSwRasterTexmapInternal.h index 0cf6cff..f31ea1e 100644 --- a/src/lib/sw_engine/tvgSwRasterTexmapInternal.h +++ b/src/lib/sw_engine/tvgSwRasterTexmapInternal.h @@ -58,8 +58,8 @@ y = yStart; while (y < yEnd) { - x1 = _xa; - x2 = _xb; + x1 = (int32_t)_xa; + x2 = (int32_t)_xb; if (!region) { minx = INT32_MAX; @@ -160,4 +160,4 @@ next: xb = _xb; ua = _ua; va = _va; -} \ No newline at end of file +} diff --git a/src/lib/tvgMath.h b/src/lib/tvgMath.h index d4d3ad9..6120216 100644 --- a/src/lib/tvgMath.h +++ b/src/lib/tvgMath.h @@ -47,7 +47,7 @@ static inline bool mathEqual(float a, float b) static inline bool mathRightAngle(const Matrix* m) { - auto radian = fabsf(atan2(m->e21, m->e11)); + auto radian = fabsf(atan2f(m->e21, m->e11)); if (radian < FLT_EPSILON || mathEqual(radian, float(M_PI_2)) || mathEqual(radian, float(M_PI))) return true; return false; } -- 2.7.4 From 8fa300f2dfb10c5c22e0da5d346cb614aa5f1c62 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 24 Jan 2022 20:48:54 +0900 Subject: [PATCH 10/16] loaders jpg: fix all memory leaks. These were detected by asan with PictureJpg example, fixed them all. Change-Id: Ie63bcef3aa40945aa511db6df3fab9cc650c595b --- src/loaders/jpg/tvgJpgLoader.cpp | 5 +++++ src/loaders/jpg/tvgJpgd.cpp | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/loaders/jpg/tvgJpgLoader.cpp b/src/loaders/jpg/tvgJpgLoader.cpp index 6795c10..7b90b4a 100644 --- a/src/loaders/jpg/tvgJpgLoader.cpp +++ b/src/loaders/jpg/tvgJpgLoader.cpp @@ -47,6 +47,7 @@ JpgLoader::~JpgLoader() { jpgdDelete(decoder); if (freeData) free(data); + free(image); } @@ -128,5 +129,9 @@ unique_ptr JpgLoader::bitmap() void JpgLoader::run(unsigned tid) { + if (image) { + free(image); + image = nullptr; + } image = jpgdDecompress(decoder); } \ No newline at end of file diff --git a/src/loaders/jpg/tvgJpgd.cpp b/src/loaders/jpg/tvgJpgd.cpp index 0c74cdf..b80516a 100644 --- a/src/loaders/jpg/tvgJpgd.cpp +++ b/src/loaders/jpg/tvgJpgd.cpp @@ -1080,7 +1080,9 @@ namespace DCT_Upsample // Unconditionally frees all allocated m_blocks. void jpeg_decoder::free_all_blocks() { + delete(m_pStream); m_pStream = nullptr; + for (mem_block *b = m_pMem_blocks; b; ) { mem_block *n = b->m_pNext; free(b); @@ -2815,7 +2817,6 @@ int jpeg_decoder::begin_decoding() jpeg_decoder::~jpeg_decoder() { free_all_blocks(); - delete(m_pStream); } @@ -3025,4 +3026,4 @@ unsigned char* jpgdDecompress(jpeg_decoder* decoder) } } return pImage_data; -} \ No newline at end of file +} -- 2.7.4 From 9acb636f80a7343ba6a99508101041def327dbb2 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 24 Jan 2022 21:21:17 +0900 Subject: [PATCH 11/16] loader png: fix all memory leaks. These were detected by asan with PicturePng example, fixed them all. Change-Id: I4a113656a0b7c06333ced36f9a8ff1d9715d83f9 --- src/loaders/png/tvgPngLoader.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/loaders/png/tvgPngLoader.cpp b/src/loaders/png/tvgPngLoader.cpp index 6126ff0..3e29317 100644 --- a/src/loaders/png/tvgPngLoader.cpp +++ b/src/loaders/png/tvgPngLoader.cpp @@ -72,6 +72,7 @@ PngLoader::PngLoader() PngLoader::~PngLoader() { if (freeData) free(data); + free(image); } @@ -121,7 +122,7 @@ bool PngLoader::open(const char* data, uint32_t size, bool copy) clear(); lodepng_state_init(&state); - + unsigned int width, height; if (lodepng_inspect(&width, &height, &state, (unsigned char*)(data), size) > 0) return false; @@ -180,10 +181,14 @@ unique_ptr PngLoader::bitmap() void PngLoader::run(unsigned tid) { + if (image) { + free(image); + image = nullptr; + } auto width = static_cast(w); auto height = static_cast(h); lodepng_decode(&image, &width, &height, &state, data, size); _premultiply((uint32_t*)(image), width, height); -} \ No newline at end of file +} -- 2.7.4 From 3726cd4945441b98c92d5f4559dc1ee4e95074ce Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 26 Jan 2022 17:58:01 +0900 Subject: [PATCH 12/16] examples images: updated sample resources Change-Id: Ifc2a5502a8b3ffb0843d409196ab839db2f59111 --- src/examples/images/godot-icon.svg | 140 +++++++++++++++++++++++++++++++ src/examples/images/godot-icon.tvg | Bin 0 -> 2189 bytes src/examples/images/samsung-galaxy-s.svg | 1 - src/examples/images/samsung-galaxy-s.tvg | Bin 6143 -> 0 bytes 4 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/examples/images/godot-icon.svg create mode 100644 src/examples/images/godot-icon.tvg delete mode 100644 src/examples/images/samsung-galaxy-s.svg delete mode 100644 src/examples/images/samsung-galaxy-s.tvg diff --git a/src/examples/images/godot-icon.svg b/src/examples/images/godot-icon.svg new file mode 100644 index 0000000..2e72438 --- /dev/null +++ b/src/examples/images/godot-icon.svg @@ -0,0 +1,140 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/examples/images/godot-icon.tvg b/src/examples/images/godot-icon.tvg new file mode 100644 index 0000000000000000000000000000000000000000..5290f7e0868df699b9a053ef1e8364e4b8955f6c GIT binary patch literal 2189 zcmWl|3pkSt0|4M}GklxPzPZfY_kC?bVjLt?yAdTve$vfpo6AAUlwVS5o0)G+rpP5Z zCOW!2HT%1$-(}{KbU6~D;xJuwszY@y{;ucw-{*Pb(z5n#Sa~%%= znIHfp@&Mp#G7|tAf9(WJiXj>}v#a+gd&C(BiQr>J7&CCtot?D)nEk3;Cum>udLXr- z3LaU3Cm`q@ zn!1b!7D%tdGkTM;l#CQi?4cV)mJq@8Jz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/examples/images/samsung-galaxy-s.tvg b/src/examples/images/samsung-galaxy-s.tvg deleted file mode 100644 index ac642325e1f0169960299c23d382df2958f0330e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6143 zcmWNV`BxM7!-Z$Eei8zi>`t=iXr;Q8gAd!KV|O3s>fsWWvtU6@V> zp{iJj_}l&gdCbm)xL9ITY&$udIjMcul74QXwy!$`j zmhW<7)R<1wr}}9{Ox-q-uJ+Z!P1=OKGf`%?Dln!WPYO5OV29_-3iH(4s}5?OceKB$ zJ>kAY*I@xIP1%4R^2Aa$yEeOhf5tNlQdyO46Q)*peW{<+$My!;`Go^{vzPVHSE&8hEtVq)~|Gje+^AfRw%a`JOMRk{G{n-Y`| zVM|=+hy@3xM%&u&FmT((p?8t90{{Cq-ea-O!W()}Y&#)Nuq@@Y6$AN-BQrJ?&-gES z+!dj_t@(;2%A!LsrlM9`s2tAk&$=>zbscGB{S0zw;J2?Fe|iRvGN8h>DD z=jOa<2pYsqHdzpwZHtS}Gubvq>O^xUkK=rHA)<63Q~3JEBR|X7H_*I2{|kIg&ePV~ zUbsa&#tkQBZEoIGmU}^6uGPUWoj*#b|q*l7=NUUolW)1 zwb8chV}W{{Ry@Fvtj{p_+qPYKp6WTD zy1y61_9#kh8|uas?W1R#7Cy52e#A3vW5PRSk?|UuG{agE<5m(&-RESDjNf!@ZDf22 z$T@7xwrLBNoU7O-R~Ka;T-$j*Tf6$ELN)Pv$&&u5*<%+y*UZh^WBdL?px>eN2X~yb zP4(V~cj`-Z?Ba|kkz-WakxejD+v0uk^{Ko5G|%EK*GfFkx%M8+JymMkGI*vmug#Qg zvth*<58{jVA6;wnJ#h5)z{<7W^%cLqUSnHK9@-di;{Dr@`DEAIjWdxFFKuF}enP%e zF}?H5KNV45cpWwoHU-a;En3KTDEIB(=5>jn$M}TZ`SFyW6oiWsZk`*L0 zavb$nR3#L1D&i;{^_&?nf|@^mI3c+SG3f5`3=uC=Xq%>v)EhaRkAJAr^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4#8SNXdps% zR9vM_(F9`ENlb9HgErv4b0EGvu;*z_eAQer^=A;3_AY0F^R76>(JAi25-cQ;Qt5jQ*W98 -- 2.7.4 From 412fc993d1ea6be71a424845f4ce3c415f1e7dab Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Mon, 31 Jan 2022 14:05:58 +0100 Subject: [PATCH 13/16] common: styling++ (tabs -> spaces) Change-Id: I101d1d536e932924cfb0f70d174d51cddc0ff9e5 --- src/lib/gl_engine/tvgGlRenderer.cpp | 4 ++-- src/lib/gl_engine/tvgGlShaderSrc.cpp | 18 ++++++++-------- src/lib/sw_engine/tvgSwRasterNeon.h | 4 ++-- src/loaders/external_jpg/meson.build | 2 +- src/meson.build | 40 ++++++++++++++++++------------------ 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/lib/gl_engine/tvgGlRenderer.cpp b/src/lib/gl_engine/tvgGlRenderer.cpp index 6123bf4..4384d52 100644 --- a/src/lib/gl_engine/tvgGlRenderer.cpp +++ b/src/lib/gl_engine/tvgGlRenderer.cpp @@ -147,8 +147,8 @@ bool GlRenderer::renderShape(RenderData data) const Fill* gradient = sdata->shape->fill(); if (gradient != nullptr) { - drawPrimitive(*sdata, gradient, i, RenderUpdateFlag::Gradient); - } + drawPrimitive(*sdata, gradient, i, RenderUpdateFlag::Gradient); + } } if(flags & (RenderUpdateFlag::Color | RenderUpdateFlag::Transform)) diff --git a/src/lib/gl_engine/tvgGlShaderSrc.cpp b/src/lib/gl_engine/tvgGlShaderSrc.cpp index ef8d8f9..bba73dc 100644 --- a/src/lib/gl_engine/tvgGlShaderSrc.cpp +++ b/src/lib/gl_engine/tvgGlShaderSrc.cpp @@ -26,13 +26,13 @@ #define TVG_COMPOSE_SHADER(shader) #shader const char* COLOR_VERT_SHADER = TVG_COMPOSE_SHADER( - attribute mediump vec4 aLocation; \n - uniform highp mat4 uTransform; \n - varying highp float vOpacity; \n - void main() \n - { \n + attribute mediump vec4 aLocation; \n + uniform highp mat4 uTransform; \n + varying highp float vOpacity; \n + void main() \n + { \n gl_Position = uTransform * vec4(aLocation.xy, 0.0, 1.0); \n - vOpacity = aLocation.z; \n + vOpacity = aLocation.z; \n }); const char* COLOR_FRAG_SHADER = TVG_COMPOSE_SHADER( @@ -47,11 +47,11 @@ const char* GRADIENT_VERT_SHADER = TVG_COMPOSE_SHADER( attribute highp vec4 aLocation; \n varying highp float vOpacity; \n varying highp vec2 vPos; \n -uniform highp mat4 uTransform; \n +uniform highp mat4 uTransform; \n \n void main() \n { \n - gl_Position = uTransform * vec4(aLocation.xy, 0.0, 1.0); \n + gl_Position = uTransform * vec4(aLocation.xy, 0.0, 1.0); \n vOpacity = aLocation.z; \n vPos = vec2((aLocation.x + 1.0) / 2.0, ((-1.0 * aLocation.y) +1.0) / 2.0); \n }); @@ -62,7 +62,7 @@ precision highp float; const int MAX_STOP_COUNT = 4; \n uniform highp vec2 uSize; \n uniform highp vec2 uCanvasSize; \n -uniform float nStops; \n +uniform float nStops; \n uniform float noise_level; \n uniform float stopPoints[MAX_STOP_COUNT]; \n uniform vec4 stopColors[MAX_STOP_COUNT]; \n diff --git a/src/lib/sw_engine/tvgSwRasterNeon.h b/src/lib/sw_engine/tvgSwRasterNeon.h index 593e4d3..a4b3cda 100644 --- a/src/lib/sw_engine/tvgSwRasterNeon.h +++ b/src/lib/sw_engine/tvgSwRasterNeon.h @@ -26,8 +26,8 @@ static inline uint8x8_t ALPHA_BLEND(uint8x8_t c, uint8x8_t a) { - uint16x8_t t = vmull_u8(c, a); - return vshrn_n_u16(t, 8); + uint16x8_t t = vmull_u8(c, a); + return vshrn_n_u16(t, 8); } diff --git a/src/loaders/external_jpg/meson.build b/src/loaders/external_jpg/meson.build index aeecf9f..ce657ba 100644 --- a/src/loaders/external_jpg/meson.build +++ b/src/loaders/external_jpg/meson.build @@ -6,7 +6,7 @@ source_file = [ jpg_dep = dependency('libturbojpeg', required: false) if not jpg_dep.found() - jpg_dep = cc.find_library('turbojpeg', required: false) + jpg_dep = cc.find_library('turbojpeg', required: false) endif if jpg_dep.found() diff --git a/src/meson.build b/src/meson.build index 8d1a270..26aba33 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,38 +29,38 @@ if host_machine.system() != 'windows' endif thorvg_lib = library( - 'thorvg', - include_directories : headers, - version : meson.project_version(), - dependencies : thorvg_lib_dep, - install : true, - cpp_args : compiler_flags, - gnu_symbol_visibility : 'hidden', + 'thorvg', + include_directories : headers, + version : meson.project_version(), + dependencies : thorvg_lib_dep, + install : true, + cpp_args : compiler_flags, + gnu_symbol_visibility : 'hidden', ) thorvg_dep = declare_dependency( - include_directories: headers, - link_with : thorvg_lib + include_directories: headers, + link_with : thorvg_lib ) if (cc.get_id() == 'emscripten') - subdir('wasm') + subdir('wasm') - executable('thorvg-wasm', - [], - include_directories : headers, - dependencies : [thorvg_lib_dep, thorvg_wasm_dep], - ) + executable('thorvg-wasm', + [], + include_directories : headers, + dependencies : [thorvg_lib_dep, thorvg_wasm_dep], + ) endif pkg_mod = import('pkgconfig') pkg_mod.generate( - libraries : thorvg_lib, - version : meson.project_version(), - name : 'libthorvg', - filebase : 'thorvg', - description : 'A Thor library for rendering vector graphics' + libraries : thorvg_lib, + version : meson.project_version(), + name : 'libthorvg', + filebase : 'thorvg', + description : 'A Thor library for rendering vector graphics' ) subdir('bin') -- 2.7.4 From 249e337e7792490d287e195e33a8cd0653bdee6e Mon Sep 17 00:00:00 2001 From: Michal Maciola Date: Fri, 4 Feb 2022 14:50:12 +0100 Subject: [PATCH 14/16] loader png external: fix potential memory leak if read fails Change-Id: I09cc563cbd7144112c5d8f593b3608a9bcdb7e40 --- src/loaders/external_png/tvgPngLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/loaders/external_png/tvgPngLoader.cpp b/src/loaders/external_png/tvgPngLoader.cpp index 2991d25..05db65c 100644 --- a/src/loaders/external_png/tvgPngLoader.cpp +++ b/src/loaders/external_png/tvgPngLoader.cpp @@ -93,7 +93,10 @@ bool PngLoader::read() png_image_free(image); return false; } - if (!png_image_finish_read(image, NULL, buffer, 0, NULL)) return false; + if (!png_image_finish_read(image, NULL, buffer, 0, NULL)) { + free(buffer); + return false; + } content = reinterpret_cast(buffer); _premultiply(reinterpret_cast(buffer), image->width, image->height); -- 2.7.4 From 60e17287c1a21a1b91936ed8170b536c26b67cb8 Mon Sep 17 00:00:00 2001 From: jykeon Date: Mon, 27 Feb 2023 17:40:43 +0900 Subject: [PATCH 15/16] Bump up 0.7.6 Change-Id: I767a52803a91fc74456ea5d25196ffd7a1864882 Signed-off-by: jykeon --- packaging/thorvg.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/thorvg.spec b/packaging/thorvg.spec index a53aa64..295f2a1 100644 --- a/packaging/thorvg.spec +++ b/packaging/thorvg.spec @@ -1,6 +1,6 @@ Name: thorvg Summary: Thor Vector Graphics Library -Version: 0.7.5 +Version: 0.7.6 Release: 1 Group: Graphics System/Rendering Engine License: MIT -- 2.7.4 From 0a3689cfe19e5b276f80fdfe78a7cedf27eac1e1 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Sat, 8 Jan 2022 20:59:50 +0100 Subject: [PATCH 16/16] svg_loader: class attribute added It's the first step in introducing the css inline style sheets into tvg. For now the class attribute is set only for SvgNodes (not for grads), it's not used yet. Change-Id: Ib81c47b38f5f1355125dc0bff44f07cfbd7c12af --- src/loaders/svg/tvgSvgLoader.cpp | 30 ++++++++++++++++++++++++++++++ src/loaders/svg/tvgSvgLoaderCommon.h | 1 + 2 files changed, 31 insertions(+) diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index 4990c5c..7def62d 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -947,6 +947,15 @@ static void _handleDisplayAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node, } +static void _handleCssClassAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node, const char* value) +{ + auto cssClass = &node->style->cssClass; + + if (*cssClass && value) free(*cssClass); + *cssClass = _copyId(value); +} + + typedef void (*styleMethod)(SvgLoaderData* loader, SvgNode* node, const char* value); #define STYLE_DEF(Name, Name1, Flag) { #Name, sizeof(#Name), _handle##Name1##Attr, Flag } @@ -1027,6 +1036,8 @@ static bool _attrParseGNode(void* data, const char* key, const char* value) } else if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else if (!strcmp(key, "clip-path")) { _handleClipPathAttr(loader, node, value); } else if (!strcmp(key, "mask")) { @@ -1054,6 +1065,8 @@ static bool _attrParseClipPathNode(void* data, const char* key, const char* valu } else if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else if (!strcmp(key, "clipPathUnits")) { if (!strcmp(value, "objectBoundingBox")) clip->userSpace = false; } else { @@ -1076,6 +1089,8 @@ static bool _attrParseMaskNode(void* data, const char* key, const char* value) } else if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else if (!strcmp(key, "maskContentUnits")) { if (!strcmp(value, "objectBoundingBox")) mask->userSpace = false; } else if (!strcmp(key, "mask-type")) { @@ -1229,6 +1244,8 @@ static bool _attrParsePathNode(void* data, const char* key, const char* value) } else if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else { return _parseStyleAttr(loader, key, value, false); } @@ -1289,6 +1306,8 @@ static bool _attrParseCircleNode(void* data, const char* key, const char* value) } else if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else { return _parseStyleAttr(loader, key, value, false); } @@ -1343,6 +1362,8 @@ static bool _attrParseEllipseNode(void* data, const char* key, const char* value if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else if (!strcmp(key, "style")) { return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader); } else if (!strcmp(key, "clip-path")) { @@ -1426,6 +1447,8 @@ static bool _attrParsePolygonNode(void* data, const char* key, const char* value } else if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else { return _parseStyleAttr(loader, key, value, false); } @@ -1500,6 +1523,8 @@ static bool _attrParseRectNode(void* data, const char* key, const char* value) if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else if (!strcmp(key, "style")) { ret = simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader); } else if (!strcmp(key, "clip-path")) { @@ -1563,6 +1588,8 @@ static bool _attrParseLineNode(void* data, const char* key, const char* value) if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else if (!strcmp(key, "style")) { return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader); } else if (!strcmp(key, "clip-path")) { @@ -1634,6 +1661,8 @@ static bool _attrParseImageNode(void* data, const char* key, const char* value) } else if (!strcmp(key, "id")) { if (node->id && value) free(node->id); node->id = _copyId(value); + } else if (!strcmp(key, "class")) { + _handleCssClassAttr(loader, node, value); } else if (!strcmp(key, "style")) { return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader); } else if (!strcmp(key, "clip-path")) { @@ -2767,6 +2796,7 @@ static void _freeNodeStyle(SvgStyleProperty* style) //style->clipPath.node and style->mask.node has only the addresses of node. Therefore, node is released from _freeNode. free(style->clipPath.url); free(style->mask.url); + free(style->cssClass); if (style->fill.paint.gradient) { style->fill.paint.gradient->clear(); diff --git a/src/loaders/svg/tvgSvgLoaderCommon.h b/src/loaders/svg/tvgSvgLoaderCommon.h index c6685c6..04f5b34 100644 --- a/src/loaders/svg/tvgSvgLoaderCommon.h +++ b/src/loaders/svg/tvgSvgLoaderCommon.h @@ -341,6 +341,7 @@ struct SvgStyleProperty int opacity; SvgColor color; bool curColorSet; + char* cssClass; SvgStyleFlags flags; }; -- 2.7.4