void strokeReset(SwStroke* stroke, const Shape* shape, const Matrix* transform);
bool strokeParseOutline(SwStroke* stroke, const SwOutline& outline);
-SwOutline* strokeExportOutline(SwStroke* stroke);
+SwOutline* strokeExportOutline(SwStroke* stroke, unsigned tid);
void strokeFree(SwStroke* stroke);
bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform, SwSurface* surface, bool ctable);
bool mpoolClear();
SwOutline* mpoolReqOutline(unsigned idx);
void mpoolRetOutline(unsigned idx);
+SwOutline* mpoolReqStrokeOutline(unsigned idx);
+void mpoolRetStrokeOutline(unsigned idx);
bool rasterCompositor(SwSurface* surface);
bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id);
/* Internal Class Implementation */
/************************************************************************/
-static unsigned threadsCnt = 1;
-static vector<SwOutline> sharedOutline;
+static vector<SwOutline> outline;
+static vector<SwOutline> strokeOutline;
/************************************************************************/
SwOutline* mpoolReqOutline(unsigned idx)
{
- return &sharedOutline[idx];
+ return &outline[idx];
}
void mpoolRetOutline(unsigned idx)
{
- sharedOutline[idx].cntrsCnt = 0;
- sharedOutline[idx].ptsCnt = 0;
+ outline[idx].cntrsCnt = 0;
+ outline[idx].ptsCnt = 0;
+}
+
+
+SwOutline* mpoolReqStrokeOutline(unsigned idx)
+{
+ return &strokeOutline[idx];
+}
+
+
+void mpoolRetStrokeOutline(unsigned idx)
+{
+ strokeOutline[idx].cntrsCnt = 0;
+ strokeOutline[idx].ptsCnt = 0;
}
bool mpoolInit(unsigned threads)
{
if (threads == 0) threads = 1;
- sharedOutline.reserve(threads);
- sharedOutline.resize(threads);
- threadsCnt = threads;
- for (auto& outline : sharedOutline) {
+ outline.reserve(threads);
+ outline.resize(threads);
+
+ for (auto& outline : outline) {
+ outline.cntrs = nullptr;
+ outline.pts = nullptr;
+ outline.types = nullptr;
+ outline.cntrsCnt = outline.reservedCntrsCnt = 0;
+ outline.ptsCnt = outline.reservedPtsCnt = 0;
+ }
+
+ strokeOutline.reserve(threads);
+ strokeOutline.resize(threads);
+
+ for (auto& outline : strokeOutline) {
outline.cntrs = nullptr;
outline.pts = nullptr;
outline.types = nullptr;
bool mpoolClear()
{
- for (auto& outline : sharedOutline) {
+ for (auto& outline : outline) {
if (outline.cntrs) {
free(outline.cntrs);
outline.cntrs = nullptr;
outline.cntrsCnt = outline.reservedCntrsCnt = 0;
outline.ptsCnt = outline.reservedPtsCnt = 0;
}
+
+ for (auto& outline : strokeOutline) {
+ if (outline.cntrs) {
+ free(outline.cntrs);
+ outline.cntrs = nullptr;
+ }
+ if (outline.pts) {
+ free(outline.pts);
+ outline.pts = nullptr;
+ }
+ if (outline.types) {
+ free(outline.types);
+ outline.types = nullptr;
+ }
+ outline.cntrsCnt = outline.reservedCntrsCnt = 0;
+ outline.ptsCnt = outline.reservedPtsCnt = 0;
+ }
+
return true;
}
}
-static void _delOutline(SwOutline* outline)
-{
- if (!outline) return;
-
- if (outline->cntrs) free(outline->cntrs);
- if (outline->pts) free(outline->pts);
- if (outline->types) free(outline->types);
- free(outline);
-}
-
-
static void _outlineEnd(SwOutline& outline)
{
_growOutlineContour(outline, 1);
goto fail;
}
- strokeOutline = strokeExportOutline(shape->stroke);
+ strokeOutline = strokeExportOutline(shape->stroke, tid);
if (!strokeOutline) {
ret = false;
goto fail;
shape->strokeRle = rleRender(strokeOutline, bbox, clip, true);
fail:
- if (freeOutline) _delOutline(shapeOutline);
- _delOutline(strokeOutline);
+ if (freeOutline) {
+ if (shapeOutline->cntrs) free(shapeOutline->cntrs);
+ if (shapeOutline->pts) free(shapeOutline->pts);
+ if (shapeOutline->types) free(shapeOutline->types);
+ }
+ mpoolRetStrokeOutline(tid);
return ret;
}
/************************************************************************/
/* Internal Class Implementation */
/************************************************************************/
+
static constexpr auto SW_STROKE_TAG_POINT = 1;
static constexpr auto SW_STROKE_TAG_CUBIC = 2;
static constexpr auto SW_STROKE_TAG_BEGIN = 4;
}
-SwOutline* strokeExportOutline(SwStroke* stroke)
+SwOutline* strokeExportOutline(SwStroke* stroke, unsigned tid)
{
uint32_t count1, count2, count3, count4;
auto ptsCnt = count1 + count3;
auto cntrsCnt = count2 + count4;
- auto outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline)));
- outline->pts = static_cast<SwPoint*>(malloc(sizeof(SwPoint) * ptsCnt));
- outline->types = static_cast<uint8_t*>(malloc(sizeof(uint8_t) * ptsCnt));
- outline->cntrs = static_cast<uint32_t*>(malloc(sizeof(uint32_t) * cntrsCnt));
+ auto outline = mpoolReqStrokeOutline(tid);
+ if (outline->reservedPtsCnt < ptsCnt) {
+ 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
_exportBorderOutline(*stroke, outline, 1); //right