From 069be41de3f0fc1cff427a4b53daf38f69a88833 Mon Sep 17 00:00:00 2001 From: Jay Shen Date: Fri, 3 Jul 2026 19:02:31 +0800 Subject: [PATCH] [webgpu] Use WebGPU context API for ThorVG targets Motivation: ThorVG now exposes WgCanvas::Context so callers can provide the WebGPU adapter together with the instance and device. The previous target overload left the adapter unset, which prevents the renderer from receiving the full WebGPU context it now tracks. Description: Pass {instance, adapter, device} through the new WgCanvas::target(context, ...) overload for both the main WebGPU window and the MultiCanvas offscreen render target. --- src/Example.h | 3 ++- src/MultiCanvas.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Example.h b/src/Example.h index bf2def5..d5a82ae 100644 --- a/src/Example.h +++ b/src/Example.h @@ -517,7 +517,8 @@ struct WgWindow : Window void resize() override { //Set the canvas target and draw on it. - verify(static_cast(canvas)->target(device, instance, surface, width, height, tvg::ColorSpace::ABGR8888S)); + tvg::WgCanvas::Context context = {instance, adapter, device}; + verify(static_cast(canvas)->target(context, surface, width, height, tvg::ColorSpace::ABGR8888)); } void refresh() override diff --git a/src/MultiCanvas.cpp b/src/MultiCanvas.cpp index b29347d..742e1d2 100644 --- a/src/MultiCanvas.cpp +++ b/src/MultiCanvas.cpp @@ -355,7 +355,8 @@ bool runWg() auto canvas = unique_ptr(tvg::WgCanvas::gen()); //Set the canvas target and draw on it. - tvgexam::verify(canvas->target(device, instance, renderTarget, SIZE, SIZE, tvg::ColorSpace::ABGR8888S, 1)); + tvg::WgCanvas::Context context = {instance, adapter, device}; + tvgexam::verify(canvas->target(context, renderTarget, SIZE, SIZE, tvg::ColorSpace::ABGR8888, 1)); content(canvas.get()); if (tvgexam::verify(canvas->draw())) { @@ -418,4 +419,4 @@ int main(int argc, char **argv) } return 0; -} \ No newline at end of file +}