summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h
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/qtriangulatingstroker_p.h
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/qtriangulatingstroker_p.h')
-rw-r--r--src/opengl/gl2paintengineex/qtriangulatingstroker_p.h11
1 files changed, 10 insertions, 1 deletions
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;
}