@@ -1787,10 +1787,8 @@ impl GlesRenderer {
17871787 where
17881788 F : FnOnce ( & ffi:: Gles2 ) -> R ,
17891789 {
1790- unsafe {
1791- self . context . egl ( ) . make_current ( ) ?;
1792- }
1793- Ok ( func ( & self . context . gl ) )
1790+ let gl = unsafe { self . context . make_current ( ) ? } ;
1791+ Ok ( func ( & * gl) )
17941792 }
17951793
17961794 /// Compile a custom pixel shader for rendering with [`GlesFrame::render_pixel_shader_to`].
@@ -1819,14 +1817,12 @@ impl GlesRenderer {
18191817 src : impl AsRef < str > ,
18201818 additional_uniforms : & [ UniformName < ' _ > ] ,
18211819 ) -> Result < GlesPixelProgram , GlesError > {
1822- unsafe {
1823- self . context . egl ( ) . make_current ( ) ?;
1824- }
1820+ let gl = unsafe { self . context . make_current ( ) ? } ;
18251821
18261822 let shader = format ! ( "#version 100\n {}" , src. as_ref( ) ) ;
1827- let program = unsafe { link_program ( & self . context . gl , shaders:: VERTEX_SHADER , & shader) ? } ;
1823+ let program = unsafe { link_program ( & gl, shaders:: VERTEX_SHADER , & shader) ? } ;
18281824 let debug_shader = format ! ( "#version 100\n #define {}\n {}" , shaders:: DEBUG_FLAGS , src. as_ref( ) ) ;
1829- let debug_program = unsafe { link_program ( & self . context . gl , shaders:: VERTEX_SHADER , & debug_shader) ? } ;
1825+ let debug_program = unsafe { link_program ( & gl, shaders:: VERTEX_SHADER , & debug_shader) ? } ;
18301826
18311827 let vert = c"vert" ;
18321828 let vert_position = c"vert_position" ;
@@ -1840,38 +1836,22 @@ impl GlesRenderer {
18401836 Ok ( GlesPixelProgram ( Arc :: new ( GlesPixelProgramInner {
18411837 normal : GlesPixelProgramInternal {
18421838 program,
1843- uniform_matrix : self
1844- . context
1845- . gl
1839+ uniform_matrix : gl
18461840 . GetUniformLocation ( program, matrix. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1847- uniform_tex_matrix : self
1848- . context
1849- . gl
1841+ uniform_tex_matrix : gl
18501842 . GetUniformLocation ( program, tex_matrix. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1851- uniform_alpha : self
1852- . context
1853- . gl
1843+ uniform_alpha : gl
18541844 . GetUniformLocation ( program, alpha. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1855- uniform_size : self
1856- . context
1857- . gl
1858- . GetUniformLocation ( program, size. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1859- attrib_vert : self
1860- . context
1861- . gl
1862- . GetAttribLocation ( program, vert. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1863- attrib_position : self
1864- . context
1865- . gl
1845+ uniform_size : gl. GetUniformLocation ( program, size. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1846+ attrib_vert : gl. GetAttribLocation ( program, vert. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1847+ attrib_position : gl
18661848 . GetAttribLocation ( program, vert_position. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
18671849 additional_uniforms : additional_uniforms
18681850 . iter ( )
18691851 . map ( |uniform| {
18701852 let name = CString :: new ( uniform. name . as_bytes ( ) ) . expect ( "Interior null in name" ) ;
1871- let location = self
1872- . context
1873- . gl
1874- . GetUniformLocation ( program, name. as_ptr ( ) as * const ffi:: types:: GLchar ) ;
1853+ let location =
1854+ gl. GetUniformLocation ( program, name. as_ptr ( ) as * const ffi:: types:: GLchar ) ;
18751855 (
18761856 uniform. name . clone ( ) . into_owned ( ) ,
18771857 UniformDesc {
@@ -1884,35 +1864,25 @@ impl GlesRenderer {
18841864 } ,
18851865 debug : GlesPixelProgramInternal {
18861866 program : debug_program,
1887- uniform_matrix : self
1888- . context
1889- . gl
1867+ uniform_matrix : gl
18901868 . GetUniformLocation ( debug_program, matrix. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1891- uniform_tex_matrix : self
1892- . context
1893- . gl
1869+ uniform_tex_matrix : gl
18941870 . GetUniformLocation ( debug_program, tex_matrix. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1895- uniform_alpha : self
1896- . context
1897- . gl
1871+ uniform_alpha : gl
18981872 . GetUniformLocation ( debug_program, alpha. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1899- uniform_size : self
1900- . context
1901- . gl
1873+ uniform_size : gl
19021874 . GetUniformLocation ( debug_program, size. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1903- attrib_vert : self
1904- . context
1905- . gl
1875+ attrib_vert : gl
19061876 . GetAttribLocation ( debug_program, vert. as_ptr ( ) as * const ffi:: types:: GLchar ) ,
1907- attrib_position : self . context . gl . GetAttribLocation (
1877+ attrib_position : gl. GetAttribLocation (
19081878 debug_program,
19091879 vert_position. as_ptr ( ) as * const ffi:: types:: GLchar ,
19101880 ) ,
19111881 additional_uniforms : additional_uniforms
19121882 . iter ( )
19131883 . map ( |uniform| {
19141884 let name = CString :: new ( uniform. name . as_bytes ( ) ) . expect ( "Interior null in name" ) ;
1915- let location = self . context . gl . GetUniformLocation (
1885+ let location = gl. GetUniformLocation (
19161886 debug_program,
19171887 name. as_ptr ( ) as * const ffi:: types:: GLchar ,
19181888 ) ;
0 commit comments