gl_engine: Fix memory leak caused by no deleted GlRenderTask

This commit is contained in:
RuiwenTang 2024-06-24 21:51:49 +08:00 committed by Hermet Park
parent 376acfacdb
commit 95dde5807e
3 changed files with 11 additions and 2 deletions

View file

@ -259,6 +259,12 @@ void GlDrawBlitTask::run()
GlClipTask::GlClipTask(GlRenderTask* clip, GlRenderTask* mask)
:GlRenderTask(nullptr), mClipTask(clip), mMaskTask(mask) {}
GlClipTask::~GlClipTask()
{
delete mClipTask;
delete mMaskTask;
}
void GlClipTask::run()
{
GL_CHECK(glEnable(GL_STENCIL_TEST));

View file

@ -169,7 +169,7 @@ class GlClipTask : public GlRenderTask
{
public:
GlClipTask(GlRenderTask* clip, GlRenderTask* mask);
~GlClipTask() override = default;
~GlClipTask() override;
void run() override;

View file

@ -567,7 +567,10 @@ void GlRenderer::drawPrimitive(GlShape& sdata, uint8_t r, uint8_t g, uint8_t b,
auto task = new GlRenderTask(mPrograms[RT_Color].get());
task->setDrawDepth(depth);
if (!sdata.geometry->draw(task, mGpuBuffer.get(), flag)) return;
if (!sdata.geometry->draw(task, mGpuBuffer.get(), flag)) {
delete task;
return;
}
GlRenderTask* stencilTask = nullptr;