egl: Make eglMakeCurrent more robust.
egl: Make eglMakeCurrent more robust.

Now that a current surface points back to its binding context, and a
current context points back to its binding thread, make sure there is no
dangling pointers.  This commit reworks eglMakeCurrent, adds more checks
to avoid stealing context or surfaces from another thread, and correctly
destroys unlinked context and surfaces.

Signed-off-by: Chia-I Wu <1c78ba4519acc7012ab6d28d2e5ef6630c8f0d2e@gmail.com>

dellis1972/glsl-optimizer,tokyovigilante/glsl-optimizer,zz85/glsl-optimizer,tokyovigilante/glsl-optimizer,jbarczak/glsl-optimizer,mcanthony/glsl-optimizer,wolf96/glsl-optimizer,adobe/glsl2agal,KTXSoftware/glsl2agal,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,adobe/glsl2agal,metora/MesaGLSLCompiler,mcanthony/glsl-optimizer,KTXSoftware/glsl2agal,adobe/glsl2agal,mcanthony/glsl-optimizer,jbarczak/glsl-optimizer,zeux/glsl-optimizer,zeux/glsl-optimizer,benaadams/glsl-optimizer,bkaradzic/glsl-optimizer,mapbox/glsl-optimizer,adobe/glsl2agal,benaadams/glsl-optimizer,wolf96/glsl-optimizer,KTXSoftware/glsl2agal,zeux/glsl-optimizer,zeux/glsl-optimizer,zeux/glsl-optimizer,zz85/glsl-optimizer,mapbox/glsl-optimizer,jbarczak/glsl-optimizer,mcanthony/glsl-optimizer,zz85/glsl-optimizer,mcanthony/glsl-optimizer,zz85/glsl-optimizer,tokyovigilante/glsl-optimizer,metora/MesaGLSLCompiler,benaadams/glsl-optimizer,zz85/glsl-optimizer,KTXSoftware/glsl2agal,djreep81/glsl-optimizer,zz85/glsl-optimizer,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,benaadams/glsl-optimizer,KTXSoftware/glsl2agal,jbarczak/glsl-optimizer,djreep81/glsl-optimizer,dellis1972/glsl-optimizer,benaadams/glsl-optimizer,tokyovigilante/glsl-optimizer,dellis1972/glsl-optimizer,metora/MesaGLSLCompiler,jbarczak/glsl-optimizer,djreep81/glsl-optimizer,bkaradzic/glsl-optimizer,benaadams/glsl-optimizer,bkaradzic/glsl-optimizer,bkaradzic/glsl-optimizer,mapbox/glsl-optimizer,bkaradzic/glsl-optimizer,djreep81/glsl-optimizer,adobe/glsl2agal,djreep81/glsl-optimizer,wolf96/glsl-optimizer