diff --git a/include/render/egl.h b/include/render/egl.h index 55e9ce80f..af38af7e1 100644 --- a/include/render/egl.h +++ b/include/render/egl.h @@ -3,13 +3,6 @@ #include -struct wlr_egl_context { - EGLDisplay display; - EGLContext context; - EGLSurface draw_surface; - EGLSurface read_surface; -}; - /** * Initializes an EGL context for the given DRM FD. * @@ -48,16 +41,4 @@ bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image); int wlr_egl_dup_drm_fd(struct wlr_egl *egl); -/** - * Save the current EGL context to the structure provided in the argument. - * - * This includes display, context, draw surface and read surface. - */ -void wlr_egl_save_context(struct wlr_egl_context *context); - -/** - * Restore EGL context that was previously saved using wlr_egl_save_current(). - */ -bool wlr_egl_restore_context(struct wlr_egl_context *context); - #endif diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 903b70a3f..88db130f7 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -29,6 +29,13 @@ #include #include +struct wlr_egl_context { + EGLDisplay display; + EGLContext context; + EGLSurface draw_surface; + EGLSurface read_surface; +}; + struct wlr_egl { EGLDisplay display; EGLContext context; @@ -80,4 +87,16 @@ bool wlr_egl_unset_current(struct wlr_egl *egl); bool wlr_egl_is_current(struct wlr_egl *egl); +/** + * Save the current EGL context to the structure provided in the argument. + * + * This includes display, context, draw surface and read surface. + */ +void wlr_egl_context_save(struct wlr_egl_context *context); + +/** + * Restore EGL context that was previously saved using wlr_egl_context_save(). + */ +bool wlr_egl_context_restore(struct wlr_egl_context *context); + #endif diff --git a/render/egl.c b/render/egl.c index 712a61c81..e7734f86c 100644 --- a/render/egl.c +++ b/render/egl.c @@ -560,14 +560,16 @@ bool wlr_egl_is_current(struct wlr_egl *egl) { return eglGetCurrentContext() == egl->context; } -void wlr_egl_save_context(struct wlr_egl_context *context) { + +void wlr_egl_context_save(struct wlr_egl_context *context) { context->display = eglGetCurrentDisplay(); context->context = eglGetCurrentContext(); context->draw_surface = eglGetCurrentSurface(EGL_DRAW); context->read_surface = eglGetCurrentSurface(EGL_READ); } -bool wlr_egl_restore_context(struct wlr_egl_context *context) { + +bool wlr_egl_context_restore(struct wlr_egl_context *context) { // If the saved context is a null-context, we must use the current // display instead of the saved display because eglMakeCurrent() can't // handle EGL_NO_DISPLAY. diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 01efaf1de..bde21f474 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -51,7 +51,7 @@ static void destroy_buffer(struct wlr_gles2_buffer *buffer) { wlr_addon_finish(&buffer->addon); struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); + wlr_egl_context_save(&prev_ctx); wlr_egl_make_current(buffer->renderer->egl); push_gles2_debug(buffer->renderer); @@ -63,7 +63,7 @@ static void destroy_buffer(struct wlr_gles2_buffer *buffer) { wlr_egl_destroy_image(buffer->renderer->egl, buffer->image); - wlr_egl_restore_context(&prev_ctx); + wlr_egl_context_restore(&prev_ctx); free(buffer); } diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 293b7a19b..bd3cf53f0 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -73,7 +73,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture, } struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); + wlr_egl_context_save(&prev_ctx); wlr_egl_make_current(texture->renderer->egl); push_gles2_debug(texture->renderer); @@ -95,7 +95,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture, pop_gles2_debug(texture->renderer); - wlr_egl_restore_context(&prev_ctx); + wlr_egl_context_restore(&prev_ctx); return true; } @@ -110,7 +110,7 @@ static bool gles2_texture_invalidate(struct wlr_gles2_texture *texture) { } struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); + wlr_egl_context_save(&prev_ctx); wlr_egl_make_current(texture->renderer->egl); push_gles2_debug(texture->renderer); @@ -122,7 +122,7 @@ static bool gles2_texture_invalidate(struct wlr_gles2_texture *texture) { pop_gles2_debug(texture->renderer); - wlr_egl_restore_context(&prev_ctx); + wlr_egl_context_restore(&prev_ctx); return true; } @@ -134,7 +134,7 @@ void gles2_texture_destroy(struct wlr_gles2_texture *texture) { } struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); + wlr_egl_context_save(&prev_ctx); wlr_egl_make_current(texture->renderer->egl); push_gles2_debug(texture->renderer); @@ -144,7 +144,7 @@ void gles2_texture_destroy(struct wlr_gles2_texture *texture) { pop_gles2_debug(texture->renderer); - wlr_egl_restore_context(&prev_ctx); + wlr_egl_context_restore(&prev_ctx); free(texture); } @@ -211,7 +211,7 @@ static struct wlr_texture *gles2_texture_from_pixels( texture->drm_format = fmt->drm_format; struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); + wlr_egl_context_save(&prev_ctx); wlr_egl_make_current(renderer->egl); push_gles2_debug(renderer); @@ -230,7 +230,7 @@ static struct wlr_texture *gles2_texture_from_pixels( pop_gles2_debug(renderer); - wlr_egl_restore_context(&prev_ctx); + wlr_egl_context_restore(&prev_ctx); return &texture->wlr_texture; } @@ -263,7 +263,7 @@ static struct wlr_texture *gles2_texture_from_dmabuf( } struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); + wlr_egl_context_save(&prev_ctx); wlr_egl_make_current(renderer->egl); bool external_only; @@ -271,7 +271,7 @@ static struct wlr_texture *gles2_texture_from_dmabuf( wlr_egl_create_image_from_dmabuf(renderer->egl, attribs, &external_only); if (texture->image == EGL_NO_IMAGE_KHR) { wlr_log(WLR_ERROR, "Failed to create EGL image from DMA-BUF"); - wlr_egl_restore_context(&prev_ctx); + wlr_egl_context_restore(&prev_ctx); wl_list_remove(&texture->link); free(texture); return NULL; @@ -290,7 +290,7 @@ static struct wlr_texture *gles2_texture_from_dmabuf( pop_gles2_debug(renderer); - wlr_egl_restore_context(&prev_ctx); + wlr_egl_context_restore(&prev_ctx); return &texture->wlr_texture; }