summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2021-08-16 20:56:14 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2021-08-20 13:50:24 +0200
commit587fe1a95ad2789c2f284fb1384f19b7f5b09917 (patch)
tree1882236bbce224780887a9cf292e6aaab494b8f6 /tests/auto/other
parent7b14329d78c63ea8c7383b07c54399a3ff888ba0 (diff)
Improve lancelot test of dashed line painting
Add painting of sets of lines, both connected and unconnected, that go outside the device area. This prepares for fixes & improvements in the painting code. Pick-to: 6.2 6.1 5.15 Change-Id: I9cffc760524e9ade42362c9a04949270ac24180f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp25
-rw-r--r--tests/auto/other/lancelot/paintcommands.h1
-rw-r--r--tests/auto/other/lancelot/scripts/linedashes2.qps48
3 files changed, 70 insertions, 4 deletions
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index 9344c9a67d..b61f170f42 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -384,6 +384,10 @@ void PaintCommands::staticInit()
"^drawLine\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
"drawLine <x1> <y1> <x2> <y2>",
"drawLine 10.0 10.0 20.0 20.0");
+ DECL_PAINTCOMMAND("drawLines", command_drawLines,
+ "^drawLines\\s+\\[([\\w\\s\\-.]*)\\]$",
+ "drawLines <[ <l1x1> <l1y1> <l1x2> <l1y2> <l2x1> <l2y1> ... ]>",
+ "drawLines [ 10 10 50 10 50 20 10 20 ]");
DECL_PAINTCOMMAND("drawRect", command_drawRect,
"^drawRect\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)\\s+(-?[\\w.]*)$",
"drawRect <x> <y> <w> <h>",
@@ -441,7 +445,7 @@ void PaintCommands::staticInit()
"drawConvexPolygon <[ <x1> <y1> ... <xn> <yn> ]>",
"drawConvexPolygon [ 1 4 6 8 5 3 ]");
DECL_PAINTCOMMAND("drawPolyline", command_drawPolyline,
- "^drawPolyline\\s+\\[([\\w\\s]*)\\]$",
+ "^drawPolyline\\s+\\[([\\w\\s\\-.]*)\\]$",
"drawPolyline <[ <x1> <y1> ... <xn> <yn> ]>",
"drawPolyline [ 1 4 6 8 5 3 ]");
DECL_PAINTCOMMAND("drawText", command_drawText,
@@ -987,6 +991,25 @@ void PaintCommands::command_drawLine(QRegularExpressionMatch re)
}
/***************************************************************************************************/
+void PaintCommands::command_drawLines(QRegularExpressionMatch re)
+{
+ static QRegularExpression separators("\\s");
+ QStringList numbers = re.captured(1).split(separators, Qt::SkipEmptyParts);
+
+ QList<QLineF> array;
+ for (int i = 0; i + 3 < numbers.size(); i += 4) {
+ QPointF pt1(numbers.at(i).toFloat(), numbers.at(i + 1).toFloat());
+ QPointF pt2(numbers.at(i + 2).toFloat(), numbers.at(i + 3).toFloat());
+ array.append(QLineF(pt1, pt2));
+ }
+
+ if (m_verboseMode)
+ printf(" -(lance) drawLines(size=%zd)\n", size_t(array.size()));
+
+ m_painter->drawLines(array);
+}
+
+/***************************************************************************************************/
void PaintCommands::command_drawPath(QRegularExpressionMatch re)
{
if (m_verboseMode)
diff --git a/tests/auto/other/lancelot/paintcommands.h b/tests/auto/other/lancelot/paintcommands.h
index e9468b1f42..0f206884ab 100644
--- a/tests/auto/other/lancelot/paintcommands.h
+++ b/tests/auto/other/lancelot/paintcommands.h
@@ -191,6 +191,7 @@ private:
void command_drawEllipse(QRegularExpressionMatch re);
void command_drawImage(QRegularExpressionMatch re);
void command_drawLine(QRegularExpressionMatch re);
+ void command_drawLines(QRegularExpressionMatch re);
void command_drawPath(QRegularExpressionMatch re);
void command_drawPie(QRegularExpressionMatch re);
void command_drawPixmap(QRegularExpressionMatch re);
diff --git a/tests/auto/other/lancelot/scripts/linedashes2.qps b/tests/auto/other/lancelot/scripts/linedashes2.qps
index 1dc4fd310e..b9a4cb9566 100644
--- a/tests/auto/other/lancelot/scripts/linedashes2.qps
+++ b/tests/auto/other/lancelot/scripts/linedashes2.qps
@@ -111,8 +111,9 @@ translate 0 780
repeat_block vertical
resetMatrix
-translate 40 400
-setPen 0xffff0000 5 dashdotline flatcap
+translate 20 380
+setPen 0xffff00ff 5 dashdotline flatcap
+begin_block offset
pen_setDashPattern [1 1 4 1 1 4]
pen_setDashOffset -4
drawLine 0 0 300 0
@@ -146,9 +147,50 @@ drawLine 0 0 300 0
translate 0 8
pen_setDashOffset 16
drawLine 0 0 300 0
+end_block offset
+
+resetMatrix
+translate 420 380
+setPen 0xffff00ff 5 dashdotline roundcap
+repeat_block offset
resetMatrix
setPen black 3 dashdotline
pen_setCosmetic true
translate 0 -150
-drawLine 500 160 500 410 \ No newline at end of file
+drawLine 500 160 500 410
+
+resetMatrix
+translate 300 480
+setPen blue 0
+
+begin_block clip_lines
+pen_setDashPattern [ 20 4 5 4 1 4 ]
+pen_setDashOffset 26.0
+drawLines [0 0 1000000 10 1000000 10 -1000000 20 -1000000 20 0 30]
+end_block clip_lines
+
+translate 0 45
+setPen blue 5
+repeat_block clip_lines
+
+translate 0 45
+setPen blue 5 SolidLine RoundCap
+repeat_block clip_lines
+
+translate 0 45
+setPen green 0
+
+begin_block clip_poly
+pen_setDashPattern [ 20 4 5 4 1 4 ]
+pen_setDashOffset 26.0
+drawPolyline [0 0 1000000 10 -1000000 20 0 30]
+end_block clip_poly
+
+translate 0 45
+setPen green 5
+repeat_block clip_poly
+
+translate 0 45
+setPen green 5 SolidLine RoundCap
+repeat_block clip_poly