mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 11:22:58 +00:00
optimize some QMatrix methods
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8bc6e64202
commit
2ca4a205ef
1 changed files with 55 additions and 64 deletions
|
@ -365,7 +365,6 @@ void QMatrix::map(int x, int y, int *tx, int *ty) const
|
||||||
|
|
||||||
QRect QMatrix::mapRect(const QRect &rect) const
|
QRect QMatrix::mapRect(const QRect &rect) const
|
||||||
{
|
{
|
||||||
QRect result;
|
|
||||||
if (_m12 == 0.0F && _m21 == 0.0F) {
|
if (_m12 == 0.0F && _m21 == 0.0F) {
|
||||||
int x = qRound(_m11*rect.x() + _dx);
|
int x = qRound(_m11*rect.x() + _dx);
|
||||||
int y = qRound(_m22*rect.y() + _dy);
|
int y = qRound(_m22*rect.y() + _dy);
|
||||||
|
@ -379,8 +378,9 @@ QRect QMatrix::mapRect(const QRect &rect) const
|
||||||
h = -h;
|
h = -h;
|
||||||
y -= h;
|
y -= h;
|
||||||
}
|
}
|
||||||
result = QRect(x, y, w, h);
|
return QRect(x, y, w, h);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// see mapToPolygon for explanations of the algorithm.
|
// see mapToPolygon for explanations of the algorithm.
|
||||||
qreal x0, y0;
|
qreal x0, y0;
|
||||||
qreal x, y;
|
qreal x, y;
|
||||||
|
@ -404,9 +404,7 @@ QRect QMatrix::mapRect(const QRect &rect) const
|
||||||
ymin = qMin(ymin, y);
|
ymin = qMin(ymin, y);
|
||||||
xmax = qMax(xmax, x);
|
xmax = qMax(xmax, x);
|
||||||
ymax = qMax(ymax, y);
|
ymax = qMax(ymax, y);
|
||||||
result = QRect(qRound(xmin), qRound(ymin), qRound(xmax)-qRound(xmin), qRound(ymax)-qRound(ymin));
|
return QRect(qRound(xmin), qRound(ymin), qRound(xmax)-qRound(xmin), qRound(ymax)-qRound(ymin));
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -430,7 +428,6 @@ QRect QMatrix::mapRect(const QRect &rect) const
|
||||||
*/
|
*/
|
||||||
QRectF QMatrix::mapRect(const QRectF &rect) const
|
QRectF QMatrix::mapRect(const QRectF &rect) const
|
||||||
{
|
{
|
||||||
QRectF result;
|
|
||||||
if (_m12 == 0.0F && _m21 == 0.0F) {
|
if (_m12 == 0.0F && _m21 == 0.0F) {
|
||||||
qreal x = _m11*rect.x() + _dx;
|
qreal x = _m11*rect.x() + _dx;
|
||||||
qreal y = _m22*rect.y() + _dy;
|
qreal y = _m22*rect.y() + _dy;
|
||||||
|
@ -444,8 +441,9 @@ QRectF QMatrix::mapRect(const QRectF &rect) const
|
||||||
h = -h;
|
h = -h;
|
||||||
y -= h;
|
y -= h;
|
||||||
}
|
}
|
||||||
result = QRectF(x, y, w, h);
|
return QRectF(x, y, w, h);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
qreal x0, y0;
|
qreal x0, y0;
|
||||||
qreal x, y;
|
qreal x, y;
|
||||||
MAPDOUBLE(rect.x(), rect.y(), x0, y0);
|
MAPDOUBLE(rect.x(), rect.y(), x0, y0);
|
||||||
|
@ -468,9 +466,7 @@ QRectF QMatrix::mapRect(const QRectF &rect) const
|
||||||
ymin = qMin(ymin, y);
|
ymin = qMin(ymin, y);
|
||||||
xmax = qMax(xmax, x);
|
xmax = qMax(xmax, x);
|
||||||
ymax = qMax(ymax, y);
|
ymax = qMax(ymax, y);
|
||||||
result = QRectF(xmin, ymin, xmax-xmin, ymax - ymin);
|
return QRectF(xmin, ymin, xmax-xmin, ymax - ymin);
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -597,11 +593,10 @@ QLine QMatrix::map(const QLine &line) const
|
||||||
QPolygon QMatrix::map(const QPolygon &a) const
|
QPolygon QMatrix::map(const QPolygon &a) const
|
||||||
{
|
{
|
||||||
int size = a.size();
|
int size = a.size();
|
||||||
int i;
|
|
||||||
QPolygon p(size);
|
QPolygon p(size);
|
||||||
const QPoint *da = a.constData();
|
const QPoint *da = a.constData();
|
||||||
QPoint *dp = p.data();
|
QPoint *dp = p.data();
|
||||||
for(i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
MAPINT(da[i].x(), da[i].y(), dp[i].rx(), dp[i].ry());
|
MAPINT(da[i].x(), da[i].y(), dp[i].rx(), dp[i].ry());
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
@ -618,11 +613,10 @@ QPolygon QMatrix::map(const QPolygon &a) const
|
||||||
QPolygonF QMatrix::map(const QPolygonF &a) const
|
QPolygonF QMatrix::map(const QPolygonF &a) const
|
||||||
{
|
{
|
||||||
int size = a.size();
|
int size = a.size();
|
||||||
int i;
|
|
||||||
QPolygonF p(size);
|
QPolygonF p(size);
|
||||||
const QPointF *da = a.constData();
|
const QPointF *da = a.constData();
|
||||||
QPointF *dp = p.data();
|
QPointF *dp = p.data();
|
||||||
for(i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
MAPDOUBLE(da[i].xp, da[i].yp, dp[i].xp, dp[i].yp);
|
MAPDOUBLE(da[i].xp, da[i].yp, dp[i].xp, dp[i].yp);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
|
@ -664,9 +658,7 @@ QRegion QMatrix::map(const QRegion &r) const
|
||||||
if (_m11 == 1.0 && _m22 == 1.0 && _m12 == 0.0 && _m21 == 0.0) { // translate or identity
|
if (_m11 == 1.0 && _m22 == 1.0 && _m12 == 0.0 && _m21 == 0.0) { // translate or identity
|
||||||
if (_dx == 0.0 && _dy == 0.0) // Identity
|
if (_dx == 0.0 && _dy == 0.0) // Identity
|
||||||
return r;
|
return r;
|
||||||
QRegion copy(r);
|
return r.translated(qRound(_dx), qRound(_dy));
|
||||||
copy.translate(qRound(_dx), qRound(_dy));
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath p = map(qt_regionToPath(r));
|
QPainterPath p = map(qt_regionToPath(r));
|
||||||
|
@ -784,8 +776,7 @@ QPolygon QMatrix::mapToPolygon(const QRect &rect) const
|
||||||
MAPDOUBLE(rect.x(), bottom, x[3], y[3]);
|
MAPDOUBLE(rect.x(), bottom, x[3], y[3]);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
int i;
|
for(int i = 0; i< 4; i++)
|
||||||
for(i = 0; i< 4; i++)
|
|
||||||
qDebug("coords(%d) = (%f/%f) (%d/%d)", i, x[i], y[i], qRound(x[i]), qRound(y[i]));
|
qDebug("coords(%d) = (%f/%f) (%d/%d)", i, x[i], y[i], qRound(x[i]), qRound(y[i]));
|
||||||
qDebug("width=%f, height=%f", qSqrt((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0])),
|
qDebug("width=%f, height=%f", qSqrt((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0])),
|
||||||
qSqrt((x[0]-x[3])*(x[0]-x[3]) + (y[0]-y[3])*(y[0]-y[3])));
|
qSqrt((x[0]-x[3])*(x[0]-x[3]) + (y[0]-y[3])*(y[0]-y[3])));
|
||||||
|
|
Loading…
Add table
Reference in a new issue