2014-10-09 09:06:48 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
*
|
|
|
|
* gdkglcontext-wayland.c: Wayland specific OpenGL wrappers
|
|
|
|
*
|
|
|
|
* Copyright © 2014 Emmanuele Bassi
|
|
|
|
* Copyright © 2014 Alexander Larsson
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gdkglcontext-wayland.h"
|
|
|
|
#include "gdkdisplay-wayland.h"
|
|
|
|
|
|
|
|
#include "gdkwaylanddisplay.h"
|
|
|
|
#include "gdkwaylandglcontext.h"
|
2018-03-20 10:46:11 +00:00
|
|
|
#include "gdkwaylandsurface.h"
|
2014-10-09 09:06:48 +00:00
|
|
|
#include "gdkprivate-wayland.h"
|
|
|
|
|
|
|
|
#include "gdkinternals.h"
|
2019-04-22 01:14:46 +00:00
|
|
|
#include "gdksurfaceprivate.h"
|
2020-01-22 19:51:40 +00:00
|
|
|
#include "gdkprofilerprivate.h"
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
#include "gdkintl.h"
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT)
|
|
|
|
|
2016-12-01 00:38:20 +00:00
|
|
|
static void gdk_wayland_gl_context_dispose (GObject *gobject);
|
2014-10-30 10:46:09 +00:00
|
|
|
|
2015-02-09 15:56:18 +00:00
|
|
|
#define N_EGL_ATTRS 16
|
|
|
|
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
static gboolean
|
|
|
|
gdk_wayland_gl_context_realize (GdkGLContext *context,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
|
|
|
|
GdkDisplay *display = gdk_gl_context_get_display (context);
|
|
|
|
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
|
2019-06-04 21:26:28 +00:00
|
|
|
GdkGLContext *shared_data_context = gdk_surface_get_shared_data_gl_context (gdk_gl_context_get_surface (context));
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
EGLContext ctx;
|
2015-02-09 15:56:18 +00:00
|
|
|
EGLint context_attribs[N_EGL_ATTRS];
|
|
|
|
int major, minor, flags;
|
2016-04-18 09:13:05 +00:00
|
|
|
gboolean debug_bit, forward_bit, legacy_bit, use_es;
|
2015-02-09 15:56:18 +00:00
|
|
|
int i = 0;
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
|
2015-02-09 15:56:18 +00:00
|
|
|
gdk_gl_context_get_required_version (context, &major, &minor);
|
|
|
|
debug_bit = gdk_gl_context_get_debug_enabled (context);
|
|
|
|
forward_bit = gdk_gl_context_get_forward_compatible (context);
|
2018-01-12 00:48:27 +00:00
|
|
|
legacy_bit = GDK_DISPLAY_DEBUG_CHECK (display, GL_LEGACY) ||
|
2015-10-07 14:26:53 +00:00
|
|
|
(share != NULL && gdk_gl_context_is_legacy (share));
|
2018-01-12 00:48:27 +00:00
|
|
|
use_es = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) ||
|
2016-04-22 11:45:32 +00:00
|
|
|
(share != NULL && gdk_gl_context_get_use_es (share));
|
2015-02-09 15:56:18 +00:00
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
|
|
|
|
if (debug_bit)
|
|
|
|
flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
|
|
|
|
if (forward_bit)
|
|
|
|
flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
|
|
|
|
2016-04-18 09:13:05 +00:00
|
|
|
if (!use_es)
|
|
|
|
{
|
2016-04-23 09:13:39 +00:00
|
|
|
eglBindAPI (EGL_OPENGL_API);
|
|
|
|
|
2016-04-18 09:13:05 +00:00
|
|
|
/* We want a core profile, unless in legacy mode */
|
|
|
|
context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
|
|
|
context_attribs[i++] = legacy_bit
|
|
|
|
? EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR
|
|
|
|
: EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
|
|
|
|
|
|
|
/* Specify the version */
|
|
|
|
context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
|
|
|
|
context_attribs[i++] = legacy_bit ? 3 : major;
|
|
|
|
context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
|
|
|
|
context_attribs[i++] = legacy_bit ? 0 : minor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-23 09:13:39 +00:00
|
|
|
eglBindAPI (EGL_OPENGL_ES_API);
|
|
|
|
|
2016-04-18 09:13:05 +00:00
|
|
|
context_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION;
|
|
|
|
if (major == 3)
|
|
|
|
context_attribs[i++] = 3;
|
|
|
|
else
|
|
|
|
context_attribs[i++] = 2;
|
|
|
|
}
|
2015-02-09 15:56:18 +00:00
|
|
|
|
|
|
|
/* Specify the flags */
|
|
|
|
context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
|
|
|
|
context_attribs[i++] = flags;
|
|
|
|
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
context_attribs[i++] = EGL_NONE;
|
2015-02-09 15:56:18 +00:00
|
|
|
g_assert (i < N_EGL_ATTRS);
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
|
2018-01-12 00:48:27 +00:00
|
|
|
GDK_DISPLAY_NOTE (display, OPENGL,
|
|
|
|
g_message ("Creating EGL context version %d.%d (debug:%s, forward:%s, legacy:%s, es:%s)",
|
2016-04-22 17:50:50 +00:00
|
|
|
major, minor,
|
|
|
|
debug_bit ? "yes" : "no",
|
|
|
|
forward_bit ? "yes" : "no",
|
|
|
|
legacy_bit ? "yes" : "no",
|
|
|
|
use_es ? "yes" : "no"));
|
|
|
|
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
ctx = eglCreateContext (display_wayland->egl_display,
|
|
|
|
context_wayland->egl_config,
|
|
|
|
share != NULL ? GDK_WAYLAND_GL_CONTEXT (share)->egl_context
|
2019-06-04 21:26:28 +00:00
|
|
|
: shared_data_context != NULL ? GDK_WAYLAND_GL_CONTEXT (shared_data_context)->egl_context
|
|
|
|
: EGL_NO_CONTEXT,
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
context_attribs);
|
2015-10-07 14:26:53 +00:00
|
|
|
|
|
|
|
/* If context creation failed without the legacy bit, let's try again with it */
|
|
|
|
if (ctx == NULL && !legacy_bit)
|
|
|
|
{
|
|
|
|
/* Ensure that re-ordering does not break the offsets */
|
|
|
|
g_assert (context_attribs[0] == EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
|
|
|
|
context_attribs[1] = EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
|
|
|
|
context_attribs[3] = 3;
|
|
|
|
context_attribs[5] = 0;
|
|
|
|
|
2016-04-23 09:13:39 +00:00
|
|
|
eglBindAPI (EGL_OPENGL_API);
|
|
|
|
|
2015-10-07 14:26:53 +00:00
|
|
|
legacy_bit = TRUE;
|
2016-04-22 17:50:50 +00:00
|
|
|
use_es = FALSE;
|
2015-10-07 14:26:53 +00:00
|
|
|
|
2018-01-12 00:48:27 +00:00
|
|
|
GDK_DISPLAY_NOTE (display, OPENGL,
|
|
|
|
g_message ("eglCreateContext failed, switching to legacy"));
|
2015-10-07 14:26:53 +00:00
|
|
|
ctx = eglCreateContext (display_wayland->egl_display,
|
|
|
|
context_wayland->egl_config,
|
|
|
|
share != NULL ? GDK_WAYLAND_GL_CONTEXT (share)->egl_context
|
2019-06-04 21:26:28 +00:00
|
|
|
: shared_data_context != NULL ? GDK_WAYLAND_GL_CONTEXT (shared_data_context)->egl_context
|
|
|
|
: EGL_NO_CONTEXT,
|
2015-10-07 14:26:53 +00:00
|
|
|
context_attribs);
|
|
|
|
}
|
|
|
|
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
if (ctx == NULL)
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, GDK_GL_ERROR,
|
|
|
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
|
|
|
_("Unable to create a GL context"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-01-12 00:48:27 +00:00
|
|
|
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Created EGL context[%p]", ctx));
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
|
|
|
|
context_wayland->egl_context = ctx;
|
|
|
|
|
2015-10-07 14:26:53 +00:00
|
|
|
gdk_gl_context_set_is_legacy (context, legacy_bit);
|
2016-04-22 11:45:32 +00:00
|
|
|
gdk_gl_context_set_use_es (context, use_es);
|
2015-10-07 14:26:53 +00:00
|
|
|
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-12-04 15:33:13 +00:00
|
|
|
static cairo_region_t *
|
|
|
|
gdk_wayland_gl_context_get_damage (GdkGLContext *context)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
EGLSurface egl_surface;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
2016-12-04 15:33:13 +00:00
|
|
|
int buffer_age = 0;
|
|
|
|
|
|
|
|
if (display_wayland->have_egl_buffer_age)
|
|
|
|
{
|
|
|
|
GdkGLContext *shared;
|
|
|
|
GdkWaylandGLContext *shared_wayland;
|
2018-11-30 12:14:00 +00:00
|
|
|
|
2016-12-04 15:33:13 +00:00
|
|
|
shared = gdk_gl_context_get_shared_context (context);
|
|
|
|
if (shared == NULL)
|
|
|
|
shared = context;
|
|
|
|
shared_wayland = GDK_WAYLAND_GL_CONTEXT (shared);
|
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
egl_surface = gdk_wayland_surface_get_egl_surface (surface,
|
2016-12-04 15:33:13 +00:00
|
|
|
shared_wayland->egl_config);
|
|
|
|
gdk_gl_context_make_current (shared);
|
|
|
|
eglQuerySurface (display_wayland->egl_display, egl_surface,
|
|
|
|
EGL_BUFFER_AGE_EXT, &buffer_age);
|
|
|
|
|
2018-11-30 12:14:00 +00:00
|
|
|
switch (buffer_age)
|
2016-12-04 15:33:13 +00:00
|
|
|
{
|
2018-11-30 12:14:00 +00:00
|
|
|
case 1:
|
|
|
|
return cairo_region_create ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if (context->old_updated_area[0])
|
|
|
|
return cairo_region_copy (context->old_updated_area[0]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
if (context->old_updated_area[0] &&
|
|
|
|
context->old_updated_area[1])
|
|
|
|
{
|
|
|
|
cairo_region_t *damage = cairo_region_copy (context->old_updated_area[0]);
|
|
|
|
cairo_region_union (damage, context->old_updated_area[1]);
|
|
|
|
return damage;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
;
|
2016-12-04 15:33:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return GDK_GL_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->get_damage (context);
|
|
|
|
}
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
static void
|
2016-12-01 00:38:20 +00:00
|
|
|
gdk_wayland_gl_context_end_frame (GdkDrawContext *draw_context,
|
2018-04-23 21:26:14 +00:00
|
|
|
cairo_region_t *painted)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
2016-12-01 00:38:20 +00:00
|
|
|
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
2016-12-01 00:38:20 +00:00
|
|
|
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
|
2014-10-09 09:06:48 +00:00
|
|
|
EGLSurface egl_surface;
|
|
|
|
|
2018-04-23 21:26:14 +00:00
|
|
|
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted);
|
2016-12-01 00:38:20 +00:00
|
|
|
if (gdk_gl_context_get_shared_context (context))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gdk_gl_context_make_current (context);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2019-04-22 01:14:46 +00:00
|
|
|
egl_surface = gdk_wayland_surface_get_egl_surface (surface,
|
2016-12-01 00:38:20 +00:00
|
|
|
context_wayland->egl_config);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2018-03-21 06:01:58 +00:00
|
|
|
gdk_wayland_surface_sync (surface);
|
2018-04-10 13:10:56 +00:00
|
|
|
gdk_wayland_surface_request_frame (surface);
|
2018-03-21 06:01:58 +00:00
|
|
|
|
2020-08-19 22:49:34 +00:00
|
|
|
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "wayland", "swap buffers");
|
2018-04-23 21:26:14 +00:00
|
|
|
if (display_wayland->have_egl_swap_buffers_with_damage)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
2018-04-23 21:26:14 +00:00
|
|
|
int i, j, n_rects = cairo_region_num_rectangles (painted);
|
2014-10-09 09:06:48 +00:00
|
|
|
EGLint *rects = g_new (EGLint, n_rects * 4);
|
|
|
|
cairo_rectangle_int_t rect;
|
2018-03-20 14:14:10 +00:00
|
|
|
int surface_height = gdk_surface_get_height (surface);
|
2019-12-03 15:32:59 +00:00
|
|
|
int scale = gdk_surface_get_scale_factor (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
for (i = 0, j = 0; i < n_rects; i++)
|
|
|
|
{
|
2018-04-23 21:26:14 +00:00
|
|
|
cairo_region_get_rectangle (painted, i, &rect);
|
2019-12-03 15:32:59 +00:00
|
|
|
rects[j++] = rect.x * scale;
|
|
|
|
rects[j++] = (surface_height - rect.height - rect.y) * scale;
|
|
|
|
rects[j++] = rect.width * scale;
|
|
|
|
rects[j++] = rect.height * scale;
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
eglSwapBuffersWithDamageEXT (display_wayland->egl_display, egl_surface, rects, n_rects);
|
|
|
|
g_free (rects);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
eglSwapBuffers (display_wayland->egl_display, egl_surface);
|
2020-09-17 16:20:08 +00:00
|
|
|
|
|
|
|
gdk_wayland_surface_notify_committed (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_gl_context_class_init (GdkWaylandGLContextClass *klass)
|
|
|
|
{
|
2014-10-30 10:46:09 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2016-12-01 00:38:20 +00:00
|
|
|
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (klass);
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
GdkGLContextClass *context_class = GDK_GL_CONTEXT_CLASS (klass);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2016-12-01 00:38:20 +00:00
|
|
|
gobject_class->dispose = gdk_wayland_gl_context_dispose;
|
|
|
|
|
|
|
|
draw_context_class->end_frame = gdk_wayland_gl_context_end_frame;
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
|
|
|
|
context_class->realize = gdk_wayland_gl_context_realize;
|
2016-12-04 15:33:13 +00:00
|
|
|
context_class->get_damage = gdk_wayland_gl_context_get_damage;
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_gl_context_init (GdkWaylandGLContext *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-10 18:12:40 +00:00
|
|
|
static EGLDisplay
|
|
|
|
gdk_wayland_get_display (GdkWaylandDisplay *display_wayland)
|
|
|
|
{
|
|
|
|
EGLDisplay dpy = NULL;
|
|
|
|
|
|
|
|
if (epoxy_has_egl_extension (NULL, "EGL_KHR_platform_base"))
|
|
|
|
{
|
|
|
|
PFNEGLGETPLATFORMDISPLAYPROC getPlatformDisplay =
|
|
|
|
(void *) eglGetProcAddress ("eglGetPlatformDisplay");
|
|
|
|
|
|
|
|
if (getPlatformDisplay)
|
|
|
|
dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
|
|
|
|
display_wayland->wl_display,
|
|
|
|
NULL);
|
|
|
|
if (dpy)
|
|
|
|
return dpy;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (epoxy_has_egl_extension (NULL, "EGL_EXT_platform_base"))
|
|
|
|
{
|
|
|
|
PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplay =
|
|
|
|
(void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
|
|
|
|
|
|
|
|
if (getPlatformDisplay)
|
|
|
|
dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT,
|
|
|
|
display_wayland->wl_display,
|
|
|
|
NULL);
|
|
|
|
if (dpy)
|
|
|
|
return dpy;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eglGetDisplay ((EGLNativeDisplayType) display_wayland->wl_display);
|
|
|
|
}
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
gboolean
|
|
|
|
gdk_wayland_display_init_gl (GdkDisplay *display)
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
EGLint major, minor;
|
2016-10-10 18:10:38 +00:00
|
|
|
EGLDisplay dpy;
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
if (display_wayland->have_egl)
|
|
|
|
return TRUE;
|
|
|
|
|
2016-10-10 18:12:40 +00:00
|
|
|
dpy = gdk_wayland_get_display (display_wayland);
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
if (dpy == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!eglInitialize (dpy, &major, &minor))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!eglBindAPI (EGL_OPENGL_API))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
display_wayland->egl_display = dpy;
|
|
|
|
display_wayland->egl_major_version = major;
|
|
|
|
display_wayland->egl_minor_version = minor;
|
|
|
|
|
|
|
|
display_wayland->have_egl = TRUE;
|
|
|
|
|
|
|
|
display_wayland->have_egl_khr_create_context =
|
|
|
|
epoxy_has_egl_extension (dpy, "EGL_KHR_create_context");
|
|
|
|
|
|
|
|
display_wayland->have_egl_buffer_age =
|
|
|
|
epoxy_has_egl_extension (dpy, "EGL_EXT_buffer_age");
|
|
|
|
|
|
|
|
display_wayland->have_egl_swap_buffers_with_damage =
|
|
|
|
epoxy_has_egl_extension (dpy, "EGL_EXT_swap_buffers_with_damage");
|
|
|
|
|
2014-10-09 14:09:05 +00:00
|
|
|
display_wayland->have_egl_surfaceless_context =
|
|
|
|
epoxy_has_egl_extension (dpy, "EGL_KHR_surfaceless_context");
|
|
|
|
|
2018-01-12 00:48:27 +00:00
|
|
|
GDK_DISPLAY_NOTE (display, OPENGL,
|
2016-02-29 02:28:01 +00:00
|
|
|
g_message ("EGL API version %d.%d found\n"
|
|
|
|
" - Vendor: %s\n"
|
|
|
|
" - Version: %s\n"
|
|
|
|
" - Client APIs: %s\n"
|
|
|
|
" - Extensions:\n"
|
|
|
|
"\t%s",
|
|
|
|
display_wayland->egl_major_version,
|
|
|
|
display_wayland->egl_minor_version,
|
|
|
|
eglQueryString (dpy, EGL_VENDOR),
|
|
|
|
eglQueryString (dpy, EGL_VERSION),
|
|
|
|
eglQueryString (dpy, EGL_CLIENT_APIS),
|
|
|
|
eglQueryString (dpy, EGL_EXTENSIONS)));
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_EGL_ATTRS 30
|
|
|
|
|
|
|
|
static gboolean
|
2018-03-20 14:14:10 +00:00
|
|
|
find_eglconfig_for_surface (GdkSurface *surface,
|
GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.
We have a couple of requirements in terms of API:
• avoid, if at all possible, the "C arrays of integers with
attribute, value pairs", which are hard to write and hard
to bind in non-C languages.
• allow failing in a recoverable way.
• do not make the GL context creation API a mess of arguments.
Looking at prior art, it seems that a common pattern is to split the
construction phase in two:
• a first phase that creates a GL context wrapper object and
does preliminary checks on the environment.
• a second phase that creates the backend-specific GL object.
We adopted a similar pattern:
• gdk_window_create_gl_context() creates a GdkGLContext
• gdk_gl_context_realize() creates the underlying resources
Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-01-27 21:23:23 +00:00
|
|
|
EGLConfig *egl_config_out,
|
|
|
|
GError **error)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
EGLint attrs[MAX_EGL_ATTRS];
|
|
|
|
EGLint count;
|
|
|
|
EGLConfig *configs;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
attrs[i++] = EGL_SURFACE_TYPE;
|
|
|
|
attrs[i++] = EGL_WINDOW_BIT;
|
|
|
|
|
|
|
|
attrs[i++] = EGL_COLOR_BUFFER_TYPE;
|
|
|
|
attrs[i++] = EGL_RGB_BUFFER;
|
|
|
|
|
|
|
|
attrs[i++] = EGL_RED_SIZE;
|
2019-06-17 16:41:01 +00:00
|
|
|
attrs[i++] = 8;
|
2014-10-09 09:06:48 +00:00
|
|
|
attrs[i++] = EGL_GREEN_SIZE;
|
2019-06-17 16:41:01 +00:00
|
|
|
attrs[i++] = 8;
|
2014-10-09 09:06:48 +00:00
|
|
|
attrs[i++] = EGL_BLUE_SIZE;
|
2019-06-17 16:41:01 +00:00
|
|
|
attrs[i++] = 8;
|
2016-10-27 21:27:49 +00:00
|
|
|
attrs[i++] = EGL_ALPHA_SIZE;
|
2019-06-17 16:41:01 +00:00
|
|
|
attrs[i++] = 8;
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
attrs[i++] = EGL_NONE;
|
|
|
|
g_assert (i < MAX_EGL_ATTRS);
|
|
|
|
|
|
|
|
if (!eglChooseConfig (display_wayland->egl_display, attrs, NULL, 0, &count) || count < 1)
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, GDK_GL_ERROR,
|
|
|
|
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
|
|
|
_("No available configurations for the given pixel format"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
configs = g_new (EGLConfig, count);
|
|
|
|
|
|
|
|
if (!eglChooseConfig (display_wayland->egl_display, attrs, configs, count, &count) || count < 1)
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, GDK_GL_ERROR,
|
|
|
|
GDK_GL_ERROR_UNSUPPORTED_FORMAT,
|
|
|
|
_("No available configurations for the given pixel format"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pick first valid configuration i guess? */
|
|
|
|
|
|
|
|
if (egl_config_out != NULL)
|
|
|
|
*egl_config_out = configs[0];
|
|
|
|
|
|
|
|
g_free (configs);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkGLContext *
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_create_gl_context (GdkSurface *surface,
|
2014-10-09 14:09:05 +00:00
|
|
|
gboolean attached,
|
2014-10-09 09:06:48 +00:00
|
|
|
GdkGLContext *share,
|
|
|
|
GError **error)
|
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
2014-10-09 09:06:48 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
GdkWaylandGLContext *context;
|
|
|
|
EGLConfig config;
|
|
|
|
|
|
|
|
if (!gdk_wayland_display_init_gl (display))
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, GDK_GL_ERROR,
|
|
|
|
GDK_GL_ERROR_NOT_AVAILABLE,
|
|
|
|
_("No GL implementation is available"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-02-12 12:34:28 +00:00
|
|
|
if (!display_wayland->have_egl_khr_create_context)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
|
|
|
g_set_error_literal (error, GDK_GL_ERROR,
|
|
|
|
GDK_GL_ERROR_UNSUPPORTED_PROFILE,
|
2015-02-12 17:30:42 +00:00
|
|
|
_("Core GL is not available on EGL implementation"));
|
2014-10-09 09:06:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (!find_eglconfig_for_surface (surface, &config, error))
|
2014-10-09 09:06:48 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-10-22 03:39:05 +00:00
|
|
|
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
|
2018-03-20 14:14:10 +00:00
|
|
|
"surface", surface,
|
2014-10-30 11:04:23 +00:00
|
|
|
"shared-context", share,
|
2014-10-09 09:06:48 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
context->egl_config = config;
|
2014-10-09 14:09:05 +00:00
|
|
|
context->is_attached = attached;
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
return GDK_GL_CONTEXT (context);
|
|
|
|
}
|
|
|
|
|
2014-10-30 10:46:09 +00:00
|
|
|
static void
|
2016-12-01 00:38:20 +00:00
|
|
|
gdk_wayland_gl_context_dispose (GObject *gobject)
|
2014-10-09 09:06:48 +00:00
|
|
|
{
|
2014-10-30 10:46:09 +00:00
|
|
|
GdkWaylandGLContext *context_wayland = GDK_WAYLAND_GL_CONTEXT (gobject);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
if (context_wayland->egl_context != NULL)
|
|
|
|
{
|
2014-10-30 10:46:09 +00:00
|
|
|
GdkGLContext *context = GDK_GL_CONTEXT (gobject);
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = gdk_gl_context_get_surface (context);
|
|
|
|
GdkDisplay *display = gdk_surface_get_display (surface);
|
2014-10-30 10:46:09 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
|
2014-10-09 09:06:48 +00:00
|
|
|
if (eglGetCurrentContext () == context_wayland->egl_context)
|
|
|
|
eglMakeCurrent(display_wayland->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
|
|
|
EGL_NO_CONTEXT);
|
|
|
|
|
2018-01-12 00:48:27 +00:00
|
|
|
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Destroying EGL context"));
|
2014-10-09 09:06:48 +00:00
|
|
|
|
|
|
|
eglDestroyContext (display_wayland->egl_display,
|
|
|
|
context_wayland->egl_context);
|
|
|
|
context_wayland->egl_context = NULL;
|
|
|
|
}
|
2014-10-30 10:46:09 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_wayland_gl_context_parent_class)->dispose (gobject);
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
2014-10-30 10:46:09 +00:00
|
|
|
gboolean
|
2014-10-09 09:06:48 +00:00
|
|
|
gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
|
|
|
|
GdkGLContext *context)
|
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
GdkWaylandGLContext *context_wayland;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface;
|
2014-10-09 09:06:48 +00:00
|
|
|
EGLSurface egl_surface;
|
|
|
|
|
|
|
|
if (context == NULL)
|
|
|
|
{
|
|
|
|
eglMakeCurrent(display_wayland->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
|
|
|
EGL_NO_CONTEXT);
|
2014-10-30 10:46:09 +00:00
|
|
|
return TRUE;
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
|
2018-03-20 14:14:10 +00:00
|
|
|
surface = gdk_gl_context_get_surface (context);
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2018-04-23 16:24:29 +00:00
|
|
|
if (context_wayland->is_attached || gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
|
2019-04-22 01:14:46 +00:00
|
|
|
egl_surface = gdk_wayland_surface_get_egl_surface (surface, context_wayland->egl_config);
|
2014-10-09 14:09:05 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (display_wayland->have_egl_surfaceless_context)
|
|
|
|
egl_surface = EGL_NO_SURFACE;
|
|
|
|
else
|
2019-04-22 01:14:46 +00:00
|
|
|
egl_surface = gdk_wayland_surface_get_dummy_egl_surface (surface,
|
2014-10-09 14:09:05 +00:00
|
|
|
context_wayland->egl_config);
|
|
|
|
}
|
2014-10-09 09:06:48 +00:00
|
|
|
|
2014-10-09 15:24:21 +00:00
|
|
|
if (!eglMakeCurrent (display_wayland->egl_display, egl_surface,
|
2014-10-30 10:46:09 +00:00
|
|
|
egl_surface, context_wayland->egl_context))
|
|
|
|
{
|
|
|
|
g_warning ("eglMakeCurrent failed");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2014-10-09 09:06:48 +00:00
|
|
|
}
|