Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.2.1
-
Ubuntu 14.04
Description
When rendering > 200 Lines on a canvas, zooming out (scale / a,d < 1) is fluid and fast as expected.
Zooming in (scale > 1) somehow gets incredibly slow (noticeable lag ~ 4 secs for rerendering) on a i7 machine with NVIDIA GPU etc.
Transforming the path by "hand" is no problem.
import QtQuick 2.0 Rectangle { width: 480 height: 480 Canvas { id: canvas anchors.fill: parent property double scale: 1 property var ctx; onAvailableChanged: { if(available) { console.log("canvas available") ctx = canvas.getContext('2d'); console.log(ctx) } } MouseArea { id: mousearea property int hitrad: 5; anchors.fill: parent onWheel: { if(wheel.angleDelta.y > 0) { canvas.scale += canvas.scale * 0.2; } else { canvas.scale -= canvas.scale * 0.2; } canvas.ctx.clearRect(0, 0, width, height); canvas.requestPaint(); } } onPaint: { ctx.reset(); var distance = ctx.lineWidth * 4; ctx.scale(scale,scale); // Using connected paths is slow: ctx.beginPath(); ctx.moveTo(0, i * distance); for (var i = 0; i < 200; ++i) { ctx.lineTo(300 + Math.random() * 100, i * distance + 100); ctx.lineTo(0 + Math.random() * 100, i * distance); } ctx.stroke(); // While creating individual paths isn't: // for (var i = 0; i < 200; ++i) { // ctx.beginPath(); // ctx.moveTo(300 + Math.random() * 100, i * distance + 100); // ctx.lineTo(0 + Math.random() * 100, i * distance); // ctx.stroke(); // } } } }