src/gui/painting/qpathclipper.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 4 3b1da2848fc7
equal deleted inserted replaced
6:dee5afe5301f 8:3f74d0d4af4c
    88 static QPointF normalize(const QPointF &p)
    88 static QPointF normalize(const QPointF &p)
    89 {
    89 {
    90     return p / qSqrt(p.x() * p.x() + p.y() * p.y());
    90     return p / qSqrt(p.x() * p.x() + p.y() * p.y());
    91 }
    91 }
    92 
    92 
    93 static bool pathToRect(const QPainterPath &path, QRectF *rect = 0);
       
    94 
       
    95 struct QIntersection
    93 struct QIntersection
    96 {
    94 {
    97     qreal alphaA;
    95     qreal alphaA;
    98     qreal alphaB;
    96     qreal alphaB;
    99 
    97 
  1658 static bool fuzzyCompare(qreal a, qreal b)
  1656 static bool fuzzyCompare(qreal a, qreal b)
  1659 {
  1657 {
  1660     return qFuzzyCompare(a, b);
  1658     return qFuzzyCompare(a, b);
  1661 }
  1659 }
  1662 
  1660 
  1663 static bool pathToRect(const QPainterPath &path, QRectF *rect)
  1661 bool QPathClipper::pathToRect(const QPainterPath &path, QRectF *rect)
  1664 {
  1662 {
  1665     if (path.elementCount() != 5)
  1663     if (path.elementCount() != 5)
  1666         return false;
  1664         return false;
  1667 
  1665 
  1668     const bool mightBeRect = path.elementAt(0).isMoveTo()
  1666     const bool mightBeRect = path.elementAt(0).isMoveTo()
  1691 
  1689 
  1692     if (path.elementAt(4).x != x1 || path.elementAt(4).y != y1)
  1690     if (path.elementAt(4).x != x1 || path.elementAt(4).y != y1)
  1693         return false;
  1691         return false;
  1694 
  1692 
  1695     if (rect)
  1693     if (rect)
  1696         *rect = QRectF(QPointF(x1, y1), QPointF(x2, y2));
  1694         rect->setCoords(x1, y1, x2, y2);
  1697 
  1695 
  1698     return true;
  1696     return true;
  1699 }
  1697 }
  1700 
  1698 
  1701 
  1699