mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +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,8 +195,6 @@ 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()));
|
||||
|
@ -211,7 +209,6 @@ void GlComposeTask::run()
|
|||
|
||||
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));
|
||||
|
|
|
@ -125,8 +125,8 @@ public:
|
|||
void run() override;
|
||||
|
||||
void setRenderSize(uint32_t width, uint32_t height) { mRenderWidth = width; mRenderHeight = height; }
|
||||
void setClearBuffer(bool clearBuffer) { mClearBuffer = clearBuffer; }
|
||||
|
||||
bool mClearBuffer = true;
|
||||
|
||||
protected:
|
||||
GLuint getTargetFbo() { return mTargetFbo; }
|
||||
|
@ -134,6 +134,8 @@ protected:
|
|||
GLuint getResolveFboId();
|
||||
void onResolve();
|
||||
|
||||
bool mClearBuffer = false;
|
||||
|
||||
private:
|
||||
GLuint mTargetFbo;
|
||||
GlRenderTarget* mFbo;
|
||||
|
|
|
@ -839,7 +839,7 @@ bool GlRenderer::sync()
|
|||
|
||||
prepareBlitTask(task);
|
||||
|
||||
task->mClearBuffer = mClearBuffer;
|
||||
task->setClearBuffer(mClearBuffer);
|
||||
task->setTargetViewport({{0, 0}, {int32_t(surface.w), int32_t(surface.h)}});
|
||||
|
||||
if (mGpuBuffer.flushToGPU()) {
|
||||
|
@ -853,6 +853,9 @@ bool GlRenderer::sync()
|
|||
|
||||
clearDisposes();
|
||||
|
||||
// Reset clear buffer flag to default (false) after use.
|
||||
mClearBuffer = false;
|
||||
|
||||
delete task;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -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_ */
|
||||
|
|
Loading…
Add table
Reference in a new issue