mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
gl_engine: Fix compose render not correct after canvas resize
When canvas size changed, need to clear cached GLRenderTarget and GLCompose.
This commit is contained in:
parent
af1f3cb59d
commit
3c6a456d2c
2 changed files with 8 additions and 20 deletions
|
@ -63,29 +63,18 @@ bool GlRenderer::target(int32_t id, uint32_t w, uint32_t h)
|
|||
surface.w = w;
|
||||
surface.h = h;
|
||||
|
||||
mTargetViewport.x = 0;
|
||||
mTargetViewport.y = 0;
|
||||
mTargetViewport.w = surface.w;
|
||||
mTargetViewport.h = surface.h;
|
||||
|
||||
mTargetFboId = static_cast<GLint>(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));
|
||||
|
||||
GLint dims[4] = {0};
|
||||
|
||||
GL_CHECK(glGetIntegerv(GL_VIEWPORT, dims));
|
||||
// If targeting on the main framebuffer ,the actual size may by adjusted by the window system.
|
||||
// In case the size is different from logical size, query and set the actual viewport here
|
||||
mTargetViewport.w = dims[2];
|
||||
mTargetViewport.h = dims[3];
|
||||
}
|
||||
|
||||
mRootTarget = make_unique<GlRenderTarget>(surface.w, surface.h);
|
||||
mRootTarget->init(mTargetFboId);
|
||||
|
||||
mRenderPassStack.clear();
|
||||
mComposeStack.clear();
|
||||
|
||||
for (uint32_t i = 0; i < mComposePool.count; i++) delete mComposePool[i];
|
||||
|
||||
mComposePool.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -109,7 +98,7 @@ bool GlRenderer::sync()
|
|||
prepareBlitTask(task);
|
||||
|
||||
task->mClearBuffer = mClearBuffer;
|
||||
task->setTargetViewport(mTargetViewport);
|
||||
task->setTargetViewport(RenderRegion{0, 0, static_cast<int32_t>(surface.w), static_cast<int32_t>(surface.h)});
|
||||
|
||||
mGpuBuffer->flushToGPU();
|
||||
mGpuBuffer->bind();
|
||||
|
|
|
@ -98,7 +98,6 @@ private:
|
|||
Surface surface;
|
||||
GLint mTargetFboId = 0;
|
||||
RenderRegion mViewport;
|
||||
RenderRegion mTargetViewport;
|
||||
//TODO: remove all unique_ptr / replace the vector with tvg::Array
|
||||
unique_ptr<GlStageBuffer> mGpuBuffer;
|
||||
vector<std::unique_ptr<GlProgram>> mPrograms;
|
||||
|
|
Loading…
Add table
Reference in a new issue