Commit 9494572a by Nicolas Capens

Fix allowing to make null EGL surfaces current.

eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, context) resulted in a null dereference. It should be supported and is a common idiom for detaching the surfaces from the context before destroying them. Bug swiftshader:70 Change-Id: I5b4406c8d594bc5db34c51bd08371ce69bbd471b Reviewed-on: https://swiftshader-review.googlesource.com/10389Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 9eaa19c2
......@@ -274,35 +274,42 @@ void Context::makeCurrent(gl::Surface *surface)
mState.viewportX = 0;
mState.viewportY = 0;
mState.viewportWidth = surface->getWidth();
mState.viewportHeight = surface->getHeight();
mState.viewportWidth = surface ? surface->getWidth() : 0;
mState.viewportHeight = surface ? surface->getHeight() : 0;
mState.scissorX = 0;
mState.scissorY = 0;
mState.scissorWidth = surface->getWidth();
mState.scissorHeight = surface->getHeight();
mState.scissorWidth = surface ? surface->getWidth() : 0;
mState.scissorHeight = surface ? surface->getHeight() : 0;
mHasBeenCurrent = true;
}
// Wrap the existing resources into GL objects and assign them to the '0' names
egl::Image *defaultRenderTarget = surface->getRenderTarget();
egl::Image *depthStencil = surface->getDepthStencil();
if(surface)
{
// Wrap the existing resources into GL objects and assign them to the '0' names
egl::Image *defaultRenderTarget = surface->getRenderTarget();
egl::Image *depthStencil = surface->getDepthStencil();
Colorbuffer *colorbufferZero = new Colorbuffer(defaultRenderTarget);
DepthStencilbuffer *depthStencilbufferZero = new DepthStencilbuffer(depthStencil);
Framebuffer *framebufferZero = new DefaultFramebuffer(colorbufferZero, depthStencilbufferZero);
Colorbuffer *colorbufferZero = new Colorbuffer(defaultRenderTarget);
DepthStencilbuffer *depthStencilbufferZero = new DepthStencilbuffer(depthStencil);
Framebuffer *framebufferZero = new DefaultFramebuffer(colorbufferZero, depthStencilbufferZero);
setFramebufferZero(framebufferZero);
setFramebufferZero(framebufferZero);
if(defaultRenderTarget)
{
defaultRenderTarget->release();
}
if(defaultRenderTarget)
{
defaultRenderTarget->release();
}
if(depthStencil)
if(depthStencil)
{
depthStencil->release();
}
}
else
{
depthStencil->release();
setFramebufferZero(nullptr);
}
markAllStateDirty();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment