remove redundant QDataBuffer operator

less code to maintain and less symbols to resolve (both at compile and
runtime), can't go wrong with that

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-29 02:51:04 +02:00
parent 509d507363
commit 4ce6c69719
6 changed files with 69 additions and 55 deletions

View file

@ -106,8 +106,6 @@ public:
qSwap(buffer, other.buffer);
}
inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; }
private:
int capacity;
int siz;

View file

@ -160,18 +160,18 @@ void QOutlineMapper::endOutline()
if (m_txop == QTransform::TxTranslate) {
for (int i=0; i<m_elements.size(); ++i) {
const QPointF &e = m_elements.at(i);
m_elements_dev << QPointF(e.x() + m_dx, e.y() + m_dy);
m_elements_dev.add(QPointF(e.x() + m_dx, e.y() + m_dy));
}
} else if (m_txop == QTransform::TxScale) {
for (int i=0; i<m_elements.size(); ++i) {
const QPointF &e = m_elements.at(i);
m_elements_dev << QPointF(m_m11 * e.x() + m_dx, m_m22 * e.y() + m_dy);
m_elements_dev.add(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) {
const QPointF &e = m_elements.at(i);
m_elements_dev << QPointF(m_m11 * e.x() + m_m21 * e.y() + m_dx,
m_m22 * e.y() + m_m12 * e.x() + m_dy);
m_elements_dev.add(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 *)m_elements.data(), m_elements.size(), m_element_types.size() ? m_element_types.data() : 0);
@ -228,39 +228,51 @@ void QOutlineMapper::convertElements(const QPointF *elements,
switch (*types) {
case QPainterPath::MoveToElement:
{
QT_FT_Vector pt_fixed = { qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y()) };
QT_FT_Vector pt_fixed = {
qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y())
};
if (i != 0)
m_contours << m_points.size() - 1;
m_points << pt_fixed;
m_tags << QT_FT_CURVE_TAG_ON;
m_contours.add(m_points.size() - 1);
m_points.add(pt_fixed);
m_tags.add(QT_FT_CURVE_TAG_ON);
}
break;
case QPainterPath::LineToElement:
{
QT_FT_Vector pt_fixed = { qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y()) };
m_points << pt_fixed;
m_tags << QT_FT_CURVE_TAG_ON;
QT_FT_Vector pt_fixed = {
qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y())
};
m_points.add(pt_fixed);
m_tags.add(QT_FT_CURVE_TAG_ON);
}
break;
case QPainterPath::CurveToElement:
{
QT_FT_Vector cp1_fixed = { qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y()) };
QT_FT_Vector cp1_fixed = {
qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y())
};
++e;
QT_FT_Vector cp2_fixed = { qreal_to_fixed_26_6((e)->x()),
qreal_to_fixed_26_6((e)->y()) };
QT_FT_Vector cp2_fixed = {
qreal_to_fixed_26_6((e)->x()),
qreal_to_fixed_26_6((e)->y())
};
++e;
QT_FT_Vector ep_fixed = { qreal_to_fixed_26_6((e)->x()),
qreal_to_fixed_26_6((e)->y()) };
QT_FT_Vector ep_fixed = {
qreal_to_fixed_26_6((e)->x()),
qreal_to_fixed_26_6((e)->y())
};
m_points << cp1_fixed << cp2_fixed << ep_fixed;
m_tags << QT_FT_CURVE_TAG_CUBIC
<< QT_FT_CURVE_TAG_CUBIC
<< QT_FT_CURVE_TAG_ON;
m_points.add(cp1_fixed);
m_points.add(cp2_fixed);
m_points.add(ep_fixed);
m_tags.add(QT_FT_CURVE_TAG_CUBIC);
m_tags.add(QT_FT_CURVE_TAG_CUBIC);
m_tags.add(QT_FT_CURVE_TAG_ON);
types += 2;
i += 2;
@ -277,16 +289,18 @@ void QOutlineMapper::convertElements(const QPointF *elements,
const QPointF *last = elements + element_count;
const QPointF *e = elements;
while (e < last) {
QT_FT_Vector pt_fixed = { qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y()) };
m_points << pt_fixed;
m_tags << QT_FT_CURVE_TAG_ON;
QT_FT_Vector pt_fixed = {
qreal_to_fixed_26_6(e->x()),
qreal_to_fixed_26_6(e->y())
};
m_points.add(pt_fixed);
m_tags.add(QT_FT_CURVE_TAG_ON);
++e;
}
}
// close the very last subpath
m_contours << m_points.size() - 1;
m_contours.add(m_points.size() - 1);
m_outline.n_contours = m_contours.size();
m_outline.n_points = m_points.size();

View file

