we don't need to apply anti-aliasing if stroke is there.
here turns off anti-alias if stroke width is more than 2.
magic number 2 is experimentally confirmed.
Change-Id: I09031dc2a0a84f31c5904651ed1e62004645ba9a
void shapeReset(SwShape& shape);
bool shapeGenOutline(SwShape& shape, const Shape* sdata);
bool shapePrepare(SwShape& shape, const Shape* sdata, const SwSize& clip, const Matrix* transform);
-bool shapeGenRle(SwShape& shape, const Shape* sdata, const SwSize& clip);
+bool shapeGenRle(SwShape& shape, const Shape* sdata, const SwSize& clip, bool antiAlias);
void shapeDelOutline(SwShape& shape);
void shapeResetStroke(SwShape& shape, const Shape* sdata);
bool shapeGenStrokeRle(SwShape& shape, const Shape* sdata, const SwSize& clip);
void fillFetchLinear(const SwFill* fill, uint32_t* dst, uint32_t y, uint32_t x, 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);
+SwRleData* rleRender(const SwOutline* outline, const SwBBox& bbox, const SwSize& clip, bool antiAlias);
void rleFree(SwRleData* rle);
bool rasterGradientShape(Surface& surface, SwShape& shape, unsigned id);
if (a > 0) rasterSolidShape(surface, task->shape, r, g, b, a);
}
task->sdata->strokeColor(&r, &g, &b, &a);
- if (a > 0) rasterStroke(surface, task->shape, r, g, b, a);
+ if (a > 0) rasterStroke(surface, task->shape, r, g, b, a);
renderTasks.pop();
}
}
//Valid Stroking?
uint8_t strokeAlpha = 0;
- if (task->sdata->strokeWidth() > FLT_EPSILON) {
+ auto strokeWidth = task->sdata->strokeWidth();
+ if (strokeWidth > FLT_EPSILON) {
task->sdata->strokeColor(nullptr, nullptr, nullptr, &strokeAlpha);
}
uint8_t alpha = 0;
task->sdata->fill(nullptr, nullptr, nullptr, &alpha);
bool renderShape = (alpha > 0 || task->sdata->fill());
- if (renderShape || strokeAlpha > 0) {
+ if (renderShape || strokeAlpha) {
if (!shapePrepare(task->shape, task->sdata, task->clip, task->transform)) return;
if (renderShape) {
- if (!shapeGenRle(task->shape, task->sdata, task->clip)) return;
+ auto antiAlias = (strokeAlpha > 0 && strokeWidth >= 2) ? false : true;
+ if (!shapeGenRle(task->shape, task->sdata, task->clip, antiAlias)) return;
}
}
}
SwSize clip;
bool invalid;
+ bool antiAlias;
};
}
if (coverage > 0) {
+ if (!rw.antiAlias) coverage = 255;
auto count = rw.spansCnt;
auto span = rw.spans + count - 1;
assert(span);
while (cell) {
- if (cell->x > x && cover != 0)
- _horizLine(rw, x, y, cover * (ONE_PIXEL * 2), cell->x - x);
-
+ 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;
-
- //OPTIMIZE ME: This occurs 1 length span data.
- if (area != 0 && cell->x >= 0)
- _horizLine(rw, cell->x, y, area, 1);
+ if (area != 0 && cell->x >= 0) _horizLine(rw, cell->x, y, area, 1);
x = cell->x + 1;
cell = cell->next;
}
- if (cover != 0)
- _horizLine(rw, x, y, cover * (ONE_PIXEL * 2), rw.cellXCnt - x);
+ if (cover != 0) _horizLine(rw, x, y, cover * (ONE_PIXEL * 2), rw.cellXCnt - x);
}
if (rw.spansCnt > 0) _genSpan(rw.rle, rw.spans, rw.spansCnt);
/* External Class Implementation */
/************************************************************************/
-SwRleData* rleRender(const SwOutline* outline, const SwBBox& bbox, const SwSize& clip)
+SwRleData* rleRender(const SwOutline* outline, const SwBBox& bbox, const SwSize& clip, bool antiAlias)
{
//Please adjust when you out of cell memory (default: 16384L)
constexpr auto RENDER_POOL_SIZE = 163840L * 2;
rw.bandSize = rw.bufferSize / (sizeof(Cell) * 8); //bandSize: 64
rw.bandShoot = 0;
rw.clip = clip;
+ rw.antiAlias = antiAlias;
rw.rle = reinterpret_cast<SwRleData*>(calloc(1, sizeof(SwRleData)));
assert(rw.rle);
}
-bool shapeGenRle(SwShape& shape, const Shape* sdata, const SwSize& clip)
+bool shapeGenRle(SwShape& shape, const Shape* sdata, const SwSize& clip, bool antiAlias)
{
//FIXME: Should we draw it?
//Case: Stroke Line
//Case A: Fast Track Rectangle Drawing
if ((shape.rect = _fastTrack(shape.outline))) return true;
//Case B: Normale Shape RLE Drawing
- if ((shape.rle = rleRender(shape.outline, shape.bbox, clip))) return true;
+ if ((shape.rle = rleRender(shape.outline, shape.bbox, clip, antiAlias))) return true;
return false;
}
if (!_checkValid(strokeOutline, bbox, clip)) return false;
- shape.strokeRle = rleRender(strokeOutline, bbox, clip);
+ shape.strokeRle = rleRender(strokeOutline, bbox, clip, true);
_delOutline(strokeOutline);
//Terminate ThorVG Engine
tvg::Initializer::term(tvgEngine);
-}
\ No newline at end of file
+}