{
GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
GdkSurface *surface;
- GdkGLContext *shared;
cairo_region_t *damage;
int ww, wh;
- shared = gdk_gl_context_get_shared_context (context);
- if (shared)
- {
- GDK_DRAW_CONTEXT_GET_CLASS (GDK_DRAW_CONTEXT (shared))->begin_frame (GDK_DRAW_CONTEXT (shared), region);
- return;
- }
-
damage = GDK_GL_CONTEXT_GET_CLASS (context)->get_damage (context);
if (context->old_updated_area[1])
gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
cairo_region_t *painted)
{
- GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
- GdkGLContext *shared;
-
- shared = gdk_gl_context_get_shared_context (context);
- if (shared)
- {
- GDK_DRAW_CONTEXT_GET_CLASS (GDK_DRAW_CONTEXT (shared))->end_frame (GDK_DRAW_CONTEXT (shared), painted);
- return;
- }
}
static void
{
GdkSurfaceClass *class = GDK_SURFACE_GET_CLASS (surface);
- if (class->create_gl_context == NULL)
- {
- g_set_error_literal (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
- _("The current backend does not support OpenGL"));
- return NULL;
- }
-
surface->gl_paint_context =
- class->create_gl_context (surface, TRUE, NULL, &internal_error);
+ class->create_gl_context (surface, &internal_error);
}
if (internal_error != NULL)
gdk_surface_create_gl_context (GdkSurface *surface,
GError **error)
{
- GdkGLContext *paint_context;
-
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- paint_context = gdk_surface_get_paint_gl_context (surface, error);
- if (paint_context == NULL)
+ if (!gdk_display_prepare_gl (surface->display, error))
return NULL;
return GDK_SURFACE_GET_CLASS (surface)->create_gl_context (surface,
- FALSE,
- paint_context,
error);
}
void (* set_opaque_region) (GdkSurface *surface,
cairo_region_t *region);
GdkGLContext *(*create_gl_context) (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error);
void (* request_layout) (GdkSurface *surface);
gboolean (* compute_size) (GdkSurface *surface);
* want to replace our damage region for the next frame (to avoid
* doing it multiple times).
*/
- if (!self->is_attached &&
- gdk_gl_context_get_shared_context (GDK_GL_CONTEXT (context)))
- ensure_gl_view (self);
+ ensure_gl_view (self);
if (self->needs_resize)
{
if (display_wayland->have_egl_buffer_age)
{
- GdkGLContext *shared;
-
- shared = gdk_gl_context_get_shared_context (context);
- if (shared == NULL)
- shared = context;
-
egl_surface = gdk_wayland_surface_get_egl_surface (surface);
- gdk_gl_context_make_current (shared);
+ gdk_gl_context_make_current (context);
eglQuerySurface (display_wayland->egl_display, egl_surface,
EGL_BUFFER_AGE_EXT, &buffer_age);
EGLSurface egl_surface;
GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->end_frame (draw_context, painted);
- if (gdk_gl_context_get_shared_context (context))
- return;
gdk_gl_context_make_current (context);
GdkGLContext *
gdk_wayland_surface_create_gl_context (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error)
{
GdkWaylandGLContext *context;
context = g_object_new (GDK_TYPE_WAYLAND_GL_CONTEXT,
"surface", surface,
- "shared-context", share,
NULL);
- context->is_attached = attached;
-
return GDK_GL_CONTEXT (context);
}
context_wayland = GDK_WAYLAND_GL_CONTEXT (context);
surface = gdk_gl_context_get_surface (context);
- if (context_wayland->is_attached || gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
+ if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
egl_surface = gdk_wayland_surface_get_egl_surface (surface);
else
{
GdkGLContext parent_instance;
EGLContext egl_context;
- gboolean is_attached;
};
struct _GdkWaylandGLContextClass
GdkGLContext * gdk_wayland_display_init_gl (GdkDisplay *display,
GError **error);
GdkGLContext * gdk_wayland_surface_create_gl_context (GdkSurface *surface,
- gboolean attach,
- GdkGLContext *share,
GError **error);
gboolean gdk_wayland_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
cairo_rectangle_int_t whole_window;
GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_parent_class)->end_frame (draw_context, painted);
- if (gdk_gl_context_get_shared_context (context))
- return;
gdk_gl_context_make_current (context);
whole_window = (GdkRectangle) { 0, 0, gdk_surface_get_width (surface), gdk_surface_get_height (surface) };
GdkGLContext *
_gdk_win32_surface_create_gl_context (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error)
{
GdkDisplay *display = gdk_surface_get_display (surface);
context = g_object_new (GDK_TYPE_WIN32_GL_CONTEXT,
"surface", surface,
- "shared-context", share,
NULL);
context->gl_hdc = impl->hdc;
- context->is_attached = attached;
#ifdef GDK_WIN32_ENABLE_EGL
if (display_win32->have_egl)
return FALSE;
}
- if (context_win32->is_attached && display_win32->hasWglEXTSwapControl)
+ if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)) &&
+ display_win32->hasWglEXTSwapControl)
{
surface = gdk_gl_context_get_surface (context);
surface = gdk_gl_context_get_surface (context);
- if (context_win32->is_attached)
+ if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
egl_surface = _gdk_win32_surface_get_egl_surface (surface, context_win32->egl_config, FALSE);
else
{
guint need_alpha_bits : 1;
/* other items */
- guint is_attached : 1;
guint do_frame_sync : 1;
#ifdef GDK_WIN32_ENABLE_EGL
GdkGLContext *
_gdk_win32_surface_create_gl_context (GdkSurface *window,
- gboolean attached,
- GdkGLContext *share,
- GError **error);
+ GError **error);
gboolean
_gdk_win32_display_make_gl_context_current (GdkDisplay *display,
if (!have_gl)
return NULL;
- return gdk_x11_surface_create_gl_context (display_x11->leader_gdk_surface, FALSE, NULL, error);
+ return gdk_x11_surface_create_gl_context (display_x11->leader_gdk_surface, error);
}
static void
EGLSurface egl_surface;
GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_egl_parent_class)->end_frame (draw_context, painted);
- if (gdk_gl_context_get_shared_context (context) != NULL)
- return;
gdk_gl_context_make_current (context);
if (display_x11->has_egl_buffer_age)
{
GdkSurface *surface = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
- GdkGLContext *shared = gdk_gl_context_get_shared_context (context);
EGLSurface egl_surface;
int buffer_age = 0;
- shared = gdk_gl_context_get_shared_context (context);
- if (shared == NULL)
- shared = context;
-
egl_surface = gdk_x11_surface_get_egl_surface (surface);
- gdk_gl_context_make_current (shared);
+ gdk_gl_context_make_current (context);
eglQuerySurface (display_x11->egl_display,
egl_surface,
GdkX11GLContext *
gdk_x11_gl_context_egl_new (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error)
{
GdkX11GLContextEGL *context;
context = g_object_new (GDK_TYPE_X11_GL_CONTEXT_EGL,
"surface", surface,
- "shared-context", share,
NULL);
return GDK_X11_GL_CONTEXT (context);
surface = gdk_gl_context_get_surface (context);
- if (context_x11->is_attached || gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
+ if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
egl_surface = gdk_x11_surface_get_egl_surface (surface);
else
{
return FALSE;
}
- if (context_x11->is_attached)
+ if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)))
{
gboolean do_frame_sync = FALSE;
static GLXDrawable
gdk_x11_gl_context_glx_get_drawable (GdkX11GLContextGLX *self)
{
- GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (self);
GdkDrawContext *draw_context = GDK_DRAW_CONTEXT (self);
GdkSurface *surface;
- if (context_x11->is_attached || gdk_draw_context_is_in_frame (draw_context))
+ if (gdk_draw_context_is_in_frame (draw_context))
surface = gdk_draw_context_get_surface (draw_context);
else
surface = GDK_X11_DISPLAY (gdk_draw_context_get_display (draw_context))->leader_gdk_surface;
GLXDrawable drawable;
GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_glx_parent_class)->end_frame (draw_context, painted);
- if (gdk_gl_context_get_shared_context (context) != NULL)
- return;
gdk_gl_context_make_current (context);
if (display_x11->has_glx_buffer_age)
{
- GdkGLContext *shared;
- GdkX11GLContextGLX *shared_glx;
-
- shared = gdk_gl_context_get_shared_context (context);
- if (shared == NULL)
- shared = context;
-
- shared_glx = GDK_X11_GL_CONTEXT_GLX (shared);
+ GdkX11GLContextGLX *self = GDK_X11_GL_CONTEXT_GLX (context);
- gdk_gl_context_make_current (shared);
- glXQueryDrawable (dpy, gdk_x11_gl_context_glx_get_drawable (shared_glx),
+ gdk_gl_context_make_current (context);
+ glXQueryDrawable (dpy, gdk_x11_gl_context_glx_get_drawable (self),
GLX_BACK_BUFFER_AGE_EXT, &buffer_age);
switch (buffer_age)
GdkX11Display *display_x11)
{
GdkX11GLContextGLX *context_glx = GDK_X11_GL_CONTEXT_GLX (context);
- GdkX11GLContext *context_x11 = GDK_X11_GL_CONTEXT (context);
XDamageNotifyEvent *damage_xevent;
- if (!context_x11->is_attached)
- return FALSE;
-
if (xevent->type != (display_x11->damage_event_base + XDamageNotify))
return FALSE;
GdkX11GLContext *
gdk_x11_gl_context_glx_new (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error)
{
GdkX11GLContextGLX *context;
return g_object_new (GDK_TYPE_X11_GL_CONTEXT_GLX,
"surface", surface,
- "shared-context", share,
NULL);
return GDK_X11_GL_CONTEXT (context);
return FALSE;
}
- if (context_x11->is_attached && GDK_X11_DISPLAY (display)->has_glx_swap_interval)
+ if (gdk_draw_context_is_in_frame (GDK_DRAW_CONTEXT (context)) &&
+ GDK_X11_DISPLAY (display)->has_glx_swap_interval)
{
/* If the WM is compositing there is no particular need to delay
* the swap when drawing on the offscreen, rendering to the screen
GdkGLContext *
gdk_x11_surface_create_gl_context (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error)
{
GdkX11GLContext *context = NULL;
display_x11 = GDK_X11_DISPLAY (display);
if (display_x11->egl_display)
- context = gdk_x11_gl_context_egl_new (surface, attached, share, error);
+ context = gdk_x11_gl_context_egl_new (surface, error);
else if (display_x11->glx_config != NULL)
- context = gdk_x11_gl_context_glx_new (surface, attached, share, error);
+ context = gdk_x11_gl_context_glx_new (surface, error);
else
{
g_assert (display_x11->gl_error);
if (context == NULL)
return NULL;
- context->is_attached = attached;
-
return GDK_GL_CONTEXT (context);
}
GdkGLContext parent_instance;
guint do_frame_sync : 1;
- guint is_attached : 1;
};
struct _GdkX11GLContextClass
GError **error);
GdkGLContext * gdk_x11_surface_create_gl_context (GdkSurface *window,
- gboolean attached,
- GdkGLContext *share,
GError **error);
gboolean gdk_x11_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context);
GType gdk_x11_gl_context_glx_get_type (void) G_GNUC_CONST;
GdkX11GLContext * gdk_x11_gl_context_glx_new (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error);
gboolean gdk_x11_gl_context_glx_make_current (GdkDisplay *display,
GdkGLContext *context);
GType gdk_x11_gl_context_egl_get_type (void) G_GNUC_CONST;
GdkX11GLContext * gdk_x11_gl_context_egl_new (GdkSurface *surface,
- gboolean attached,
- GdkGLContext *share,
GError **error);
gboolean gdk_x11_gl_context_egl_make_current (GdkDisplay *display,
GdkGLContext *context);