mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 06:34:01 +00:00
sw_engine rle: performance optimization.
Tis is a subsequential trial of 1b8188ee67
for opimizing memory alloc count.
In this time, it concentrates on rle span.
@Issues: 75
This commit is contained in:
parent
2b762f00e2
commit
006e6e0920
4 changed files with 17 additions and 12 deletions
|
@ -290,8 +290,9 @@ void fillFree(SwFill* fill);
|
|||
void fillFetchLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t offset, uint32_t len);
|
||||
void fillFetchRadial(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, uint32_t len);
|
||||
|
||||
SwRleData* rleRender(const SwOutline* outline, const SwBBox& bbox, const SwSize& clip, bool antiAlias);
|
||||
SwRleData* rleRender(SwRleData* rle, const SwOutline* outline, const SwBBox& bbox, const SwSize& clip, bool antiAlias);
|
||||
void rleFree(SwRleData* rle);
|
||||
void rleReset(SwRleData* rle);
|
||||
void rleClipPath(SwRleData *rle, const SwRleData *clip);
|
||||
void rleClipRect(SwRleData *rle, const SwBBox* clip);
|
||||
|
||||
|
|
|
@ -707,7 +707,7 @@ SwSpan* _intersectSpansRect(const SwBBox *bbox, const SwRleData *targetRle, SwSp
|
|||
/* External Class Implementation */
|
||||
/************************************************************************/
|
||||
|
||||
SwRleData* rleRender(const SwOutline* outline, const SwBBox& bbox, const SwSize& clip, bool antiAlias)
|
||||
SwRleData* rleRender(SwRleData* rle, const SwOutline* outline, const SwBBox& bbox, const SwSize& clip, bool antiAlias)
|
||||
{
|
||||
constexpr auto RENDER_POOL_SIZE = 16384L;
|
||||
constexpr auto BAND_SIZE = 40;
|
||||
|
@ -736,7 +736,9 @@ SwRleData* rleRender(const SwOutline* outline, const SwBBox& bbox, const SwSize&
|
|||
rw.bandShoot = 0;
|
||||
rw.clip = clip;
|
||||
rw.antiAlias = antiAlias;
|
||||
rw.rle = reinterpret_cast<SwRleData*>(calloc(1, sizeof(SwRleData)));
|
||||
|
||||
if (!rle) rw.rle = reinterpret_cast<SwRleData*>(calloc(1, sizeof(SwRleData)));
|
||||
else rw.rle = rle;
|
||||
|
||||
//Generate RLE
|
||||
Band bands[BAND_SIZE];
|
||||
|
@ -830,6 +832,13 @@ error:
|
|||
}
|
||||
|
||||
|
||||
void rleReset(SwRleData* rle)
|
||||
{
|
||||
if (!rle) return;
|
||||
rle->size = 0;
|
||||
}
|
||||
|
||||
|
||||
void rleFree(SwRleData* rle)
|
||||
{
|
||||
if (!rle) return;
|
||||
|
|
|
@ -459,7 +459,7 @@ bool shapeGenRle(SwShape* shape, TVG_UNUSED const Shape* sdata, const SwSize& cl
|
|||
//Case A: Fast Track Rectangle Drawing
|
||||
if (!hasComposite && (shape->rect = _fastTrack(shape->outline))) return true;
|
||||
//Case B: Normale Shape RLE Drawing
|
||||
if ((shape->rle = rleRender(shape->outline, shape->bbox, clip, antiAlias))) return true;
|
||||
if ((shape->rle = rleRender(shape->rle, shape->outline, shape->bbox, clip, antiAlias))) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -474,8 +474,7 @@ void shapeDelOutline(SwShape* shape, uint32_t tid)
|
|||
|
||||
void shapeReset(SwShape* shape)
|
||||
{
|
||||
rleFree(shape->rle);
|
||||
shape->rle = nullptr;
|
||||
rleReset(shape->rle);
|
||||
shape->rect = false;
|
||||
_initBBox(shape->bbox);
|
||||
}
|
||||
|
@ -597,9 +596,7 @@ void shapeResetStroke(SwShape* shape, const Shape* sdata, const Matrix* transfor
|
|||
if (!stroke) return;
|
||||
|
||||
strokeReset(stroke, sdata, transform);
|
||||
|
||||
rleFree(shape->strokeRle);
|
||||
shape->strokeRle = nullptr;
|
||||
rleReset(shape->strokeRle);
|
||||
}
|
||||
|
||||
|
||||
|
@ -642,7 +639,7 @@ bool shapeGenStrokeRle(SwShape* shape, const Shape* sdata, unsigned tid, const M
|
|||
goto fail;
|
||||
}
|
||||
|
||||
shape->strokeRle = rleRender(strokeOutline, bbox, clip, true);
|
||||
shape->strokeRle = rleRender(shape->strokeRle, strokeOutline, bbox, clip, true);
|
||||
|
||||
fail:
|
||||
if (freeOutline) {
|
||||
|
|
|
@ -920,12 +920,10 @@ SwOutline* strokeExportOutline(SwStroke* stroke, unsigned tid)
|
|||
outline->pts = static_cast<SwPoint*>(realloc(outline->pts, sizeof(SwPoint) * ptsCnt));
|
||||
outline->types = static_cast<uint8_t*>(realloc(outline->types, sizeof(uint8_t) * ptsCnt));
|
||||
outline->reservedPtsCnt = ptsCnt;
|
||||
printf("pts(%d)\n", sizeof(SwPoint) * ptsCnt);
|
||||
}
|
||||
if (outline->reservedCntrsCnt < cntrsCnt) {
|
||||
outline->cntrs = static_cast<uint32_t*>(realloc(outline->cntrs, sizeof(uint32_t) * cntrsCnt));
|
||||
outline->reservedCntrsCnt = cntrsCnt;
|
||||
printf("cntrs(%d)\n", sizeof(SwPoint) * ptsCnt);
|
||||
}
|
||||
|
||||
_exportBorderOutline(*stroke, outline, 0); //left
|
||||
|
|
Loading…
Add table
Reference in a new issue