From 6c83dadea241f2e52d0cbcfa5c81e43c7eaeb90f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 26 Oct 2009 08:36:38 +0100 Subject: Kill a tiny few sin/cos/sqrt calls in the new stroker Reviewed-by: Eskil --- src/opengl/gl2paintengineex/qtriangulatingstroker.cpp | 4 ++-- src/opengl/gl2paintengineex/qtriangulatingstroker_p.h | 11 ++++++++++- 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; } -- cgit v0.12