summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-10-26 07:36:38 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-10-26 08:59:52 (GMT)
commit6c83dadea241f2e52d0cbcfa5c81e43c7eaeb90f (patch)
tree49085e7e186175740509a57b4f0825322f2433ca /src/opengl/gl2paintengineex
parent9a1ee410d24321e7eedaea6bb4f1b21fcc6fb427 (diff)
downloadQt-6c83dadea241f2e52d0cbcfa5c81e43c7eaeb90f.zip
Qt-6c83dadea241f2e52d0cbcfa5c81e43c7eaeb90f.tar.gz
Qt-6c83dadea241f2e52d0cbcfa5c81e43c7eaeb90f.tar.bz2
Kill a tiny few sin/cos/sqrt calls in the new stroker
Reviewed-by: Eskil
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker_p.h11
2 files changed, 12 insertions, 3 deletions
diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
index a3c8266..a5a743f 100644
--- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
+++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp
@@ -130,8 +130,8 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen)
if (m_roundness > 24)
m_roundness = 24;
- m_sin_theta = qSin(Q_PI / m_roundness); // ### Use qFastSin
- m_cos_theta = qCos(Q_PI / m_roundness);
+ m_sin_theta = qFastSin(Q_PI / m_roundness);
+ m_cos_theta = qFastCos(Q_PI / m_roundness);
const qreal *endPts = pts + (count<<1);
const qreal *startPts;
diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
index b7354db..ae56e87 100644
--- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
+++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
@@ -124,7 +124,16 @@ inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, fl
{
float dx = x2 - x1;
float dy = y2 - y1;
- float pw = m_width / sqrt(dx*dx + dy*dy);
+
+ float pw;
+
+ if (dx == 0)
+ pw = m_width / dy;
+ else if (dy == 0)
+ pw = m_width / dx;
+ else
+ pw = m_width / sqrt(dx*dx + dy*dy);
+
*nx = -dy * pw;
*ny = dx * pw;
}