@ -118,8 +118,8 @@ public:
#endif
closeSubpath();
m_subpath_start = m_elements.size();
m_elements << pt;
m_element_types << QPainterPath::MoveToElement;
m_elements.add(pt);
m_element_types.add(QPainterPath::MoveToElement);
}
inline void lineTo(const QPointF &pt) {
@ -127,17 +127,19 @@ public:
printf("QOutlineMapper::lineTo() (%f, %f)\n", pt.x(), pt.y());
#endif
m_elements.add(pt);
m_element_types << QPainterPath::LineToElement;
m_element_types.add(QPainterPath::LineToElement);
}
inline void curveTo(const QPointF &cp1, const QPointF &cp2, const QPointF &ep) {
#ifdef QT_DEBUG_CONVERT
printf("QOutlineMapper::curveTo() (%f, %f)\n", ep.x(), ep.y());
#endif
m_elements << cp1 << cp2 << ep;
m_element_types << QPainterPath::CurveToElement
<< QPainterPath::CurveToDataElement
<< QPainterPath::CurveToDataElement;
m_elements.add(cp1);
m_elements.add(cp2);
m_elements.add(ep);
m_element_types.add(QPainterPath::CurveToElement);
m_element_types.add(QPainterPath::CurveToDataElement);
m_element_types.add(QPainterPath::CurveToDataElement);
}
inline void closeSubpath() {
@ -156,7 +158,7 @@ public:
if (m_element_types.size())
lineTo(pt);
else
m_elements << pt;
m_elements.add(pt);
}
}

View file

@ -741,9 +741,9 @@ void QPathSegments::mergePoints()
Q_ASSERT(finder.result() != -1);
if (finder.result() >= mergedPoints.size())
mergedPoints << m_points.at(i);
mergedPoints.add(m_points.at(i));
pointIndices << finder.result();
pointIndices.add(finder.result());
}
for (int i = 0; i < m_segments.size(); ++i) {
@ -776,7 +776,7 @@ void QWingedEdge::intersectAndAdd()
const QPathSegments::Intersection *isect = m_segments.intersectionAt(i);
while (isect) {
intersections << *isect;
intersections.add(*isect);
if (isect->next) {
isect += isect->next;
@ -902,24 +902,24 @@ void QPathSegments::addPath(const QPainterPath &path)
if (i > 0 && comparePoints(m_points.at(lastMoveTo), currentPoint))
current = lastMoveTo;
else
m_points << currentPoint;
m_points.add(currentPoint);
switch (path.elementAt(i).type) {
case QPainterPath::MoveToElement:
if (hasMoveTo && last != lastMoveTo && !comparePoints(m_points.at(last), m_points.at(lastMoveTo)))
m_segments << Segment(m_pathId, last, lastMoveTo);
m_segments.add(Segment(m_pathId, last, lastMoveTo));
hasMoveTo = true;
last = lastMoveTo = current;
break;
case QPainterPath::LineToElement:
m_segments << Segment(m_pathId, last, current);
m_segments.add(Segment(m_pathId, last, current));
last = current;
break;
case QPainterPath::CurveToElement:
{
QBezier bezier = QBezier::fromPoints(m_points.at(last), path.elementAt(i), path.elementAt(i+1), path.elementAt(i+2));
if (isLine(bezier)) {
m_segments << Segment(m_pathId, last, current);
m_segments.add(Segment(m_pathId, last, current));
} else {
QRectF bounds = bezier.bounds();
@ -933,13 +933,13 @@ void QPathSegments::addPath(const QPainterPath &path)
currentPoint = bezier.pointAt(t * one_over_threshold_minus_1);
int index = m_points.size();
m_segments << Segment(m_pathId, last, index);
m_segments.add(Segment(m_pathId, last, index));
last = index;
m_points << currentPoint;
m_points.add(currentPoint);
}
m_segments << Segment(m_pathId, last, current);
m_segments.add(Segment(m_pathId, last, current));
}
}
last = current;
@ -952,7 +952,7 @@ void QPathSegments::addPath(const QPainterPath &path)
}
if (hasMoveTo && last != lastMoveTo && !comparePoints(m_points.at(last), m_points.at(lastMoveTo)))
m_segments << Segment(m_pathId, last, lastMoveTo);
m_segments.add(Segment(m_pathId, last, lastMoveTo));
for (int i = firstSegment; i < m_segments.size(); ++i) {
const QLineF line = lineAt(i);
@ -1166,7 +1166,7 @@ int QWingedEdge::addEdge(int fi, int si)
if (common >= 0)
return common;
m_edges << QPathEdge(fi, si);
m_edges.add(QPathEdge(fi, si));
int ei = m_edges.size() - 1;
@ -1249,7 +1249,7 @@ int QWingedEdge::insert(const QPathVertex &vertex)
}
}
m_vertices << vertex;
m_vertices.add(vertex);
return m_vertices.size() - 1;
}

View file

@ -334,7 +334,7 @@ inline const QPointF &QPathSegments::pointAt(int i) const
inline int QPathSegments::addPoint(const QPointF &point)
{
m_points << point;
m_points.add(point);
return m_points.size() - 1;
}
@ -375,7 +375,7 @@ inline int QPathSegments::intersections() const
inline void QPathSegments::addIntersection(int index, const Intersection &intersection)
{
m_intersections << intersection;
m_intersections.add(intersection);
Segment &segment = m_segments.at(index);
if (segment.intersection < 0) {
@ -428,7 +428,7 @@ inline int QWingedEdge::vertexCount() const
inline int QWingedEdge::addVertex(const QPointF &p)
{
m_vertices << p;
m_vertices.add(p);
return m_vertices.size() - 1;
}

View file

@ -303,7 +303,7 @@ void qScanConvert(QScanConverter &d, bool allVertical)
d.m_active.at(j+1) = d.m_active.at(j);
d.m_active.at(j+1) = l;
} else {
d.m_active << &d.m_lines.at(line);
d.m_active.add(&d.m_lines.at(line));
}
}