summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtessellator
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:34:13 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:34:13 (GMT)
commit67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch)
tree1dbf50b3dff8d5ca7e9344733968c72704eb15ff /tests/auto/qtessellator
downloadQt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2
Long live Qt!
Diffstat (limited to 'tests/auto/qtessellator')
-rw-r--r--tests/auto/qtessellator/.gitignore1
-rw-r--r--tests/auto/qtessellator/XrenderFake.h110
-rw-r--r--tests/auto/qtessellator/arc.cpp49
-rw-r--r--tests/auto/qtessellator/arc.data2
-rw-r--r--tests/auto/qtessellator/arc.h48
-rw-r--r--tests/auto/qtessellator/datafiles.qrc6
-rw-r--r--tests/auto/qtessellator/dataparser.cpp161
-rw-r--r--tests/auto/qtessellator/dataparser.h51
-rw-r--r--tests/auto/qtessellator/oldtessellator.cpp446
-rw-r--r--tests/auto/qtessellator/oldtessellator.h52
-rw-r--r--tests/auto/qtessellator/qnum.h145
-rw-r--r--tests/auto/qtessellator/qtessellator.pro7
-rw-r--r--tests/auto/qtessellator/sample_data.h51
-rw-r--r--tests/auto/qtessellator/simple.cpp49
-rw-r--r--tests/auto/qtessellator/simple.data195
-rw-r--r--tests/auto/qtessellator/simple.h48
-rw-r--r--tests/auto/qtessellator/testtessellator.cpp114
-rw-r--r--tests/auto/qtessellator/testtessellator.h59
-rw-r--r--tests/auto/qtessellator/tst_tessellator.cpp378
-rw-r--r--tests/auto/qtessellator/utils.cpp93
-rw-r--r--tests/auto/qtessellator/utils.h56
21 files changed, 2121 insertions, 0 deletions
diff --git a/tests/auto/qtessellator/.gitignore b/tests/auto/qtessellator/.gitignore
new file mode 100644
index 0000000..99f2160
--- /dev/null
+++ b/tests/auto/qtessellator/.gitignore
@@ -0,0 +1 @@
+tst_qtessellator
diff --git a/tests/auto/qtessellator/XrenderFake.h b/tests/auto/qtessellator/XrenderFake.h
new file mode 100644
index 0000000..b29331b
--- /dev/null
+++ b/tests/auto/qtessellator/XrenderFake.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+/**
+ These are just defines we need to compile this across platforms
+**/
+/*
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _XRENDER_FAKE_H_
+#define _XRENDER_FAKE_H_
+
+#ifndef _XRENDER_H_
+typedef double XDouble;
+
+typedef struct _XPointDouble {
+ XDouble x, y;
+} XPointDouble;
+
+#define XDoubleToFixed(f) ((XFixed) ((f) * 65536))
+#define XFixedToDouble(f) (((XDouble) (f)) / 65536)
+
+typedef int XFixed;
+
+typedef struct _XPointFixed {
+ XFixed x, y;
+} XPointFixed;
+
+typedef struct _XLineFixed {
+ XPointFixed p1, p2;
+} XLineFixed;
+
+typedef struct _XTriangle {
+ XPointFixed p1, p2, p3;
+} XTriangle;
+
+typedef struct _XTrapezoid {
+ XFixed top, bottom;
+ XLineFixed left, right;
+} XTrapezoid;
+
+typedef struct _XSpanFix {
+ XFixed left, right, y;
+} XSpanFix;
+
+typedef struct _XTrap {
+ XSpanFix top, bottom;
+} XTrap;
+
+#endif
+
+#endif /* _XRENDER_H_ */
diff --git a/tests/auto/qtessellator/arc.cpp b/tests/auto/qtessellator/arc.cpp
new file mode 100644
index 0000000..7627937
--- /dev/null
+++ b/tests/auto/qtessellator/arc.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 "arc.h"
+
+#include "dataparser.h"
+#include <QString>
+
+FullData arcData()
+{
+ return parseFile(":/arc.data");
+}
diff --git a/tests/auto/qtessellator/arc.data b/tests/auto/qtessellator/arc.data
new file mode 100644
index 0000000..f541372
--- /dev/null
+++ b/tests/auto/qtessellator/arc.data
@@ -0,0 +1,2 @@
+330.399757,524.281800, 478.120912,550.329025, 477.831298,550.531815, 478.810211,541.885349, 478.599541,533.099490, 478.834287,533.328092, 330.341973,524.777589, 330.399757,524.281800, 330.370717,524.278415, 478.863031,532.828919, 479.097777,533.057521, 479.308667,541.907694, 478.323702,550.618639, 478.034088,550.821429, 330.312933,524.774204, 330.370717,524.278415, 330.399757,524.281800, 330.340478,524.278506, 475.092081,515.072484, 474.871052,515.401854, 472.271033,508.556408, 469.166670,501.975570, 465.531259,495.623207, 461.338095,489.463185, 456.560474,483.459373, 451.171691,477.575636, 438.453817,466.023860, 438.731065,466.049958, 330.475509,524.747774, 330.340478,524.278506, 330.399757,524.281800, 330.237181,524.308229, 438.492737,465.610413, 438.769984,465.636512, 451.529578,477.230250, 456.941391,483.142024, 461.742023,489.176805, 465.957079,495.369400, 469.612164,501.754612, 472.732885,508.367246, 475.344846,515.242105, 475.123817,515.571476, 330.372213,524.777498, 330.237181,524.308229, 330.399757,524.281800, 330.198654,524.334009, 419.097609,452.070769, 419.126347,452.478938, 406.609897,445.517586, 393.734425,439.489615, 380.499126,434.394819, 366.903191,430.232997, 352.945816,427.003943, 338.626193,424.707455, 323.943517,423.343328, 308.896980,422.911359, 309.141051,422.609824, 330.600976,524.476466, 330.198654,524.334009, 330.399757,524.281800, 330.111715,524.579537, 308.651790,422.712895, 308.895862,422.411361, 323.970137,422.844875, 338.685103,424.213480, 353.039954,426.516970, 367.033883,429.755143, 380.666084,433.927795, 393.935751,439.034722, 406.842076,445.075720, 419.384253,452.050587, 419.412991,452.458756, 330.514037,524.721995, 330.111715,524.579537, 330.399757,524.281800, 330.129715,524.633543, 283.437924,424.371616, 283.696186,424.514066, 274.149920,425.955307, 264.995958,427.789229, 256.246650,430.007574, 247.914348,432.602085, 240.011405,435.564508, 232.550171,438.886583, 225.542998,442.560055, 219.002238,446.576668, 212.940243,450.928163, 207.369363,455.606286, 202.301952,460.602778, 197.750359,465.909384, 193.726937,471.517846, 190.244038,477.419909, 187.314013,483.607314, 184.949214,490.071807, 184.768427,489.753472, 330.414019,524.284745, 330.129715,524.633543, 330.399757,524.281800, 330.298671,524.771258, 184.653079,490.239985, 184.472293,489.921650, 186.849209,483.425660, 189.795371,477.207106, 193.297958,471.274452, 197.344150,465.636164, 201.921125,460.300704, 207.016064,455.276537, 212.616146,450.572127, 218.708551,446.195939, 225.280457,442.156435, 232.319044,438.462081, 239.811492,435.121341, 247.744980,432.142678, 256.106687,429.534556, 264.883794,427.305441, 274.063479,425.463796, 283.632922,424.018084, 283.891183,424.160534, 330.582975,524.422461, 330.298671,524.771258, 330.399757,524.281800, 330.602547,524.571414, 313.237730,623.052184, 312.948116,623.254974, 297.919322,620.079380, 283.498874,615.993956, 269.752665,611.061508, 256.746589,605.344843, 244.546537,598.906766, 233.218404,591.810084, 222.828081,584.117603, 213.441462,575.892130, 205.124439,567.196470, 197.942906,558.093430, 191.962756,548.645817, 187.249880,538.916436, 183.870173,528.968094, 181.889527,518.863598, 181.373834,508.665752, 182.388989,498.437365, 182.678603,498.234575, 330.399757,524.281800, 330.602547,524.571414, 330.399757,524.281800, 473.399671,549.750400, 470.969436,559.210379, 467.157740,568.141238, 462.045076,576.508539, 455.711937,584.277845, 448.238814,591.414720, 439.706200,597.884727, 430.194588,603.653429, 419.784468,608.686389, 408.556335,612.949170, 396.590680,616.407336, 383.967995,619.026449, 370.768773,620.772073, 357.073506,621.609771, 342.962685,621.505106, 328.516805,620.423642, 313.816356,618.330940, 299.286707,615.269587, 285.342137,611.345049, 272.046506,606.617217, 259.463674,601.145981, 247.657501,594.991231, 236.691847,588.212857, 226.630571,580.870749, 217.537534,573.024797, 209.476596,564.734892, 202.511616,556.060922, 196.706454,547.062779, 192.124971,537.800351, 188.831026,528.333530, 186.888479,518.722205, 186.361190,509.026267, 187.313019,499.305604, 189.743255,489.845625, 193.554950,480.914766, 198.667614,472.547465, 205.000754,464.778159, 212.473876,457.641284, 221.006490,451.171277, 230.518103,445.402575, 240.928222,440.369615, 252.156355,436.106834, 264.122010,432.648668, 276.744695,430.029555, 289.943918,428.283931, 303.639185,427.446233, 317.750005,427.550898, 332.195885,428.632362, 346.896334,430.725063, 361.425983,433.786417, 375.370553,437.710955, 388.666184,442.438787, 401.249016,447.910023, 413.055189,454.064773, 424.020844,460.843147, 434.082119,468.185255, 443.175156,476.031206, 451.236095,484.321112, 458.201075,492.995082, 464.006236,501.993225, 468.587719,511.255653, 471.881665,520.722474, 473.824212,530.333799, 474.351500,540.029737, 473.399671,549.750400, 330.399757,524.281800, 472.907267,549.663576, 473.854306,539.992980, 473.329738,530.347191, 471.396677,520.785684, 468.118232,511.367936, 463.557515,502.153423, 457.777638,493.201621, 450.841711,484.572006, 442.812847,476.324055, 433.754155,468.517243, 423.728748,461.211047, 412.799737,454.464943, 401.030232,448.338407, 388.483346,442.890916, 375.222190,438.181944, 361.309874,434.270969, 346.809510,431.217467, 332.139266,429.127404, 317.728333,428.044226, 303.656359,427.933629, 290.002991,428.761309, 276.847876,430.492962, 264.270661,433.094284, 252.350994,436.530972, 241.168522,440.768720, 230.802891,445.773225, 221.333750,451.510184, 212.840745,457.945292, 205.403525,465.044245, 199.101735,472.772739, 194.015023,481.096470, 190.223037,489.981135, 187.805423,499.392428, 186.858385,509.063024, 187.382952,518.708813, 189.316014,528.270320, 192.594458,537.688068, 197.155175,546.902581, 202.935052,555.854383, 209.870979,564.483998, 217.899844,572.731949, 226.958535,580.538761, 236.983942,587.844957, 247.912954,594.591061, 259.682458,600.717597, 272.229344,606.165088, 285.490501,610.874060, 299.402817,614.785034, 313.903180,617.838537, 328.573424,619.928600, 342.984357,621.011778, 357.056331,621.122375, 370.709699,620.294695, 383.864814,618.563042, 396.442029,615.961720, 408.361696,612.525032, 419.544169,608.287284, 429.909799,603.282779, 439.378940,597.545820, 447.871945,591.110712, 455.309166,584.011759, 461.610956,576.283265, 466.697667,567.959534, 470.489654,559.074869, 472.907267,549.663576, 330.399757,524.281800, 330.454707,524.298165, 454.667822,577.456961, 454.762318,577.845876, 445.497902,587.443966, 440.285366,591.692799, 434.641502,595.603281, 421.926464,602.494557, 407.086134,608.288530, 406.823265,608.220270, 330.172154,524.697039, 330.454707,524.298165, 330.399757,524.281800, 330.540537,524.358965, 407.191648,607.882196, 406.928779,607.813936, 421.715525,602.044127, 434.366600,595.191446, 439.978360,591.303580, 445.160720,587.078457, 454.376603,577.527719, 454.471098,577.916634, 330.257983,524.757839, 330.540537,524.358965, 330.399757,524.281800, 330.568526,524.395792, 385.970533,613.309333, 385.803321,613.687465, 372.603353,615.647129, 359.376368,616.703732, 346.123165,616.857358, 332.844541,616.108092, 319.541292,614.456018, 306.214217,611.901220, 292.864113,608.443782, 279.491776,604.083789, 279.365802,603.713738, 330.145795,524.393211, 330.568526,524.395792, 330.399757,524.281800, 330.566895,524.662793, 279.786902,603.983321, 279.660927,603.613270, 293.007562,607.965618, 306.326866,611.416496, 319.619636,613.965989, 332.886669,615.614181, 346.128763,616.361156, 359.346715,616.206998, 372.541322,615.151791, 385.713383,613.195620, 385.546171,613.573752, 330.144165,524.660212, 330.566895,524.662793, 330.399757,524.281800, 330.312933,524.774204, 182.591778,498.726979, 182.881392,498.524189, 181.870979,508.702932, 182.383959,518.850950, 184.355179,528.905860, 187.719481,538.805277, 192.411711,548.486821, 198.366713,557.888107, 205.519330,566.946753, 213.804409,575.600375, 223.156792,583.786592, 233.511325,591.443019, 244.802851,598.507275, 256.966215,604.916975, 269.936262,610.609738, 283.647836,615.523180, 298.035780,619.594918, 313.034940,622.762570, 312.745326,622.965360, 330.110143,524.484590, 330.312933,524.774204, 330.399757,524.281800,
+
diff --git a/tests/auto/qtessellator/arc.h b/tests/auto/qtessellator/arc.h
new file mode 100644
index 0000000..0ad7279
--- /dev/null
+++ b/tests/auto/qtessellator/arc.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 ARC_H
+#define ARC_H
+
+#include "sample_data.h"
+
+FullData arcData();
+
+#endif
diff --git a/tests/auto/qtessellator/datafiles.qrc b/tests/auto/qtessellator/datafiles.qrc
new file mode 100644
index 0000000..bb0ed37
--- /dev/null
+++ b/tests/auto/qtessellator/datafiles.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/">
+ <file>simple.data</file>
+ <file>arc.data</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/qtessellator/dataparser.cpp b/tests/auto/qtessellator/dataparser.cpp
new file mode 100644
index 0000000..c767cfa
--- /dev/null
+++ b/tests/auto/qtessellator/dataparser.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** 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 "dataparser.h"
+#include <QString>
+#include <QVector>
+#include <QFile>
+#include <QTextStream>
+
+#include <QtDebug>
+
+static QList<qreal> parseNumbersList(QByteArray::const_iterator &itr)
+{
+ QList<qreal> points;
+ QByteArray temp;
+ while ((*itr) == ' ')
+ ++itr;
+ while (((*itr) >= '0' && (*itr) <= '9') ||
+ (*itr) == '-' || (*itr) == '+') {
+ temp = QByteArray();
+
+ if ((*itr) == '-')
+ temp += *itr++;
+ else if ((*itr) == '+')
+ temp += *itr++;
+ while ((*itr) >= '0' && (*itr) <= '9')
+ temp += *itr++;
+ if ((*itr) == '.')
+ temp += *itr++;
+ while ((*itr) >= '0' && (*itr) <= '9')
+ temp += *itr++;
+ if (( *itr) == 'e') {
+ temp += *itr++;
+ if ((*itr) == '-' ||
+ (*itr) == '+')
+ temp += *itr++;
+ }
+ while ((*itr) >= '0' && (*itr) <= '9')
+ temp += *itr++;
+ while ((*itr) == ' ')
+ ++itr;
+ if ((*itr) == ',')
+ ++itr;
+ points.append(temp.toDouble());
+ //eat the rest of space
+ while ((*itr) == ' ')
+ ++itr;
+ }
+
+ return points;
+}
+
+static QList<QPointF> parsePoints(const QByteArray &line)
+{
+ QList<QPointF> res;
+
+ QByteArray::const_iterator it = line.constBegin();
+ if (*it == ',')
+ ++it;
+
+ QList<qreal> nums = parseNumbersList(it);
+ QList<qreal>::const_iterator nitr;
+ for (nitr = nums.begin(); nitr != nums.end(); ++nitr) {
+ qreal x = *nitr; ++nitr;
+ Q_ASSERT(nitr != nums.end());
+ qreal y = *nitr;
+ res.append(QPointF(x, y));
+ }
+
+ return res;
+}
+
+QList< QVector<QPointF> > parseData(const QByteArray &contents)
+{
+ QList<QByteArray> lines = contents.split('\n');
+ QList<QByteArray>::const_iterator itr;
+
+ QList< QVector<QPointF> > res;
+ QVector<QPointF> current;
+
+ for (itr = lines.begin(); itr != lines.end(); ++itr) {
+ QByteArray line = (*itr).trimmed();
+ if (line.isEmpty() || line.startsWith('/')) {
+ if (!current.isEmpty()) {
+ res.append(current);
+ current = QVector<QPointF>();
+ }
+ continue;
+ } else {
+ QList<QPointF> lst = parsePoints(line);
+ current << lst.toVector();
+ }
+ }
+ return res;
+}
+
+QList< QVector<QPointF> > parseFile(const QString &fileName)
+{
+ QList< QVector<QPointF> > res;
+ QFile file(fileName);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ qDebug()<<"couldn't open "<<fileName;
+ return res;
+ }
+
+ QVector<QPointF> current;
+
+ while (!file.atEnd()) {
+ QByteArray line = file.readLine().trimmed();
+ if (line.isEmpty() || line.startsWith('/')) {
+ if (!current.isEmpty()) {
+ res.append(current);
+ current = QVector<QPointF>();
+ }
+ continue;
+ } else {
+ QList<QPointF> lst = parsePoints(line);
+ current << lst.toVector();
+ }
+ }
+
+ return res;
+}
diff --git a/tests/auto/qtessellator/dataparser.h b/tests/auto/qtessellator/dataparser.h
new file mode 100644
index 0000000..8f8571b
--- /dev/null
+++ b/tests/auto/qtessellator/dataparser.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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 DATAPARSER_H
+#define DATAPARSER_H
+
+#include <QList>
+#include <QVector>
+#include <QPointF>
+
+QList< QVector<QPointF> > parseData(const QByteArray &contents);
+QList< QVector<QPointF> > parseFile(const QString &fileName);
+
+#endif
diff --git a/tests/auto/qtessellator/oldtessellator.cpp b/tests/auto/qtessellator/oldtessellator.cpp
new file mode 100644
index 0000000..edfc1aa
--- /dev/null
+++ b/tests/auto/qtessellator/oldtessellator.cpp
@@ -0,0 +1,446 @@
+/****************************************************************************
+**
+** 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 "oldtessellator.h"
+#include <QPointF>
+#include <QVector>
+#include <QList>
+#include <QVariant>
+#include <QVarLengthArray>
+#include <qdebug.h>
+
+#include "limits.h"
+#include "utils.h"
+
+#include "qnum.h"
+#include "XrenderFake.h"
+
+/*
+ * Polygon tesselator - can probably be optimized a bit more
+ */
+
+//#define QT_DEBUG_TESSELATOR
+#define FloatToXFixed(i) (int)((i) * 65536)
+#define IntToXFixed(i) ((i) << 16)
+
+//inline int qrealToXFixed(qreal f)
+//{ return f << 8; }
+
+struct QEdge {
+ inline QEdge()
+ {}
+ inline QEdge(const QPointF &pt1,
+ const QPointF &pt2)
+ {
+ p1.x = XDoubleToFixed(pt1.x());
+ p1.y = XDoubleToFixed(pt1.y());
+ p2.x = XDoubleToFixed(pt2.x());
+ p2.y = XDoubleToFixed(pt2.y());
+ m = (pt1.x() - pt2.x()) ? (pt1.y() - pt2.y()) / (pt1.x() - pt2.x()) : 0;
+ im = m ? 1/m : 0;
+ b = pt1.y() - m * pt1.x();
+ vertical = p1.x == p2.x;
+ horizontal = p1.y == p2.y;
+ }
+
+ inline qreal xAt(const qreal &y) const
+ {
+ Q_ASSERT(p1.y != p2.y);
+ XFixed yf = XDoubleToFixed(y);
+
+ if (yf == p1.y)
+ return XFixedToDouble(p1.x);
+ else if (yf == p2.y)
+ return XFixedToDouble(p2.x);
+
+ return (!vertical) ? (((y - b)*im)) : pf1.x();
+ }
+
+ QPointF pf1, pf2;
+ XPointFixed p1, p2;
+ qreal m;
+ qreal im;
+ qreal b;
+ qreal intersection;
+ signed short winding;
+ bool vertical;
+ bool horizontal;
+};
+
+struct QVrtx {
+ typedef QList<QEdge> Edges;
+ XPointFixed coords;
+ Edges startingEdges;
+ Edges endingEdges;
+ Edges intersectingEdges;
+};
+
+struct QIntersectionPoint {
+ qreal x;
+ const QEdge *edge;
+};
+
+QT_BEGIN_NAMESPACE
+Q_DECLARE_TYPEINFO(QEdge, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QVrtx, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(QIntersectionPoint, Q_PRIMITIVE_TYPE);
+QT_END_NAMESPACE
+
+
+// used by the edge point sort algorithm
+static qreal currentY = 0.f;
+
+static inline bool compareEdges(const QEdge *e1, const QEdge *e2)
+{
+ return e1->p1.y < e2->p1.y;
+}
+
+static inline bool isEqual(const XPointFixed &p1, const XPointFixed &p2)
+{
+ return ((p1.x == p2.x) && (p1.y == p2.y));
+}
+
+static inline bool compareIntersections(const QIntersectionPoint &i1, const QIntersectionPoint &i2)
+{
+ if (qAbs(i1.x - i2.x) > 0.01) { // x != other.x in 99% of the cases
+ return i1.x < i2.x;
+ } else {
+ qreal x1 = (i1.edge->p1.x != i1.edge->p2.x) ?
+ ((currentY+1 - i1.edge->b)*i1.edge->m) : XFixedToDouble(i1.edge->p1.x);
+ qreal x2 = (i2.edge->p1.x != i2.edge->p2.x) ?
+ ((currentY+1 - i2.edge->b)*i2.edge->m) : XFixedToDouble(i2.edge->p1.x);
+// qDebug() << ">>>" << currentY << i1.edge << i2.edge << x1 << x2;
+ return x1 < x2;
+ }
+}
+
+#ifdef QT_USE_FIXED_POINT
+inline int qrealToXFixed(qreal f)
+{ return f.value() << 8; }
+#else
+#define qrealToXFixed FloatToXFixed
+#endif
+
+static XTrapezoid QT_FASTCALL toXTrapezoid(XFixed y1, XFixed y2, const QEdge &left, const QEdge &right)
+{
+ XTrapezoid trap;
+ trap.top = y1;
+ trap.bottom = y2;
+ trap.left.p1.y = left.p1.y;
+ trap.left.p2.y = left.p2.y;
+ trap.right.p1.y = right.p1.y;
+ trap.right.p2.y = right.p2.y;
+ trap.left.p1.x = left.p1.x;
+ trap.left.p2.x = left.p2.x;
+ trap.right.p1.x = right.p1.x;
+ trap.right.p2.x = right.p2.x;
+ return trap;
+}
+
+#ifdef QT_DEBUG_TESSELATOR
+static void dump_edges(const QList<const QEdge *> &et)
+{
+ for (int x = 0; x < et.size(); ++x) {
+ qDebug() << "edge#" << x << et.at(x) << "("
+ << XFixedToDouble(et.at(x)->p1.x)
+ << XFixedToDouble(et.at(x)->p1.y)
+ << ") ("
+ << XFixedToDouble(et.at(x)->p2.x)
+ << XFixedToDouble(et.at(x)->p2.y)
+ << ") b: " << et.at(x)->b << "m:" << et.at(x)->m;
+ }
+}
+
+static void dump_trap(const XTrapezoid &t)
+{
+ qDebug() << "trap# t=" << t.top/65536.0 << "b=" << t.bottom/65536.0 << "h="
+ << XFixedToDouble(t.bottom - t.top) << "\tleft p1: ("
+ << XFixedToDouble(t.left.p1.x) << ","<< XFixedToDouble(t.left.p1.y)
+ << ")" << "\tleft p2: (" << XFixedToDouble(t.left.p2.x) << ","
+ << XFixedToDouble(t.left.p2.y) << ")" << "\n\t\t\t\tright p1:("
+ << XFixedToDouble(t.right.p1.x) << "," << XFixedToDouble(t.right.p1.y) << ")"
+ << "\tright p2:(" << XFixedToDouble(t.right.p2.x) << ","
+ << XFixedToDouble(t.right.p2.y) << ")";
+}
+#endif
+
+
+typedef int Q27Dot5;
+#define Q27Dot5ToDouble(i) (i/32.)
+#define FloatToQ27Dot5(i) (int)((i) * 32)
+#define IntToQ27Dot5(i) ((i) << 5)
+#define Q27Dot5ToXFixed(i) ((i) << 11)
+#define Q27Dot5Factor 32
+
+void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pgSize,
+ bool winding)
+{
+ QVector<QEdge> edges;
+ edges.reserve(128);
+ qreal ymin(INT_MAX/256);
+ qreal ymax(INT_MIN/256);
+
+ //painter.begin(pg, pgSize);
+ Q_ASSERT(pg[0] == pg[pgSize-1]);
+ // generate edge table
+// qDebug() << "POINTS:";
+ for (int x = 0; x < pgSize-1; ++x) {
+ QEdge edge;
+ QPointF p1(Q27Dot5ToDouble(FloatToQ27Dot5(pg[x].x())),
+ Q27Dot5ToDouble(FloatToQ27Dot5(pg[x].y())));
+ QPointF p2(Q27Dot5ToDouble(FloatToQ27Dot5(pg[x+1].x())),
+ Q27Dot5ToDouble(FloatToQ27Dot5(pg[x+1].y())));
+
+// qDebug() << " "
+// << p1;
+ edge.winding = p1.y() > p2.y() ? 1 : -1;
+ if (edge.winding > 0)
+ qSwap(p1, p2);
+ edge.p1.x = XDoubleToFixed(p1.x());
+ edge.p1.y = XDoubleToFixed(p1.y());
+ edge.p2.x = XDoubleToFixed(p2.x());
+ edge.p2.y = XDoubleToFixed(p2.y());
+
+ edge.m = (p1.y() - p2.y()) / (p1.x() - p2.x()); // line derivative
+ edge.b = p1.y() - edge.m * p1.x(); // intersection with y axis
+ edge.m = edge.m != 0.0 ? 1.0 / edge.m : 0.0; // inverted derivative
+ edges.append(edge);
+ ymin = qMin(ymin, qreal(XFixedToDouble(edge.p1.y)));
+ ymax = qMax(ymax, qreal(XFixedToDouble(edge.p2.y)));
+ }
+
+ QList<const QEdge *> et; // edge list
+ for (int i = 0; i < edges.size(); ++i)
+ et.append(&edges.at(i));
+
+ // sort edge table by min y value
+ qSort(et.begin(), et.end(), compareEdges);
+
+ // eliminate shared edges
+ for (int i = 0; i < et.size(); ++i) {
+ for (int k = i+1; k < et.size(); ++k) {
+ const QEdge *edgeI = et.at(i);
+ const QEdge *edgeK = et.at(k);
+ if (edgeK->p1.y > edgeI->p1.y)
+ break;
+ if (edgeI->winding != edgeK->winding &&
+ isEqual(edgeI->p1, edgeK->p1) && isEqual(edgeI->p2, edgeK->p2)
+ ) {
+ et.removeAt(k);
+ et.removeAt(i);
+ --i;
+ break;
+ }
+ }
+ }
+
+ if (ymax <= ymin)
+ return;
+ QList<const QEdge *> aet; // edges that intersects the current scanline
+
+// if (ymin < 0)
+// ymin = 0;
+// if (paintEventClipRegion) // don't scan more lines than we have to
+// ymax = paintEventClipRegion->boundingRect().height();
+
+#ifdef QT_DEBUG_TESSELATOR
+ qDebug("==> ymin = %f, ymax = %f", ymin, ymax);
+#endif // QT_DEBUG_TESSELATOR
+
+ currentY = ymin; // used by the less than op
+ for (qreal y = ymin; y < ymax;) {
+ // fill active edge table with edges that intersect the current line
+ for (int i = 0; i < et.size(); ++i) {
+ const QEdge *edge = et.at(i);
+ if (edge->p1.y > XDoubleToFixed(y))
+ break;
+ aet.append(edge);
+ et.removeAt(i);
+ --i;
+ }
+
+ // remove processed edges from active edge table
+ for (int i = 0; i < aet.size(); ++i) {
+ if (aet.at(i)->p2.y <= XDoubleToFixed(y)) {
+ aet.removeAt(i);
+ --i;
+ }
+ }
+ if (aet.size()%2 != 0) {
+#ifndef QT_NO_DEBUG
+ qWarning("QX11PaintEngine: aet out of sync - this should not happen.");
+#endif
+ return;
+ }
+
+ // done?
+ if (!aet.size()) {
+ if (!et.size()) {
+ break;
+ } else {
+ y = currentY = XFixedToDouble(et.at(0)->p1.y);
+ continue;
+ }
+ }
+
+ // calculate the next y where we have to start a new set of trapezoids
+ qreal next_y(INT_MAX/256);
+ for (int i = 0; i < aet.size(); ++i) {
+ const QEdge *edge = aet.at(i);
+ if (XFixedToDouble(edge->p2.y) < next_y)
+ next_y = XFixedToDouble(edge->p2.y);
+ }
+
+ if (et.size() && next_y > XFixedToDouble(et.at(0)->p1.y))
+ next_y = XFixedToDouble(et.at(0)->p1.y);
+
+ int aetSize = aet.size();
+ for (int i = 0; i < aetSize; ++i) {
+ for (int k = i+1; k < aetSize; ++k) {
+ const QEdge *edgeI = aet.at(i);
+ const QEdge *edgeK = aet.at(k);
+ qreal m1 = edgeI->m;
+ qreal b1 = edgeI->b;
+ qreal m2 = edgeK->m;
+ qreal b2 = edgeK->b;
+
+ if (qAbs(m1 - m2) < 0.001)
+ continue;
+
+ // ### intersect is not calculated correctly when optimized with -O2 (gcc)
+ volatile qreal intersect = 0;
+ if (!qIsFinite(b1))
+ intersect = (1.f / m2) * XFixedToDouble(edgeI->p1.x) + b2;
+ else if (!qIsFinite(b2))
+ intersect = (1.f / m1) * XFixedToDouble(edgeK->p1.x) + b1;
+ else
+ intersect = (b1*m1 - b2*m2) / (m1 - m2);
+
+ if (intersect > y && intersect < next_y)
+ next_y = intersect;
+ }
+ }
+
+ XFixed yf, next_yf;
+ yf = qrealToXFixed(y);
+ next_yf = qrealToXFixed(next_y);
+
+ if (yf == next_yf) {
+ y = currentY = next_y;
+ continue;
+ }
+
+#ifdef QT_DEBUG_TESSELATOR
+ qDebug("###> y = %f, next_y = %f, %d active edges", y, next_y, aet.size());
+ qDebug("===> edges");
+ dump_edges(et);
+ qDebug("===> active edges");
+ dump_edges(aet);
+#endif
+ // calc intersection points
+ QVarLengthArray<QIntersectionPoint> isects(aet.size()+1);
+ for (int i = 0; i < isects.size()-1; ++i) {
+ const QEdge *edge = aet.at(i);
+ isects[i].x = (edge->p1.x != edge->p2.x) ?
+ ((y - edge->b)*edge->m) : XFixedToDouble(edge->p1.x);
+ isects[i].edge = edge;
+ }
+
+ Q_ASSERT(isects.size()%2 == 1);
+
+ // sort intersection points
+ qSort(&isects[0], &isects[isects.size()-1], compareIntersections);
+// qDebug() << "INTERSECTION_POINTS:";
+// for (int i = 0; i < isects.size(); ++i)
+// qDebug() << isects[i].edge << isects[i].x;
+
+ if (winding) {
+ // winding fill rule
+ for (int i = 0; i < isects.size()-1;) {
+ int winding = 0;
+ const QEdge *left = isects[i].edge;
+ const QEdge *right = 0;
+ winding += isects[i].edge->winding;
+ for (++i; i < isects.size()-1 && winding != 0; ++i) {
+ winding += isects[i].edge->winding;
+ right = isects[i].edge;
+ }
+ if (!left || !right)
+ break;
+ //painter.addTrapezoid(&toXTrapezoid(yf, next_yf, *left, *right));
+ traps->append(toXTrapezoid(yf, next_yf, *left, *right));
+ }
+ } else {
+ // odd-even fill rule
+ for (int i = 0; i < isects.size()-2; i += 2) {
+ //painter.addTrapezoid(&toXTrapezoid(yf, next_yf, *isects[i].edge, *isects[i+1].edge));
+ traps->append(toXTrapezoid(yf, next_yf, *isects[i].edge, *isects[i+1].edge));
+ }
+ }
+ y = currentY = next_y;
+ }
+
+#ifdef QT_DEBUG_TESSELATOR
+ qDebug("==> number of trapezoids: %d - edge table size: %d\n", traps->size(), et.size());
+
+ for (int i = 0; i < traps->size(); ++i)
+ dump_trap(traps->at(i));
+#endif
+
+ // optimize by unifying trapezoids that share left/right lines
+ // and have a common top/bottom edge
+// for (int i = 0; i < tps.size(); ++i) {
+// for (int k = i+1; k < tps.size(); ++k) {
+// if (i != k && tps.at(i).right == tps.at(k).right
+// && tps.at(i).left == tps.at(k).left
+// && (tps.at(i).top == tps.at(k).bottom
+// || tps.at(i).bottom == tps.at(k).top))
+// {
+// tps[i].bottom = tps.at(k).bottom;
+// tps.removeAt(k);
+// i = 0;
+// break;
+// }
+// }
+// }
+ //static int i = 0;
+ //QImage img = painter.end();
+ //img.save(QString("res%1.png").arg(i++), "PNG");
+}
diff --git a/tests/auto/qtessellator/oldtessellator.h b/tests/auto/qtessellator/oldtessellator.h
new file mode 100644
index 0000000..c01e215
--- /dev/null
+++ b/tests/auto/qtessellator/oldtessellator.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** 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 NEWTESSELATOR_H
+#define NEWTESSELATOR_H
+
+#include <QVector>
+#include <QPointF>
+#include "XrenderFake.h"
+
+void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pgSize,
+ bool winding);
+
+
+#endif
diff --git a/tests/auto/qtessellator/qnum.h b/tests/auto/qtessellator/qnum.h
new file mode 100644
index 0000000..03158c5
--- /dev/null
+++ b/tests/auto/qtessellator/qnum.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** 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 QNUM_H
+#define QNUM_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qglobal.h"
+
+static const unsigned char qt_be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
+static const unsigned char qt_le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
+static inline double qtInf()
+{
+ return *reinterpret_cast<const double *>(QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_inf_bytes : qt_le_inf_bytes);
+}
+#define Q_INFINITY (::qtInf())
+
+// Signaling NAN
+static const unsigned char qt_be_snan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
+static const unsigned char qt_le_snan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
+static inline double qtSnan()
+{
+ return *reinterpret_cast<const double *>(QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_snan_bytes : qt_le_snan_bytes);
+}
+#define Q_SNAN (::qtSnan())
+
+// Quiet NAN
+static const unsigned char qt_be_qnan_bytes[] = { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 };
+static const unsigned char qt_le_qnan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0xff };
+static inline double qtQnan()
+{
+ return *reinterpret_cast<const double *>(QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_qnan_bytes : qt_le_qnan_bytes);
+}
+#define Q_QNAN (::qtQnan())
+
+static inline bool qIsInf(double d)
+{
+ uchar *ch = (uchar *)&d;
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ return (ch[0] & 0x7f) == 0x7f && ch[1] == 0xf0;
+ } else {
+ return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0;
+ }
+}
+
+static inline bool qIsNaN(double d)
+{
+ uchar *ch = (uchar *)&d;
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0;
+ } else {
+ return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0;
+ }
+}
+
+static inline bool qIsFinite(double d)
+{
+ uchar *ch = (uchar *)&d;
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0xf0) != 0xf0;
+ } else {
+ return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0;
+ }
+}
+
+static inline bool qIsInf(float d)
+{
+ uchar *ch = (uchar *)&d;
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ return (ch[0] & 0x7f) == 0x7f && ch[1] == 0x80;
+ } else {
+ return (ch[3] & 0x7f) == 0x7f && ch[2] == 0x80;
+ }
+}
+
+static inline bool qIsNaN(float d)
+{
+ uchar *ch = (uchar *)&d;
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ return (ch[0] & 0x7f) == 0x7f && ch[1] > 0x80;
+ } else {
+ return (ch[3] & 0x7f) == 0x7f && ch[2] > 0x80;
+ }
+}
+
+static inline bool qIsFinite(float d)
+{
+ uchar *ch = (uchar *)&d;
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0x80) != 0x80;
+ } else {
+ return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0x80) != 0x80;
+ }
+}
+
+#endif // QNUMERIC_P_H
diff --git a/tests/auto/qtessellator/qtessellator.pro b/tests/auto/qtessellator/qtessellator.pro
new file mode 100644
index 0000000..e043a4d
--- /dev/null
+++ b/tests/auto/qtessellator/qtessellator.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+SOURCES += tst_tessellator.cpp testtessellator.cpp oldtessellator.cpp utils.cpp simple.cpp dataparser.cpp arc.cpp
+HEADERS += oldtessellator.h testtessellator.h utils.h XRenderFake.h simple.h qnum.h dataparser.h arc.h
+
+RESOURCES += datafiles.qrc
+
+
diff --git a/tests/auto/qtessellator/sample_data.h b/tests/auto/qtessellator/sample_data.h
new file mode 100644
index 0000000..540ef30
--- /dev/null
+++ b/tests/auto/qtessellator/sample_data.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** 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 SAMPLE_DATA_H
+#define SAMPLE_DATA_H
+
+#include <QVector>
+#include <QPointF>
+#include <QList>
+
+typedef QVector<QPointF> SampleData;
+typedef QList< SampleData > FullData;
+
+#endif
diff --git a/tests/auto/qtessellator/simple.cpp b/tests/auto/qtessellator/simple.cpp
new file mode 100644
index 0000000..34e0f6c
--- /dev/null
+++ b/tests/auto/qtessellator/simple.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** 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 "simple.h"
+
+#include "dataparser.h"
+#include <QString>
+
+FullData simpleData()
+{
+ return parseFile(":/simple.data");
+}
diff --git a/tests/auto/qtessellator/simple.data b/tests/auto/qtessellator/simple.data
new file mode 100644
index 0000000..ab46f39
--- /dev/null
+++ b/tests/auto/qtessellator/simple.data
@@ -0,0 +1,195 @@
+16.000000,6.000000, 16.000000,18.000000, 16.000000,1.000000, 16.000000,14.000000, 10.000000,17.000000, 16.000000,6.000000,
+
+10,10,16,18,18,14,21,18,25,18,25,11,15,7,15,12,13,12,10,10
+
+10,10,20,10,20,20,10,20,10,10
+
+0,0,0,10,12,10,12,0,0,0,4,2,4,6,10,6,10,2,4,2,0,0
+
+0,0,0,10,12,10,12,0,0,0,4,2,4,6,10,6,10,2,4,2,0,0,0,0,0,10,12,10,12,0,0,0,4,2,4,6,10,6,10,2,4,2,0,0
+
+10,11,22,10,12,4,16,14,20,4,10,11
+
+10,11,22,10,12,4,16,14,20,4,10,11,10,11,22,10,12,4,16,14,20,4,10,11
+
+0,0,10,10,10,0,0,10,0,0
+
+0,15,15,15,15,0,5,0,5,20,10,20,10,5,0,5,0,15
+
+0,15,15,15,15,0,5,0,5,20,10,20,10,5,0,5,0,15,0,15,15,15,15,0,5,0,5,20,10,20,10,5,0,5,0,15
+
+0,10,10,10,10,0,0,0,10,10,0,10,10,0,10,5,0,5,5,0,5,10,0,10
+
+10,16,19,8,8,8,4,4,17,14,1,1,10,16
+
+19,1,13,4,15,19,5,4,8,15,15,7,0,7,15,8,9,1,19,1
+
+15,9,18,3,14,11,4,12,10,14,7,16,15,9
+
+16,10,4,14,12,15,17,10,14,19,13,11,16,10
+
+5,19,12,8,12,12,7,19,9,14,3,18,5,19
+
+3,14,11,2,1,15,3,13,10,3,15,11,3,14
+
+8,6,8,1,12,2,0,4,4,15,10,9,8,6
+
+15,16,0,3,16,16,19,5,10,9,15,4,15,16
+
+3,19,17,14,9,8,16,6,16,7,17,6,3,19
+
+0,13,0,4,5,5,7,10,4,10,0,8,0,13
+
+4,18,5,17,19,2,0,4,8,8,10,12,4,18
+
+13,12,15,19,11,5,0,14,19,15,11,11,13,12
+
+7,11,18,8,9,7,17,7,3,7,12,1,7,11
+
+10,10,7,8,13,14,7,9,8,9,6,17,10,10
+
+13,16,7,13,19,5,8,18,1,11,7,6,13,16
+
+9,6,16,11,7,10,14,12,17,2,15,13,9,6
+
+9,11,17,17,2,14,19,15,1 12,16,15,9,11
+
+1,8,7,17,0,19,12,7,5,14,13,6,1,8
+
+11,7,13,6,8,6,7,11,7,16,13,6,11,7
+
+1,1,18,1,1,14,2,14,14,3,18,1,1,1
+
+1495,174,1965,1194,622,795,1892,1044,1618,1608,1464,1758,1495,174
+
+12.437167782336,18.332947529852,6.037403680384,0.577168781310,17.369421254843,3.538437001407,1.208027666435,3.512877216563,6.647234912962,10.036138510332,13.422909136862,2.474576039240,12.437167782336,18.332947529852
+
+5.591339580715,19.434930747375, 10.417904593050,11.852347580716, 18.050480354577,3.041639151052, 5.511732324958,17.206167224795, 4.091005269438,17.285228203982, 14.422692870721,17.285191211849, 5.591339580715,19.434930747375
+
+9.662125930190,13.671313980594, 18.663120605052,13.914435822517, 4.666417893022,0.991358347237, 5.612019170076,9.671168159693, 14.484839309007,1.828807275742, 14.513027202338,18.705772804096, 9.662125930190,13.671313980594
+
+85,54,64,169,73,28,77,104,122,113,7,90,85,54
+
+8,9,13,2,16,8,6,16,15,18,18,1,8,9
+
+1,19,1,19,16,4,12,4,17,10,9,18,1,19
+
+7,5,4,1,17,16,4,1,18,9,19,18,7,5
+
+5,2,10,7,2,15,10,7,19,7,4,18,5,2
+
+193.344000,167.079000,193.927000,223.478000,192.927000,224.489000,191.461000,224.489000,190.462000,223.517000,190.144000,214.550000,189.758000,207.495000,189.303000,202.313000,189.303000,202.314000,188.432000,196.134000,187.401000,191.208000,186.180000,187.421000,185.546000,186.021000,184.895000,184.970000,184.121000,184.112000,183.389000,183.504000,182.740000,183.226000,181.868000,183.160000,181.868000,183.160000,174.478000,183.160000,175.478000,182.160000,175.478000,365.969000,175.506000,372.881000,175.590000,378.848000,175.930000,387.984000,176.507000,393.460000,176.506000,393.454000,177.006000,395.653000,177.567000,397.365000,178.244000,398.733000,178.559000,399.226000,178.834000,399.548000,179.193000,399.834000,179.499000,400.046000,179.699000,400.114000,180.048000,400.119000,180.048000,400.119000,181.868000,400.119000,182.868000,401.119000,182.868000,407.673000,181.868000,408.673000,159.625000,408.673000,158.625000,407.673000,158.625000,401.119000,159.625000,400.119000,161.481000,400.119000,161.858000,400.113000,162.068000,400.029000,162.391000,399.766000,162.784000,399.401000,163.092000,398.979000,163.431000,398.358000,164.137000,396.643000,164.715000,394.484000,165.207000,391.744000,165.207000,391.744000,165.679000,386.379000,165.959000,377.809000,166.051000,365.969000,166.051000,182.160000,167.051000,183.160000,160.744000,183.160000,159.690000,183.204000,158.850000,183.365000,158.032000,183.688000,157.329000,184.077000,156.837000,184.522000,156.371000,185.190000,156.377000,185.181000,155.135000,188.005000,154.052000,192.134000,153.069000,197.733000,152.247000,204.835000,151.685000,213.407000,151.378000,223.505000,150.378000,224.489000,148.912000,224.489000,147.912000,223.478000,148.531000,167.079000,149.531000,166.090000,192.344000,166.090000,193.344000,167.079000,192.344000,168.090000,149.531000,168.090000,150.531000,167.100000,149.912000,223.500000,148.912000,222.489000,150.378000,222.489000,149.378000,223.472000,149.691000,213.305000,150.264000,204.608000,151.091000,197.438000,152.142000,191.648000,153.353000,187.164000,154.663000,184.149000,154.669000,184.139000,155.353000,183.276000,156.247000,182.469000,157.167000,181.884000,158.209000,181.511000,159.466000,181.255000,160.744000,181.160000,160.744000,181.160000,167.051000,181.160000,168.051000,182.160000,168.051000,365.969000,167.953000,377.887000,167.663000,386.600000,167.185000,392.042000,167.185000,392.043000,166.641000,394.941000,165.969000,397.395000,165.212000,399.268000,164.738000,400.056000,164.180000,400.787000,163.652000,401.319000,163.002000,401.697000,162.185000,401.997000,161.481000,402.119000,161.481000,402.119000,159.625000,402.119000,160.625000,401.119000,160.625000,407.673000,159.625000,406.673000,181.868000,406.673000,180.868000,407.673000,180.868000,401.119000,181.868000,402.119000,180.048000,402.119000,179.401000,402.020000,178.647000,401.777000,178.044000,401.471000,177.539000,401.029000,176.994000,400.418000,176.533000,399.769000,175.791000,398.232000,175.109000,396.207000,174.543000,393.839000,174.542000,393.833000,174.221000,391.520000,173.956000,388.260000,173.599000,378.945000,173.478000,365.969000,173.478000,182.160000,174.478000,181.160000,181.868000,181.160000,183.093000,181.365000,184.400000,181.902000,185.484000,182.650000,186.386000,183.691000,187.271000,185.083000,188.032000,186.667000,188.032000,186.667000,189.288000,190.589000,190.384000,195.766000,191.290000,202.082000,191.290000,202.083000,191.748000,207.310000,192.140000,214.448000,192.461000,223.460000,191.461000,222.489000,192.927000,222.489000,191.927000,223.499000,191.344000,167.100000,192.344000,168.090000,193.344000,167.079000
+
+13.000000,7.000000, 8.000000,15.000000, 16.000000,2.000000, 17.000000,13.000000, 5.000000,10.000000, 19.000000,17.000000, 13.000000,7.000000
+
+10.000000,6.000000, 16.000000,4.000000, 0.000000,10.000000, 14.000000,10.000000, 9.000000,5.000000, 5.000000,15.000000, 10.000000,6.000000
+
+2.000000,18.000000, 14.000000,11.000000, 2.000000,14.000000, 5.000000,19.000000, 14.000000,19.000000, 2.000000,1.000000, 2.000000,18.000000
+
+18.000000,14.000000, 18.000000,6.000000, 18.000000,18.000000, 3.000000,9.000000, 19.000000,10.000000, 3.000000,19.000000, 18.000000,14.000000
+
+0.000000,14.000000, 5.000000,11.000000, 19.000000,5.000000, 0.000000,16.000000, 12.000000,13.000000, 0.000000,14.000000, 0.000000,14.000000
+
+6.000000,9.000000, 4.000000,7.000000, 11.000000,14.000000, 4.000000,10.000000, 11.000000,8.000000, 9.000000,15.000000, 6.000000,9.000000
+
+15.000000,4.000000, 15.000000,3.000000, 11.000000,13.000000, 12.000000,4.000000, 19.000000,5.000000, 6.000000,9.000000, 15.000000,4.000000
+
+4.000000,2.000000, 11.000000,8.000000, 19.000000,19.000000, 1.000000,18.000000, 19.000000,0.000000, 15.000000,15.000000, 4.000000,2.000000
+
+7.000000,14.000000, 18.000000,6.000000, 8.000000,2.000000, 14.000000,14.000000, 4.000000,8.000000, 9.000000,11.000000, 7.000000,14.000000
+
+16.000000,8.000000, 15.000000,9.000000, 9.000000,17.000000, 9.000000,16.000000, 4.000000,3.000000, 8.000000,16.000000, 16.000000,8.000000
+
+11.000000,10.000000, 12.000000,10.000000, 11.000000,2.000000, 7.000000,4.000000, 5.000000,13.000000, 11.000000,10.000000, 11.000000,10.000000
+
+17.000000,1.000000, 2.000000,15.000000, 17.000000,17.000000, 7.000000,7.000000, 16.000000,19.000000, 3.000000,18.000000, 7.000000,0.000000, 7.000000,0.000000, 6.000000,4.000000, 2.000000,1.000000, 4.000000,2.000000, 7.000000,16.000000, 11.000000,16.000000, 7.000000,3.000000, 11.000000,16.000000, 5.000000,9.000000, 18.000000,8.000000, 4.000000,15.000000, 5.000000,11.000000, 17.000000,1.000000
+
+10.000000,8.000000, 12.000000,3.000000, 10.000000,8.000000, 10.000000,19.000000, 2.000000,8.000000, 16.000000,11.000000, 10.000000,8.000000
+
+10.000000,10.000000, 13.000000,11.000000, 18.000000,2.000000, 13.000000,11.000000, 11.000000,10.000000, 10.000000,14.000000, 10.000000,10.000000
+
+8.000000,13.000000, 8.000000,7.000000, 12.000000,19.000000, 8.000000,8.000000, 8.000000,7.000000, 8.000000,2.000000, 8.000000,13.000000
+
+//1.000000,7.000000, 12.000000,16.000000, 3.000000,4.000000, 16.000000,18.000000, 11.000000,3.000000, 16.000000,18.000000, 2.000000,4.000000, 11.000000,4.000000, 11.000000,16.000000, 1.000000,7.000000
+
+1.000000,0.000000, 18.000000,13.000000, 0.000000,4.000000, 4.000000,6.000000, 16.000000,15.000000, 4.000000,3.000000, 4.000000,16.000000, 1.000000,0.000000
+
+17.000000,17.000000, 7.000000,12.000000, 1.000000,17.000000, 8.000000,17.000000, 15.000000,15.000000, 17.000000,12.000000, 12.000000,15.000000, 5.000000,11.000000, 9.000000,13.000000, 15.000000,18.000000, 7.000000,8.000000, 17.000000,17.000000
+
+//4.000000,0.000000, 15.000000,2.000000, 1.000000,2.000000, 17.000000,9.000000, 11.000000,4.000000, 3.000000,2.000000, 4.000000,8.000000, 6.000000,12.000000, 18.000000,15.000000, 15.000000,2.000000, 4.000000,0.000000
+
+5.000000,14.000000, 7.000000,15.000000, 9.000000,15.000000, 5.000000,16.000000, 12.000000,2.000000, 7.000000,12.000000, 5.000000,11.000000, 10.000000,9.000000, 5.000000,4.000000, 11.000000,18.000000, 9.000000,8.000000, 5.000000,14.000000
+
+//1.000000,19.000000, 6.000000,5.000000, 12.000000,6.000000, 8.000000,5.000000, 6.000000,1.000000, 8.000000,5.000000, 2.000000,5.000000, 1.000000,19.000000,
+
+3.000000,18.000000, 0.000000,2.000000, 13.000000,0.000000, 1.000000,0.000000, 19.000000,19.000000, 2.000000,1.000000, 17.000000,0.000000, 3.000000,18.000000,
+
+12.000000,10.000000, 4.000000,19.000000, 10.000000,0.000000, 6.000000,19.000000, 4.000000,16.000000, 4.000000,19.000000, 0.000000,15.000000, 4.000000,16.000000, 11.000000,5.000000, 12.000000,10.000000,
+
+0.000000,2.000000, 9.000000,11.000000, 13.000000,8.000000, 8.000000,7.000000, 10.000000,15.000000, 16.000000,1.000000, 9.000000,11.000000, 8.000000,14.000000, 10.000000,11.000000, 0.000000,2.000000
+
+13.000000,11.000000, 5.000000,7.000000, 15.000000,15.000000, 0.000000,3.000000, 16.000000,17.000000, 3.000000,9.000000, 6.000000,6.000000, 5.000000,7.000000, 3.000000,6.000000, 13.000000,11.000000,
+
+6.000000,6.000000, 2.000000,5.000000, 15.000000,6.000000, 14.000000,8.000000, 10.000000,11.000000, 18.000000,3.000000, 10.000000,11.000000, 15.000000,1.000000, 15.000000,19.000000, 6.000000,6.000000,
+
+15.000000,15.000000, 14.000000,14.000000, 1.000000,19.000000, 19.000000,12.000000, 1.000000,19.000000, 16.000000,18.000000, 2.000000,17.000000, 14.000000,19.000000, 2.000000,14.000000, 15.000000,15.000000,
+
+17.000000,1.000000, 2.000000,14.000000, 19.000000,11.000000, 18.000000,11.000000, 4.000000,16.000000, 10.000000,11.000000, 8.000000,16.000000, 12.000000,12.000000, 11.000000,14.000000, 17.000000,1.000000,
+
+17.000000,4.000000, 18.000000,9.000000, 10.000000,1.000000, 18.000000,9.000000, 4.000000,12.000000, 14.000000,17.000000, 4.000000,1.000000, 5.000000,17.000000, 4.000000,3.000000, 17.000000,4.000000,
+
+6.000000,12.000000, 13.000000,1.000000, 10.000000,15.000000, 0.000000,1.000000, 12.000000,12.000000, 1.000000,2.000000, 14.000000,2.000000, 9.000000,10.000000, 10.000000,9.000000, 6.000000,12.000000,
+
+10.000000,2.000000, 1.000000,19.000000, 18.000000,10.000000, 5.000000,11.000000, 13.000000,3.000000, 16.000000,12.000000, 13.000000,2.000000, 19.000000,4.000000, 12.000000,16.000000, 10.000000,2.000000,
+
+15.000000,18.000000, 9.000000,4.000000, 17.000000,19.000000, 8.000000,2.000000, 12.000000,14.000000, 16.000000,4.000000, 17.000000,11.000000, 1.000000,13.000000, 16.000000,8.000000, 15.000000,18.000000,
+
+0.000000,1.000000, 3.000000,5.000000, 6.000000,18.000000, 8.000000,10.000000, 2.000000,9.000000, 12.000000,13.000000, 17.000000,0.000000, 3.000000,10.000000, 16.000000,1.000000, 0.000000,1.000000,
+
+2.000000,5.000000, 5.000000,12.000000, 11.000000,2.000000, 1.000000,19.000000, 6.000000,5.000000, 17.000000,1.000000, 8.000000,0.000000, 14.000000,10.000000, 2.000000,5.000000
+
+12.000000,17.000000, 14.000000,7.000000, 12.000000,17.000000, 15.000000,9.000000, 3.000000,8.000000, 15.000000,2.000000, 13.000000,13.000000, 12.000000,17.000000,
+
+16.000000,9.000000, 12.000000,17.000000, 9.000000,7.000000, 6.000000,14.000000, 10.000000,10.000000, 0.000000,18.000000, 19.000000,9.000000, 2.000000,11.000000, 16.000000,9.000000,
+
+2.000000,11.000000, 8.000000,4.000000, 5.000000,15.000000, 19.000000,7.000000, 1.000000,4.000000, 11.000000,15.000000, 6.000000,0.000000, 10.000000,13.000000, 15.000000,0.000000, 5.000000,7.000000, 2.000000,11.000000,
+
+14.000000,16.000000, 13.000000,3.000000, 13.000000,7.000000, 13.000000,4.000000, 4.000000,19.000000, 18.000000,3.000000, 3.000000,6.000000, 14.000000,16.000000
+
+1.000000,10.000000, 16.000000,11.000000, 5.000000,12.000000, 14.000000,12.000000, 1.000000,10.000000,
+
+3.000000,14.000000, 18.000000,13.000000, 0.000000,13.000000, 17.000000,15.000000, 3.000000,14.000000
+
+113.978891,188.283650, 114.049102,188.354061, 114.028390,188.311950, 140.621311,218.434785, 113.925508,188.451788, 114.028390,188.311950, 114.038094,188.325206, 107.079712,223.213808, 113.978891,188.283650
+
+149.124266,243.836328, 149.130825,243.837775, 140.462458,289.372639, 149.124266,243.836328, 174.003258,285.357827, 149.081172,244.062877, 80.895955,240.414297, 149.081172,244.062877, 149.124266,243.836328,
+
+29.389873,51.154090, 34.288345,59.861919, 29.364091,51.189091, 29.379701,51.200590, 15.480095,51.026265, 27.327001,60.472279, 29.361537,51.172254, 29.379701,51.200590, 29.389873,51.154090,
+
+23.402194,41.096844, 23.406381,41.132628, 34.465476,40.926093, 32.678424,45.608817, 23.389763,41.132654, 23.414672,41.106110, 21.719863,48.560185, 23.402194,41.096844,
+
+30.951431,53.763363, 30.939362,53.811917, 41.512607,48.598876, 25.528987,61.504482, 30.925582,53.773491, 30.940776,53.812269, 28.790798,63.563660, 30.921651,53.782489, 30.951431,53.763363,
+
+40.932299,70.331769, 33.882179,80.568702, 40.952469,70.382541, 33.906555,80.507737, 38.158710,83.200483, 40.932299,70.331769
+
+37.291393,64.307940, 47.917795,74.087993, 37.307928,64.317812, 51.927660,71.285431, 34.739208,76.059738, 37.291393,64.307940
+
+97.604218,162.191009, 81.519079,186.128039, 97.652864,162.308413, 81.609840,186.099213, 67.592573,182.092187, 91.591892,192.217346, 97.604218,162.191009
+
+135.877528,222.962402, 135.792476,222.983126, 195.753543,234.556614, 135.814790,223.162055, 135.936349,222.995801, 135.947907,223.011493, 127.815883,264.424834, 135.877528,222.962402,
+
+140.157057,229.713961, 140.069413,229.735364, 201.872134,241.630761, 140.092507,229.919758, 140.217696,229.748350, 140.229617,229.764516, 131.871019,272.449909, 140.157057,229.713961
+
+193.086469,312.646765, 108.189184,287.648923, 193.023897,312.936441, 237.949462,362.828686, 192.949279,312.891753, 266.364944,345.116804, 192.999843,312.928266, 192.913653,312.765449, 193.086469,312.646765
+
+247.422415,396.899455, 247.217314,397.163923, 247.574394,397.118778, 142.852727,414.776640, 288.712650,464.492402, 247.228121,397.184104, 135.733401,392.254819, 233.734466,471.311838, 247.203092,397.051434, 247.355072,397.270757, 247.422415,396.899455,
+
+330.399757,524.281800, 330.600976,524.476466, 323.970137,422.844875, 330.540537,524.358965, 406.928779,607.813936, 330.568526,524.395792, 359.346715,616.206998, 330.399757,524.281800,
+
+304.198844,484.203463, 173.561956,487.759775, 436.078782,489.984415, 374.610016,561.755629, 304.198844,484.203463, 354.969812,566.668108, 304.118093,484.657714, 304.198844,484.203463,
+
+216.327573,348.779345, 182.153126,401.142486, 216.158855,348.851925, 194.442338,411.748517, 216.134810,348.912273, 216.267739,349.105035, 216.327573,348.779345,
+
+40.510823,69.635522, 40.490212,69.696716, 38.684855,81.300842, 40.530783,69.685790, 47.264190,81.490170, 40.497275,69.699095, 37.801306,82.350057, 37.762746,82.375070, 40.472263,69.660535, 40.510823,69.635522
+
+/
diff --git a/tests/auto/qtessellator/simple.h b/tests/auto/qtessellator/simple.h
new file mode 100644
index 0000000..aef0638
--- /dev/null
+++ b/tests/auto/qtessellator/simple.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** 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 SIMPLEDATA_H
+#define SIMPLEDATA_H
+
+#include "sample_data.h"
+
+FullData simpleData();
+
+#endif
diff --git a/tests/auto/qtessellator/testtessellator.cpp b/tests/auto/qtessellator/testtessellator.cpp
new file mode 100644
index 0000000..bd2795c
--- /dev/null
+++ b/tests/auto/qtessellator/testtessellator.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** 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 <testtessellator.h>
+#include <private/qtessellator_p.h>
+
+#include "math.h"
+
+class TestTessellator : public QTessellator
+{
+public:
+ QVector<XTrapezoid> *traps;
+ void addTrap(const Trapezoid &trap);
+};
+
+void TestTessellator::addTrap(const Trapezoid &trap)
+{
+ XTrapezoid xtrap;
+ xtrap.top = Q27Dot5ToXFixed(trap.top);
+ xtrap.bottom = Q27Dot5ToXFixed(trap.bottom);
+ xtrap.left.p1.x = Q27Dot5ToXFixed(trap.topLeft->x);
+ xtrap.left.p1.y = Q27Dot5ToXFixed(trap.topLeft->y);
+ xtrap.left.p2.x = Q27Dot5ToXFixed(trap.bottomLeft->x);
+ xtrap.left.p2.y = Q27Dot5ToXFixed(trap.bottomLeft->y);
+ xtrap.right.p1.x = Q27Dot5ToXFixed(trap.topRight->x);
+ xtrap.right.p1.y = Q27Dot5ToXFixed(trap.topRight->y);
+ xtrap.right.p2.x = Q27Dot5ToXFixed(trap.bottomRight->x);
+ xtrap.right.p2.y = Q27Dot5ToXFixed(trap.bottomRight->y);
+ traps->append(xtrap);
+}
+
+
+void test_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *points, int nPoints,
+ bool winding)
+{
+ TestTessellator t;
+ t.traps = traps;
+ t.setWinding(winding);
+ t.tessellate(points, nPoints);
+}
+
+
+void test_tessellate_polygon_convex(QVector<XTrapezoid> *traps, const QPointF *points, int nPoints,
+ bool winding)
+{
+ TestTessellator t;
+ t.traps = traps;
+ t.setWinding(winding);
+ t.tessellateConvex(points, nPoints);
+}
+
+
+void test_tessellate_polygon_rect(QVector<XTrapezoid> *traps, const QPointF *points, int nPoints,
+ bool winding)
+{
+ // 5 points per rect
+ Q_ASSERT(nPoints % 5 == 0);
+
+ TestTessellator t;
+ t.traps = traps;
+ t.setWinding(winding);
+ for (int i = 0; i < nPoints / 5; ++i) {
+ QPointF rectA = points[5*i];
+ QPointF rectB = points[5*i+1];
+ QPointF rectC = points[5*i+2];
+ QPointF rectD = points[5*i+3];
+
+ QPointF a = (rectA + rectD) * 0.5;
+ QPointF b = (rectB + rectC) * 0.5;
+
+ QPointF delta = rectA - rectD;
+
+ qreal width = sqrt(delta.x() * delta.x() + delta.y() * delta.y());
+
+ t.tessellateRect(a, b, width);
+ }
+}
diff --git a/tests/auto/qtessellator/testtessellator.h b/tests/auto/qtessellator/testtessellator.h
new file mode 100644
index 0000000..089f094
--- /dev/null
+++ b/tests/auto/qtessellator/testtessellator.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** 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 TESTTESSELLATOR_H
+#define TESTTESSELLATOR_H
+
+#include <QVector>
+#include <QPointF>
+#include "XrenderFake.h"
+
+typedef void (*tessellate_function)(QVector<XTrapezoid> *traps, const QPointF *points, int nPoints,
+ bool winding);
+
+void test_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *points, int nPoints,
+ bool winding);
+
+void test_tessellate_polygon_convex(QVector<XTrapezoid> *traps, const QPointF *points, int nPoints,
+ bool winding);
+
+void test_tessellate_polygon_rect(QVector<XTrapezoid> *traps, const QPointF *points, int nPoints,
+ bool winding);
+#endif
diff --git a/tests/auto/qtessellator/tst_tessellator.cpp b/tests/auto/qtessellator/tst_tessellator.cpp
new file mode 100644
index 0000000..8958ac3
--- /dev/null
+++ b/tests/auto/qtessellator/tst_tessellator.cpp
@@ -0,0 +1,378 @@
+/****************************************************************************
+**
+** 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 <QtTest/QtTest>
+#include <QCoreApplication>
+#include <QVector>
+#include <qdebug.h>
+#include <qpolygon.h>
+#include <qmatrix.h>
+
+#include "oldtessellator.h"
+#include "testtessellator.h"
+#include "utils.h"
+#include "simple.h"
+#include "arc.h"
+
+#include "math.h"
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QTessellator : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QTessellator() {
+ }
+
+private slots:
+ void testStandardSet();
+ void testRandom();
+ void testArc();
+ void testRects();
+ void testConvexRects();
+ void testConvex();
+};
+
+
+QPointF creatPoint()
+{
+ qreal x = int(20.0 * (rand() / (RAND_MAX + 1.0)));
+ qreal y = int(20.0 * (rand() / (RAND_MAX + 1.0)));
+ return QPointF(x, y);
+}
+
+bool test(const QPointF *pg, int pgSize, bool winding, tessellate_function tessellate = test_tesselate_polygon, qreal maxDiff = 0.005)
+{
+ QVector<XTrapezoid> traps;
+ qreal area1 = 0;
+ qreal area2 = 0;
+
+ old_tesselate_polygon(&traps, pg, pgSize, winding);
+ area1 = compute_area_for_x(traps);
+
+ traps.clear();
+
+ tessellate(&traps, pg, pgSize, winding);
+ area2 = compute_area_for_x(traps);
+
+ bool result = (qAbs(area2 - area1) < maxDiff);
+ if (!result && area1)
+ result = (qAbs(area1 - area2)/area1 < maxDiff);
+
+ if (!result)
+ qDebug() << area1 << area2;
+
+ return result;
+}
+
+
+void simplifyTestFailure(QVector<QPointF> failure, bool winding)
+{
+ int i = 1;
+ while (i < failure.size() - 1) {
+ QVector<QPointF> t = failure;
+ t.remove(i);
+ if (test(t.data(), t.size(), winding)) {
+ ++i;
+ continue;
+ }
+ failure = t;
+ i = 1;
+ }
+
+ for (int x = 0; x < failure.size(); ++x) {
+ fprintf(stderr, "%lf,%lf, ", failure[x].x(), failure[x].y());
+ }
+ fprintf(stderr, "\n\n");
+}
+
+void tst_QTessellator::testStandardSet()
+{
+ QVector<FullData> sampleSet;
+ sampleSet.append(simpleData());
+
+ foreach(FullData data, sampleSet) {
+ for (int i = 0; i < data.size(); ++i) {
+ if (!test(data[i].data(), data[i].size(), false)) {
+ simplifyTestFailure(data[i], false);
+ QCOMPARE(true, false);
+ }
+ if (!test(data[i].data(), data[i].size(), true)) {
+ simplifyTestFailure(data[i], true);
+ QCOMPARE(true, false);
+ }
+ }
+ }
+}
+
+
+
+void fillRandomVec(QVector<QPointF> &vec)
+{
+ int size = vec.size(); --size;
+ for (int i = 0; i < size; ++i) {
+ vec[i] = creatPoint();
+ }
+ vec[size] = vec[0];
+}
+
+void tst_QTessellator::testRandom()
+{
+ int failures = 0;
+ for (int i = 5; i < 12; ++i) {
+ QVector<QPointF> vec(i);
+#ifdef QT_ARCH_ARM
+ int k = 200;
+#else
+ int k = 5000;
+#endif
+ while (--k) {
+ fillRandomVec(vec);
+ if (!test(vec.data(), vec.size(), false)) {
+ simplifyTestFailure(vec, false);
+ ++failures;
+ }
+ if (!test(vec.data(), vec.size(), true)) {
+ simplifyTestFailure(vec, true);
+ ++failures;
+ }
+ }
+ }
+ QVERIFY(failures == 0);
+}
+
+
+// we need a higher threshold for failure here than in the above tests, as this basically draws
+// a very thin outline, where the discretization in the new tesselator shows
+bool test_arc(const QPolygonF &poly, bool winding)
+{
+ QVector<XTrapezoid> traps;
+ qreal area1 = 0;
+ qreal area2 = 0;
+
+ old_tesselate_polygon(&traps, poly.data(), poly.size(), winding);
+ area1 = compute_area_for_x(traps);
+
+ traps.clear();
+
+ test_tesselate_polygon(&traps, poly.data(), poly.size(), winding);
+ area2 = compute_area_for_x(traps);
+
+ bool result = (area2 - area1 < .02);
+ if (!result && area1)
+ result = (qAbs(area1 - area2)/area1 < .02);
+
+ return result;
+}
+
+
+
+void tst_QTessellator::testArc()
+{
+ FullData arc = arcData();
+
+ QMatrix mat;
+#ifdef QT_ARCH_ARM
+ const int stop = 5;
+#else
+ const int stop = 1000;
+#endif
+ for (int i = 0; i < stop; ++i) {
+ mat.rotate(.01);
+ mat.scale(.99, .99);
+ QPolygonF poly = arc.at(0);
+ QPolygonF vec = poly * mat;
+ QVERIFY(test_arc(vec, true));
+ QVERIFY(test_arc(vec, false));
+ }
+}
+
+static bool isConvex(const QVector<QPointF> &v)
+{
+ int nPoints = v.size() - 1;
+
+ qreal lastCross = 0;
+ for (int i = 0; i < nPoints; ++i) {
+ QPointF a = v[i];
+ QPointF b = v[(i + 1) % nPoints];
+
+ QPointF d1 = b - a;
+
+ for (int j = 0; j < nPoints; ++j) {
+ if (j == i || j == i + 1)
+ continue;
+
+ QPointF p = v[j];
+ QPointF d2 = p - a;
+
+ qreal cross = d1.x() * d2.y() - d1.y() * d2.x();
+
+ if (!qFuzzyCompare(cross + 1, 1)
+ && !qFuzzyCompare(cross + 1, 1)
+ && (lastCross > 0) != (cross > 0))
+ return false;
+
+ lastCross = cross;
+ }
+ }
+
+ return true;
+}
+
+static void fillRectVec(QVector<QPointF> &v)
+{
+ int numRects = v.size() / 5;
+
+ int first = 0;
+ v[first++] = QPointF(0, 0);
+ v[first++] = QPointF(10, 0);
+ v[first++] = QPointF(10, 10);
+ v[first++] = QPointF(0, 10);
+ v[first++] = QPointF(0, 0);
+
+ v[first++] = QPointF(0, 0);
+ v[first++] = QPointF(2, 2);
+ v[first++] = QPointF(4, 0);
+ v[first++] = QPointF(2, -2);
+ v[first++] = QPointF(0, 0);
+
+ v[first++] = QPointF(0, 0);
+ v[first++] = QPointF(4, 4);
+ v[first++] = QPointF(6, 2);
+ v[first++] = QPointF(2, -2);
+ v[first++] = QPointF(0, 0);
+
+ for (int i = first / 5; i < numRects; ++i) {
+ QPointF a = creatPoint();
+ QPointF b = creatPoint();
+
+ QPointF delta = a - b;
+ QPointF perp(delta.y(), -delta.x());
+
+ perp *= ((int)(20.0 * rand() / (RAND_MAX + 1.0))) / 20.0;
+
+ int j = 5 * i;
+ v[j++] = a + perp;
+ v[j++] = a - perp;
+ v[j++] = b - perp;
+ v[j++] = b + perp;
+ v[j++] = a + perp;
+ }
+}
+
+#ifdef QT_ARCH_ARM
+const int numRects = 500;
+#else
+const int numRects = 5000;
+#endif
+
+void tst_QTessellator::testConvexRects()
+{
+ return;
+ int failures = 0;
+ QVector<QPointF> vec(numRects * 5);
+ fillRectVec(vec);
+ for (int rect = 0; rect < numRects; ++rect) {
+ QVector<QPointF> v(5);
+ for (int i = 0; i < 5; ++i)
+ v[i] = vec[5 * rect + i];
+ if (!test(v.data(), v.size(), false, test_tessellate_polygon_convex)) {
+ simplifyTestFailure(v, false);
+ ++failures;
+ }
+ if (!test(v.data(), v.size(), true, test_tessellate_polygon_convex)) {
+ simplifyTestFailure(v, true);
+ ++failures;
+ }
+ }
+ QVERIFY(failures == 0);
+}
+
+void tst_QTessellator::testConvex()
+{
+ int failures = 0;
+ for (int i = 4; i < 10; ++i) {
+ QVector<QPointF> vec(i);
+ int k = 5000;
+ while (k--) {
+ fillRandomVec(vec);
+ if (!isConvex(vec))
+ continue;
+ if (!test(vec.data(), vec.size(), false, test_tessellate_polygon_convex)) {
+ simplifyTestFailure(vec, false);
+ ++failures;
+ }
+ if (!test(vec.data(), vec.size(), true, test_tessellate_polygon_convex)) {
+ simplifyTestFailure(vec, true);
+ ++failures;
+ }
+ }
+ }
+ QVERIFY(failures == 0);
+}
+
+
+void tst_QTessellator::testRects()
+{
+ int failures = 0;
+ QVector<QPointF> vec(numRects * 5);
+ fillRectVec(vec);
+ for (int rect = 0; rect < numRects; ++rect) {
+ QVector<QPointF> v(5);
+ for (int i = 0; i < 5; ++i)
+ v[i] = vec[5 * rect + i];
+ if (!test(v.data(), v.size(), false, test_tessellate_polygon_rect, 0.05)) {
+ simplifyTestFailure(v, false);
+ ++failures;
+ }
+ if (!test(v.data(), v.size(), true, test_tessellate_polygon_rect, 0.05)) {
+ simplifyTestFailure(v, true);
+ ++failures;
+ }
+ }
+ QVERIFY(failures == 0);
+}
+
+
+QTEST_MAIN(tst_QTessellator)
+#include "tst_tessellator.moc"
diff --git a/tests/auto/qtessellator/utils.cpp b/tests/auto/qtessellator/utils.cpp
new file mode 100644
index 0000000..8a9dc1e
--- /dev/null
+++ b/tests/auto/qtessellator/utils.cpp
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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 "utils.h"
+
+#include <assert.h>
+#include <qglobal.h>
+
+#include <qnum.h>
+
+#define FloatToXFixed(i) (int)((i) * 65536)
+#define IntToXFixed(i) ((i) << 16)
+
+static double compute_x_at(XFixed y, XPointFixed p1, XPointFixed p2)
+{
+ double d = XFixedToDouble(p2.x - p1.x);
+ return
+ XFixedToDouble(p1.x) + d*XFixedToDouble(y - p1.y)/XFixedToDouble(p2.y - p1.y);
+}
+
+double compute_area(XTrapezoid *trap)
+{
+ double x1 = compute_x_at(trap->top, trap->left.p1, trap->left.p2);
+ double x2 = compute_x_at(trap->top, trap->right.p1, trap->right.p2);
+ double x3 = compute_x_at(trap->bottom, trap->left.p1, trap->left.p2);
+ double x4 = compute_x_at(trap->bottom, trap->right.p1, trap->right.p2);
+
+ double top = XFixedToDouble(trap->top);
+ double bottom = XFixedToDouble(trap->bottom);
+ double h = bottom - top;
+
+ double top_base = x2 - x1;
+ double bottom_base = x4 - x3;
+
+ if ((top_base < 0 && bottom_base > 0)
+ || (top_base > 0 && bottom_base < 0)) {
+ double y0 = top_base*h/(top_base - bottom_base) + top;
+ double area = qAbs(top_base * (y0 - top) / 2.);
+ area += qAbs(bottom_base * (bottom - y0) /2.);
+ return area;
+ }
+
+
+ return 0.5 * h * qAbs(top_base + bottom_base);
+}
+
+double compute_area_for_x(const QVector<XTrapezoid> &traps)
+{
+ double area = 0;
+
+ for (int i = 0; i < traps.size(); ++i) {
+ XTrapezoid trap = traps[i];
+ area += compute_area(&trap);
+ }
+ return area;
+}
diff --git a/tests/auto/qtessellator/utils.h b/tests/auto/qtessellator/utils.h
new file mode 100644
index 0000000..bc27853
--- /dev/null
+++ b/tests/auto/qtessellator/utils.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** 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 UTILS_H
+#define UTILS_H
+
+#include <QVector>
+#include <QPointF>
+#include <QDebug>
+#include "XrenderFake.h"
+
+double compute_area(XTrapezoid *trap);
+double compute_area_for_x(const QVector<XTrapezoid> &traps);
+
+QT_BEGIN_NAMESPACE
+Q_DECLARE_TYPEINFO(XTrapezoid, Q_PRIMITIVE_TYPE);
+QT_END_NAMESPACE
+
+#endif