[SailfishDevel] Drawing ShaderEffect to Canvas

Kimmo Lindholm Kimmo.Lindholm at eke.fi
Mon Oct 26 06:55:01 UTC 2015


Hi,

This relates to my Paint app. Doing tools to modify image, blur, invert, colorchannel swap etc. from area under your finger, like realtime brush.

Doing the bitmanipulation with javascript in canvas-onPaint works but even simple things like invert are utterly slow.

Then I decided to give ShaderEffect a try. I can successfully get image data under mouse from Canvas;

ShaderEffectSource {
    sourceItem: myCanvas
    sourceRect: Qt.rect(x,y,w,h)
...

The shader outputs the selected part of canvas nicely on screen with fragmentShader applied. Looks great.

Now I would like to draw the shader output to my 2nd canvas, which is later drawn on top of the actual canvas if accepted by user.

But putImageData(myShader,x,y) does not draw on canvas, and does not give any error. (other trials complain that ImageDataObject is invalid)

I managed to do this by calling myCanvas.grabToImage(...) and drawImage(result.url) but this is again as slow as the Javascript implementation.
Nothing that I can use on realtime-editing. This could be used after masking an area where to apply the shader.

If someone has any ideas?

-kimmo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20151026/80d3ba9d/attachment.html>


More information about the Devel mailing list