diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-12-12 12:57:08 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-16 00:51:47 +0100 |
commit | 6506e0a6eec67985432427c630b148e825184c5d (patch) | |
tree | 1216f1ef8fe485fd6f5d0fa306a0cb29d1e4d2b5 /src/gui/painting/qbezier.cpp | |
parent | 7b874b7fc4c56a039eaab7f8828379637fff8212 (diff) |
Improved path filling performance in the raster paint engine.
Convert bezier curves to polylines before rasterizing with gray
raster.
Change-Id: I353debd4338f2a3ce2fa1cfa1bff9dd2e36f05ab
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/gui/painting/qbezier.cpp')
-rw-r--r-- | src/gui/painting/qbezier.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 9d204f9a39..bdba3f21ef 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -220,6 +220,38 @@ void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold } } +void QBezier::addToPolygon(QDataBuffer<QPointF> &polygon, qreal bezier_flattening_threshold) const +{ + QBezier beziers[32]; + beziers[0] = *this; + QBezier *b = beziers; + + while (b >= beziers) { + // check if we can pop the top bezier curve from the stack + qreal y4y1 = b->y4 - b->y1; + qreal x4x1 = b->x4 - b->x1; + qreal l = qAbs(x4x1) + qAbs(y4y1); + qreal d; + if (l > 1.) { + d = qAbs( (x4x1)*(b->y1 - b->y2) - (y4y1)*(b->x1 - b->x2) ) + + qAbs( (x4x1)*(b->y1 - b->y3) - (y4y1)*(b->x1 - b->x3) ); + } else { + d = qAbs(b->x1 - b->x2) + qAbs(b->y1 - b->y2) + + qAbs(b->x1 - b->x3) + qAbs(b->y1 - b->y3); + l = 1.; + } + if (d < bezier_flattening_threshold*l || b == beziers + 31) { + // good enough, we pop it off and add the endpoint + polygon.add(QPointF(b->x4, b->y4)); + --b; + } else { + // split, second half of the polygon goes lower into the stack + b->split(b+1, b); + ++b; + } + } +} + QRectF QBezier::bounds() const { qreal xmin = x1; |