Possible CanvasKit Issue?

16 views
Skip to first unread message

Bruno Nicoletti

unread,
Nov 11, 2024, 8:03:49 AMNov 11
to skia-discuss
Hi,

My intention is to write a C++ library, with minimal js + html wrappers that will allow a C++ program to execute Skia code in a browser when compiled to WASM. I’m basing my code on the existing canvaskit code.

I've come across something I'm not quite sure of. Several js files in Modules/canvaskit reference `this._context`, where ‘this’ is the CanvasKit module. For example `webgl.js`, which has several calls that set the current WebGL context based on this value. However, `this._context` is never set. Am I missing something or is this a bug of some form?

Thanks

Bruno

Данил Буланов

unread,
Nov 11, 2024, 8:20:27 AMNov 11
to skia-discuss
In case of the webgl.js file, this refers not to the wasm Module, it refers to the this of the js function. It means, that when you call function canvas.readPixels() this == canvas, or surface.makeImageSnaphost() this == surface

So this _context field is set for surface in this method for instance https://skia.googlesource.com/skia/+/refs/heads/main/modules/canvaskit/webgl.js#129
And you can also have a look at the surface.getCanvas() method, the _context is set there too https://skia.googlesource.com/skia/+/refs/heads/main/modules/canvaskit/interface.js#1005

понедельник, 11 ноября 2024 г. в 16:03:49 UTC+3, bruno.j....@gmail.com:

Bruno Nicoletti

unread,
Nov 11, 2024, 8:54:33 AMNov 11
to skia-discuss
Thanks for the reply. 

I figured that about 10 minutes after I posted the question and wasn't able to delete it. Sorry to have bothered you all.
Reply all
Reply to author
Forward
0 new messages