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,17 +274,19 @@ void Context::makeCurrent(gl::Surface *surface) ...@@ -274,17 +274,19 @@ void Context::makeCurrent(gl::Surface *surface)
mState.viewportX = 0; mState.viewportX = 0;
mState.viewportY = 0; mState.viewportY = 0;
mState.viewportWidth = surface->getWidth(); mState.viewportWidth = surface ? surface->getWidth() : 0;
mState.viewportHeight = surface->getHeight(); mState.viewportHeight = surface ? surface->getHeight() : 0;
mState.scissorX = 0; mState.scissorX = 0;
mState.scissorY = 0; mState.scissorY = 0;
mState.scissorWidth = surface->getWidth(); mState.scissorWidth = surface ? surface->getWidth() : 0;
mState.scissorHeight = surface->getHeight(); mState.scissorHeight = surface ? surface->getHeight() : 0;
mHasBeenCurrent = true; mHasBeenCurrent = true;
} }
if(surface)
{
// Wrap the existing resources into GL objects and assign them to the '0' names // Wrap the existing resources into GL objects and assign them to the '0' names
egl::Image *defaultRenderTarget = surface->getRenderTarget(); egl::Image *defaultRenderTarget = surface->getRenderTarget();
egl::Image *depthStencil = surface->getDepthStencil(); egl::Image *depthStencil = surface->getDepthStencil();
...@@ -304,6 +306,11 @@ void Context::makeCurrent(gl::Surface *surface) ...@@ -304,6 +306,11 @@ void Context::makeCurrent(gl::Surface *surface)
{ {
depthStencil->release(); depthStencil->release();
} }
}
else
{
setFramebufferZero(nullptr);
}
markAllStateDirty(); 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