Changeset 561 for trunk/src/gui/painting/qstroker.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/painting/qstroker.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 453 453 454 454 if (join == FlatJoin) { 455 QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y), 456 qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y)); 457 QPointF isect; 458 QLineF::IntersectType type = prevLine.intersect(nextLine, &isect); 459 QLineF shortCut(prevLine.p2(), nextLine.p1()); 460 qreal angle = shortCut.angleTo(prevLine); 461 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { 462 emitLineTo(focal_x, focal_y); 463 emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); 464 return; 465 } 455 466 emitLineTo(qt_real_to_fixed(nextLine.x1()), 456 467 qt_real_to_fixed(nextLine.y1())); … … 469 480 QLineF shortCut(prevLine.p2(), nextLine.p1()); 470 481 qreal angle = shortCut.angleTo(prevLine); 471 472 482 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { 483 emitLineTo(focal_x, focal_y); 473 484 emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); 474 485 return; … … 510 521 511 522 QLineF shortCut(prevLine.p2(), nextLine.p1()); 512 qreal angle = prevLine.angle(shortCut);523 qreal angle = shortCut.angleTo(prevLine); 513 524 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { 525 emitLineTo(focal_x, focal_y); 514 526 emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); 515 527 return; … … 582 594 qt_real_to_fixed(l1.y1())); 583 595 } else if (join == SvgMiterJoin) { 596 QLineF shortCut(prevLine.p2(), nextLine.p1()); 597 qreal angle = shortCut.angleTo(prevLine); 598 if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) { 599 emitLineTo(focal_x, focal_y); 600 emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); 601 return; 602 } 584 603 QLineF miterLine(QPointF(qt_fixed_to_real(focal_x), 585 604 qt_fixed_to_real(focal_y)), isect); … … 764 783 qreal qt_t_for_arc_angle(qreal angle) 765 784 { 766 if (qFuzzy Compare(angle + 1, qreal(1)))785 if (qFuzzyIsNull(angle)) 767 786 return 0; 768 787 … … 892 911 } 893 912 894 int startSegment = int( floor(startAngle / 90));895 int endSegment = int( floor((startAngle + sweepLength) / 90));913 int startSegment = int(qFloor(startAngle / 90)); 914 int endSegment = int(qFloor((startAngle + sweepLength) / 90)); 896 915 897 916 qreal startT = (startAngle - startSegment * 90) / 90; … … 905 924 906 925 // avoid empty start segment 907 if (qFuzzy Compare(startT,qreal(1))) {926 if (qFuzzyIsNull(startT - qreal(1))) { 908 927 startT = 0; 909 928 startSegment += delta; … … 911 930 912 931 // avoid empty end segment 913 if (qFuzzy Compare(endT + 1, qreal(1))) {932 if (qFuzzyIsNull(endT)) { 914 933 endT = 1; 915 934 endSegment -= delta; … … 919 938 endT = qt_t_for_arc_angle(endT * 90); 920 939 921 const bool splitAtStart = !qFuzzy Compare(startT + 1, qreal(1));922 const bool splitAtEnd = !qFuzzy Compare(endT,qreal(1));940 const bool splitAtStart = !qFuzzyIsNull(startT); 941 const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1)); 923 942 924 943 const int end = endSegment + delta; … … 970 989 971 990 991 static inline void qdashstroker_moveTo(qfixed x, qfixed y, void *data) { 992 ((QStroker *) data)->moveTo(x, y); 993 } 994 995 static inline void qdashstroker_lineTo(qfixed x, qfixed y, void *data) { 996 ((QStroker *) data)->lineTo(x, y); 997 } 998 999 static inline void qdashstroker_cubicTo(qfixed, qfixed, qfixed, qfixed, qfixed, qfixed, void *) { 1000 Q_ASSERT(0); 1001 // ((QStroker *) data)->cubicTo(c1x, c1y, c2x, c2y, ex, ey); 1002 } 1003 1004 972 1005 /******************************************************************************* 973 1006 * QDashStroker members 974 1007 */ 975 1008 QDashStroker::QDashStroker(QStroker *stroker) 976 : m_stroker(stroker), m_dashOffset(0) 977 { 978 1009 : m_stroker(stroker), m_dashOffset(0), m_stroke_width(1), m_miter_limit(1) 1010 { 1011 if (m_stroker) { 1012 setMoveToHook(qdashstroker_moveTo); 1013 setLineToHook(qdashstroker_lineTo); 1014 setCubicToHook(qdashstroker_cubicTo); 1015 } 979 1016 } 980 1017 … … 1013 1050 qfixed dashes[32]; 1014 1051 1052 if (m_stroker) { 1053 m_customData = m_stroker; 1054 m_stroke_width = m_stroker->strokeWidth(); 1055 m_miter_limit = m_stroker->miterLimit(); 1056 } 1057 1058 qreal longestLength = 0; 1015 1059 qreal sumLength = 0; 1016 1060 for (int i=0; i<dashCount; ++i) { 1017 dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroke r->strokeWidth();1061 dashes[i] = qMax(m_dashPattern.at(i), qreal(0)) * m_stroke_width; 1018 1062 sumLength += dashes[i]; 1019 } 1020 1021 if (qFuzzyCompare(sumLength + 1, qreal(1))) 1063 if (dashes[i] > longestLength) 1064 longestLength = dashes[i]; 1065 } 1066 1067 if (qFuzzyIsNull(sumLength)) 1022 1068 return; 1023 1069 … … 1029 1075 qreal pos = 0; // The position on the curve, 0 <= pos <= path.length 1030 1076 qreal elen = 0; // element length 1031 qreal doffset = m_dashOffset * m_stroke r->strokeWidth();1077 qreal doffset = m_dashOffset * m_stroke_width; 1032 1078 1033 1079 // make sure doffset is in range [0..sumLength) … … 1054 1100 1055 1101 // Pad to avoid clipping the borders of thick pens. 1056 qfixed padding = q Max(m_stroker->strokeWidth(), m_stroker->miterLimit());1102 qfixed padding = qt_real_to_fixed(qMax(m_stroke_width, m_miter_limit) * longestLength); 1057 1103 qfixed2d clip_tl = { qt_real_to_fixed(m_clip_rect.left()) - padding, 1058 1104 qt_real_to_fixed(m_clip_rect.top()) - padding }; … … 1106 1152 // new subpath. 1107 1153 if (!has_offset || !hasMoveTo) { 1108 m_stroker->moveTo(move_to_pos.x, move_to_pos.y);1154 emitMoveTo(move_to_pos.x, move_to_pos.y); 1109 1155 hasMoveTo = true; 1110 1156 } … … 1118 1164 && line_to_pos.y > clip_tl.y && line_to_pos.y < clip_br.y)) 1119 1165 { 1120 m_stroker->lineTo(line_to_pos.x, line_to_pos.y);1166 emitLineTo(line_to_pos.x, line_to_pos.y); 1121 1167 } 1122 1168 } else { … … 1132 1178 prev = e; 1133 1179 } 1180 1134 1181 } 1135 1182
Note:
See TracChangeset
for help on using the changeset viewer.