mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 22:23:27 +00:00
sw_engine: memory optimization.
Save the size of the Countour array, 16 bits is large enough to count the points number in one Shape.
This commit is contained in:
parent
2280bb9ce7
commit
e1d5ade705
4 changed files with 8 additions and 8 deletions
|
@ -98,12 +98,12 @@ struct SwSize
|
||||||
|
|
||||||
struct SwOutline
|
struct SwOutline
|
||||||
{
|
{
|
||||||
uint32_t* cntrs; //the contour end points
|
|
||||||
uint32_t cntrsCnt; //number of contours in glyph
|
|
||||||
uint32_t reservedCntrsCnt;
|
|
||||||
SwPoint* pts; //the outline's points
|
SwPoint* pts; //the outline's points
|
||||||
uint32_t ptsCnt; //number of points in the glyph
|
uint16_t ptsCnt; //number of points in the glyph
|
||||||
uint32_t reservedPtsCnt;
|
uint16_t reservedPtsCnt;
|
||||||
|
uint16_t* cntrs; //the contour end points
|
||||||
|
uint16_t cntrsCnt; //number of contours in glyph
|
||||||
|
uint16_t reservedCntrsCnt;
|
||||||
uint8_t* types; //curve type
|
uint8_t* types; //curve type
|
||||||
bool* closed; //opened or closed path?
|
bool* closed; //opened or closed path?
|
||||||
FillRule fillRule;
|
FillRule fillRule;
|
||||||
|
|
|
@ -39,7 +39,7 @@ static bool _genOutline(SwImage* image, const Matrix* transform, SwMpool* mpool,
|
||||||
|
|
||||||
if (outline->reservedCntrsCnt < 1) {
|
if (outline->reservedCntrsCnt < 1) {
|
||||||
outline->reservedCntrsCnt = 1;
|
outline->reservedCntrsCnt = 1;
|
||||||
outline->cntrs = static_cast<uint32_t*>(realloc(outline->cntrs, outline->reservedCntrsCnt * sizeof(uint32_t)));
|
outline->cntrs = static_cast<uint16_t*>(realloc(outline->cntrs, outline->reservedCntrsCnt * sizeof(uint16_t)));
|
||||||
outline->closed = static_cast<bool*>(realloc(outline->closed, outline->reservedCntrsCnt * sizeof(bool)));
|
outline->closed = static_cast<bool*>(realloc(outline->closed, outline->reservedCntrsCnt * sizeof(bool)));
|
||||||
outline->closed[0] = true;
|
outline->closed[0] = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ static bool _growOutlineContour(SwOutline& outline, uint32_t n)
|
||||||
{
|
{
|
||||||
if (outline.reservedCntrsCnt >= outline.cntrsCnt + n) return false;
|
if (outline.reservedCntrsCnt >= outline.cntrsCnt + n) return false;
|
||||||
outline.reservedCntrsCnt = outline.cntrsCnt + n;
|
outline.reservedCntrsCnt = outline.cntrsCnt + n;
|
||||||
outline.cntrs = static_cast<uint32_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint32_t)));
|
outline.cntrs = static_cast<uint16_t*>(realloc(outline.cntrs, outline.reservedCntrsCnt * sizeof(uint16_t)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -921,7 +921,7 @@ SwOutline* strokeExportOutline(SwStroke* stroke, SwMpool* mpool, unsigned tid)
|
||||||
outline->reservedPtsCnt = ptsCnt;
|
outline->reservedPtsCnt = ptsCnt;
|
||||||
}
|
}
|
||||||
if (outline->reservedCntrsCnt < cntrsCnt) {
|
if (outline->reservedCntrsCnt < cntrsCnt) {
|
||||||
outline->cntrs = static_cast<uint32_t*>(realloc(outline->cntrs, sizeof(uint32_t) * cntrsCnt));
|
outline->cntrs = static_cast<uint16_t*>(realloc(outline->cntrs, sizeof(uint16_t) * cntrsCnt));
|
||||||
outline->reservedCntrsCnt = cntrsCnt;
|
outline->reservedCntrsCnt = cntrsCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue