From 1b8e870e9f1058604f5f1fce4958f20de7232236 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 29 Jun 2021 14:23:38 +0900 Subject: [PATCH] sw_engine renderer: fix a broken composition bug tvg sw_engine tries to skip composition as far as its doable, it tries composition only if the translucent shape with stroking is there. There has been a condition bug that composition is applied unnecessarily even if stroking is disabled. This resulted in broken blending at gradient filling since it applied alpha values multiple times. Issues: https://github.com/Samsung/thorvg/issues/445 Change-Id: I09ba606b2e6c0c5f4750c9e8810b74c705851b63 --- src/lib/sw_engine/tvgSwRenderer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRenderer.cpp b/src/lib/sw_engine/tvgSwRenderer.cpp index ba5629d..24800f2 100644 --- a/src/lib/sw_engine/tvgSwRenderer.cpp +++ b/src/lib/sw_engine/tvgSwRenderer.cpp @@ -71,7 +71,8 @@ struct SwShapeTask : SwTask /* Valid filling & stroking each increases the value by 1. This value is referenced for compositing shape & stroking. */ - uint32_t addStroking = 0; + bool stroking = false; + bool filling = false; //Valid Stroking? uint8_t strokeAlpha = 0; @@ -102,7 +103,7 @@ struct SwShapeTask : SwTask Also, it shouldn't be dash style. */ auto antiAlias = (strokeAlpha == 255 && strokeWidth > 2 && sdata->strokeDash(nullptr) == 0) ? false : true; if (!shapeGenRle(&shape, sdata, antiAlias, clips.count > 0 ? true : false)) goto err; - ++addStroking; + filling = true; } } } @@ -114,7 +115,7 @@ struct SwShapeTask : SwTask auto ctable = (flags & RenderUpdateFlag::Gradient) ? true : false; if (ctable) shapeResetFill(&shape); if (!shapeGenFillColors(&shape, fill, transform, surface, opacity, ctable)) goto err; - ++addStroking; + filling = true; } else { shapeDelFill(&shape); } @@ -125,7 +126,7 @@ struct SwShapeTask : SwTask if (validStroke) { shapeResetStroke(&shape, sdata, transform); if (!shapeGenStrokeRle(&shape, sdata, transform, clipRegion, bbox, mpool, tid)) goto err; - ++addStroking; + stroking = true; if (auto fill = sdata->strokeFill()) { auto ctable = (flags & RenderUpdateFlag::GradientStroke) ? true : false; @@ -159,7 +160,7 @@ struct SwShapeTask : SwTask shapeReset(&shape); end: shapeDelOutline(&shape, mpool, tid); - if (addStroking > 1 && opacity < 255) cmpStroking = true; + if (stroking && filling && opacity < 255) cmpStroking = true; else cmpStroking = false; } -- 2.7.4