equal
deleted
inserted
replaced
54 /******************************************************************************* |
54 /******************************************************************************* |
55 * |
55 * |
56 * class QVectorPath |
56 * class QVectorPath |
57 * |
57 * |
58 */ |
58 */ |
|
59 QVectorPath::~QVectorPath() |
|
60 { |
|
61 if (m_hints & ShouldUseCacheHint) { |
|
62 CacheEntry *e = m_cache; |
|
63 while (e) { |
|
64 if (e->data) |
|
65 e->cleanup(e->engine, e->data); |
|
66 CacheEntry *n = e->next; |
|
67 delete e; |
|
68 e = n; |
|
69 } |
|
70 } |
|
71 } |
|
72 |
59 |
73 |
60 QRectF QVectorPath::controlPointRect() const |
74 QRectF QVectorPath::controlPointRect() const |
61 { |
75 { |
62 if (m_hints & ControlPointRect) |
76 if (m_hints & ControlPointRect) |
63 return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); |
77 return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); |
89 } |
103 } |
90 |
104 |
91 m_hints |= ControlPointRect; |
105 m_hints |= ControlPointRect; |
92 return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); |
106 return QRectF(QPointF(m_cp_rect.x1, m_cp_rect.y1), QPointF(m_cp_rect.x2, m_cp_rect.y2)); |
93 } |
107 } |
|
108 |
|
109 |
|
110 QVectorPath::CacheEntry *QVectorPath::addCacheData(QPaintEngineEx *engine, void *data, |
|
111 qvectorpath_cache_cleanup cleanup) const{ |
|
112 Q_ASSERT(!lookupCacheData(engine)); |
|
113 if ((m_hints & IsCachedHint) == 0) { |
|
114 m_cache = 0; |
|
115 m_hints |= IsCachedHint; |
|
116 } |
|
117 CacheEntry *e = new CacheEntry; |
|
118 e->engine = engine; |
|
119 e->data = data; |
|
120 e->cleanup = cleanup; |
|
121 e->next = m_cache; |
|
122 m_cache = e; |
|
123 return m_cache; |
|
124 } |
|
125 |
94 |
126 |
95 const QVectorPath &qtVectorPathForPath(const QPainterPath &path) |
127 const QVectorPath &qtVectorPathForPath(const QPainterPath &path) |
96 { |
128 { |
97 Q_ASSERT(path.d_func()); |
129 Q_ASSERT(path.d_func()); |
98 return path.d_func()->vectorPath(); |
130 return path.d_func()->vectorPath(); |
411 d->strokeHandler->types.reset(); |
443 d->strokeHandler->types.reset(); |
412 d->strokeHandler->pts.reset(); |
444 d->strokeHandler->pts.reset(); |
413 |
445 |
414 // Some engines might decide to optimize for the non-shape hint later on... |
446 // Some engines might decide to optimize for the non-shape hint later on... |
415 uint flags = QVectorPath::WindingFill; |
447 uint flags = QVectorPath::WindingFill; |
|
448 |
|
449 if (path.elementCount() > 2) |
|
450 flags |= QVectorPath::NonConvexShapeMask; |
|
451 |
416 if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin) |
452 if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin) |
417 flags |= QVectorPath::CurvedShapeHint; |
453 flags |= QVectorPath::CurvedShapeMask; |
418 |
454 |
419 // ### Perspective Xforms are currently not supported... |
455 // ### Perspective Xforms are currently not supported... |
420 if (!pen.isCosmetic()) { |
456 if (!pen.isCosmetic()) { |
421 // We include cosmetic pens in this case to avoid having to |
457 // We include cosmetic pens in this case to avoid having to |
422 // change the current transform. Normal transformed, |
458 // change the current transform. Normal transformed, |
440 d->activeStroker->cubicTo(points[0], points[1], |
476 d->activeStroker->cubicTo(points[0], points[1], |
441 points[2], points[3], |
477 points[2], points[3], |
442 points[4], points[5]); |
478 points[4], points[5]); |
443 points += 6; |
479 points += 6; |
444 types += 3; |
480 types += 3; |
445 flags |= QVectorPath::CurvedShapeHint; |
481 flags |= QVectorPath::CurvedShapeMask; |
446 break; |
482 break; |
447 default: |
483 default: |
448 break; |
484 break; |
449 } |
485 } |
450 } |
486 } |
502 QPointF c2 = ((QPointF *) points)[1] * state()->matrix; |
538 QPointF c2 = ((QPointF *) points)[1] * state()->matrix; |
503 QPointF e = ((QPointF *) points)[2] * state()->matrix; |
539 QPointF e = ((QPointF *) points)[2] * state()->matrix; |
504 d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y()); |
540 d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y()); |
505 points += 6; |
541 points += 6; |
506 types += 3; |
542 types += 3; |
507 flags |= QVectorPath::CurvedShapeHint; |
543 flags |= QVectorPath::CurvedShapeMask; |
508 break; |
544 break; |
509 } |
545 } |
510 default: |
546 default: |
511 break; |
547 break; |
512 } |
548 } |
578 clip(vp, op); |
614 clip(vp, op); |
579 } |
615 } |
580 |
616 |
581 void QPaintEngineEx::clip(const QRegion ®ion, Qt::ClipOperation op) |
617 void QPaintEngineEx::clip(const QRegion ®ion, Qt::ClipOperation op) |
582 { |
618 { |
583 if (region.numRects() == 1) |
619 if (region.rectCount() == 1) |
584 clip(region.boundingRect(), op); |
620 clip(region.boundingRect(), op); |
585 |
621 |
586 QVector<QRect> rects = region.rects(); |
622 QVector<QRect> rects = region.rects(); |
587 if (rects.size() <= 32) { |
623 if (rects.size() <= 32) { |
588 qreal pts[2*32*4]; |
624 qreal pts[2*32*4]; |
734 x1, y1 + KAPPA * yRadius, // CurveTo |
770 x1, y1 + KAPPA * yRadius, // CurveTo |
735 x1 + (1 - KAPPA) * xRadius, y1, |
771 x1 + (1 - KAPPA) * xRadius, y1, |
736 x1 + xRadius, y1 |
772 x1 + xRadius, y1 |
737 }; |
773 }; |
738 |
774 |
739 QVectorPath path(pts, 17, qpaintengineex_roundedrect_types); |
775 QVectorPath path(pts, 17, qpaintengineex_roundedrect_types, QVectorPath::RoundedRectHint); |
740 draw(path); |
776 draw(path); |
741 } |
777 } |
742 |
778 |
743 |
779 |
744 |
780 |
825 pts[++oset] = points[i].x(); |
861 pts[++oset] = points[i].x(); |
826 pts[++oset] = points[i].y(); |
862 pts[++oset] = points[i].y(); |
827 pts[++oset] = points[i].x() + 0.001; |
863 pts[++oset] = points[i].x() + 0.001; |
828 pts[++oset] = points[i].y(); |
864 pts[++oset] = points[i].y(); |
829 } |
865 } |
830 QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::NonCurvedShapeHint); |
866 QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint); |
831 stroke(path, pen); |
867 stroke(path, pen); |
832 pointCount -= 16; |
868 pointCount -= 16; |
833 points += 16; |
869 points += 16; |
834 } |
870 } |
835 } else { |
871 } else { |
856 pts[++oset] = points[i].x(); |
892 pts[++oset] = points[i].x(); |
857 pts[++oset] = points[i].y(); |
893 pts[++oset] = points[i].y(); |
858 pts[++oset] = points[i].x() + 0.001; |
894 pts[++oset] = points[i].x() + 0.001; |
859 pts[++oset] = points[i].y(); |
895 pts[++oset] = points[i].y(); |
860 } |
896 } |
861 QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::NonCurvedShapeHint); |
897 QVectorPath path(pts, count * 2, qpaintengineex_line_types_16, QVectorPath::LinesHint); |
862 stroke(path, pen); |
898 stroke(path, pen); |
863 pointCount -= 16; |
899 pointCount -= 16; |
864 points += 16; |
900 points += 16; |
865 } |
901 } |
866 } else { |
902 } else { |