This worked and rendered correctly using the GPU, but the actual FPDF_RenderPageSkia() call was executed via CPU — the SkPicture was then drawn to the GPU surface afterward, which isn’t what I want.
So I changed my code to render directly to a GPU-backed canvas like this:
-----------------------------------------code begin---------------------------------------------------SkImageInfo info = SkImageInfo::Make(width, height, kUnknown_SkColorType, kPremul_SkAlphaType);
sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(grContext.get(), skgpu::Budgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorWHITE);
FPDF_RenderPageSkia(reinterpret_cast<FPDF_SKIA_CANVAS>(canvas), page, width, height);
-------------------------------------code end-----------------------------------------------------------
However, SkSurfaces::RenderTarget() returns nullptr in this case, so I can't get a valid GPU-backed SkCanvas.
My question is:
How can I create a valid GPU-backed SkSurface (and SkCanvas) that is compatible with FPDF_RenderPageSkia, so the rendering happens fully on the GPU instead of via CPU-recorded SkPicture?
Any guidance on the proper SkImageInfo configuration, or whether FPDF_RenderPageSkia supports GPU rendering directly, would be greatly appreciated.
Thank you!