@@ -2609,6 +2609,22 @@ getWlEglWindowVersionAndSurface(struct wl_egl_window *window,
2609
2609
}
2610
2610
}
2611
2611
2612
+ static bool
2613
+ wlEglInitializeSurfaceCommon (WlEglDisplay * display ,
2614
+ WlEglSurface * surface ,
2615
+ EGLConfig config )
2616
+ {
2617
+ surface -> wlEglDpy = display ;
2618
+ surface -> eglConfig = config ;
2619
+ surface -> syncPoint = 1 ;
2620
+ surface -> refCount = 1 ;
2621
+ surface -> isDestroyed = EGL_FALSE ;
2622
+ wl_list_init (& surface -> ctx .streamImages );
2623
+ wl_list_init (& surface -> oldCtxList );
2624
+
2625
+ return wlEglInitializeMutex (& surface -> ctx .streamImagesMutex );
2626
+ }
2627
+
2612
2628
EGLSurface wlEglCreatePlatformWindowSurfaceHook (EGLDisplay dpy ,
2613
2629
EGLConfig config ,
2614
2630
void * nativeWin ,
@@ -2669,17 +2685,17 @@ EGLSurface wlEglCreatePlatformWindowSurfaceHook(EGLDisplay dpy,
2669
2685
goto fail ;
2670
2686
}
2671
2687
2672
- if (!wlEglInitializeMutex ( & surface -> mutexLock )) {
2688
+ if (!wlEglInitializeSurfaceCommon ( display , surface , config )) {
2673
2689
err = EGL_BAD_ALLOC ;
2674
2690
goto fail ;
2675
2691
}
2676
2692
2677
- if (!wlEglInitializeMutex (& surface -> mutexFrameSync )) {
2693
+ if (!wlEglInitializeMutex (& surface -> mutexLock )) {
2678
2694
err = EGL_BAD_ALLOC ;
2679
2695
goto fail ;
2680
2696
}
2681
2697
2682
- if (!wlEglInitializeMutex (& surface -> ctx . streamImagesMutex )) {
2698
+ if (!wlEglInitializeMutex (& surface -> mutexFrameSync )) {
2683
2699
err = EGL_BAD_ALLOC ;
2684
2700
goto fail ;
2685
2701
}
@@ -2689,18 +2705,11 @@ EGLSurface wlEglCreatePlatformWindowSurfaceHook(EGLDisplay dpy,
2689
2705
goto fail ;
2690
2706
}
2691
2707
2692
- wl_list_init (& surface -> ctx .streamImages );
2693
-
2694
- surface -> wlEglDpy = display ;
2695
- surface -> eglConfig = config ;
2696
2708
surface -> wlEglWin = window ;
2697
2709
surface -> ctx .eglStream = EGL_NO_STREAM_KHR ;
2698
2710
surface -> ctx .eglSurface = EGL_NO_SURFACE ;
2699
2711
surface -> ctx .isOffscreen = EGL_FALSE ;
2700
2712
surface -> isSurfaceProducer = EGL_TRUE ;
2701
- surface -> refCount = 1 ;
2702
- surface -> isDestroyed = EGL_FALSE ;
2703
- surface -> syncPoint = 1 ;
2704
2713
// FIFO_LENGTH == 1 to set FIFO mode, FIFO_LENGTH == 0 to set MAILBOX mode
2705
2714
// We set two here however to bump the "swapchain" count to 4 on Wayland.
2706
2715
// This is done to better match what Mesa does, as apparently 4 is the
@@ -2732,7 +2741,6 @@ EGLSurface wlEglCreatePlatformWindowSurfaceHook(EGLDisplay dpy,
2732
2741
getWlEglWindowVersionAndSurface (window ,
2733
2742
& surface -> wlEglWinVer ,
2734
2743
& surface -> wlSurface );
2735
- wl_list_init (& surface -> oldCtxList );
2736
2744
2737
2745
err = assignWlEglSurfaceAttribs (surface , attribs );
2738
2746
if (err != EGL_SUCCESS ) {
@@ -2883,18 +2891,13 @@ EGLSurface wlEglCreatePbufferSurfaceHook(EGLDisplay dpy,
2883
2891
goto fail ;
2884
2892
}
2885
2893
2886
- if (!wlEglInitializeMutex ( & surface -> mutexLock )) {
2894
+ if (!wlEglInitializeSurfaceCommon ( display , surface , config )) {
2887
2895
err = EGL_BAD_ALLOC ;
2888
2896
goto fail ;
2889
2897
}
2890
2898
2891
- surface -> wlEglDpy = display ;
2892
- surface -> eglConfig = config ;
2893
2899
surface -> ctx .eglSurface = surf ;
2894
2900
surface -> ctx .isOffscreen = EGL_TRUE ;
2895
- surface -> refCount = 1 ;
2896
- surface -> isDestroyed = EGL_FALSE ;
2897
- wl_list_init (& surface -> oldCtxList );
2898
2901
2899
2902
wl_list_insert (& display -> wlEglSurfaceList , & surface -> link );
2900
2903
pthread_mutex_unlock (& display -> mutex );
0 commit comments