summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpathclipper
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:18:55 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:18:55 (GMT)
commite5fcad302d86d316390c6b0f62759a067313e8a9 (patch)
treec2afbf6f1066b6ce261f14341cf6d310e5595bc1 /tests/auto/qpathclipper
downloadQt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz
Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2
Long live Qt 4.5!
Diffstat (limited to 'tests/auto/qpathclipper')
-rw-r--r--tests/auto/qpathclipper/.gitignore1
-rw-r--r--tests/auto/qpathclipper/paths.cpp734
-rw-r--r--tests/auto/qpathclipper/paths.h95
-rw-r--r--tests/auto/qpathclipper/qpathclipper.pro8
-rw-r--r--tests/auto/qpathclipper/tst_qpathclipper.cpp1403
5 files changed, 2241 insertions, 0 deletions
diff --git a/tests/auto/qpathclipper/.gitignore b/tests/auto/qpathclipper/.gitignore
new file mode 100644
index 0000000..a689eef
--- /dev/null
+++ b/tests/auto/qpathclipper/.gitignore
@@ -0,0 +1 @@
+tst_qpathclipper
diff --git a/tests/auto/qpathclipper/paths.cpp b/tests/auto/qpathclipper/paths.cpp
new file mode 100644
index 0000000..b92b72d
--- /dev/null
+++ b/tests/auto/qpathclipper/paths.cpp
@@ -0,0 +1,734 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "paths.h"
+
+QPainterPath Paths::rect()
+{
+ QPainterPath path;
+
+ path.moveTo(45.885571, 62.857143);
+ path.lineTo(154.11442, 62.857143);
+ path.cubicTo(162.1236, 62.857143,
+ 168.57142, 70.260744,
+ 168.57142, 79.457144);
+ path.lineTo(168.57142, 123.4);
+ path.cubicTo(168.57142, 132.5964,
+ 162.1236, 140,
+ 154.11442, 140);
+ path.lineTo(45.885571, 140);
+ path.cubicTo(37.876394, 140,
+ 31.428572, 132.5964,
+ 31.428572, 123.4);
+ path.lineTo(31.428572, 79.457144);
+ path.cubicTo(31.428572,70.260744,
+ 37.876394,62.857143,
+ 45.885571,62.857143);
+ path.closeSubpath();
+ return path;
+}
+
+QPainterPath Paths::rect6()
+{
+ QPainterPath path;
+
+ path.moveTo(45.885571, 62.857143);
+ path.lineTo(154.11442, 62.857143);
+ path.cubicTo(162.1236, 62.857143,
+ 168.57142, 70.260744,
+ 168.57142, 79.457144);
+ path.lineTo(168.57142, 123.4);
+ path.cubicTo(168.57142, 132.5964,
+ 162.1236, 140,
+ 154.11442, 140);
+ path.lineTo(45.885571, 140);
+ path.closeSubpath();
+ return path;
+}
+
+
+QPainterPath Paths::heart()
+{
+ QPainterPath path;
+ path.moveTo(263.41570, 235.14588);
+ path.cubicTo(197.17570,235.14588,
+ 143.41575,288.90587,
+ 143.41575,355.14588);
+ path.cubicTo(143.41575, 489.90139,
+ 279.34890, 525.23318,
+ 371.97820, 658.45392);
+ path.cubicTo(459.55244,526.05056,
+ 600.54070,485.59932,
+ 600.54070,355.14588);
+ path.cubicTo(600.54070,288.90588, 546.78080,235.14587, 480.54070,235.14588);
+ path.cubicTo(432.49280,235.14588, 391.13910,263.51631, 371.97820,304.33338);
+ path.cubicTo(352.81740,263.51630, 311.46370,235.14587, 263.41570,235.14588);
+ path.closeSubpath();
+ return path;
+}
+
+
+QPainterPath Paths::body()
+{
+ QPainterPath path;
+ path.moveTo(62.500000,15.531250);
+ path.cubicTo(48.633197,15.531250, 37.374999,26.789445, 37.375000,40.656250);
+ path.cubicTo(37.375000,54.523053, 48.633195,65.781252, 62.500000,65.781250);
+ path.cubicTo(76.366803,65.781250, 87.624998,54.523052, 87.625000,40.656250);
+ path.cubicTo(87.625000,26.789447, 76.366802,15.531250, 62.500000,15.531250);
+ path.closeSubpath();
+ path.moveTo(54.437500,65.812500);
+ path.cubicTo(35.184750,65.812499, 19.687500,81.341002, 19.687500,100.59375);
+ path.lineTo(19.687500,155.68750);
+ path.cubicTo(19.687501,167.50351, 25.539122,177.88308, 34.500000,184.15625);
+ path.lineTo(34.500000,254.03125);
+ path.cubicTo(34.499999,257.03306, 46.990615,259.43748, 62.500000,259.43750);
+ path.cubicTo(78.009381,259.43751, 90.468750,257.03307, 90.468750,254.03125);
+ path.lineTo(90.468750,184.15625);
+ path.cubicTo(99.429633,177.88307, 105.28125,167.50352, 105.28125,155.68750);
+ path.lineTo(105.28125,100.59375);
+ path.cubicTo(105.28125,81.341000, 89.784000,65.812500, 70.531250,65.812500);
+ path.lineTo(54.437500,65.812500);
+ path.closeSubpath();
+
+ return path;
+}
+
+
+QPainterPath Paths::mailbox()
+{
+ QPainterPath path;
+ path.moveTo(355.22951,136.82424);
+ path.lineTo(332.03629,112.56585);
+ path.lineTo(325.71086,57.501867);
+ path.cubicTo(325.71086,57.501867, 410.12308,19.428758, 427.45202,29.094560);
+ path.cubicTo(444.78096,38.760366, 443.62570,54.289660, 443.62570,54.289660);
+ path.lineTo(443.62570,100.11509);
+ path.lineTo(355.22951,136.82424);
+ path.closeSubpath();
+
+ return path;
+}
+
+
+QPainterPath Paths::deer()
+{
+ QPainterPath path;
+
+ path.moveTo(39.88,31.658);
+ path.cubicTo(35.632,31.658, 31.398,31.004, 27.871,32.82);
+ path.cubicTo(25.015,34.29, 19.608,34.158, 16.297,34.158);
+ path.cubicTo(14.722,34.158, 17.755,37.718, 17.709,38.922);
+ path.cubicTo(17.578,42.396, 24.612,43.15, 26.755,44.058);
+ path.cubicTo(30.062,45.46, 28.682,47.701, 28.963,50.574);
+ path.cubicTo(29.715,58.243, 26.887,63.745, 24.182,70.589);
+ path.cubicTo(23.365,72.657, 21.772,75.56, 21.972,77.866);
+ path.cubicTo(22.333,82.029, 15.803,77.207, 13.894,76.535);
+ path.cubicTo(10.977,75.508, 5.507,74.071, 2.424,75.331);
+ path.cubicTo(-1.532,76.947, 0.076,80.491, 2.169,82.806);
+ path.cubicTo(6.17,87.234, 2.703,90.713, 3.895,95.363);
+ path.cubicTo(4.321,97.026, 11.682,104.683, 12.858,103.668);
+ path.cubicTo(16.706,100.347, 11.464,98.692, 10.105,96.164);
+ path.cubicTo(9.487,95.015, 8.616,83.742, 8.866,83.759);
+ path.cubicTo(10.018,83.837, 12.591,85.867, 13.671,86.392);
+ path.cubicTo(16.889,87.954, 20.066,89.63, 22.963,91.741);
+ path.cubicTo(29.156,94.47, 35.543,96.965, 42.102,98.676);
+ path.cubicTo(51.085,101.02, 59.407,102.003, 68.009,106.005);
+ path.cubicTo(72.92,108.289, 72.05,113.282, 75.744,117.004);
+ path.cubicTo(79.422,120.709, 84.733,123.053, 88.978,126.053);
+ path.cubicTo(92.402,128.473, 95.422,132.308, 97.334,135.998);
+ path.cubicTo(99.551,140.279, 99.071,146.004, 99.838,150.674);
+ path.cubicTo(100.369,153.91, 104.378,156.321, 106.302,158.859);
+ path.cubicTo(110.471,164.355, 109.86,155.112, 108.163,154.412);
+ path.cubicTo(104.97,153.094, 103.991,146.625, 103.812,143.439);
+ path.cubicTo(103.525,138.336, 105.568,134.331, 101.918,130.346);
+ path.cubicTo(95.104,122.907, 89.488,114.182, 94.711,103.742);
+ path.cubicTo(96.889,99.388, 91.191,95.497, 96.94,94.368);
+ path.cubicTo(99.551,93.856, 102.49,94.367, 104.326,92.034);
+ path.cubicTo(106.639,89.095, 105.063,85.343, 102.943,82.798);
+ path.cubicTo(102.686,82.417, 102.359,82.121, 101.962,81.909);
+ path.cubicTo(102.331,81.909, 101.923,86.98, 100.981,87.628);
+ path.cubicTo(98.868,89.082, 95.569,91.586, 92.88,91.672);
+ path.cubicTo(90.569,91.745, 86.738,89.184, 85.212,87.658);
+ path.cubicTo(84.092,86.538, 80.176,86.157, 78.598,85.83);
+ path.cubicTo(74.737,85.031, 71.741,84.326, 68.012,82.806);
+ path.cubicTo(63.318,80.893, 58.687,78.672, 54.555,75.71);
+ path.cubicTo(44.573,68.555, 42.755,56.146, 44.022,44.495);
+ path.cubicTo(44.295,41.987, 43.169,38.057, 44.617,35.915);
+ path.cubicTo(44.961,35.406, 46.52,35.553, 47.119,35.024);
+ path.cubicTo(47.882,34.35, 49.574,31.822, 49.878,30.792);
+ path.cubicTo(51.126,26.569, 44.36,32.002, 45.336,31.938);
+ path.cubicTo(43.861,32.036, 47.011,22.934, 47.191,22.574);
+ path.cubicTo(47.555,21.846, 52.489,13.123, 49.511,13.222);
+ path.cubicTo(47.643,13.284, 48.563,18.667, 46.354,18.227);
+ path.cubicTo(43.964,17.751, 40.522,11.396, 41.566,9.011);
+ path.cubicTo(43.4,4.819, 39.743,3.905, 39.214,7.564);
+ path.cubicTo(39.112,8.269, 40.893,13.438, 38.159,12.665);
+ path.cubicTo(35.335,11.866, 35.748,-0.125, 34.38,-8.0352391e-15);
+ path.cubicTo(31.991,0.219, 34.074,10.836, 33.361,12.176);
+ path.cubicTo(33.144,12.584, 29.68,8.66, 29.459,7.718);
+ path.cubicTo(28.48,3.558, 28.031,5.106, 26.87,7.752);
+ path.cubicTo(25.333,11.254, 37.159,17.423, 39.292,18.663);
+ path.cubicTo(40.993,19.651, 42.39,20.504, 42.973,22.48);
+ path.cubicTo(43.482,24.205, 44.098,26.568, 42.926,28.191);
+ path.cubicTo(42.092,29.346, 39.88,29.982, 39.88,31.658);
+ return path;
+}
+
+
+QPainterPath Paths::fire()
+{
+ QPainterPath path;
+
+ path.moveTo(362.83759,116.70426);
+ path.cubicTo(342.56574,131.59686, 300.71403,161.23127, 311.38454,218.12635);
+ path.cubicTo(322.05506,275.02144, 358.53432,301.66527, 328.90674,328.73285);
+ path.cubicTo(299.27916,355.80044, 251.48877,339.59410, 255.46042,288.61972);
+ path.cubicTo(258.22374,253.15368, 278.34141,205.10942, 278.34141,205.10942);
+ path.cubicTo(278.34141,205.10942, 234.02455,233.13427, 219.68939,254.01270);
+ path.cubicTo(205.35424,274.89113, 189.71452,330.07842, 208.58356,373.33974);
+ path.cubicTo(227.45261,416.60109, 316.46286,456.33444, 351.12048,514.32780);
+ path.cubicTo(374.10258,552.78425, 355.05815,613.59741, 310.80422,636.59310);
+ path.cubicTo(256.63287,664.74219, 299.16588,580.49238, 285.22551,523.86186);
+ path.cubicTo(273.46790,476.09839, 265.70022,445.12001, 188.03132,432.51681);
+ path.cubicTo(233.72591,465.34901, 242.16068,495.04075, 241.45928,524.11772);
+ path.cubicTo(240.78648,552.00862, 214.39595,634.57293, 177.39967,596.79021);
+ path.cubicTo(140.72642,559.33737, 214.27071,512.68654, 170.92945,471.62081);
+ path.cubicTo(174.73284,501.40284, 145.30515,514.98828, 131.55318,544.54392);
+ path.cubicTo(118.22673,573.18509, 123.55251,610.30651, 139.07596,645.41379);
+ path.cubicTo(181.14122,740.38745, 266.95518,726.23964, 208.75321,797.88229);
+ path.cubicTo(164.01134,852.95649, 162.90150,907.45084, 205.60384,970.81121);
+ path.cubicTo(240.06795,1021.9479, 371.11663,1060.7652, 432.20697,960.93460);
+ path.cubicTo(501.87852,820.00694, 357.14883,780.33174, 386.29974,732.84721);
+ path.cubicTo(405.70205,701.24238, 472.56601,668.86516, 501.09199,644.21233);
+ path.cubicTo(564.18184,587.55421, 561.84437,497.32621, 522.74229,471.25817);
+ path.cubicTo(530.19030,501.05022, 514.99952,542.79339, 483.67099,551.29691);
+ path.cubicTo(423.41173,567.65308, 458.18351,411.79373, 564.02075,393.61925);
+ path.cubicTo(530.91135,366.44998, 501.31413,367.33484, 454.91711,379.11707);
+ path.cubicTo(397.61736,393.57908, 407.64322,315.40944, 494.34643,262.67861);
+ path.cubicTo(549.19500,229.32101, 499.11573,147.63302, 491.66772,136.46100);
+ path.cubicTo(485.38713,213.93294, 435.43515,233.35601, 409.98053,235.72292);
+ path.cubicTo(375.27049,238.95043, 377.84554,214.33812, 396.75003,178.92950);
+ path.cubicTo(416.21172,142.47722, 448.15395,89.429942, 376.51366,44.060977);
+ path.cubicTo(388.13560,71.270572, 395.93673,94.012962, 362.83759,116.70426);
+ path.closeSubpath();
+ return path;
+}
+
+
+QPainterPath Paths::lips()
+{
+ QPainterPath path;
+
+ path.moveTo(177.02257,176.65905);
+ path.cubicTo(154.11895,176.65905, 136.56711,174.32266, 110.41800,155.61729);
+ path.cubicTo(83.894106,136.64382, 70.456540,123.78263, 44.264608,101.00195);
+ path.cubicTo(36.985036,94.670475, 11.607987,76.421189, 0.62503194,72.562763);
+ path.cubicTo(22.778258,60.937514, 46.738237,46.430325, 55.325084,40.325054);
+ path.cubicTo(79.128700,23.400628, 99.203004,0.53294656, 116.15033,0.61582047);
+ path.cubicTo(129.59137,0.68308215, 144.54744,18.524567, 177.02257,18.524567);
+ path.cubicTo(210.04060,18.524567, 224.45379,0.68308215, 237.89483,0.61582047);
+ path.cubicTo(254.84216,0.53294656, 274.91646,23.400628, 298.72008,40.325054);
+ path.cubicTo(307.30692,46.430325, 331.26690,60.937514, 353.42013,72.562763);
+ path.cubicTo(342.43717,76.421189, 317.06013,94.670475, 309.78055,101.00195);
+ path.cubicTo(283.58862,123.78263, 270.15105,136.64382, 243.62716,155.61729);
+ path.cubicTo(217.47805,174.32266, 199.38332,176.65905, 177.02257,176.65905);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::bezier1()
+{
+ QPainterPath path;
+ path.moveTo(50, 50);
+ path.cubicTo(100, 100,
+ 520, 90,
+ 400,400);
+ return path;
+}
+
+QPainterPath Paths::bezier2()
+{
+ QPainterPath path;
+ path.moveTo(200,200);
+ path.cubicTo(200,125, 500,100, 500,500);
+
+ return path;
+}
+
+QPainterPath Paths::random1()
+{
+ QPainterPath path;
+
+ path.moveTo(65.714286,91.428571);
+ path.lineTo(217.14286, 102.85714);
+ path.cubicTo(219.04762, 106.66666,
+ 220.95238, 110.47619,
+ 222.85714,114.28571);
+ path.cubicTo(231.2679, 131.10723,
+ 214.72525, 138.24185,
+ 211.42857,151.42857);
+ path.cubicTo(207.25902, 168.10676,
+ 213.24674, 175.8441,
+ 217.14286,191.42857);
+ path.cubicTo(221.088, 207.20915,
+ 201.21538,205.71429,
+ 188.57143,205.71429);
+ path.cubicTo(170.18303, 205.71429,
+ 161.42918, 197.50045,
+ 145.71429,185.71429);
+ path.cubicTo(113.93441, 161.87938,
+ 132.73699, 182.37652,
+ 137.14286, 200);
+ path.cubicTo(140.37884, 212.94392,
+ 128.50252, 217.16009,
+ 117.14286, 220);
+ path.cubicTo(98.323209, 224.70491,
+ 91.206108, 205.41767,
+ 82.857143, 194.28571);
+ path.cubicTo(77.307286, 186.8859,
+ 84.541768, 158.97578,
+ 85.714286, 154.28571);
+ path.cubicTo(87.843677, 145.76815,
+ 67.066253, 132.78054,
+ 60 , 125.71429);
+ path.cubicTo(54.074503, 119.78879,
+ 64.646395, 95.700137,
+ 65.714286, 91.428571);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::random2()
+{
+ QPainterPath path;
+
+ path.moveTo(314.28571,160);
+ path.cubicTo(434.28571,125.71429,
+ 505.71429,200,
+ 505.71429,200);
+ path.lineTo(454.28571, 305.71429);
+ path.lineTo(337.14286, 302.85714);
+ path.cubicTo(337.14286, 302.85714,
+ 308.57143, 340,
+ 337.14286, 302.85714);
+ path.cubicTo(365.71429, 265.71429,
+ 200, 420,
+ 300, 291.42857);
+ path.cubicTo(400, 162.85714,
+ 254.28571, 240,
+ 254.28571, 240);
+ path.cubicTo(254.28571,240,
+ 240,71.428571,
+ 288.57143,134.28571);
+ path.cubicTo(337.14286,197.14286,
+ 314.28571,162.85714,
+ 314.28571,160);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::bezier3()
+{
+ QPainterPath path;
+ path.moveTo(295, 217);
+ path.cubicTo(364, 57,
+ 377, 34,
+ 456, 222);
+ return path;
+}
+
+QPainterPath Paths::bezier4()
+{
+ QPainterPath path;
+ path.moveTo(200, 125);
+ path.cubicTo(200, 125,
+ 623, 126,
+ 623, 126);
+ return path;
+}
+
+QPainterPath Paths::heart2()
+{
+ QPainterPath path;
+ path.moveTo(263.41570, 235.14588);
+ path.cubicTo(197.17570,235.14588,
+ 143.41575,288.90587,
+ 143.41575,355.14588);
+ path.cubicTo(143.41575, 489.90139,
+ 279.34890, 525.23318,
+ 371.97820, 658.45392);
+ return path;
+}
+
+QPainterPath Paths::rect2()
+{
+ QPainterPath path;
+
+ path.addRect(80, 80, 100, 100);
+
+ return path;
+}
+
+
+QPainterPath Paths::rect3()
+{
+ QPainterPath path;
+
+ path.addRect(100, 40, 100, 100);
+
+ return path;
+}
+
+
+QPainterPath Paths::rect4()
+{
+ QPainterPath path;
+
+ path.addRect(100, 0, 200, 200);
+
+ path.addRect(120, 20, 80, 80);
+
+ return path;
+}
+
+QPainterPath Paths::simpleCurve()
+{
+ QPainterPath path;
+ path.moveTo(74, 160);
+ path.cubicTo( 74, 160,
+ 274, 406,
+ 425, 166);
+ path.cubicTo(577, -73,
+ 77, 160,
+ 74, 160);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::simpleCurve2()
+{
+ QPainterPath path;
+ path.moveTo(54, 140);
+ path.cubicTo( 54, 140,
+ 254, 386,
+ 405, 146);
+ path.cubicTo(557, -93,
+ 57, 140,
+ 54, 140);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::frame1()
+{
+ QPainterPath path;
+ path.moveTo(190.71429, 40.933613);
+ path.lineTo(683.57141, 40.933613);
+ path.cubicTo(697.42141, 40.933613,
+ 708.57141, 52.083613,
+ 708.57141, 65.933613);
+ path.lineTo(708.57141, 375.93361);
+ path.cubicTo(708.57141, 389.78361,
+ 697.42141, 400.93361,
+ 683.57141, 400.93361);
+ path.lineTo(190.71429, 400.93361);
+ path.cubicTo(176.86429, 400.93361,
+ 165.71429, 389.78361,
+ 165.71429,375.93361);
+ path.lineTo(165.71429, 65.933613);
+ path.cubicTo(165.71429,52.083613,
+ 176.86429,40.933613,
+ 190.71429,40.933613);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::frame2()
+{
+ QPainterPath path;
+ path.moveTo(55.114286, 103.79076);
+ path.lineTo(187.74288, 103.79076);
+ path.cubicTo(192.95048, 103.79076,
+ 197.14288, 107.88102,
+ 197.14288, 112.96176);
+ path.lineTo(197.14288, 131.76261);
+ path.cubicTo(197.14288, 136.84335,
+ 192.95048, 140.93361,
+ 187.74288, 140.93361);
+ path.lineTo(55.114286, 140.93361);
+ path.cubicTo(49.906687, 140.93361,
+ 45.714287, 136.84335,
+ 45.714287, 131.76261);
+ path.lineTo(45.714287, 112.96176);
+ path.cubicTo(45.714287, 107.88102,
+ 49.906687, 103.79076,
+ 55.114286, 103.79076);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::frame3()
+{
+ QPainterPath path;
+ path.moveTo(200,80.933609);
+ path.lineTo(682.85715,80.933609);
+ path.lineTo(682.85715,446.6479);
+ path.lineTo(200,446.6479);
+ path.lineTo(200,80.933609);
+ path.closeSubpath();
+ return path;
+}
+
+QPainterPath Paths::frame4()
+{
+ QPainterPath path;
+
+ path.moveTo(88.571434,206.64789);
+ path.lineTo(231.42858,206.64789);
+ path.lineTo(231.42858,246.64789);
+ path.lineTo(88.571434,246.64789);
+ path.lineTo(88.571434,206.64789);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::simpleCurve3()
+{
+ QPainterPath path;
+
+ path.moveTo(0, 0);
+ path.cubicTo(400,0,
+ 0,400,
+ 0,0);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::rect5()
+{
+ QPainterPath path;
+
+ path.addRect(0, 0, 200, 200);
+
+ return path;
+}
+
+QPainterPath Paths::triangle1()
+{
+ QPainterPath path;
+
+ path.moveTo(0, 0);
+ path.lineTo(60, 0);
+ path.lineTo(60, 60);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::triangle2()
+{
+ QPainterPath path;
+
+ path.moveTo(0, 120);
+ path.lineTo(60, 120);
+ path.lineTo(60, 60);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::node()
+{
+ QRectF m_rect;
+ m_rect.setWidth(150);
+ m_rect.setHeight(100);
+
+ QPainterPath shape;
+ shape.addRoundRect(m_rect, 25);
+
+ const int conWidth = 10;
+ const int xOffset = 7;
+
+ QRectF rect(xOffset,
+ conWidth + 20,
+ conWidth, conWidth);
+ shape.addEllipse(rect);
+ //shape.addRect(rect);
+
+ rect = QRectF(m_rect.right() - conWidth - xOffset,
+ conWidth + 20,
+ conWidth, conWidth);
+ shape.addEllipse(rect);
+ //shape.addRect(rect);
+ return shape;
+}
+
+QPainterPath Paths::interRect()
+{
+ QPainterPath path;
+ path.addRect(132, 42, 1, 1);
+ return path;
+}
+
+QPainterPath Paths::bezierFlower()
+{
+ QPainterPath path;
+ path.moveTo(0, 0);
+ path.cubicTo(0, 50, -25, 75, -50, 100);
+ path.closeSubpath();
+ path.moveTo(0, 0);
+ path.cubicTo(0, 50, 25, 75, 50, 100);
+ path.closeSubpath();
+
+ path.moveTo(0, 0);
+ path.cubicTo(0, -50, -25, -75, -50, -100);
+ path.closeSubpath();
+ path.moveTo(0, 0);
+ path.cubicTo(0, -50, 25, -75, 50, -100);
+ path.closeSubpath();
+
+ path.moveTo(0, 0);
+ path.cubicTo(-50, 0, -75, -25, -100, -50);
+ path.closeSubpath();
+ path.moveTo(0, 0);
+ path.cubicTo(-50, 0, -75, 25, -100, 50);
+ path.closeSubpath();
+
+ path.moveTo(0, 0);
+ path.cubicTo(50, 0, 75, -25, 100, -50);
+ path.closeSubpath();
+ path.moveTo(0, 0);
+ path.cubicTo(50, 0, 75, 25, 100, 50);
+ path.closeSubpath();
+
+ return path;
+}
+
+QPainterPath Paths::clover()
+{
+ QPainterPath path;
+ path.moveTo(50, 50);
+ path.lineTo(100, 25);
+ path.lineTo(100, 75);
+ path.lineTo(0, 25);
+ path.lineTo(0, 75);
+ path.lineTo(50, 50);
+ path.lineTo(75, 0);
+ path.lineTo(25, 0);
+ path.lineTo(75, 100);
+ path.lineTo(25, 100);
+ path.lineTo(50, 50);
+ return path;
+}
+
+QPainterPath Paths::ellipses()
+{
+ QPainterPath path;
+ path.addEllipse(0, 0, 100, 100);
+ path.addEllipse(0, 20, 100, 60);
+ path.addEllipse(0, 40, 100, 20);
+ return path;
+}
+
+QPainterPath Paths::windingFill()
+{
+ QPainterPath path;
+ path.addRect(0, 0, 100, 100);
+ path.addRect(50, 25, 100, 50);
+ path.setFillRule(Qt::WindingFill);
+ return path;
+}
+
+QPainterPath Paths::oddEvenFill()
+{
+ QPainterPath path;
+ path.addRect(0, 0, 100, 100);
+ path.moveTo(50, 25);
+ path.lineTo(50, 75);
+ path.lineTo(150, 75);
+ path.lineTo(150, 25);
+ path.lineTo(50, 25);
+ path.setFillRule(Qt::OddEvenFill);
+ return path;
+}
+
+QPainterPath Paths::squareWithHole()
+{
+ QPainterPath path;
+ path.addRect(0, 0, 100, 100);
+ path.addRect(30, 30, 40, 40);
+ return path;
+}
+
+QPainterPath Paths::circleWithHole()
+{
+ QPainterPath path;
+ path.addEllipse(0, 0, 100, 100);
+ path.addEllipse(30, 30, 40, 40);
+ return path;
+}
+
+QPainterPath Paths::bezierQuadrant()
+{
+ QPainterPath path;
+ int d = 1;
+ for (int i = 25; i <= 85; i += 10) {
+ path.moveTo(50, 100);
+ path.cubicTo(50, i, 50 + i* d / 2, 0, 50 + 50 * d, 0);
+ path.lineTo(50 + 50 * d, 100);
+ path.closeSubpath();
+ }
+
+ QMatrix m(2, 0,
+ 0, 2,
+ 0, 0);
+
+ return path;
+}
diff --git a/tests/auto/qpathclipper/paths.h b/tests/auto/qpathclipper/paths.h
new file mode 100644
index 0000000..6f6c888
--- /dev/null
+++ b/tests/auto/qpathclipper/paths.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef PATHS_H
+#define PATHS_H
+
+#include <QPainterPath>
+
+namespace Paths
+{
+ QPainterPath rect();
+ QPainterPath heart();
+ QPainterPath body();
+ QPainterPath mailbox();
+ QPainterPath deer();
+ QPainterPath fire();
+ QPainterPath lips();
+
+ QPainterPath bezier1();
+ QPainterPath bezier2();
+ QPainterPath bezier3();
+ QPainterPath bezier4();
+
+ QPainterPath random1();
+ QPainterPath random2();
+
+ QPainterPath heart2();
+ QPainterPath rect2();
+ QPainterPath rect3();
+ QPainterPath rect4();
+ QPainterPath rect5();
+ QPainterPath rect6();
+
+ QPainterPath simpleCurve();
+ QPainterPath simpleCurve2();
+ QPainterPath simpleCurve3();
+
+ QPainterPath frame1();
+ QPainterPath frame2();
+ QPainterPath frame3();
+ QPainterPath frame4();
+
+ QPainterPath triangle1();
+ QPainterPath triangle2();
+
+ QPainterPath node();
+ QPainterPath interRect();
+
+ QPainterPath bezierFlower();
+ QPainterPath clover();
+ QPainterPath ellipses();
+ QPainterPath windingFill();
+ QPainterPath oddEvenFill();
+ QPainterPath squareWithHole();
+ QPainterPath circleWithHole();
+ QPainterPath bezierQuadrant();
+}
+#endif
diff --git a/tests/auto/qpathclipper/qpathclipper.pro b/tests/auto/qpathclipper/qpathclipper.pro
new file mode 100644
index 0000000..675e463
--- /dev/null
+++ b/tests/auto/qpathclipper/qpathclipper.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+INCLUDEPATH += .
+HEADERS += paths.h
+SOURCES += tst_qpathclipper.cpp paths.cpp
+
+unix:!mac:LIBS+=-lm
+
+
diff --git a/tests/auto/qpathclipper/tst_qpathclipper.cpp b/tests/auto/qpathclipper/tst_qpathclipper.cpp
new file mode 100644
index 0000000..e25c6f1
--- /dev/null
+++ b/tests/auto/qpathclipper/tst_qpathclipper.cpp
@@ -0,0 +1,1403 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "private/qpathclipper_p.h"
+#include "paths.h"
+
+#include <QtTest/QtTest>
+
+#include <qpainterpath.h>
+#include <qpolygon.h>
+#include <qdebug.h>
+#include <qpainter.h>
+
+#include <math.h>
+
+class tst_QPathClipper : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QPathClipper();
+ virtual ~tst_QPathClipper();
+
+private:
+ void clipTest(int subjectIndex, int clipIndex, QPathClipper::Operation op);
+
+ QList<QPainterPath> paths;
+
+public slots:
+ void initTestCase();
+
+private slots:
+ void testWingedEdge();
+
+ void testComparePaths();
+
+ void clip_data();
+ void clip();
+
+ void clip2();
+ void clip3();
+
+ void testIntersections();
+ void testIntersections2();
+ void testIntersections3();
+ void testIntersections4();
+ void testIntersections5();
+ void testIntersections6();
+ void testIntersections7();
+ void testIntersections8();
+ void testIntersections9();
+
+ void zeroDerivativeCurves();
+
+ void task204301_data();
+ void task204301();
+
+ void task209056();
+};
+
+Q_DECLARE_METATYPE(QPainterPath)
+Q_DECLARE_METATYPE(QPathClipper::Operation)
+
+tst_QPathClipper::tst_QPathClipper()
+{
+}
+
+tst_QPathClipper::~tst_QPathClipper()
+{
+}
+
+void tst_QPathClipper::initTestCase()
+{
+ paths << Paths::rect();
+ paths << Paths::heart();
+ paths << Paths::body();
+ paths << Paths::mailbox();
+ paths << Paths::deer();
+ paths << Paths::fire();
+
+ paths << Paths::random1();
+ paths << Paths::random2();
+
+ paths << Paths::heart2();
+ paths << Paths::rect2();
+ paths << Paths::rect3();
+ paths << Paths::rect4();
+ paths << Paths::rect5();
+ paths << Paths::rect6();
+
+ paths << Paths::frame1();
+ paths << Paths::frame2();
+ paths << Paths::frame3();
+ paths << Paths::frame4();
+
+ paths << Paths::triangle1();
+ paths << Paths::triangle2();
+
+ paths << Paths::node();
+ paths << Paths::interRect();
+
+ paths << Paths::simpleCurve();
+ paths << Paths::simpleCurve2();
+ paths << Paths::simpleCurve3();
+
+ paths << Paths::bezier1();
+ paths << Paths::bezier2();
+ paths << Paths::bezier3();
+ paths << Paths::bezier4();
+
+ paths << Paths::bezierFlower();
+ paths << Paths::lips();
+ paths << Paths::clover();
+ paths << Paths::ellipses();
+ paths << Paths::windingFill();
+ paths << Paths::oddEvenFill();
+ paths << Paths::squareWithHole();
+ paths << Paths::circleWithHole();
+ paths << Paths::bezierQuadrant();
+
+ // make sure all the bounding rects are centered at the origin
+ for (int i = 0; i < paths.size(); ++i) {
+ QRectF bounds = paths[i].boundingRect();
+
+ QMatrix m(1, 0,
+ 0, 1,
+ -bounds.center().x(), -bounds.center().y());
+
+ paths[i] = m.map(paths[i]);
+ }
+}
+
+static QPainterPath samplePath1()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(200, 246.64789));
+ path.lineTo(QPointF(200, 206.64789));
+ path.lineTo(QPointF(231.42858, 206.64789));
+ path.lineTo(QPointF(231.42858, 246.64789));
+ path.lineTo(QPointF(200, 246.64789));
+ return path;
+}
+
+static QPainterPath samplePath2()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(200, 146.64789));
+ path.lineTo(QPointF(200, 106.64789));
+ path.lineTo(QPointF(231.42858, 106.64789));
+ path.lineTo(QPointF(231.42858, 146.64789));
+ path.lineTo(QPointF(200, 146.64789));
+ return path;
+}
+
+static QPainterPath samplePath3()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(231.42858, 80.933609));
+ path.lineTo(QPointF(200, 80.933609));
+ path.lineTo(QPointF(200, 96.64788999999999));
+ path.lineTo(QPointF(231.42858, 96.64788999999999));
+ path.lineTo(QPointF(231.42858, 80.933609));
+ return path;
+}
+
+static QPainterPath samplePath4()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(288.571434, 80.933609));
+ path.lineTo(QPointF(431.42858, 80.933609));
+ path.lineTo(QPointF(431.42858, 96.64788999999999));
+ path.lineTo(QPointF(288.571434, 96.64788999999999));
+ path.lineTo(QPointF(288.571434, 80.933609));
+ return path;
+}
+
+static QPainterPath samplePath5()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(588.571434, 80.933609));
+ path.lineTo(QPointF(682.85715, 80.933609));
+ path.lineTo(QPointF(682.85715, 96.64788999999999));
+ path.lineTo(QPointF(588.571434, 96.64788999999999));
+ path.lineTo(QPointF(588.571434, 80.933609));
+ return path;
+}
+
+static QPainterPath samplePath6()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(588.571434, 80.933609));
+ path.lineTo(QPointF(200, 80.933609));
+ path.lineTo(QPointF(200, 446.6479));
+ path.lineTo(QPointF(682.85715, 446.6479));
+ path.lineTo(QPointF(682.85715, 96.64788999999999));
+ path.lineTo(QPointF(731.42858, 96.64788999999999));
+ path.lineTo(QPointF(731.42858, 56.64788999999999));
+ path.lineTo(QPointF(588.571434, 56.64788999999999));
+ path.lineTo(QPointF(588.571434, 80.933609));
+ return path;
+}
+
+static QPainterPath samplePath7()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(682.85715, 206.64789));
+ path.lineTo(QPointF(682.85715, 246.64789));
+ path.lineTo(QPointF(588.571434, 246.64789));
+ path.lineTo(QPointF(588.571434, 206.64789));
+ path.lineTo(QPointF(682.85715, 206.64789));
+ return path;
+}
+
+static QPainterPath samplePath8()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(682.85715, 406.64789));
+ path.lineTo(QPointF(682.85715, 446.64789));
+ path.lineTo(QPointF(588.571434, 446.64789));
+ path.lineTo(QPointF(588.571434, 406.64789));
+ path.lineTo(QPointF(682.85715, 406.64789));
+ return path;
+}
+
+static QPainterPath samplePath9()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(682.85715, 426.64789));
+ path.lineTo(QPointF(682.85715, 446.6479));
+ path.lineTo(QPointF(568.571434, 446.6479));
+ path.lineTo(QPointF(568.571434, 426.64789));
+ path.lineTo(QPointF(682.85715, 426.64789));
+ return path;
+}
+
+static QPainterPath samplePath10()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(511.42858, 446.6479));
+ path.lineTo(QPointF(368.571434, 446.6479));
+ path.lineTo(QPointF(368.571434, 426.64789));
+ path.lineTo(QPointF(511.42858, 426.64789));
+ path.lineTo(QPointF(511.42858, 446.6479));
+ return path;
+}
+
+static QPainterPath samplePath11()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(165.71429, 338.79076));
+ path.lineTo(QPointF(227.74288, 338.79076));
+ path.cubicTo(QPointF(232.95048, 338.79076),
+ QPointF(237.14288, 342.88102),
+ QPointF(237.14288, 347.96176));
+ path.lineTo(QPointF(237.14288, 366.76261));
+ path.cubicTo(QPointF(237.14288, 371.84335),
+ QPointF(232.95048, 375.93361),
+ QPointF(227.74288, 375.93361));
+ path.lineTo(QPointF(165.7142905131896, 375.93361));
+ path.lineTo(QPointF(165.71429, 338.79076));
+ return path;
+}
+static QPainterPath samplePath12()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(333.297085225735, 61.53486494396167));
+ path.cubicTo(QPointF(339.851755668807, 65.26555884471786),
+ QPointF(346.7164458828328, 69.04482864715078),
+ QPointF(353.4159970843586, 72.56059416636147));
+ path.cubicTo(QPointF(353.4166971116034, 72.56155590850551),
+ QPointF(353.4173961086004, 72.56251809989483),
+ QPointF(353.4180950127331, 72.56348028832946));
+ path.cubicTo(QPointF(342.4340366381152, 76.42344228577481),
+ QPointF(317.0596805768079, 94.67086588954379),
+ QPointF(309.78055, 101.00195));
+ path.cubicTo(QPointF(286.0370715501102, 121.6530659984711),
+ QPointF(272.7748256344584, 134.1525788344904),
+ QPointF(250.7436468364447, 150.4434491585085));
+ path.lineTo(QPointF(247.03629, 146.56585));
+ path.lineTo(QPointF(240.71086, 91.501867));
+ path.cubicTo(QPointF(240.71086, 91.501867),
+ QPointF(305.6382515924416, 62.21715375368672),
+ QPointF(333.297085225735, 61.53486494396167));
+ return path;
+}
+
+static QPainterPath samplePath13()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(160, 200));
+ path.lineTo(QPointF(100, 200));
+ path.lineTo(QPointF(100, 130));
+ path.lineTo(QPointF(160, 130));
+ path.lineTo(QPointF(160, 200));
+ return path;
+}
+
+static QPainterPath samplePath14()
+{
+ QPainterPath path;
+ path.moveTo(QPointF(100, 180));
+ path.lineTo(QPointF(100, 80));
+ path.lineTo(QPointF(120, 80));
+ path.lineTo(QPointF(120, 100));
+ path.lineTo(QPointF(160, 100));
+ path.lineTo(QPointF(160, 180));
+ path.lineTo(QPointF(100, 180));
+ return path;
+}
+
+void tst_QPathClipper::clip_data()
+{
+ //create the testtable instance and define the elements
+ QTest::addColumn<QPainterPath>("subject");
+ QTest::addColumn<QPainterPath>("clip");
+ QTest::addColumn<QPathClipper::Operation>("op");
+ QTest::addColumn<QPainterPath>("result");
+
+ //next we fill it with data
+ QTest::newRow( "simple1" ) << Paths::frame3()
+ << Paths::frame4()
+ << QPathClipper::BoolAnd
+ << samplePath1();
+
+ QTest::newRow( "simple2" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(0, -100)
+ << QPathClipper::BoolAnd
+ << samplePath2();
+
+ QTest::newRow( "simple3" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(0, -150)
+ << QPathClipper::BoolAnd
+ << samplePath3();
+
+ QTest::newRow( "simple4" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(200, -150)
+ << QPathClipper::BoolAnd
+ << samplePath4();
+
+ QTest::newRow( "simple5" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(500, -150)
+ << QPathClipper::BoolAnd
+ << samplePath5();
+
+ QTest::newRow( "simple6" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(500, -150)
+ << QPathClipper::BoolOr
+ << samplePath6();
+
+ QTest::newRow( "simple7" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(500, 0)
+ << QPathClipper::BoolAnd
+ << samplePath7();
+
+ QTest::newRow( "simple8" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(500, 200)
+ << QPathClipper::BoolAnd
+ << samplePath8();
+
+ QTest::newRow( "simple9" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(480, 220)
+ << QPathClipper::BoolAnd
+ << samplePath9();
+
+ QTest::newRow( "simple10" ) << Paths::frame3()
+ << Paths::frame4() * QTransform().translate(280, 220)
+ << QPathClipper::BoolAnd
+ << samplePath10();
+
+ QTest::newRow( "simple11" ) << Paths::frame2()*QTransform().translate(40, 235)
+ << Paths::frame1()
+ << QPathClipper::BoolAnd
+ << samplePath11();
+
+ QTest::newRow( "intersection_at_edge" ) << Paths::lips()
+ << Paths::mailbox()*QTransform().translate(-85, 34)
+ << QPathClipper::BoolAnd
+ << samplePath12();
+
+ QTest::newRow( "simple_move_to1" ) << Paths::rect4()
+ << Paths::rect2() * QTransform().translate(-20, 50)
+ << QPathClipper::BoolAnd
+ << samplePath13();
+
+ QTest::newRow( "simple_move_to2" ) << Paths::rect4()
+ << Paths::rect2() * QTransform().translate(-20, 0)
+ << QPathClipper::BoolAnd
+ << samplePath14();
+}
+
+static const int precision = 8;
+static const qreal epsilon = pow(0.1, precision);
+
+static inline bool fuzzyIsZero(qreal x, qreal relative)
+{
+ if (qAbs(relative) < epsilon)
+ return qAbs(x) < epsilon;
+ else
+ return qAbs(x / relative) < epsilon;
+}
+
+static bool fuzzyCompare(const QPointF &a, const QPointF &b)
+{
+ const QPointF delta = a - b;
+
+ const qreal x = qMax(qAbs(a.x()), qAbs(b.x()));
+ const qreal y = qMax(qAbs(a.y()), qAbs(b.y()));
+
+ return fuzzyIsZero(delta.x(), x) && fuzzyIsZero(delta.y(), y);
+}
+
+static bool isClosed(const QPainterPath &path)
+{
+ if (path.elementCount() == 0)
+ return false;
+
+ QPointF first = path.elementAt(0);
+ QPointF last = path.elementAt(path.elementCount() - 1);
+
+ return fuzzyCompare(first, last);
+}
+
+// rotation and direction independent path comparison
+// allows paths to be shifted or reversed relative to each other
+static bool comparePaths(const QPainterPath &actual, const QPainterPath &expected)
+{
+ const int endActual = isClosed(actual) ? actual.elementCount() - 1 : actual.elementCount();
+ const int endExpected = isClosed(expected) ? expected.elementCount() - 1 : expected.elementCount();
+
+ if (endActual != endExpected)
+ return false;
+
+ for (int i = 0; i < endActual; ++i) {
+ int k = 0;
+ for (k = 0; k < endActual; ++k) {
+ int i1 = k;
+ int i2 = (i + k) % endActual;
+
+ QPointF a = actual.elementAt(i1);
+ QPointF b = expected.elementAt(i2);
+
+ if (!fuzzyCompare(a, b))
+ break;
+ }
+
+ if (k == endActual)
+ return true;
+
+ for (k = 0; k < endActual; ++k) {
+ int i1 = k;
+ int i2 = (i + endActual - k) % endActual;
+
+ QPointF a = actual.elementAt(i1);
+ QPointF b = expected.elementAt(i2);
+
+ if (!fuzzyCompare(a, b))
+ break;
+ }
+
+ if (k == endActual)
+ return true;
+ }
+
+ return false;
+}
+
+// sanity check to make sure comparePaths declared above works
+void tst_QPathClipper::testComparePaths()
+{
+ QPainterPath a;
+ QPainterPath b;
+
+ a.addRect(0, 0, 10, 10);
+ b.addRect(0, 0, 10.00001, 10.00001);
+
+ QVERIFY(!comparePaths(a, b));
+
+ b = QPainterPath();
+ b.addRect(0, 0, 10.00000000001, 10.00000000001);
+
+ QVERIFY(comparePaths(a, b));
+
+ b = QPainterPath();
+ b.moveTo(10, 0);
+ b.lineTo(0, 0);
+ b.lineTo(0, 10);
+ b.lineTo(10, 10);
+
+ QVERIFY(comparePaths(a, b));
+ b.lineTo(10, 0);
+ QVERIFY(comparePaths(a, b));
+
+ b = QPainterPath();
+ b.moveTo(10, 0);
+ b.lineTo(0, 10);
+ b.lineTo(0, 0);
+ b.lineTo(10, 10);
+
+ QVERIFY(!comparePaths(a, b));
+}
+
+void tst_QPathClipper::clip()
+{
+ if (sizeof(double) != sizeof(qreal)) {
+ QSKIP("This test only works for qreal=double, otherwise ends in rounding errors", SkipAll);
+ }
+ QFETCH( QPainterPath, subject );
+ QFETCH( QPainterPath, clip );
+ QFETCH( QPathClipper::Operation, op );
+ QFETCH( QPainterPath, result);
+ QPathClipper clipper(subject, clip);
+ QPainterPath x = clipper.clip(op);
+
+ QVERIFY(comparePaths(x, result));
+}
+
+static inline QPointF randomPointInRect(const QRectF &rect)
+{
+ qreal rx = qrand() / (RAND_MAX + 1.);
+ qreal ry = qrand() / (RAND_MAX + 1.);
+
+ return QPointF(rect.left() + rx * rect.width(),
+ rect.top() + ry * rect.height());
+}
+
+void tst_QPathClipper::clipTest(int subjectIndex, int clipIndex, QPathClipper::Operation op)
+{
+ const QPainterPath &subject = paths[subjectIndex];
+ const QPainterPath &clip = paths[clipIndex];
+ const int count = 40;
+
+ QRectF bounds = subject.boundingRect().united(clip.boundingRect());
+
+ const qreal adjustX = bounds.width() * 0.01;
+ const qreal adjustY = bounds.height() * 0.01;
+
+ // make sure we test some points that are outside both paths as well
+ bounds = bounds.adjusted(-adjustX, -adjustY, adjustX, adjustY);
+
+ const int dim = 256;
+ const qreal scale = qMin(dim / bounds.width(), dim / bounds.height());
+
+ QPathClipper clipper(subject, clip);
+ QPainterPath result = clipper.clip(op);
+
+ // using the image here is a bit of a hacky way to make sure we don't test points that
+ // are too close to the path edges to avoid test fails that are due to numerical errors
+ QImage img(dim, dim, QImage::Format_ARGB32_Premultiplied);
+ img.fill(0x0);
+ QPainter p(&img);
+ p.setRenderHint(QPainter::Antialiasing);
+ p.scale(scale, scale);
+ p.translate(-bounds.topLeft());
+ p.setPen(Qt::black);
+ p.drawPath(subject);
+ p.setPen(Qt::red);
+ p.drawPath(clip);
+ p.end();
+
+ for (int i = 0; i < count; ++i) {
+ QPointF point;
+ QRgb pixel;
+ do {
+ point = randomPointInRect(bounds);
+ const QPointF imagePoint = (point - bounds.topLeft()) * scale;
+
+ pixel = img.pixel(int(imagePoint.x()), int(imagePoint.y()));
+ } while (qAlpha(pixel) > 0);
+
+ const bool inSubject = subject.contains(point);
+ const bool inClip = clip.contains(point);
+
+ const bool inResult = result.contains(point);
+
+ bool expected = false;
+ switch (op) {
+ case QPathClipper::BoolAnd:
+ expected = inSubject && inClip;
+ break;
+ case QPathClipper::BoolOr:
+ expected = inSubject || inClip;
+ break;
+ case QPathClipper::BoolSub:
+ expected = inSubject && !inClip;
+ break;
+ default:
+ break;
+ }
+
+ if (expected != inResult) {
+ char str[256];
+ const char *opStr =
+ op == QPathClipper::BoolAnd ? "and" :
+ op == QPathClipper::BoolOr ? "or" : "sub";
+ sprintf(str, "Expected: %d, actual: %d, subject: %d, clip: %d, op: %s\n",
+ int(expected), int(inResult), subjectIndex, clipIndex, opStr);
+
+ // debugging
+#if 0
+ QRect rect = bounds.toAlignedRect();
+
+ QPainter p(&img);
+ p.scale(scale, scale);
+ p.translate(-bounds.topLeft());
+
+ p.setPen(Qt::NoPen);
+ p.setBrush(QColor(0x700ff00));
+ p.drawPath(result);
+
+ p.setPen(Qt::blue);
+ p.drawPoint(point);
+ p.end();
+
+ char str2[256];
+ sprintf(str2, "fail-%d-%d-%s.png", subjectIndex, clipIndex, opStr);
+ img.save(str2);
+#endif
+ QFAIL(str);
+ }
+ }
+}
+
+void tst_QPathClipper::clip2()
+{
+ if (sizeof(double) != sizeof(qreal))
+ QSKIP("This test only works for qreal=double, otherwise ends in rounding errors", SkipAll);
+
+ int operation = 0;
+
+ for (int i = 0; i < paths.size(); ++i) {
+ for (int j = 0; j <= i; ++j) {
+ QPathClipper::Operation op = QPathClipper::Operation((operation++) % 3);
+ clipTest(i, j, op);
+ }
+ }
+}
+
+void tst_QPathClipper::clip3()
+{
+ int operation = 0;
+
+ // this subset should work correctly for qreal = float
+ for (int i = 0; i < 20; ++i) {
+ for (int j = 0; j <= i; ++j) {
+ QPathClipper::Operation op = QPathClipper::Operation((operation++) % 3);
+ clipTest(i, j, op);
+ }
+ }
+}
+
+void tst_QPathClipper::testIntersections()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+
+ path1.addRect(0, 0, 100, 100);
+ path2.addRect(20, 20, 20, 20);
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+ QVERIFY(path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addEllipse(0, 0, 100, 100);
+ path2.addEllipse(200, 200, 100, 100);
+ QVERIFY(!path1.intersects(path2));
+ QVERIFY(!path2.intersects(path1));
+ QVERIFY(!path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addEllipse(0, 0, 100, 100);
+ path2.addEllipse(50, 50, 100, 100);
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+ QVERIFY(!path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(100, 100, 100, 100);
+ path2.addRect(50, 100, 100, 20);
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+ QVERIFY(!path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(100, 100, 100, 100);
+ path2.addRect(110, 201, 100, 20);
+ QVERIFY(!path1.intersects(path2));
+ QVERIFY(!path2.intersects(path1));
+ QVERIFY(!path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(0, 0, 100, 100);
+ path2.addRect(20, 20, 20, 20);
+ path2.addRect(25, 25, 5, 5);
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+ QVERIFY(path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+}
+
+void tst_QPathClipper::testIntersections2()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+
+ path1.moveTo(-8,-8);
+ path1.lineTo(107,-8);
+ path1.lineTo(107,107);
+ path1.lineTo(-8,107);
+
+ path2.moveTo(0,0);
+ path2.lineTo(100,0);
+ path2.lineTo(100,100);
+ path2.lineTo(0,100);
+ path2.lineTo(0,0);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+ QVERIFY(path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+
+ path1.closeSubpath();
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+ QVERIFY(path1.contains(path2));
+ QVERIFY(!path2.contains(path1));
+}
+
+void tst_QPathClipper::testIntersections3()
+{
+ QPainterPath path1 = Paths::node();
+ QPainterPath path2 = Paths::interRect();
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+}
+
+void tst_QPathClipper::testIntersections4()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+
+ path1.moveTo(-5, 0);
+ path1.lineTo(5, 0);
+
+ path2.moveTo(0, -5);
+ path2.lineTo(0, 5);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+}
+
+void tst_QPathClipper::testIntersections5()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+
+ path1.addRect(0, 0, 4, 4);
+ path1.addRect(2, 1, 1, 1);
+ path2.addRect(0.5, 2, 1, 1);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+}
+
+void tst_QPathClipper::testIntersections6()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+
+ path1.moveTo(QPointF(-115.567, -98.3254));
+ path1.lineTo(QPointF(-45.9007, -98.3254));
+ path1.lineTo(QPointF(-45.9007, -28.6588));
+ path1.lineTo(QPointF(-115.567, -28.6588));
+
+ path2.moveTo(QPointF(-110, -110));
+ path2.lineTo(QPointF(110, -110));
+ path2.lineTo(QPointF(110, 110));
+ path2.lineTo(QPointF(-110, 110));
+ path2.lineTo(QPointF(-110, -110));
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+}
+
+
+void tst_QPathClipper::testIntersections7()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+
+ path1.addRect(0, 0, 10, 10);
+ path2.addRect(5, 0, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(0, 0, 10, 10);
+ path2.addRect(0, 5, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(0, 0, 10, 10);
+ path2.addRect(0, 0, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ ///
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 10, 10);
+ path2.addRect(5, 1, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 10, 10);
+ path2.addRect(1, 5, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 10, 10);
+ path2.addRect(1, 1, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 10, 10);
+ path2.addRect(5, 5, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 10, 10);
+ path2.addRect(9, 9, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 10, 10);
+ path2.addRect(10, 10, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 9, 9);
+ path2.addRect(11, 11, 10, 10);
+
+ QVERIFY(!path1.intersects(path2));
+ QVERIFY(!path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(1, 1, 10, 10);
+ path2.addRect(12, 12, 10, 10);
+
+ QVERIFY(!path1.intersects(path2));
+ QVERIFY(!path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(11, 11, 10, 10);
+ path2.addRect(12, 12, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();
+ path2 = QPainterPath();
+ path1.addRect(11, 11, 10, 10);
+ path2.addRect(10, 10, 10, 10);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+}
+
+
+void tst_QPathClipper::testIntersections8()
+{
+ QPainterPath path1 = Paths::node() * QTransform().translate(100, 50);
+ QPainterPath path2 = Paths::node() * QTransform().translate(150, 50);;
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = Paths::node();
+ path2 = Paths::node();
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = Paths::node();
+ path2 = Paths::node() * QTransform().translate(0, 30);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = Paths::node();
+ path2 = Paths::node() * QTransform().translate(30, 0);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = Paths::node();
+ path2 = Paths::node() * QTransform().translate(30, 30);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = Paths::node();
+ path2 = Paths::node() * QTransform().translate(1, 1);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+}
+
+
+void tst_QPathClipper::testIntersections9()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+
+ path1.addRect(QRectF(-1,143, 146, 106));
+ path2.addRect(QRectF(-9,145, 150, 100));
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();;
+ path2 = QPainterPath();
+
+ path1.addRect(QRectF(-1,191, 136, 106));
+ path2.addRect(QRectF(-19,194, 150, 100));
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+
+ path1 = QPainterPath();;
+ path2 = QPainterPath();
+
+ path1.moveTo(-1 , 143);
+ path1.lineTo(148 , 143);
+ path1.lineTo(148 , 250);
+ path1.lineTo(-1 , 250);
+
+ path2.moveTo(-5 , 146);
+ path2.lineTo(145 , 146);
+ path2.lineTo(145 , 246);
+ path2.lineTo(-5 , 246);
+ path2.lineTo(-5 , 146);
+
+ QVERIFY(path1.intersects(path2));
+ QVERIFY(path2.intersects(path1));
+}
+
+QPainterPath pathFromRect(qreal x, qreal y, qreal w, qreal h)
+{
+ QPainterPath path;
+ path.addRect(QRectF(x, y, w, h));
+ return path;
+}
+
+QPainterPath pathFromLine(qreal x1, qreal y1, qreal x2, qreal y2)
+{
+ QPainterPath path;
+ path.moveTo(x1, y1);
+ path.lineTo(x2, y2);
+ return path;
+}
+
+static int loopLength(const QWingedEdge &list, QWingedEdge::TraversalStatus status)
+{
+ int start = status.edge;
+
+ int length = 0;
+ do {
+ ++length;
+ status = list.next(status);
+ } while (status.edge != start);
+
+ return length;
+}
+
+void tst_QPathClipper::testWingedEdge()
+{
+ {
+ QWingedEdge list;
+ int e1 = list.addEdge(QPointF(0, 0), QPointF(10, 0));
+ int e2 = list.addEdge(QPointF(0, 0), QPointF(0, 10));
+ int e3 = list.addEdge(QPointF(0, 0), QPointF(-10, 0));
+ int e4 = list.addEdge(QPointF(0, 0), QPointF(0, -10));
+
+ QCOMPARE(list.edgeCount(), 4);
+ QCOMPARE(list.vertexCount(), 5);
+
+ QWingedEdge::TraversalStatus status = { e1, QPathEdge::RightTraversal, QPathEdge::Forward };
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e1);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e4);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e4);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e3);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e3);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e2);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e2);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e1);
+ }
+ {
+ QWingedEdge list;
+ int e1 = list.addEdge(QPointF(5, 0), QPointF(5, 10));
+ int e2 = list.addEdge(QPointF(5, 0), QPointF(10, 5));
+ int e3 = list.addEdge(QPointF(10, 5), QPointF(5, 10));
+ int e4 = list.addEdge(QPointF(5, 0), QPointF(0, 5));
+ int e5 = list.addEdge(QPointF(0, 5), QPointF(5, 10));
+
+ QCOMPARE(list.edgeCount(), 5);
+ QCOMPARE(list.vertexCount(), 4);
+
+ QWingedEdge::TraversalStatus status = { e1, QPathEdge::RightTraversal, QPathEdge::Forward };
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e5);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e4);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e1);
+
+ QCOMPARE(loopLength(list, status), 3);
+
+ status.flip();
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(loopLength(list, status), 3);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e2);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e3);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e1);
+
+ status = list.next(status);
+ status.flip();
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e2);
+ QCOMPARE(loopLength(list, status), 4);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e4);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Forward);
+ QCOMPARE(status.traversal, QPathEdge::RightTraversal);
+ QCOMPARE(status.edge, e5);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e3);
+
+ status = list.next(status);
+ QCOMPARE(status.direction, QPathEdge::Backward);
+ QCOMPARE(status.traversal, QPathEdge::LeftTraversal);
+ QCOMPARE(status.edge, e2);
+ }
+ {
+ QPainterPath path = pathFromRect(0, 0, 20, 20);
+ QWingedEdge list(path, QPainterPath());
+
+ QCOMPARE(list.edgeCount(), 4);
+ QCOMPARE(list.vertexCount(), 4);
+
+ QWingedEdge::TraversalStatus status = { 0, QPathEdge::RightTraversal, QPathEdge::Forward };
+
+ QPathEdge *edge = list.edge(status.edge);
+ QCOMPARE(QPointF(*list.vertex(edge->first)), QPointF(0, 0));
+ QCOMPARE(QPointF(*list.vertex(edge->second)), QPointF(20, 0));
+
+ status = list.next(status);
+ QCOMPARE(status.edge, 1);
+
+ status = list.next(status);
+ QCOMPARE(status.edge, 2);
+
+ status = list.next(status);
+ QCOMPARE(status.edge, 3);
+
+ status = list.next(status);
+ QCOMPARE(status.edge, 0);
+
+ status.flipDirection();
+ status = list.next(status);
+ QCOMPARE(status.edge, 3);
+
+ status = list.next(status);
+ QCOMPARE(status.edge, 2);
+
+ status = list.next(status);
+ QCOMPARE(status.edge, 1);
+
+ status = list.next(status);
+ QCOMPARE(status.edge, 0);
+
+ QWingedEdge list2(path, pathFromRect(10, 5, 20, 10));
+
+ QCOMPARE(list2.edgeCount(), 12);
+ QCOMPARE(list2.vertexCount(), 10);
+
+ status.flipDirection();
+ QCOMPARE(loopLength(list2, status), 8);
+
+ status = list2.next(status);
+ edge = list2.edge(status.edge);
+ QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(20, 0));
+ QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(20, 5));
+
+ status = list2.next(status);
+ status.flipTraversal();
+
+ edge = list2.edge(status.edge);
+ QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(10, 5));
+ QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(20, 5));
+
+ QCOMPARE(loopLength(list2, status), 4);
+
+ status.flipDirection();
+ status = list2.next(status);
+ status.flipTraversal();
+
+ edge = list2.edge(status.edge);
+ QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(20, 5));
+ QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(20, 15));
+
+ QCOMPARE(loopLength(list2, status), 4);
+ status = list2.next(status);
+ status = list2.next(status);
+
+ edge = list2.edge(status.edge);
+ QCOMPARE(QPointF(*list2.vertex(edge->first)), QPointF(30, 5));
+ QCOMPARE(QPointF(*list2.vertex(edge->second)), QPointF(30, 15));
+ }
+}
+
+void tst_QPathClipper::zeroDerivativeCurves()
+{
+ // zero derivative at end
+ {
+ QPainterPath a;
+ a.cubicTo(100, 0, 100, 100, 100, 100);
+ a.lineTo(100, 200);
+ a.lineTo(0, 200);
+
+ QPainterPath b;
+ b.moveTo(50, 100);
+ b.lineTo(150, 100);
+ b.lineTo(150, 150);
+ b.lineTo(50, 150);
+
+ QPainterPath c = a.united(b);
+ QVERIFY(c.contains(QPointF(25, 125)));
+ QVERIFY(c.contains(QPointF(75, 125)));
+ QVERIFY(c.contains(QPointF(125, 125)));
+ }
+
+ // zero derivative at start
+ {
+ QPainterPath a;
+ a.cubicTo(100, 0, 100, 100, 100, 100);
+ a.lineTo(100, 200);
+ a.lineTo(0, 200);
+
+ QPainterPath b;
+ b.moveTo(50, 100);
+ b.lineTo(150, 100);
+ b.lineTo(150, 150);
+ b.lineTo(50, 150);
+
+ QPainterPath c = a.united(b);
+ QVERIFY(c.contains(QPointF(25, 125)));
+ QVERIFY(c.contains(QPointF(75, 125)));
+ QVERIFY(c.contains(QPointF(125, 125)));
+ }
+}
+
+static bool strictContains(const QPainterPath &a, const QPainterPath &b)
+{
+ return b.subtracted(a) == QPainterPath();
+}
+
+Q_DECLARE_METATYPE(QPolygonF)
+
+void tst_QPathClipper::task204301_data()
+{
+ QTest::addColumn<QPolygonF>("points");
+
+ {
+ QPointF a(51.09013255685567855835, 31.30814891308546066284);
+ QPointF b(98.39898971840739250183, 11.02079074829816818237);
+ QPointF c(91.23911846894770860672, 45.86981737054884433746);
+ QPointF d(66.58616356085985898972, 63.10526528395712375641);
+ QPointF e(82.08219456479714892794, 94.90238165489137145414);
+ QPointF f(16.09013040543221251255, 105.66263409332729850121);
+ QPointF g(10.62811442650854587555, 65.09154842235147953033);
+ QPointF h(5.16609844751656055450, 24.52046275138854980469);
+ QPolygonF v;
+ v << a << b << c << d << e << f << g << h;
+ QTest::newRow("failed_on_linux") << v;
+ }
+
+ {
+ QPointF a(50.014648437500000, 24.392089843750000);
+ QPointF b(92.836303710937500, 5.548706054687500);
+ QPointF c(92.145690917968750, 54.390258789062500);
+ QPointF d(65.402221679687500, 74.345092773437500);
+ QPointF e(80.789794921787347, 124.298095703129690);
+ QPointF f(34.961242675812954, 87.621459960852135);
+ QPointF g(18.305969238281250, 57.426757812500000);
+ QPointF h(1.650695800781250, 27.232055664062500);
+ QPolygonF v;
+ v << a << b << c << d << e << f << g << h;
+ QTest::newRow("failed_on_windows") << v;
+ }
+}
+
+void tst_QPathClipper::task204301()
+{
+ QFETCH(QPolygonF, points);
+
+ QPointF a = points[0];
+ QPointF b = points[1];
+ QPointF c = points[2];
+ QPointF d = points[3];
+ QPointF e = points[4];
+ QPointF f = points[5];
+ QPointF g = points[6];
+ QPointF h = points[7];
+
+ QPainterPath subA;
+ subA.addPolygon(QPolygonF() << a << b << c << d);
+ subA.closeSubpath();
+
+ QPainterPath subB;
+ subB.addPolygon(QPolygonF() << f << e << d << g);
+ subB.closeSubpath();
+
+ QPainterPath subC;
+ subC.addPolygon(QPolygonF() << h << a << d << g);
+ subC.closeSubpath();
+
+ QPainterPath path;
+ path.addPath(subA);
+ path.addPath(subB);
+ path.addPath(subC);
+
+ QPainterPath simplified = path.simplified();
+
+ QVERIFY(strictContains(simplified, subA));
+ QVERIFY(strictContains(simplified, subB));
+ QVERIFY(strictContains(simplified, subC));
+}
+
+void tst_QPathClipper::task209056()
+{
+ QPainterPath p1;
+ p1.moveTo( QPointF(188.506, 287.793) );
+ p1.lineTo( QPointF(288.506, 287.793) );
+ p1.lineTo( QPointF(288.506, 387.793) );
+ p1.lineTo( QPointF(188.506, 387.793) );
+ p1.lineTo( QPointF(188.506, 287.793) );
+
+ QPainterPath p2;
+ p2.moveTo( QPointF(419.447, 164.383) );
+ p2.cubicTo( QPointF(419.447, 69.5486), QPointF(419.447, 259.218),QPointF(419.447, 164.383) );
+
+ p2.cubicTo( QPointF(48.9378, 259.218), QPointF(131.879, 336.097),QPointF(234.192, 336.097) );
+ p2.cubicTo( QPointF(336.506, 336.097), QPointF(419.447, 259.218),QPointF(419.447, 164.383) );
+
+ QPainterPath p3 = p1.intersected(p2);
+
+ QVERIFY(p3 != QPainterPath());
+}
+
+QTEST_APPLESS_MAIN(tst_QPathClipper)
+
+
+#include "tst_qpathclipper.moc"