mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
sw_engine: fix to update stroking transform
when shape doesn't have fill color, stroking is missed in update. this fixs that issue. Change-Id: I49292475e56caa834e79497a16db705b965bcf5f
This commit is contained in:
parent
61cb144122
commit
f377f33993
3 changed files with 17 additions and 9 deletions
|
@ -175,12 +175,19 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
|
||||||
task->flags = flags;
|
task->flags = flags;
|
||||||
|
|
||||||
auto asyncTask = [](SwTask* task) {
|
auto asyncTask = [](SwTask* task) {
|
||||||
|
|
||||||
|
//Valid Stroking?
|
||||||
|
uint8_t strokeAlpha = 0;
|
||||||
|
if (task->sdata->strokeWidth() > FLT_EPSILON) {
|
||||||
|
task->sdata->strokeColor(nullptr, nullptr, nullptr, &strokeAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
//Shape
|
//Shape
|
||||||
if (task->flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform)) {
|
if (task->flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Transform)) {
|
||||||
shapeReset(task->shape);
|
shapeReset(task->shape);
|
||||||
uint8_t alpha = 0;
|
uint8_t alpha = 0;
|
||||||
task->sdata->fill(nullptr, nullptr, nullptr, &alpha);
|
task->sdata->fill(nullptr, nullptr, nullptr, &alpha);
|
||||||
if (alpha > 0 || task->sdata->fill()) {
|
if (alpha > 0 || task->sdata->fill() || strokeAlpha > 0) {
|
||||||
if (!shapeGenRle(task->shape, task->sdata, task->clip, task->transform)) return;
|
if (!shapeGenRle(task->shape, task->sdata, task->clip, task->transform)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,13 +204,9 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
|
||||||
}
|
}
|
||||||
//Stroke
|
//Stroke
|
||||||
if (task->flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
|
if (task->flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
|
||||||
if (task->sdata->strokeWidth() > FLT_EPSILON) {
|
if (strokeAlpha > 0) {
|
||||||
shapeResetStroke(task->shape, task->sdata);
|
shapeResetStroke(task->shape, task->sdata);
|
||||||
uint8_t alpha = 0;
|
if (!shapeGenStrokeRle(task->shape, task->sdata, task->clip)) return;
|
||||||
task->sdata->strokeColor(nullptr, nullptr, nullptr, &alpha);
|
|
||||||
if (alpha > 0) {
|
|
||||||
if (!shapeGenStrokeRle(task->shape, task->sdata, task->clip)) return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
shapeDelStroke(task->shape);
|
shapeDelStroke(task->shape);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ static bool _updateBBox(SwOutline* outline, SwBBox& bbox)
|
||||||
bbox.min.y = yMin >> 6;
|
bbox.min.y = yMin >> 6;
|
||||||
bbox.max.y = (yMax + 63) >> 6;
|
bbox.max.y = (yMax + 63) >> 6;
|
||||||
|
|
||||||
if (xMax - xMin < 1 || yMax - yMin < 1) return false;
|
if (xMax - xMin < 1 && yMax - yMin < 1) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -451,6 +451,9 @@ bool shapeGenRle(SwShape& shape, const Shape* sdata, const SwSize& clip, const M
|
||||||
|
|
||||||
if (!_checkValid(shape.outline, shape.bbox, clip)) goto end;
|
if (!_checkValid(shape.outline, shape.bbox, clip)) goto end;
|
||||||
|
|
||||||
|
//Case: Stroke Line
|
||||||
|
if (shape.outline->opened) return true;
|
||||||
|
|
||||||
shape.rle = rleRender(shape.outline, shape.bbox, clip);
|
shape.rle = rleRender(shape.outline, shape.bbox, clip);
|
||||||
end:
|
end:
|
||||||
if (shape.rle) return true;
|
if (shape.rle) return true;
|
||||||
|
|
|
@ -26,6 +26,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
shape->lineTo(-53, -5.5);
|
shape->lineTo(-53, -5.5);
|
||||||
shape->close();
|
shape->close();
|
||||||
shape->fill(0, 0, 255, 255);
|
shape->fill(0, 0, 255, 255);
|
||||||
|
shape->stroke(3);
|
||||||
|
shape->stroke(255, 255, 255, 255);
|
||||||
if (canvas->push(move(shape)) != tvg::Result::Success) return;
|
if (canvas->push(move(shape)) != tvg::Result::Success) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue