mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-25 23:59:12 +00:00
gl_engine: fix FBO validation
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
At the moment, we use the value GL_INVALID_VALUE to mark an invalid handle for FBO, which is not correct. It is more correct to use the value 0, which signals that the buffer was not created. Canvas initialization processes have also been adjusted.
This commit is contained in:
parent
7730f8ba8b
commit
9369642642
3 changed files with 9 additions and 6 deletions
|
@ -31,7 +31,8 @@ GlRenderTarget::~GlRenderTarget()
|
|||
|
||||
void GlRenderTarget::init(uint32_t width, uint32_t height, GLint resolveId)
|
||||
{
|
||||
if (mFbo != GL_INVALID_VALUE || width == 0 || height == 0) return;
|
||||
if (width == 0 || height == 0) return;
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
||||
|
@ -77,14 +78,16 @@ void GlRenderTarget::init(uint32_t width, uint32_t height, GLint resolveId)
|
|||
|
||||
void GlRenderTarget::reset()
|
||||
{
|
||||
if (mFbo == 0 || mFbo == GL_INVALID_VALUE) return;
|
||||
if (mFbo == 0) return;
|
||||
|
||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
|
||||
GL_CHECK(glDeleteFramebuffers(1, &mFbo));
|
||||
GL_CHECK(glDeleteRenderbuffers(1, &mColorBuffer));
|
||||
GL_CHECK(glDeleteRenderbuffers(1, &mDepthStencilBuffer));
|
||||
GL_CHECK(glDeleteFramebuffers(1, &mResolveFbo));
|
||||
GL_CHECK(glDeleteTextures(1, &mColorTex));
|
||||
mFbo = GL_INVALID_VALUE;
|
||||
|
||||
mFbo = mColorBuffer = mDepthStencilBuffer = mResolveFbo = mColorTex = 0;
|
||||
}
|
||||
|
||||
GlRenderTargetPool::GlRenderTargetPool(uint32_t maxWidth, uint32_t maxHeight): mMaxWidth(maxWidth), mMaxHeight(maxHeight), mPool() {}
|
||||
|
|
|
@ -44,13 +44,13 @@ public:
|
|||
void setViewport(const RenderRegion& vp) { mViewport = vp; }
|
||||
const RenderRegion& getViewport() const { return mViewport; }
|
||||
|
||||
bool invalid() const { return mFbo == GL_INVALID_VALUE; }
|
||||
bool invalid() const { return mFbo == 0; }
|
||||
|
||||
private:
|
||||
uint32_t mWidth = 0;
|
||||
uint32_t mHeight = 0;
|
||||
RenderRegion mViewport{};
|
||||
GLuint mFbo = GL_INVALID_VALUE;
|
||||
GLuint mFbo = 0;
|
||||
GLuint mColorBuffer = 0;
|
||||
GLuint mDepthStencilBuffer = 0;
|
||||
GLuint mResolveFbo = 0;
|
||||
|
|
|
@ -790,7 +790,7 @@ bool GlRenderer::clear()
|
|||
bool GlRenderer::target(void* context, int32_t id, uint32_t w, uint32_t h)
|
||||
{
|
||||
//assume the context zero is invalid
|
||||
if (!context || id == GL_INVALID_VALUE || w == 0 || h == 0) return false;
|
||||
if (!context || w == 0 || h == 0) return false;
|
||||
|
||||
if (mContext) currentContext();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue