summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cogl/Makefile.am3
-rw-r--r--cogl/cogl-context.c13
-rw-r--r--cogl/cogl-egl.h20
-rw-r--r--cogl/cogl-glx.h95
-rw-r--r--cogl/cogl.symbols5
-rw-r--r--cogl/winsys/cogl-winsys-egl.c27
-rw-r--r--cogl/winsys/cogl-winsys-glx.c9
-rw-r--r--cogl/winsys/cogl-winsys-private.h5
8 files changed, 148 insertions, 29 deletions
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index 550493b2..9c01227d 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -435,6 +435,7 @@ cogl_sources_c += \
$(srcdir)/winsys/cogl-texture-pixmap-x11-private.h
endif
if SUPPORT_GLX
+cogl_experimental_h += $(srcdir)/cogl-glx.h
cogl_sources_c += \
$(srcdir)/cogl-glx-renderer-private.h \
$(srcdir)/cogl-glx-display-private.h \
@@ -667,7 +668,7 @@ if UNIT_TESTS
Cogl_1_0_gir_LIBS += $(top_builddir)/test-fixtures/libtest-fixtures.la
endif
Cogl_1_0_gir_FILES = $(cogl_1_public_h) cogl-enum-types.h
-Cogl_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -UCOGL_ENABLE_EXPERIMENTAL_API -UCOGL_ENABLE_EXPERIMENTAL_2_0_API -UCOGL_COMPILATION -D__COGL_H_INSIDE__ -D__COGL_XLIB_H_INSIDE__ -D__COGL_EGL_H_INSIDE__ -DCOGL_GIR_SCANNING
+Cogl_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -UCOGL_ENABLE_EXPERIMENTAL_API -UCOGL_ENABLE_EXPERIMENTAL_2_0_API -UCOGL_COMPILATION -D__COGL_H_INSIDE__ -D__COGL_XLIB_H_INSIDE__ -D__COGL_EGL_H_INSIDE__ -D__COGL_GLX_H_INSIDE__ -DCOGL_GIR_SCANNING
Cogl_1_0_gir_INCLUDES = GL-1.0 GObject-2.0
Cogl_1_0_gir_EXPORT_PACKAGES = cogl-1.0
Cogl_1_0_gir_SCANNERFLAGS = --warn-all --c-include='cogl/cogl.h'
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 7a6d0a43..2c005794 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -639,19 +639,6 @@ cogl_context_get_renderer (CoglContext *context)
return context->display->renderer;
}
-#ifdef COGL_HAS_EGL_SUPPORT
-EGLDisplay
-cogl_egl_context_get_egl_display (CoglContext *context)
-{
- const CoglWinsysVtable *winsys = _cogl_context_get_winsys (context);
-
- /* This should only be called for EGL contexts */
- _COGL_RETURN_VAL_IF_FAIL (winsys->context_egl_get_egl_display != NULL, NULL);
-
- return winsys->context_egl_get_egl_display (context);
-}
-#endif
-
CoglBool
_cogl_context_update_features (CoglContext *context,
CoglError **error)
diff --git a/cogl/cogl-egl.h b/cogl/cogl-egl.h
index 624b0690..cea7b103 100644
--- a/cogl/cogl-egl.h
+++ b/cogl/cogl-egl.h
@@ -79,6 +79,26 @@ COGL_BEGIN_DECLS
EGLDisplay
cogl_egl_context_get_egl_display (CoglContext *context);
+/**
+ * cogl_egl_context_get_egl_context:
+ * @context: A #CoglContext pointer
+ *
+ * If you have done a runtime check to determine that Cogl is using
+ * EGL internally then this API can be used to retrieve the EGLContext
+ * handle that was setup internally. The result is undefined if Cogl
+ * is not using EGL.
+ *
+ * Note: The current window system backend can be checked using
+ * cogl_renderer_get_winsys_id().
+ *
+ * Return value: The internally setup EGLDisplay handle.
+ * Since: 1.18
+ * Stability: unstable
+ */
+EGLContext
+cogl_egl_context_get_egl_context (CoglContext *context);
+
+
COGL_END_DECLS
/* The gobject introspection scanner seems to parse public headers in
diff --git a/cogl/cogl-glx.h b/cogl/cogl-glx.h
new file mode 100644
index 00000000..15918bba
--- /dev/null
+++ b/cogl/cogl-glx.h
@@ -0,0 +1,95 @@
+/*
+ * Cogl
+ *
+ * A Low-Level GPU Graphics and Utilities API
+ *
+ * Copyright (C) 2014 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *
+ */
+
+#ifndef __COGL_GLX_H__
+#define __COGL_GLX_H__
+
+/* NB: this is a top-level header that can be included directly but we
+ * want to be careful not to define __COGL_H_INSIDE__ when this is
+ * included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private api
+ * definitions
+ */
+#ifndef COGL_COMPILATION
+
+/* Note: When building Cogl .gir we explicitly define
+ * __COGL_GLX_H_INSIDE__ */
+#ifndef __COGL_GLX_H_INSIDE__
+#define __COGL_GLX_H_INSIDE__
+#endif
+
+/* Note: When building Cogl .gir we explicitly define
+ * __COGL_H_INSIDE__ */
+#ifndef __COGL_H_INSIDE__
+#define __COGL_H_INSIDE__
+#define __COGL_MUST_UNDEF_COGL_H_INSIDE__
+#endif
+
+#endif /* COGL_COMPILATION */
+
+
+#include <GL/glx.h>
+#include <cogl/cogl-types.h>
+
+COGL_BEGIN_DECLS
+
+/**
+ * cogl_glx_context_get_glx_context:
+ * @context: A #CoglContext pointer
+ *
+ * If you have done a runtime check to determine that Cogl is using
+ * GLX internally then this API can be used to retrieve the GLXContext
+ * handle that was setup internally. The result is undefined if Cogl
+ * is not using GLX.
+ *
+ * Return value: The internally setup GLXContext handle.
+ * Since: 1.18
+ * Stability: unstable
+ */
+GLXContext
+cogl_glx_context_get_glx_context (CoglContext *context);
+
+COGL_END_DECLS
+
+/* The gobject introspection scanner seems to parse public headers in
+ * isolation which means we need to be extra careful about how we
+ * define and undefine __COGL_H_INSIDE__ used to detect when internal
+ * headers are incorrectly included by developers. In the gobject
+ * introspection case we have to manually define __COGL_H_INSIDE__ as
+ * a commandline argument for the scanner which means we must be
+ * careful not to undefine it in a header...
+ */
+#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE__
+#undef __COGL_H_INSIDE__
+#undef __COGL_GLX_H_INSIDE__
+#undef __COGL_MUST_UNDEF_COGL_H_INSIDE__
+#endif
+
+#endif /* __COGL_GLX_H__ */
diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols
index 89626763..a1f170ff 100644
--- a/cogl/cogl.symbols
+++ b/cogl/cogl.symbols
@@ -164,6 +164,11 @@ cogl_color_unpremultiply
#ifdef COGL_HAS_EGL_SUPPORT
cogl_egl_context_get_egl_display
+cogl_egl_context_get_egl_context
+#endif
+
+#ifdef COGL_HAS_GLX_SUPPORT
+cogl_glx_context_get_glx_context
#endif
cogl_context_get_display
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index fbdadfb1..2f15c5c6 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -47,6 +47,7 @@
#include "cogl-onscreen-template-private.h"
#include "cogl-gles2-context-private.h"
#include "cogl-error-private.h"
+#include "cogl-egl.h"
#include "cogl-private.h"
@@ -860,14 +861,6 @@ _cogl_winsys_onscreen_update_swap_throttled (CoglOnscreen *onscreen)
_cogl_winsys_onscreen_bind (onscreen);
}
-static EGLDisplay
-_cogl_winsys_context_egl_get_egl_display (CoglContext *context)
-{
- CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
-
- return egl_renderer->edpy;
-}
-
static void
_cogl_winsys_save_context (CoglContext *ctx)
{
@@ -974,8 +967,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
.display_destroy = _cogl_winsys_display_destroy,
.context_init = _cogl_winsys_context_init,
.context_deinit = _cogl_winsys_context_deinit,
- .context_egl_get_egl_display =
- _cogl_winsys_context_egl_get_egl_display,
.context_create_gles2_context =
_cogl_winsys_context_create_gles2_context,
.destroy_gles2_context = _cogl_winsys_destroy_gles2_context,
@@ -1074,3 +1065,19 @@ _cogl_egl_query_wayland_buffer (CoglContext *ctx,
value);
}
#endif
+
+EGLDisplay
+cogl_egl_context_get_egl_display (CoglContext *context)
+{
+ CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
+
+ return egl_renderer->edpy;
+}
+
+EGLContext
+cogl_egl_context_get_egl_context (CoglContext *context)
+{
+ CoglDisplayEGL *egl_display = context->display->winsys;
+
+ return egl_display->egl_context;
+}
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 2b135be8..3095acfd 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -59,6 +59,7 @@
#include "cogl-error-private.h"
#include "cogl-poll-private.h"
#include "cogl-version.h"
+#include "cogl-glx.h"
#include <stdlib.h>
#include <sys/types.h>
@@ -2707,3 +2708,11 @@ _cogl_winsys_glx_get_vtable (void)
{
return &_cogl_winsys_vtable;
}
+
+GLXContext
+cogl_glx_context_get_glx_context (CoglContext *context)
+{
+ CoglGLXDisplay *glx_display = context->display->winsys;
+
+ return glx_display->glx_context;
+}
diff --git a/cogl/winsys/cogl-winsys-private.h b/cogl/winsys/cogl-winsys-private.h
index a08e1b08..d6ff1658 100644
--- a/cogl/winsys/cogl-winsys-private.h
+++ b/cogl/winsys/cogl-winsys-private.h
@@ -145,11 +145,6 @@ typedef struct _CoglWinsysVtable
int
(*onscreen_get_buffer_age) (CoglOnscreen *onscreen);
-#ifdef COGL_HAS_EGL_SUPPORT
- EGLDisplay
- (*context_egl_get_egl_display) (CoglContext *context);
-#endif
-
#ifdef COGL_HAS_XLIB_SUPPORT
XVisualInfo *
(*xlib_get_visual_info) (void);