aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/styles/TraceUtils.js
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-10-13 13:50:34 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2015-10-13 11:18:44 +0000
commit1cff990cb387d3e782db198e83e76d766cbabaa4 (patch)
tree9ee218744c45b085cdc4498d0f81f8759b2f9dec /src/virtualkeyboard/styles/TraceUtils.js
parent924e99480a67fe40a302cd55890aaffb6df20e32 (diff)
Fix drawing errors in HWR
Multiple issues were identified in trace rendering: 1. quadraticCurveTo() method does not move the current position to endpoint in all cases. This causes a rendering glitch in situations where the line turns back sharply on x or y axis. The correct position is now ensured by the following moveTo() call. 2. Although this only was happening when running test cases, sometimes the trace rendering was started before the style attributes were applied to the drawing context. Now the start of trace rendering is delayed until the available becomes true. 3. The final lineTo() call was lacking prior moveTo() call. Task-number: QTRD-3680 Change-Id: I3ea311ee3a488a50f4c843a29d4c3cdd3942933a Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com>
Diffstat (limited to 'src/virtualkeyboard/styles/TraceUtils.js')
-rw-r--r--src/virtualkeyboard/styles/TraceUtils.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/virtualkeyboard/styles/TraceUtils.js b/src/virtualkeyboard/styles/TraceUtils.js
index 7e225d79..1624e891 100644
--- a/src/virtualkeyboard/styles/TraceUtils.js
+++ b/src/virtualkeyboard/styles/TraceUtils.js
@@ -57,19 +57,22 @@ function renderSmoothedLine(ctx, trace, renderPos) {
pt2 = points[i]
tp = Qt.point((pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2)
ctx.quadraticCurveTo(pt1.x, pt1.y, tp.x, tp.y)
+ ctx.moveTo(tp.x, tp.y)
}
+ ctx.stroke()
}
// Draw the remainder of the line
if (trace.isFinal) {
if (i < points.length) {
+ tp = points[i - 1]
+ ctx.beginPath()
+ ctx.moveTo(tp.x, tp.y)
tp = points[i++]
ctx.lineTo(tp.x, tp.y)
+ ctx.stroke()
}
}
- if (i > 1)
- ctx.stroke()
-
return renderPos + i - 1
}