WebKit Surface on SDL using Cairo directly instead of PNG?

Hello SDL Community!

am working on a software that renders WebKitGtk snapshots on top of VLC video using SDL (full source code here: https://github.com/jankammerath/iptvx). I am using WebKitGtk to create a cairo_surface out of which a PNG is generated. That PNG then is rendered as an SDL surface.

cairo_surface_t *surface = webkit_web_view_get_snapshot_finish(WEBKIT_WEB_VIEW(webview),res,&err);
    old_png_byte_data = png_byte_data;  
png_byte_data = g_byte_array_new();
overlay_data.data = png_byte_data->data;
overlay_data.length = png_byte_data->len;

Afterwards it is rendered in a window on top of VLC-generated video with the following lines.

SDL_RWops *overlay_rwops = SDL_RWFromMem(overlay_png_ref->data,overlay_png_ref->length);
overlay = IMG_LoadPNG_RW(overlay_rwops);
SDL_BlitSurface(overlay, NULL, screen, NULL);

Is it possible to render the cairo_surface_t directly without making a PNG out of it and are there any performance advantages with it?

Many thanks and best regards,


from https://cairographics.org/manual/cairo-cairo-surface-t.html, example 1, get data/width/height/stride of your cairo surface, and create your SDL_Surface or SDL_Texture with those information, for instance, with SDL_CreateRGBSurfaceWithFormatFrom() or SDL_UpdateTexture().