diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2015-10-13 13:50:34 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2015-10-13 11:18:44 +0000 |
commit | 1cff990cb387d3e782db198e83e76d766cbabaa4 (patch) | |
tree | 9ee218744c45b085cdc4498d0f81f8759b2f9dec /src/virtualkeyboard/styles | |
parent | 924e99480a67fe40a302cd55890aaffb6df20e32 (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')
-rw-r--r-- | src/virtualkeyboard/styles/TraceCanvas.qml | 10 | ||||
-rw-r--r-- | src/virtualkeyboard/styles/TraceUtils.js | 9 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/virtualkeyboard/styles/TraceCanvas.qml b/src/virtualkeyboard/styles/TraceCanvas.qml index e5670ec1..b7ad547a 100644 --- a/src/virtualkeyboard/styles/TraceCanvas.qml +++ b/src/virtualkeyboard/styles/TraceCanvas.qml @@ -113,6 +113,8 @@ Canvas { property int __renderPos + property bool __renderingEnabled + /*! Renders smoothed line with round corners. This function is incremental and renders only the new part added to the Trace. @@ -125,8 +127,14 @@ Canvas { onTraceChanged: if (trace === null && autoDestroy) destroy(autoDestroyDelay) + onAvailableChanged: { + __renderingEnabled = available + if (__renderingEnabled) + requestAnimationFrame(renderFunction) + } + Connections { - target: trace ? trace : null + target: canvas.__renderingEnabled && trace ? trace : null onLengthChanged: if (renderFunction) canvas.requestAnimationFrame(renderFunction) onFinalChanged: if (renderFunction) canvas.requestAnimationFrame(renderFunction) } 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 } |