@@ -10,7 +10,7 @@ use crate::platform::unix::{
10
10
use crate :: platform_impl:: { x11_utils, PlatformAttributes } ;
11
11
use crate :: {
12
12
Api , ContextError , CreationError , GlAttributes , GlRequest , PixelFormat ,
13
- PixelFormatRequirements ,
13
+ PixelFormatRequirements , ContextBuilderWrapper
14
14
} ;
15
15
16
16
use glutin_glx_sys as ffi;
@@ -98,7 +98,7 @@ unsafe impl Sync for Context {}
98
98
pub fn select_config < T , F > (
99
99
xconn : & Arc < XConnection > ,
100
100
transparent : Option < bool > ,
101
- plat_attr : & PlatformAttributes ,
101
+ cb : & ContextBuilderWrapper < & ' _ Context > ,
102
102
config_ids : Vec < T > ,
103
103
mut convert_to_xvisualinfo : F ,
104
104
) -> Result < ( T , ffi:: XVisualInfo ) , ( ) >
@@ -119,7 +119,7 @@ where
119
119
& xconn,
120
120
visual_infos,
121
121
transparent == Some ( true ) ,
122
- plat_attr. x11_visual_xid ,
122
+ cb . plat_attr . x11_visual_xid ,
123
123
) ;
124
124
125
125
let pict_format = unsafe {
@@ -184,6 +184,7 @@ impl Context {
184
184
}
185
185
}
186
186
187
+ /*
187
188
#[inline]
188
189
pub fn new_headless<T>(
189
190
el: &EventLoop<T>,
@@ -310,24 +311,22 @@ impl Context {
310
311
311
312
Ok(context)
312
313
}
313
- }
314
+ }*/
314
315
315
316
#[ inline]
316
317
fn new_first_stage < ' a > (
317
318
xconn : & Arc < XConnection > ,
318
- pf_reqs : & PixelFormatRequirements ,
319
- gl_attr : & ' a GlAttributes < & ' a Context > ,
320
- plat_attr : & ' a PlatformAttributes ,
319
+ cb : & ContextBuilderWrapper < & ' _ Context > ,
321
320
screen_id : raw:: c_int ,
322
- builder_glx_u : & ' a mut Option < GlAttributes < & ' a GlxContext > > ,
323
- builder_egl_u : & ' a mut Option < GlAttributes < & ' a EglContext > > ,
321
+ builder_glx_u : & ' _ mut Option < ContextBuilderWrapper < & ' _ GlxContext > > ,
322
+ builder_egl_u : & ' _ mut Option < ContextBuilderWrapper < & ' _ EglContext > > ,
324
323
surface_type : EglSurfaceType ,
325
324
prefer_egl : bool ,
326
325
force_prefer_unless_only : bool ,
327
326
transparent : Option < bool > ,
328
327
) -> Result < Prototype < ' a > , CreationError > {
329
328
let select_config = |cs, display| {
330
- select_config ( & xconn, transparent, plat_attr , cs, |config_id| {
329
+ select_config ( & xconn, transparent, cb , cs, |config_id| {
331
330
let xid = egl:: get_native_visual_id ( display, * config_id)
332
331
as ffi:: VisualID ;
333
332
if xid == 0 {
@@ -337,7 +336,7 @@ impl Context {
337
336
} )
338
337
. map ( |( c, _) | c)
339
338
} ;
340
- Ok ( match gl_attr. version {
339
+ Ok ( match cb . gl_attr . version {
341
340
GlRequest :: Latest
342
341
| GlRequest :: Specific ( Api :: OpenGl , _)
343
342
| GlRequest :: GlThenGles { .. } => {
@@ -347,25 +346,23 @@ impl Context {
347
346
// However, with surfaceless, GLX isn't really there, so we
348
347
// should prefer EGL.
349
348
let glx = |builder_u : & ' a mut Option < _ > | {
350
- let builder = gl_attr . clone ( ) ;
349
+ let builder = cb . clone ( ) ;
351
350
* builder_u =
352
351
Some ( builder. map_sharing ( |c| match c. context {
353
352
X11Context :: Glx ( ref c) => c,
354
353
_ => panic ! ( ) ,
355
354
} ) ) ;
356
355
Ok ( Prototype :: Glx ( GlxContext :: new (
357
356
Arc :: clone ( & xconn) ,
358
- pf_reqs,
359
357
builder_u. as_ref ( ) . unwrap ( ) ,
360
- plat_attr,
361
358
screen_id,
362
359
surface_type,
363
360
transparent,
364
361
) ?) )
365
362
} ;
366
363
367
364
let egl = |builder_u : & ' a mut Option < _ > | {
368
- let builder = gl_attr . clone ( ) ;
365
+ let builder = cb . clone ( ) ;
369
366
* builder_u =
370
367
Some ( builder. map_sharing ( |c| match c. context {
371
368
X11Context :: Egl ( ref c) => c,
@@ -374,9 +371,7 @@ impl Context {
374
371
let native_display =
375
372
NativeDisplay :: X11 ( Some ( xconn. display as * const _ ) ) ;
376
373
Ok ( Prototype :: Egl ( EglContext :: new (
377
- pf_reqs,
378
374
builder_u. as_ref ( ) . unwrap ( ) ,
379
- plat_attr,
380
375
native_display,
381
376
surface_type,
382
377
select_config,
@@ -428,16 +423,14 @@ impl Context {
428
423
}
429
424
GlRequest :: Specific ( Api :: OpenGlEs , _) => {
430
425
if let Some ( _) = * EGL {
431
- let builder = gl_attr . clone ( ) ;
426
+ let builder = cb . clone ( ) ;
432
427
* builder_egl_u =
433
428
Some ( builder. map_sharing ( |c| match c. context {
434
429
X11Context :: Egl ( ref c) => c,
435
430
_ => panic ! ( ) ,
436
431
} ) ) ;
437
432
Prototype :: Egl ( EglContext :: new (
438
- pf_reqs,
439
433
builder_egl_u. as_ref ( ) . unwrap ( ) ,
440
- plat_attr,
441
434
NativeDisplay :: X11 ( Some ( xconn. display as * const _ ) ) ,
442
435
surface_type,
443
436
select_config,
@@ -458,25 +451,25 @@ impl Context {
458
451
459
452
#[ inline]
460
453
pub fn new < T > (
461
- wb : WindowBuilder ,
462
454
el : & EventLoop < T > ,
463
- pf_reqs : & PixelFormatRequirements ,
464
- gl_attr : & GlAttributes < & Context > ,
465
- plat_attr : & PlatformAttributes ,
466
- ) -> Result < ( Window , Self ) , CreationError > {
455
+ cb : ContextBuilderWrapper < & ' _ Context > ,
456
+ pbuffer_support : bool ,
457
+ window_surface_support : bool ,
458
+ surfaceless_support : bool ,
459
+ ) -> Result < Self , CreationError > {
467
460
Self :: try_then_fallback ( |fallback| {
468
- Self :: new_impl ( wb . clone ( ) , el , pf_reqs , gl_attr , plat_attr , fallback)
461
+ Self :: new_impl ( el , & cb , pbuffer_support , window_surface_support , surfaceless_support , fallback)
469
462
} )
470
463
}
471
464
472
465
fn new_impl < T > (
473
- wb : WindowBuilder ,
474
466
el : & EventLoop < T > ,
475
- pf_reqs : & PixelFormatRequirements ,
476
- gl_attr : & GlAttributes < & Context > ,
477
- plat_attr : & PlatformAttributes ,
467
+ cb : & ContextBuilderWrapper < & ' _ Context > ,
468
+ pbuffer_support : bool ,
469
+ window_surface_support : bool ,
470
+ surfaceless_support : bool ,
478
471
fallback : bool ,
479
- ) -> Result < ( Window , Self ) , CreationError > {
472
+ ) -> Result < Self , CreationError > {
480
473
let xconn = match el. xlib_xconnection ( ) {
481
474
Some ( xconn) => xconn,
482
475
None => {
@@ -495,9 +488,7 @@ impl Context {
495
488
// start the context building process
496
489
let context = Self :: new_first_stage (
497
490
& xconn,
498
- pf_reqs,
499
- gl_attr,
500
- plat_attr,
491
+ cb,
501
492
screen_id,
502
493
& mut builder_glx_u,
503
494
& mut builder_egl_u,
@@ -537,6 +528,7 @@ impl Context {
537
528
Ok ( ( win, context) )
538
529
}
539
530
531
+ /*
540
532
#[inline]
541
533
pub fn new_raw_context(
542
534
xconn: Arc<XConnection>,
@@ -624,6 +616,7 @@ impl Context {
624
616
625
617
Ok(context)
626
618
}
619
+ */
627
620
628
621
#[ inline]
629
622
pub unsafe fn make_current ( & self ) -> Result < ( ) , ContextError > {
0 commit comments