Hi,
I would like to draw SkImages in my multithreaded application, these images are decoded in raster images in the application's main thread and drawn in a render thread in a GPU Ganesh context (openGL or Metal).
I use SkPictures in the main thread to generate draw commands and I playback these pictures in the render thread.
My question is: What is the best way to pass this images to the GPU without having the GrDirectContext in the main thread, and keep this images alive in the GPU memory during the whole ganesh context lifetime ?
First I did it naively using the raster image, it will upload the image when it has to be drawn, but it seems that Skia can also remove the image when its internal cache is full.
There is some function like the "SkImages::TextureFromImage" giving me access to the skgpu::Budgeted::kNo, but it needs a GrDirectContext to be used and I don't have it on my main thread.
The solution I found is to use the "SkImages::DeferredFromTextureGenerator" function, combined with "GrExternalTextureGenerator" and the
"SkImages::TextureFromImage, but I don't know how the lifetime of the texture is managed in a case like this.
But in this case I don't now what is the lifetime of my texture, should I remove it by hand ? Or is it the same as the image I uploaded to the GPU ?
In graphite the solution is straightforward as I can implement a "graphite::ImageProvider" and keep my images in this object.
If there is a similar solution I'd be happy to know.
Thanks