diff options
Diffstat (limited to 'src/gui/painting/qbezier.cpp')
-rw-r--r-- | src/gui/painting/qbezier.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 9861fffff3..7622262da9 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -106,10 +106,10 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold int levels[10]; beziers[0] = *this; levels[0] = 9; - QBezier *b = beziers; - int *lvl = levels; + int top = 0; - while (b >= beziers) { + while (top >= 0) { + QBezier *b = &beziers[top]; // check if we can pop the top bezier curve from the stack qreal y4y1 = b->y4 - b->y1; qreal x4x1 = b->x4 - b->x1; @@ -123,17 +123,15 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); l = 1.; } - if (d < bezier_flattening_threshold*l || *lvl == 0) { + if (d < bezier_flattening_threshold * l || levels[top] == 0) { // good enough, we pop it off and add the endpoint polygon->append(QPointF(b->x4, b->y4)); - --b; - --lvl; + --top; } else { // split, second half of the polygon goes lower into the stack std::tie(b[1], b[0]) = b->split(); - lvl[1] = --lvl[0]; - ++b; - ++lvl; + levels[top + 1] = --levels[top]; + ++top; } } } @@ -144,10 +142,10 @@ void QBezier::addToPolygon(QDataBuffer<QPointF> &polygon, qreal bezier_flattenin int levels[10]; beziers[0] = *this; levels[0] = 9; - QBezier *b = beziers; - int *lvl = levels; + int top = 0; - while (b >= beziers) { + while (top >= 0) { + QBezier *b = &beziers[top]; // check if we can pop the top bezier curve from the stack qreal y4y1 = b->y4 - b->y1; qreal x4x1 = b->x4 - b->x1; @@ -161,17 +159,15 @@ void QBezier::addToPolygon(QDataBuffer<QPointF> &polygon, qreal bezier_flattenin qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); l = 1.; } - if (d < bezier_flattening_threshold*l || *lvl == 0) { + if (d < bezier_flattening_threshold * l || levels[top] == 0) { // good enough, we pop it off and add the endpoint polygon.add(QPointF(b->x4, b->y4)); - --b; - --lvl; + --top; } else { // split, second half of the polygon goes lower into the stack std::tie(b[1], b[0]) = b->split(); - lvl[1] = --lvl[0]; - ++b; - ++lvl; + levels[top + 1] = --levels[top]; + ++top; } } } |