Use QTransform instead of doing transforms manually
Minor cleanup of QOutlineMapper to take advantage of QTransform. Change-Id: I15534970a821c7f1de42f4a5a2560f04ae420d16 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
parent
0a1c8cc668
commit
c327fb79e1
@ -38,9 +38,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qoutlinemapper_p.h"
|
||||
#include <private/qpainterpath_p.h>
|
||||
|
||||
#include "qbezier_p.h"
|
||||
#include "qmath.h"
|
||||
#include <private/qbezier_p.h>
|
||||
#include "qpainterpath_p.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -187,39 +188,9 @@ void QOutlineMapper::endOutline()
|
||||
QPointF *elements = m_elements.data();
|
||||
|
||||
// Transform the outline
|
||||
if (m_txop == QTransform::TxNone) {
|
||||
// Nothing to do.
|
||||
} else if (m_txop == QTransform::TxTranslate) {
|
||||
for (int i = 0; i < m_elements.size(); ++i) {
|
||||
QPointF &e = elements[i];
|
||||
e = QPointF(e.x() + m_dx, e.y() + m_dy);
|
||||
}
|
||||
} else if (m_txop == QTransform::TxScale) {
|
||||
for (int i = 0; i < m_elements.size(); ++i) {
|
||||
QPointF &e = elements[i];
|
||||
e = QPointF(m_m11 * e.x() + m_dx, m_m22 * e.y() + m_dy);
|
||||
}
|
||||
} else if (m_txop < QTransform::TxProject) {
|
||||
for (int i = 0; i < m_elements.size(); ++i) {
|
||||
QPointF &e = elements[i];
|
||||
e = QPointF(m_m11 * e.x() + m_m21 * e.y() + m_dx,
|
||||
m_m22 * e.y() + m_m12 * e.x() + m_dy);
|
||||
}
|
||||
} else {
|
||||
const QVectorPath vp((qreal *)elements, m_elements.size(),
|
||||
m_element_types.size() ? m_element_types.data() : 0);
|
||||
QPainterPath path = vp.convertToPainterPath();
|
||||
path = QTransform(m_m11, m_m12, m_m13, m_m21, m_m22, m_m23, m_dx, m_dy, m_m33).map(path);
|
||||
if (!(m_outline.flags & QT_FT_OUTLINE_EVEN_ODD_FILL))
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
uint old_txop = m_txop;
|
||||
m_txop = QTransform::TxNone;
|
||||
if (path.isEmpty())
|
||||
m_valid = false;
|
||||
else
|
||||
convertPath(path);
|
||||
m_txop = old_txop;
|
||||
return;
|
||||
if (!m_in_clip_elements) {
|
||||
for (int i = 0; i < m_elements.size(); ++i)
|
||||
elements[i] = m_transform.map(elements[i]);
|
||||
}
|
||||
|
||||
controlPointRect = boundingRect(elements, m_elements.size());
|
||||
@ -387,13 +358,10 @@ void QOutlineMapper::clipElements(const QPointF *elements,
|
||||
QPainterPath clipPath;
|
||||
clipPath.addRect(m_clip_rect);
|
||||
QPainterPath clippedPath = path.intersected(clipPath);
|
||||
uint old_txop = m_txop;
|
||||
m_txop = QTransform::TxNone;
|
||||
if (clippedPath.isEmpty())
|
||||
m_valid = false;
|
||||
else
|
||||
convertPath(clippedPath);
|
||||
m_txop = old_txop;
|
||||
|
||||
m_in_clip_elements = false;
|
||||
}
|
||||
|
@ -104,16 +104,7 @@ public:
|
||||
*/
|
||||
void setMatrix(const QTransform &m)
|
||||
{
|
||||
m_m11 = m.m11();
|
||||
m_m12 = m.m12();
|
||||
m_m13 = m.m13();
|
||||
m_m21 = m.m21();
|
||||
m_m22 = m.m22();
|
||||
m_m23 = m.m23();
|
||||
m_m33 = m.m33();
|
||||
m_dx = m.dx();
|
||||
m_dy = m.dy();
|
||||
m_txop = m.type();
|
||||
m_transform = m;
|
||||
|
||||
qreal scale;
|
||||
qt_scaleForTransform(m, &scale);
|
||||
@ -207,20 +198,10 @@ public:
|
||||
QRectF controlPointRect; // only valid after endOutline()
|
||||
|
||||
QT_FT_Outline m_outline;
|
||||
uint m_txop;
|
||||
|
||||
int m_subpath_start;
|
||||
|
||||
// Matrix
|
||||
qreal m_m11;
|
||||
qreal m_m12;
|
||||
qreal m_m13;
|
||||
qreal m_m21;
|
||||
qreal m_m22;
|
||||
qreal m_m23;
|
||||
qreal m_m33;
|
||||
qreal m_dx;
|
||||
qreal m_dy;
|
||||
QTransform m_transform;
|
||||
|
||||
qreal m_curve_threshold;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user