Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-118751

QTransform::map() will failled when m33 is negative

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2
    • GUI: Painting
    • None
    • All

    Description

      In the source file qtransform.cpp, the micro Q_NEAR_CLIP is defined a positive tiny number.

      68 | #define Q_NEAR_CLIP (sizeof(qreal) == sizeof(double) ? 0.000001 : 0.0001)
      

      Where the Q_NEAR_CLIP is used

      1604 |    if (ha.w < Q_NEAR_CLIP && hb.w < Q_NEAR_CLIP)
      1605 |        return false;
      

      will be return false when ha.w and hb.w is negative, when  m33 is a negative. So before compare with Q_NEAR_CLIP, number should be round with qAbs().

      1604 |    if (qAbs(ha.w) < Q_NEAR_CLIP && qAbs(hb.w) < Q_NEAR_CLIP)
      1605 |        return false;
      

       

      Here the test code is:

      #include <QtGui>
      int main(int argc, char* argv[])
      {
          QPolygonF a(QRectF(0, 0, 100, 200));
          qDebug() << "points count in polygon a is " << a.size();
          qDebug() << a;
      
          QTransform t1(1, 0, 0, 0, 1, 0, 0, 0, 1);
          qDebug() << "transform: " << t1;
          QPolygonF b = t1.map(a);
          qDebug() << "points count in polygon b is " << b.size();
          qDebug() << b;
      
          QTransform t2(1, 0, 0, 0, 1, 0, 0, 0, -1);   //map will failled when m33 is negative
          qDebug() << "transform: " << t2;
          QPolygonF c = t2.map(a);
          qDebug() << "points count in polygon c is " << c.size();
          qDebug() << c;
      
          return 0;
      } 
      

      Output as:

      points count in polygon a is  5 
      QPolygonF(QPointF(0,0)QPointF(100,0)QPointF(100,200)QPointF(0,200)QPointF(0,0)) 
      transform:  QTransform(type=TxNone, 11=1 12=0 13=0 21=0 22=1 23=0 31=0 32=0 33=1) 
      points count in polygon b is  5 
      QPolygonF(QPointF(0,0)QPointF(100,0)QPointF(100,200)QPointF(0,200)QPointF(0,0)) 
      transform:  QTransform(type=TxProject, 11=1 12=0 13=0 21=0 22=1 23=0 31=0 32=0 33=-1) 
      points count in polygon c is  1 
      QPolygonF(QPointF(0,0))
      

      We expect the map result c is the same as b, but fail. The bug occur here when the transform.m33 is a negative number.

      Attachments

        For Gerrit Dashboard: QTBUG-118751
        # Subject Branch Project Status CR V

        Activity

          People

            vgt Eirik Aavitsland
            pmyy gradua Z
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change