summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-04-12 12:23:40 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-04-12 12:23:40 (GMT)
commit0f790634c57400f4ddffd36f5e3443c712d1a1c3 (patch)
tree2b9f01a1798c5700f3c82e72a3db97dac6a625d5 /src/opengl/gl2paintengineex
parent67e8e5baeec38d592596f259894e6dda420728ea (diff)
parent119d7dddc8da189ccd1cbc55ed3292f311c30e0c (diff)
downloadQt-0f790634c57400f4ddffd36f5e3443c712d1a1c3.zip
Qt-0f790634c57400f4ddffd36f5e3443c712d1a1c3.tar.gz
Qt-0f790634c57400f4ddffd36f5e3443c712d1a1c3.tar.bz2
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker.cpp28
2 files changed, 27 insertions, 5 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index a163fa9..f5ba2d6 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -217,7 +217,9 @@ void QGL2PaintEngineExPrivate::updateBrushTexture()
const QPixmap& texPixmap = currentBrush.texture();
glActiveTexture(GL_TEXTURE0 + QT_BRUSH_TEXTURE_UNIT);
- QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption);
+ QGLTexture *tex = ctx->d_func()->bindTexture(texPixmap, GL_TEXTURE_2D, GL_RGBA,
+ QGLContext::InternalBindOption |
+ QGLContext::CanFlipNativePixmapBindOption);
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, q->state()->renderHints & QPainter::SmoothPixmapTransform);
textureInvertedY = tex->options & QGLContext::InvertedYBindOption ? -1 : 1;
}
diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
index d952988..16340a1 100644
--- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
+++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
@@ -111,7 +111,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, co
// depending on if the pen is cosmetic or not.
//
// The curvyness value of PI/14 was based on,
- // arcLength=2*PI*r/4=PI/2 and splitting length into somewhere
+ // arcLength = 2*PI*r/4 = PI*r/2 and splitting length into somewhere
// between 3 and 8 where 5 seemed to be give pretty good results
// hence: Q_PI/14. Lower divisors will give more detail at the
// direct cost of performance.
@@ -487,6 +487,8 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c
const QPainterPath::ElementType *types = path.elements();
int count = path.elementCount();
+ bool cosmetic = pen.isCosmetic();
+
m_points.reset();
m_types.reset();
@@ -495,10 +497,26 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c
width = 1;
m_dash_stroker.setDashPattern(pen.dashPattern());
- m_dash_stroker.setStrokeWidth(pen.isCosmetic() ? width * m_inv_scale : width);
+ m_dash_stroker.setStrokeWidth(cosmetic ? width * m_inv_scale : width);
m_dash_stroker.setMiterLimit(pen.miterLimit());
m_dash_stroker.setClipRect(clip);
- qreal curvyness = sqrt(width) * m_inv_scale / 8;
+
+ float curvynessAdd, curvynessMul, roundness = 0;
+
+ // simplfy pens that are thin in device size (2px wide or less)
+ if (width < 2.5 && (cosmetic || m_inv_scale == 1)) {
+ curvynessAdd = 0.5;
+ curvynessMul = CURVE_FLATNESS / m_inv_scale;
+ roundness = 1;
+ } else if (cosmetic) {
+ curvynessAdd= width / 2;
+ curvynessMul= CURVE_FLATNESS;
+ roundness = qMax<int>(4, width * CURVE_FLATNESS);
+ } else {
+ curvynessAdd = width * m_inv_scale;
+ curvynessMul = CURVE_FLATNESS / m_inv_scale;
+ roundness = qMax<int>(4, width * curvynessMul);
+ }
if (count < 2)
return;
@@ -533,9 +551,11 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c
*(((const QPointF *) pts) + 1),
*(((const QPointF *) pts) + 2));
QRectF bounds = b.bounds();
- int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * curvyness);
+ float rad = qMax(bounds.width(), bounds.height());
+ int threshold = qMin<float>(64, (rad + curvynessAdd) * curvynessMul);
if (threshold < 4)
threshold = 4;
+
qreal threshold_minus_1 = threshold - 1;
for (int i=0; i<threshold; ++i) {
QPointF pt = b.pointAt(i / threshold_minus_1);