mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
renderer: safety++
introduced a threshold for the minimum dash size to prevent excessive fragmentation. issue: https://github.com/thorvg/thorvg/issues/3332
This commit is contained in:
parent
aa697d9311
commit
ba00675559
3 changed files with 6 additions and 5 deletions
|
@ -2284,7 +2284,7 @@ void DashStroke::dashLineTo(const GlPoint &to)
|
|||
} else {
|
||||
detail::Line curr{mPtCur, to};
|
||||
|
||||
while (len - mCurrLen > 0.0001f) {
|
||||
while (len - mCurrLen > DASH_PATTERN_THRESHOLD) {
|
||||
detail::Line right;
|
||||
if (mCurrLen > 0.0f) {
|
||||
detail::Line left;
|
||||
|
@ -2347,7 +2347,7 @@ void DashStroke::dashCubicTo(const GlPoint &cnt1, const GlPoint &cnt2, const GlP
|
|||
this->cubicTo(cnt1, cnt2, end);
|
||||
}
|
||||
} else {
|
||||
while (len - mCurrLen > 0.0001f) {
|
||||
while (len - mCurrLen > DASH_PATTERN_THRESHOLD) {
|
||||
Bezier right;
|
||||
if (mCurrLen > 0.0f) {
|
||||
Bezier left;
|
||||
|
|
|
@ -102,7 +102,6 @@ static void _dashLineTo(SwDashStroke& dash, const Point* to, const Matrix& trans
|
|||
{
|
||||
Line cur = {dash.ptCur, *to};
|
||||
auto len = cur.length();
|
||||
|
||||
if (tvg::zero(len)) {
|
||||
_outlineMoveTo(*dash.outline, &dash.ptCur, transform);
|
||||
//draw the current line fully
|
||||
|
@ -117,7 +116,7 @@ static void _dashLineTo(SwDashStroke& dash, const Point* to, const Matrix& trans
|
|||
}
|
||||
//draw the current line partially
|
||||
} else {
|
||||
while (len - dash.curLen > 0.0001f) {
|
||||
while (len - dash.curLen > DASH_PATTERN_THRESHOLD) {
|
||||
Line left, right;
|
||||
if (dash.curLen > 0) {
|
||||
len -= dash.curLen;
|
||||
|
@ -178,7 +177,7 @@ static void _dashCubicTo(SwDashStroke& dash, const Point* ctrl1, const Point* ct
|
|||
}
|
||||
//draw the current line partially
|
||||
} else {
|
||||
while ((len - dash.curLen) > 0.0001f) {
|
||||
while ((len - dash.curLen) > DASH_PATTERN_THRESHOLD) {
|
||||
Bezier left, right;
|
||||
if (dash.curLen > 0) {
|
||||
len -= dash.curLen;
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace tvg
|
|||
using RenderData = void*;
|
||||
using pixel_t = uint32_t;
|
||||
|
||||
#define DASH_PATTERN_THRESHOLD 0.001f
|
||||
|
||||
enum RenderUpdateFlag : uint8_t {None = 0, Path = 1, Color = 2, Gradient = 4, Stroke = 8, Transform = 16, Image = 32, GradientStroke = 64, Blend = 128, All = 255};
|
||||
enum CompositionFlag : uint8_t {Invalid = 0, Opacity = 1, Blending = 2, Masking = 4, PostProcessing = 8}; //Composition Purpose
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue