for (unsigned i = 0; i < mpool->allocSize; ++i) {
+ //Outline
p = &mpool->outline[i];
- if (p->cntrs) {
- free(p->cntrs);
- p->cntrs = nullptr;
- }
- if (p->pts) {
- free(p->pts);
- p->pts = nullptr;
- }
- if (p->types) {
- free(p->types);
- p->types = nullptr;
- }
+ free(p->cntrs);
+ p->cntrs = nullptr;
+
+ free(p->pts);
+ p->pts = nullptr;
+
+ free(p->types);
+ p->types = nullptr;
+
p->cntrsCnt = p->reservedCntrsCnt = 0;
p->ptsCnt = p->reservedPtsCnt = 0;
+ //StrokeOutline
p = &mpool->strokeOutline[i];
- if (p->cntrs) {
- free(p->cntrs);
- p->cntrs = nullptr;
- }
- if (p->pts) {
- free(p->pts);
- p->pts = nullptr;
- }
- if (p->types) {
- free(p->types);
- p->types = nullptr;
- }
+ free(p->cntrs);
+ p->cntrs = nullptr;
+
+ free(p->pts);
+ p->pts = nullptr;
+
+ free(p->types);
+ p->types = nullptr;
+
p->cntrsCnt = p->reservedCntrsCnt = 0;
p->ptsCnt = p->reservedPtsCnt = 0;
}
SwRenderer::~SwRenderer()
{
- clear();
clearCompositors();
if (surface) delete(surface);
for (auto task = tasks.data; task < (tasks.data + tasks.count); ++task) (*task)->done();
tasks.clear();
+ if (!sharedMpool) mpoolClear(mpool);
+
if (surface) {
vport.x = vport.y = 0;
vport.w = surface->w;
/* when the rle needs to be regenerated because of attribute change. */
if (rle->alloc < newSize) {
rle->alloc = (newSize * 2);
+ //OPTIMIZE: use mempool!
rle->spans = static_cast<SwSpan*>(realloc(rle->spans, rle->alloc * sizeof(SwSpan)));
}
/* compute the coverage line's coverage, depending on the outline fill rule */
/* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
- auto coverage = static_cast<int>(area >> (PIXEL_BITS * 2 + 1 - 8)); //range 0 - 256
+ auto coverage = static_cast<int>(area >> (PIXEL_BITS * 2 + 1 - 8)); //range 0 - 255
if (coverage < 0) coverage = -coverage;
auto cell = rw.yCells[y];
while (cell) {
-
if (cell->x > x && cover != 0) _horizLine(rw, x, y, cover * (ONE_PIXEL * 2), cell->x - x);
cover += cell->cover;
auto area = cover * (ONE_PIXEL * 2) - cell->area;
if (area != 0 && cell->x >= 0) _horizLine(rw, cell->x, y, area, 1);
-
x = cell->x + 1;
cell = cell->next;
}
while (maxCur < maxNew)
maxCur += (maxCur >> 1) + 16;
-
+ //OPTIMIZE: use mempool!
border->pts = static_cast<SwPoint*>(realloc(border->pts, maxCur * sizeof(SwPoint)));
border->tags = static_cast<uint8_t*>(realloc(border->tags, maxCur * sizeof(uint8_t)));
border->maxPts = maxCur;