mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
loaders svg: fix a wrongly handles the corner case.
Stop the internel loop quick as possible, and state must be reset.
This commit is contained in:
parent
b3559ecf56
commit
d3a73f7ee9
1 changed files with 7 additions and 5 deletions
|
@ -592,12 +592,13 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
||||||
|
|
||||||
float points[8];
|
float points[8];
|
||||||
int ptCount = 0;
|
int ptCount = 0;
|
||||||
float sx, sy;
|
|
||||||
MatrixState state = MatrixState::Unknown;
|
|
||||||
char* str = (char*)value;
|
char* str = (char*)value;
|
||||||
char* end = str + strlen(str);
|
char* end = str + strlen(str);
|
||||||
|
|
||||||
while (str < end) {
|
while (str < end) {
|
||||||
|
|
||||||
|
auto state = MatrixState::Unknown;
|
||||||
|
|
||||||
if (isspace(*str) || (*str == ',')) {
|
if (isspace(*str) || (*str == ',')) {
|
||||||
++str;
|
++str;
|
||||||
continue;
|
continue;
|
||||||
|
@ -606,6 +607,7 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
||||||
if (!strncmp(matrixTags[i].tag, str, matrixTags[i].sz - 1)) {
|
if (!strncmp(matrixTags[i].tag, str, matrixTags[i].sz - 1)) {
|
||||||
state = matrixTags[i].state;
|
state = matrixTags[i].state;
|
||||||
str += (matrixTags[i].sz - 1);
|
str += (matrixTags[i].sz - 1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state == MatrixState::Unknown) goto error;
|
if (state == MatrixState::Unknown) goto error;
|
||||||
|
@ -650,8 +652,8 @@ static Matrix* _parseTransformationMatrix(const char* value)
|
||||||
}
|
}
|
||||||
} else if (state == MatrixState::Scale) {
|
} else if (state == MatrixState::Scale) {
|
||||||
if (ptCount < 1 || ptCount > 2) goto error;
|
if (ptCount < 1 || ptCount > 2) goto error;
|
||||||
sx = points[0];
|
auto sx = points[0];
|
||||||
sy = sx;
|
auto sy = sx;
|
||||||
if (ptCount == 2) sy = points[1];
|
if (ptCount == 2) sy = points[1];
|
||||||
Matrix tmp = { sx, 0, 0, 0, sy, 0, 0, 0, 1 };
|
Matrix tmp = { sx, 0, 0, 0, sy, 0, 0, 0, 1 };
|
||||||
_matrixCompose(matrix, &tmp, matrix);
|
_matrixCompose(matrix, &tmp, matrix);
|
||||||
|
|
Loading…
Add table
Reference in a new issue