src/video/wayland/SDL_waylandopengles.c
changeset 12400 28303fca62bd
parent 11811 5d94cb6b24d3
child 12503 806492103856
equal deleted inserted replaced
12399:2ea6e539b218 12400:28303fca62bd
    20 */
    20 */
    21 #include "../../SDL_internal.h"
    21 #include "../../SDL_internal.h"
    22 
    22 
    23 #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL
    23 #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL
    24 
    24 
       
    25 #include "../SDL_sysvideo.h"
       
    26 #include "../../events/SDL_windowevents_c.h"
    25 #include "SDL_waylandvideo.h"
    27 #include "SDL_waylandvideo.h"
    26 #include "SDL_waylandopengles.h"
    28 #include "SDL_waylandopengles.h"
    27 #include "SDL_waylandwindow.h"
    29 #include "SDL_waylandwindow.h"
    28 #include "SDL_waylandevents_c.h"
    30 #include "SDL_waylandevents_c.h"
    29 #include "SDL_waylanddyn.h"
    31 #include "SDL_waylanddyn.h"
       
    32 
       
    33 #include "xdg-shell-client-protocol.h"
       
    34 #include "xdg-shell-unstable-v6-client-protocol.h"
    30 
    35 
    31 /* EGL implementation of SDL OpenGL ES support */
    36 /* EGL implementation of SDL OpenGL ES support */
    32 
    37 
    33 int
    38 int
    34 Wayland_GLES_LoadLibrary(_THIS, const char *path) {
    39 Wayland_GLES_LoadLibrary(_THIS, const char *path) {
    55 }
    60 }
    56 
    61 
    57 int
    62 int
    58 Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
    63 Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
    59 {
    64 {
    60     if (SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface) < 0) {
    65     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
       
    66     struct wl_region *region;
       
    67 
       
    68     if (SDL_EGL_SwapBuffers(_this, data->egl_surface) < 0) {
    61         return -1;
    69         return -1;
    62     }
    70     }
    63     WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display );
    71 
       
    72     // Wayland-EGL forbids drawing calls in-between SwapBuffers and wl_egl_window_resize
       
    73     if (data->resize.pending) {
       
    74         SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, data->resize.width, data->resize.height);
       
    75         window->w = data->resize.width;
       
    76         window->h = data->resize.height;
       
    77 
       
    78         WAYLAND_wl_egl_window_resize(data->egl_window, window->w, window->h, 0, 0);
       
    79 
       
    80         if (data->waylandData->shell.xdg) {
       
    81            xdg_surface_ack_configure(data->shell_surface.xdg.surface, data->resize.serial);
       
    82         } else if (data->waylandData->shell.zxdg) {
       
    83            zxdg_surface_v6_ack_configure(data->shell_surface.zxdg.surface, data->resize.serial);
       
    84         }
       
    85 
       
    86         region = wl_compositor_create_region(data->waylandData->compositor);
       
    87         wl_region_add(region, 0, 0, window->w, window->h);
       
    88         wl_surface_set_opaque_region(data->surface, region);
       
    89         wl_region_destroy(region);
       
    90 
       
    91         data->resize.pending = SDL_FALSE;
       
    92     }
       
    93 
       
    94     WAYLAND_wl_display_flush( data->waylandData->display );
       
    95 
    64     return 0;
    96     return 0;
    65 }
    97 }
    66 
    98 
    67 int
    99 int
    68 Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
   100 Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)