mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
sw_engine: fix render fill region
Shape's bbox represents only fill's render region. Render region of fill and stroke is stored in SwTask. This was visible while rendering shapes with a stroke - fill was to big. @Issue: https://github.com/thorvg/thorvg/issues/2908 Co-Authored-By: Hermet Park <hermet@lottiefiles.com>
This commit is contained in:
parent
16111bf55b
commit
ed90581a1f
2 changed files with 8 additions and 5 deletions
|
@ -119,7 +119,8 @@ struct SwShapeTask : SwTask
|
|||
}
|
||||
|
||||
auto strokeWidth = validStrokeWidth();
|
||||
bool visibleFill = false;
|
||||
SwBBox renderRegion{};
|
||||
auto visibleFill = false;
|
||||
|
||||
//This checks also for the case, if the invisible shape turned to visible by alpha.
|
||||
auto prepareShape = false;
|
||||
|
@ -133,9 +134,9 @@ struct SwShapeTask : SwTask
|
|||
visibleFill = (alpha > 0 || rshape->fill);
|
||||
shapeReset(&shape);
|
||||
if (visibleFill || clipper) {
|
||||
if (!shapePrepare(&shape, rshape, transform, bbox, shape.bbox, mpool, tid, clips.count > 0 ? true : false)) {
|
||||
if (!shapePrepare(&shape, rshape, transform, bbox, renderRegion, mpool, tid, clips.count > 0 ? true : false)) {
|
||||
visibleFill = false;
|
||||
shape.bbox.reset();
|
||||
renderRegion.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,8 +157,8 @@ struct SwShapeTask : SwTask
|
|||
if (flags & (RenderUpdateFlag::Path | RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
|
||||
if (strokeWidth > 0.0f) {
|
||||
shapeResetStroke(&shape, rshape, transform);
|
||||
if (!shapeGenStrokeRle(&shape, rshape, transform, bbox, shape.bbox, mpool, tid)) goto err;
|
||||
|
||||
if (!shapeGenStrokeRle(&shape, rshape, transform, bbox, renderRegion, mpool, tid)) goto err;
|
||||
if (auto fill = rshape->strokeFill()) {
|
||||
auto ctable = (flags & RenderUpdateFlag::GradientStroke) ? true : false;
|
||||
if (ctable) shapeResetStrokeFill(&shape);
|
||||
|
@ -182,7 +183,7 @@ struct SwShapeTask : SwTask
|
|||
if (shape.strokeRle && !clipper->clip(shape.strokeRle)) goto err;
|
||||
}
|
||||
|
||||
bbox = shape.bbox; //sync
|
||||
bbox = renderRegion; //sync
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
@ -498,6 +498,8 @@ bool shapePrepare(SwShape* shape, const RenderShape* rshape, const Matrix& trans
|
|||
if (!_genOutline(shape, rshape, transform, mpool, tid, hasComposite)) return false;
|
||||
if (!mathUpdateOutlineBBox(shape->outline, clipRegion, renderRegion, shape->fastTrack)) return false;
|
||||
|
||||
shape->bbox = renderRegion;
|
||||
|
||||
//Check valid region
|
||||
if (renderRegion.max.x - renderRegion.min.x < 1 && renderRegion.max.y - renderRegion.min.y < 1) return false;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue