src/gui/painting/qpathclipper.cpp
changeset 18 2f34d5167611
parent 3 41300fa6a67c
child 30 5dc02b23752f
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     7 ** This file is part of the QtGui module of the Qt Toolkit.
     8 **
     8 **
    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