From 4aba0caaadfd3e7cde30cefa54f61ddac4a6cd7a Mon Sep 17 00:00:00 2001 From: Jinny You Date: Fri, 10 Jan 2025 16:26:40 +0800 Subject: [PATCH] wasm: fix build issue in sw/wg build only case - resolved EMSCRIPTEN_WEBGL_CONTEXT_HANDLE declaration problem. - currentContext() should be also called after `mContext` is initialized. --- src/bindings/wasm/tvgWasmLottieAnimation.cpp | 2 +- src/renderer/gl_engine/tvgGlRenderer.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bindings/wasm/tvgWasmLottieAnimation.cpp b/src/bindings/wasm/tvgWasmLottieAnimation.cpp index fee1e9b9..693d20dd 100644 --- a/src/bindings/wasm/tvgWasmLottieAnimation.cpp +++ b/src/bindings/wasm/tvgWasmLottieAnimation.cpp @@ -188,7 +188,7 @@ struct TvgWgEngine : TvgEngineMethod struct TvgGLEngine : TvgEngineMethod { - EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = 0; + intptr_t context = 0; ~TvgGLEngine() override { #ifdef THORVG_GL_RASTER_SUPPORT diff --git a/src/renderer/gl_engine/tvgGlRenderer.cpp b/src/renderer/gl_engine/tvgGlRenderer.cpp index 675e56fa..29f75975 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.cpp +++ b/src/renderer/gl_engine/tvgGlRenderer.cpp @@ -797,7 +797,7 @@ bool GlRenderer::target(void* context, int32_t id, uint32_t w, uint32_t h) //assume the context zero is invalid if (!context || id == GL_INVALID_VALUE || w == 0 || h == 0) return false; - currentContext(); + if (mContext) currentContext(); flush(); @@ -808,6 +808,8 @@ bool GlRenderer::target(void* context, int32_t id, uint32_t w, uint32_t h) mContext = context; mTargetFboId = static_cast(id); + currentContext(); + mRootTarget = GlRenderTarget(surface.w, surface.h); mRootTarget.setViewport({0, 0, static_cast(surface.w), static_cast(surface.h)}); mRootTarget.init(mTargetFboId);