From: JunsuChoi Date: Tue, 22 Sep 2020 05:28:51 +0000 (+0900) Subject: SvgPath: When path end(Z,z), Current point are returned to starting point(M,m) X-Git-Tag: accepted/tizen/6.0/unified/20201030.120901~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5775133bb4097a2d7bdfa317d0c0d83712fd5601;p=platform%2Fcore%2Fgraphics%2Ftizenvg.git SvgPath: When path end(Z,z), Current point are returned to starting point(M,m) When path ends with 'z' or 'Z' command, if 'm' comes as next command, the current point is incorrectly referenced. Since 'Z', 'z' means to close the path, so, Save point and reuse it when 'M' or 'm' is called. Change-Id: I6b47ec0d424dbc7dfc3bcf1344cf2ae4c15a1081 --- diff --git a/src/loaders/svg/tvgSvgPath.cpp b/src/loaders/svg/tvgSvgPath.cpp index 2e3edab..e3ea03e 100644 --- a/src/loaders/svg/tvgSvgPath.cpp +++ b/src/loaders/svg/tvgSvgPath.cpp @@ -280,7 +280,7 @@ static int _numberCount(char cmd) } -static void _processCommand(vector* cmds, vector* pts, char cmd, float* arr, int count, Point* cur, Point* curCtl, bool *isQuadratic) +static void _processCommand(vector* cmds, vector* pts, char cmd, float* arr, int count, Point* cur, Point* curCtl, Point* startPoint, bool *isQuadratic) { int i; switch (cmd) { @@ -321,6 +321,7 @@ static void _processCommand(vector* cmds, vector* pts, char cmds->push_back(PathCommand::MoveTo); pts->push_back(p); *cur = {arr[0] ,arr[1]}; + *startPoint = {arr[0] ,arr[1]}; break; } case 'l': @@ -432,6 +433,7 @@ static void _processCommand(vector* cmds, vector* pts, char case 'z': case 'Z': { cmds->push_back(PathCommand::Close); + *cur = *startPoint; break; } case 'a': @@ -503,6 +505,7 @@ tuple, vector> svgPathToTvgPath(const char* svgPath) int numberCount = 0; Point cur = { 0, 0 }; Point curCtl = { 0, 0 }; + Point startPoint = { 0, 0 }; char cmd = 0; bool isQuadratic = false; char* path = (char*)svgPath; @@ -515,7 +518,7 @@ tuple, vector> svgPathToTvgPath(const char* svgPath) while ((path[0] != '\0')) { path = _nextCommand(path, &cmd, numberArray, &numberCount); if (!path) break; - _processCommand(&cmds, &pts, cmd, numberArray, numberCount, &cur, &curCtl, &isQuadratic); + _processCommand(&cmds, &pts, cmd, numberArray, numberCount, &cur, &curCtl, &startPoint, &isQuadratic); } setlocale(LC_NUMERIC, curLocale);