mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
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:
parent
0fa5d41c8d
commit
a3a8a999b7
4 changed files with 21 additions and 19 deletions
|
@ -195,23 +195,20 @@ void GlComposeTask::run()
|
||||||
{
|
{
|
||||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, getSelfFbo()));
|
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, getSelfFbo()));
|
||||||
|
|
||||||
// clear this fbo
|
// we must clear all area of fbo
|
||||||
if (mClearBuffer) {
|
GL_CHECK(glViewport(0, 0, mFbo->getWidth(), mFbo->getHeight()));
|
||||||
// we must clear all area of fbo
|
GL_CHECK(glScissor(0, 0, mFbo->getWidth(), mFbo->getHeight()));
|
||||||
GL_CHECK(glViewport(0, 0, mFbo->getWidth(), mFbo->getHeight()));
|
GL_CHECK(glClearColor(0, 0, 0, 0));
|
||||||
GL_CHECK(glScissor(0, 0, mFbo->getWidth(), mFbo->getHeight()));
|
GL_CHECK(glClearStencil(0));
|
||||||
GL_CHECK(glClearColor(0, 0, 0, 0));
|
#ifdef THORVG_GL_TARGET_GLES
|
||||||
GL_CHECK(glClearStencil(0));
|
GL_CHECK(glClearDepthf(0.0));
|
||||||
#ifdef THORVG_GL_TARGET_GLES
|
#else
|
||||||
GL_CHECK(glClearDepthf(0.0));
|
GL_CHECK(glClearDepth(0.0));
|
||||||
#else
|
#endif
|
||||||
GL_CHECK(glClearDepth(0.0));
|
GL_CHECK(glDepthMask(1));
|
||||||
#endif
|
|
||||||
GL_CHECK(glDepthMask(1));
|
|
||||||
|
|
||||||
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||||
GL_CHECK(glDepthMask(0));
|
GL_CHECK(glDepthMask(0));
|
||||||
}
|
|
||||||
|
|
||||||
GL_CHECK(glViewport(0, 0, mRenderWidth, mRenderHeight));
|
GL_CHECK(glViewport(0, 0, mRenderWidth, mRenderHeight));
|
||||||
GL_CHECK(glScissor(0, 0, mRenderWidth, mRenderHeight));
|
GL_CHECK(glScissor(0, 0, mRenderWidth, mRenderHeight));
|
||||||
|
|
|
@ -125,8 +125,8 @@ public:
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|
||||||
void setRenderSize(uint32_t width, uint32_t height) { mRenderWidth = width; mRenderHeight = height; }
|
void setRenderSize(uint32_t width, uint32_t height) { mRenderWidth = width; mRenderHeight = height; }
|
||||||
|
void setClearBuffer(bool clearBuffer) { mClearBuffer = clearBuffer; }
|
||||||
|
|
||||||
bool mClearBuffer = true;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GLuint getTargetFbo() { return mTargetFbo; }
|
GLuint getTargetFbo() { return mTargetFbo; }
|
||||||
|
@ -134,6 +134,8 @@ protected:
|
||||||
GLuint getResolveFboId();
|
GLuint getResolveFboId();
|
||||||
void onResolve();
|
void onResolve();
|
||||||
|
|
||||||
|
bool mClearBuffer = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint mTargetFbo;
|
GLuint mTargetFbo;
|
||||||
GlRenderTarget* mFbo;
|
GlRenderTarget* mFbo;
|
||||||
|
|
|
@ -839,7 +839,7 @@ bool GlRenderer::sync()
|
||||||
|
|
||||||
prepareBlitTask(task);
|
prepareBlitTask(task);
|
||||||
|
|
||||||
task->mClearBuffer = mClearBuffer;
|
task->setClearBuffer(mClearBuffer);
|
||||||
task->setTargetViewport({{0, 0}, {int32_t(surface.w), int32_t(surface.h)}});
|
task->setTargetViewport({{0, 0}, {int32_t(surface.w), int32_t(surface.h)}});
|
||||||
|
|
||||||
if (mGpuBuffer.flushToGPU()) {
|
if (mGpuBuffer.flushToGPU()) {
|
||||||
|
@ -853,6 +853,9 @@ bool GlRenderer::sync()
|
||||||
|
|
||||||
clearDisposes();
|
clearDisposes();
|
||||||
|
|
||||||
|
// Reset clear buffer flag to default (false) after use.
|
||||||
|
mClearBuffer = false;
|
||||||
|
|
||||||
delete task;
|
delete task;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -153,7 +153,7 @@ private:
|
||||||
} mDisposed;
|
} mDisposed;
|
||||||
|
|
||||||
BlendMethod mBlendMethod = BlendMethod::Normal;
|
BlendMethod mBlendMethod = BlendMethod::Normal;
|
||||||
bool mClearBuffer = true; //FIXME: clear buffer should be optional (default is false)
|
bool mClearBuffer = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _TVG_GL_RENDERER_H_ */
|
#endif /* _TVG_GL_RENDERER_H_ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue