79 class QVectorPathConverter; |
79 class QVectorPathConverter; |
80 |
80 |
81 class QVectorPathConverter |
81 class QVectorPathConverter |
82 { |
82 { |
83 public: |
83 public: |
84 QVectorPathConverter(const QVector<QPainterPath::Element> &path, uint fillRule) |
84 QVectorPathConverter(const QVector<QPainterPath::Element> &path, uint fillRule, bool convex) |
85 : pathData(path, fillRule), |
85 : pathData(path, fillRule, convex), |
86 path(pathData.points.data(), path.size(), |
86 path(pathData.points.data(), path.size(), |
87 pathData.elements.data(), pathData.flags) {} |
87 pathData.elements.data(), pathData.flags) {} |
88 |
88 |
89 const QVectorPath &vectorPath() { |
89 const QVectorPath &vectorPath() { |
90 return path; |
90 return path; |
91 } |
91 } |
92 |
92 |
93 struct QVectorPathData { |
93 struct QVectorPathData { |
94 QVectorPathData(const QVector<QPainterPath::Element> &path, uint fillRule) |
94 QVectorPathData(const QVector<QPainterPath::Element> &path, uint fillRule, bool convex) |
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; |
101 const QPainterPath::Element &e = path.at(i); |
101 const QPainterPath::Element &e = path.at(i); |
102 elements[i] = e.type; |
102 elements[i] = e.type; |
103 points[ptsPos++] = e.x; |
103 points[ptsPos++] = e.x; |
104 points[ptsPos++] = e.y; |
104 points[ptsPos++] = e.y; |
105 if (e.type == QPainterPath::CurveToElement) |
105 if (e.type == QPainterPath::CurveToElement) |
106 flags |= QVectorPath::CurvedShapeHint; |
106 flags |= QVectorPath::CurvedShapeMask; |
107 } |
107 } |
108 |
108 |
109 if (fillRule == Qt::WindingFill) |
109 if (fillRule == Qt::WindingFill) |
110 flags |= QVectorPath::WindingFill; |
110 flags |= QVectorPath::WindingFill; |
111 else |
111 else |
112 flags |= QVectorPath::OddEvenFill; |
112 flags |= QVectorPath::OddEvenFill; |
113 |
113 |
|
114 if (!convex) |
|
115 flags |= QVectorPath::NonConvexShapeMask; |
114 } |
116 } |
115 QVarLengthArray<QPainterPath::ElementType> elements; |
117 QVarLengthArray<QPainterPath::ElementType> elements; |
116 QVarLengthArray<qreal> points; |
118 QVarLengthArray<qreal> points; |
117 uint flags; |
119 uint flags; |
118 }; |
120 }; |
126 |
128 |
127 class QPainterPathData : public QPainterPathPrivate |
129 class QPainterPathData : public QPainterPathPrivate |
128 { |
130 { |
129 public: |
131 public: |
130 QPainterPathData() : |
132 QPainterPathData() : |
131 cStart(0), fillRule(Qt::OddEvenFill), |
133 cStart(0), |
132 dirtyBounds(false), dirtyControlBounds(false), |
134 fillRule(Qt::OddEvenFill), |
|
135 dirtyBounds(false), |
|
136 dirtyControlBounds(false), |
133 pathConverter(0) |
137 pathConverter(0) |
134 { |
138 { |
135 ref = 1; |
139 ref = 1; |
136 require_moveTo = false; |
140 require_moveTo = false; |
|
141 convex = false; |
137 } |
142 } |
138 |
143 |
139 QPainterPathData(const QPainterPathData &other) : |
144 QPainterPathData(const QPainterPathData &other) : |
140 QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule), |
145 QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule), |
141 dirtyBounds(other.dirtyBounds), bounds(other.bounds), |
146 bounds(other.bounds), |
|
147 controlBounds(other.controlBounds), |
|
148 dirtyBounds(other.dirtyBounds), |
142 dirtyControlBounds(other.dirtyControlBounds), |
149 dirtyControlBounds(other.dirtyControlBounds), |
143 controlBounds(other.controlBounds), |
150 convex(other.convex), |
144 pathConverter(0) |
151 pathConverter(0) |
145 { |
152 { |
146 ref = 1; |
153 ref = 1; |
147 require_moveTo = false; |
154 require_moveTo = false; |
148 elements = other.elements; |
155 elements = other.elements; |
156 inline void close(); |
163 inline void close(); |
157 inline void maybeMoveTo(); |
164 inline void maybeMoveTo(); |
158 |
165 |
159 const QVectorPath &vectorPath() { |
166 const QVectorPath &vectorPath() { |
160 if (!pathConverter) |
167 if (!pathConverter) |
161 pathConverter = new QVectorPathConverter(elements, fillRule); |
168 pathConverter = new QVectorPathConverter(elements, fillRule, convex); |
162 return pathConverter->path; |
169 return pathConverter->path; |
163 } |
170 } |
164 |
171 |
165 int cStart; |
172 int cStart; |
166 Qt::FillRule fillRule; |
173 Qt::FillRule fillRule; |
167 |
174 |
168 bool require_moveTo; |
|
169 |
|
170 bool dirtyBounds; |
|
171 QRectF bounds; |
175 QRectF bounds; |
172 bool dirtyControlBounds; |
|
173 QRectF controlBounds; |
176 QRectF controlBounds; |
|
177 |
|
178 uint require_moveTo : 1; |
|
179 uint dirtyBounds : 1; |
|
180 uint dirtyControlBounds : 1; |
|
181 uint convex : 1; |
174 |
182 |
175 QVectorPathConverter *pathConverter; |
183 QVectorPathConverter *pathConverter; |
176 }; |
184 }; |
177 |
185 |
178 |
186 |