diff --git a/inc/thorvg.h b/inc/thorvg.h index 6a137b79..f51b2c81 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1724,6 +1724,7 @@ public: * @param[in] h The height (in pixels) of the raster image. * * @warning This API is experimental and not officially supported. It may be modified or removed in future versions. + * @warning Drawing on the main surface is currently not permitted. If the identifier (@p id) is set to @c 0, the operation will be aborted. * * @note Currently, this only allows the GL_RGBA8 color space format. * @note Experimental API diff --git a/src/renderer/gl_engine/tvgGlRenderer.cpp b/src/renderer/gl_engine/tvgGlRenderer.cpp index 3d7ffdb8..f83ec846 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.cpp +++ b/src/renderer/gl_engine/tvgGlRenderer.cpp @@ -57,7 +57,7 @@ bool GlRenderer::clear() bool GlRenderer::target(int32_t id, uint32_t w, uint32_t h) { - assert(w > 0 && h > 0); + if (id == GL_INVALID_VALUE || w == 0 || h == 0) return false; surface.stride = w; surface.w = w; @@ -70,6 +70,11 @@ bool GlRenderer::target(int32_t id, uint32_t w, uint32_t h) mTargetFboId = static_cast(id); + //TODO: It's not allow to draw onto the main surface. Need to confirm the policy. + if (mTargetFboId == 0) { + GL_CHECK(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mTargetFboId)); + } + mRootTarget = make_unique(surface.w, surface.h); mRootTarget->init(mTargetFboId);