gl_engine: fix always-true clear flag

The clear flag specified in Canvas::draw is ignored when set to false,
since GlRenderer::mClearBuffer is never explicitly reset to false.

This commit ensures that mClearBuffer is reset to its default (false)
after being used, so that the clear operation behaves correctly per frame.

- Issue: #1779
This commit is contained in:
Sungun No 2025-06-06 20:40:57 +09:00 committed by Hermet Park
parent 8eb046c318
commit 676a465c55
3 changed files with 17 additions and 17 deletions

View file

@ -195,23 +195,20 @@ void GlComposeTask::run()
{
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, getSelfFbo()));
// clear this fbo
if (mClearBuffer) {
// we must clear all area of fbo
GL_CHECK(glViewport(0, 0, mFbo->getWidth(), mFbo->getHeight()));
GL_CHECK(glScissor(0, 0, mFbo->getWidth(), mFbo->getHeight()));
GL_CHECK(glClearColor(0, 0, 0, 0));
GL_CHECK(glClearStencil(0));
#ifdef THORVG_GL_TARGET_GLES
GL_CHECK(glClearDepthf(0.0));
#else
GL_CHECK(glClearDepth(0.0));
#endif
GL_CHECK(glDepthMask(1));
// we must clear all area of fbo
GL_CHECK(glViewport(0, 0, mFbo->getWidth(), mFbo->getHeight()));
GL_CHECK(glScissor(0, 0, mFbo->getWidth(), mFbo->getHeight()));
GL_CHECK(glClearColor(0, 0, 0, 0));
GL_CHECK(glClearStencil(0));
#ifdef THORVG_GL_TARGET_GLES
GL_CHECK(glClearDepthf(0.0));
#else
GL_CHECK(glClearDepth(0.0));
#endif
GL_CHECK(glDepthMask(1));
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
GL_CHECK(glDepthMask(0));
}
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
GL_CHECK(glDepthMask(0));
GL_CHECK(glViewport(0, 0, mRenderWidth, mRenderHeight));
GL_CHECK(glScissor(0, 0, mRenderWidth, mRenderHeight));

View file

@ -853,6 +853,9 @@ bool GlRenderer::sync()
clearDisposes();
// Reset clear buffer flag to default (false) after use.
mClearBuffer = false;
delete task;
return true;

View file

@ -153,7 +153,7 @@ private:
} mDisposed;
BlendMethod mBlendMethod = BlendMethod::Normal;
bool mClearBuffer = true; //FIXME: clear buffer should be optional (default is false)
bool mClearBuffer = false;
};
#endif /* _TVG_GL_RENDERER_H_ */