/* bind the new context */
oldCtx = _eglBindContextToThread(newCtx, t);
- if (newCtx) {
+ if (newCtx)
_eglBindContextToSurfaces(newCtx, draw, read);
- }
- else {
+
+ /* unbind the old context from its binding surfaces */
+ if (oldCtx && oldCtx != newCtx) {
assert(!*draw && !*read);
- if (oldCtx) {
- *draw = oldCtx->DrawSurface;
- *read = oldCtx->ReadSurface;
- assert(*draw && *read);
- /* unbind the old context from its surfaces */
- _eglBindContextToSurfaces(NULL, draw, read);
- }
+ *draw = oldCtx->DrawSurface;
+ *read = oldCtx->ReadSurface;
+ assert(*draw && *read);
+
+ _eglBindContextToSurfaces(NULL, draw, read);
}
*ctx = oldCtx;