WASM SkSurface backend details

84 views
Skip to first unread message

craste...@gmail.com

unread,
May 15, 2024, 10:22:57 AM5/15/24
to skia-discuss
Is there an API for asking an SkSurface (or an SkCanvas) what kind of backend was implemented behind the scenes?  I have  case where Skia slows down significantly in browser when the display adapter is the generic (software I assume) display adapter driver.

I obviously can't do anything about that, but I would like to be able to query when and if it happens.

Brian Osman

unread,
May 15, 2024, 10:31:32 AM5/15/24
to skia-d...@googlegroups.com
You can tell if a surface (or canvas) is backed by the CPU implementation of Skia, by calling peekPixels(nullptr). That will return true for the CPU backend, and false for all others. If you want information about which specific GPU backend is used, there are additional queries you could make: SkSurface::recordingContext() will return a non-null GrRecordingContext* if the surface is Ganesh-based. Similarly, ::recorder() will return non-null if Graphite is being used.

Assuming it's Ganesh, then you can call GrRecordingContext::backend() to find out which 3D API is used. There is more information available in the "caps" object, but that's not public API.

On Wed, May 15, 2024 at 10:23 AM craste...@gmail.com <craste...@gmail.com> wrote:
Is there an API for asking an SkSurface (or an SkCanvas) what kind of backend was implemented behind the scenes?  I have  case where Skia slows down significantly in browser when the display adapter is the generic (software I assume) display adapter driver.

I obviously can't do anything about that, but I would like to be able to query when and if it happens.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/815168eb-016d-493c-a0c1-5cabb83a9f67n%40googlegroups.com.

Greg Daniel

unread,
May 15, 2024, 10:40:08 AM5/15/24
to skia-d...@googlegroups.com
Out of curiosity, how are you creating the SkSurfaces originally? Usually the user would know what backs the SkSurface since they are the ones creating it.

craste...@gmail.com

unread,
May 15, 2024, 11:25:04 AM5/15/24
to skia-discuss
Thanks guys! I will

I don't have the code in front of me at the moment, but you are right.  I make a WebGL context and then make an SkSurface using that number.
I found something useful when it comes to video card name: (for anyone searching this subject)

Reply all
Reply to author
Forward
0 new messages