src/gui/painting/qpainterpath_p.h
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     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 **
    95             : elements(path.size()),
    95             : elements(path.size()),
    96               points(path.size() * 2),
    96               points(path.size() * 2),
    97               flags(0)
    97               flags(0)
    98         {
    98         {
    99             int ptsPos = 0;
    99             int ptsPos = 0;
       
   100             bool isLines = true;
   100             for (int i=0; i<path.size(); ++i) {
   101             for (int i=0; i<path.size(); ++i) {
   101                 const QPainterPath::Element &e = path.at(i);
   102                 const QPainterPath::Element &e = path.at(i);
   102                 elements[i] = e.type;
   103                 elements[i] = e.type;
   103                 points[ptsPos++] = e.x;
   104                 points[ptsPos++] = e.x;
   104                 points[ptsPos++] = e.y;
   105                 points[ptsPos++] = e.y;
   105                 if (e.type == QPainterPath::CurveToElement)
   106                 if (e.type == QPainterPath::CurveToElement)
   106                     flags |= QVectorPath::CurvedShapeMask;
   107                     flags |= QVectorPath::CurvedShapeMask;
       
   108 
       
   109                 // This is to check if the path contains only alternating lineTo/moveTo,
       
   110                 // in which case we can set the LinesHint in the path. MoveTo is 0 and
       
   111                 // LineTo is 1 so the i%2 gets us what we want cheaply.
       
   112                 isLines = isLines && e.type == (QPainterPath::ElementType) (i%2);
   107             }
   113             }
   108 
   114 
   109             if (fillRule == Qt::WindingFill)
   115             if (fillRule == Qt::WindingFill)
   110                 flags |= QVectorPath::WindingFill;
   116                 flags |= QVectorPath::WindingFill;
   111             else
   117             else
   112                 flags |= QVectorPath::OddEvenFill;
   118                 flags |= QVectorPath::OddEvenFill;
   113 
   119 
   114             if (!convex)
   120             if (isLines)
   115                 flags |= QVectorPath::NonConvexShapeMask;
   121                 flags |= QVectorPath::LinesShapeMask;
       
   122             else {
       
   123                 flags |= QVectorPath::AreaShapeMask;
       
   124                 if (!convex)
       
   125                     flags |= QVectorPath::NonConvexShapeMask;
       
   126             }
       
   127 
   116         }
   128         }
   117         QVarLengthArray<QPainterPath::ElementType> elements;
   129         QVarLengthArray<QPainterPath::ElementType> elements;
   118         QVarLengthArray<qreal> points;
   130         QVarLengthArray<qreal> points;
   119         uint flags;
   131         uint flags;
   120     };
   132     };