2008-04-25 09:37:36 -04:00
|
|
|
/*
|
2009-04-27 10:48:12 -04:00
|
|
|
* Cogl
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2009-04-27 10:48:12 -04:00
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
2011-02-24 19:31:41 -05:00
|
|
|
* Copyright (C) 2007,2008,2009,2010,2011 Intel Corporation.
|
2008-04-25 09:37:36 -04:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2011-02-24 19:31:41 -05:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-03-01 07:56:10 -05:00
|
|
|
*
|
|
|
|
*
|
2011-02-24 19:31:41 -05:00
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
2008-04-25 09:37:36 -04:00
|
|
|
*/
|
|
|
|
|
Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.
Currently this is the structure I'm aiming for:
cogl/
cogl/
<put common source here>
winsys/
cogl-glx.c
cogl-wgl.c
driver/
gl/
gles/
os/ ?
utils/
cogl-fixed
cogl-matrix-stack?
cogl-journal?
cogl-primitives?
pango/
The new winsys component is a starting point for migrating window system
code (i.e. x11,glx,wgl,osx,egl etc) from Clutter to Cogl.
The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.
Overview of the planned structure:
* The winsys/ API is the API that binds OpenGL to a specific window system,
be that X11 or win32 etc. Example are glx, wgl and egl. Much of the logic
under clutter/{glx,osx,win32 etc} should migrate here.
* Note there is also the idea of a winsys-base that may represent a window
system for which there are multiple winsys APIs. An example of this is
x11, since glx and egl may both be used with x11. (currently only Clutter
has the idea of a winsys-base)
* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
GLES 1.1 (fixed funciton) and 2.0 (fully shader based)
* Everything under cogl/ should fundamentally be supporting access to the
GPU. Essentially Cogl's most basic requirement is to provide a nice GPU
Graphics API and drawing a line between this and the utility functionality
we add to support Clutter should help keep this lean and maintainable.
* Code under utils/ as suggested builds on cogl/ adding more convenient
APIs or mechanism to optimize special cases. Broadly speaking you can
compare cogl/ to OpenGL and utils/ to GLU.
* clutter/pango will be moved to clutter/cogl/pango
How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"
Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps
As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-07-27 21:02:02 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2008-04-25 09:37:36 -04:00
|
|
|
|
Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.
Currently this is the structure I'm aiming for:
cogl/
cogl/
<put common source here>
winsys/
cogl-glx.c
cogl-wgl.c
driver/
gl/
gles/
os/ ?
utils/
cogl-fixed
cogl-matrix-stack?
cogl-journal?
cogl-primitives?
pango/
The new winsys component is a starting point for migrating window system
code (i.e. x11,glx,wgl,osx,egl etc) from Clutter to Cogl.
The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.
Overview of the planned structure:
* The winsys/ API is the API that binds OpenGL to a specific window system,
be that X11 or win32 etc. Example are glx, wgl and egl. Much of the logic
under clutter/{glx,osx,win32 etc} should migrate here.
* Note there is also the idea of a winsys-base that may represent a window
system for which there are multiple winsys APIs. An example of this is
x11, since glx and egl may both be used with x11. (currently only Clutter
has the idea of a winsys-base)
* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
GLES 1.1 (fixed funciton) and 2.0 (fully shader based)
* Everything under cogl/ should fundamentally be supporting access to the
GPU. Essentially Cogl's most basic requirement is to provide a nice GPU
Graphics API and drawing a line between this and the utility functionality
we add to support Clutter should help keep this lean and maintainable.
* Code under utils/ as suggested builds on cogl/ adding more convenient
APIs or mechanism to optimize special cases. Broadly speaking you can
compare cogl/ to OpenGL and utils/ to GLU.
* clutter/pango will be moved to clutter/cogl/pango
How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"
Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps
As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-07-27 21:02:02 -04:00
|
|
|
#include "cogl.h"
|
|
|
|
|
2011-05-24 18:15:37 -04:00
|
|
|
#include "cogl-winsys-egl-private.h"
|
2011-02-24 19:31:41 -05:00
|
|
|
#include "cogl-winsys-private.h"
|
|
|
|
#include "cogl-feature-private.h"
|
|
|
|
#include "cogl-context-private.h"
|
|
|
|
#include "cogl-framebuffer.h"
|
|
|
|
#include "cogl-swap-chain-private.h"
|
|
|
|
#include "cogl-renderer-private.h"
|
|
|
|
#include "cogl-onscreen-template-private.h"
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
#include "cogl-xlib-renderer-private.h"
|
|
|
|
#include "cogl-xlib-display-private.h"
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
2011-05-24 18:15:37 -04:00
|
|
|
|
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
|
|
|
#include "cogl-texture-pixmap-x11-private.h"
|
|
|
|
#include "cogl-texture-2d-private.h"
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
#include "cogl-private.h"
|
|
|
|
|
2011-03-17 15:31:34 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
#include <wayland-client.h>
|
|
|
|
#include <wayland-egl.h>
|
|
|
|
#endif
|
|
|
|
|
2011-05-16 11:43:30 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT
|
|
|
|
#include <android/native_window.h>
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
#include <X11/Xlib.h>
|
2011-05-04 12:02:04 -04:00
|
|
|
|
|
|
|
#define COGL_ONSCREEN_X11_EVENT_MASK StructureNotifyMask
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
|
2011-05-24 12:21:28 -04:00
|
|
|
typedef enum _CoglEGLWinsysFeature
|
|
|
|
{
|
|
|
|
COGL_EGL_WINSYS_FEATURE_SWAP_REGION =1L<<0,
|
|
|
|
COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_X11_PIXMAP =1L<<1,
|
|
|
|
COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_WAYLAND_BUFFER =1L<<2
|
|
|
|
} CoglEGLWinsysFeature;
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
typedef struct _CoglRendererEGL
|
|
|
|
{
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibRenderer _parent;
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
|
2011-05-24 12:21:28 -04:00
|
|
|
CoglEGLWinsysFeature private_features;
|
|
|
|
|
2011-03-17 15:31:34 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
struct wl_display *wayland_display;
|
|
|
|
struct wl_compositor *wayland_compositor;
|
|
|
|
uint32_t wayland_event_mask;
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
EGLDisplay edpy;
|
|
|
|
|
|
|
|
EGLint egl_version_major;
|
|
|
|
EGLint egl_version_minor;
|
|
|
|
|
2011-03-04 07:50:39 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
gboolean gdl_initialized;
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
/* Function pointers for GLX specific extensions */
|
2011-05-24 12:21:28 -04:00
|
|
|
#define COGL_WINSYS_FEATURE_BEGIN(a, b, c, d)
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
#define COGL_WINSYS_FEATURE_FUNCTION(ret, name, args) \
|
|
|
|
ret (APIENTRY * pf_ ## name) args;
|
|
|
|
|
|
|
|
#define COGL_WINSYS_FEATURE_END()
|
|
|
|
|
|
|
|
#include "cogl-winsys-egl-feature-functions.h"
|
|
|
|
|
|
|
|
#undef COGL_WINSYS_FEATURE_BEGIN
|
|
|
|
#undef COGL_WINSYS_FEATURE_FUNCTION
|
|
|
|
#undef COGL_WINSYS_FEATURE_END
|
|
|
|
} CoglRendererEGL;
|
|
|
|
|
|
|
|
typedef struct _CoglDisplayEGL
|
|
|
|
{
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibDisplay _parent;
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
EGLContext egl_context;
|
2011-03-17 15:31:34 -04:00
|
|
|
#if defined (COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT)
|
|
|
|
EGLSurface dummy_surface;
|
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
|
|
|
|
struct wl_surface *wayland_surface;
|
|
|
|
struct wl_egl_window *wayland_egl_native_window;
|
2011-02-24 19:31:41 -05:00
|
|
|
EGLSurface dummy_surface;
|
2011-03-04 07:50:39 -05:00
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
|
2011-05-16 11:43:30 -04:00
|
|
|
defined (COGL_HAS_EGL_PLATFORM_GDL_SUPPORT) || \
|
|
|
|
defined (COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT)
|
2011-02-24 19:31:41 -05:00
|
|
|
EGLSurface egl_surface;
|
|
|
|
int egl_surface_width;
|
|
|
|
int egl_surface_height;
|
|
|
|
gboolean have_onscreen;
|
2010-09-28 10:17:46 -04:00
|
|
|
#else
|
2011-02-24 19:31:41 -05:00
|
|
|
#error "Unknown EGL platform"
|
2010-09-28 10:17:46 -04:00
|
|
|
#endif
|
2010-03-25 23:55:31 -04:00
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
EGLConfig egl_config;
|
|
|
|
gboolean found_egl_config;
|
|
|
|
} CoglDisplayEGL;
|
|
|
|
|
|
|
|
typedef struct _CoglContextEGL
|
|
|
|
{
|
|
|
|
EGLSurface current_surface;
|
|
|
|
} CoglContextEGL;
|
|
|
|
|
2011-03-17 15:31:34 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-02-24 19:31:41 -05:00
|
|
|
typedef struct _CoglOnscreenXlib
|
|
|
|
{
|
|
|
|
Window xwin;
|
|
|
|
gboolean is_foreign_xwin;
|
|
|
|
} CoglOnscreenXlib;
|
2011-03-17 15:31:34 -04:00
|
|
|
#endif
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
typedef struct _CoglOnscreenEGL
|
|
|
|
{
|
2011-03-17 15:31:34 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-02-24 19:31:41 -05:00
|
|
|
CoglOnscreenXlib _parent;
|
2011-03-17 15:31:34 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
struct wl_egl_window *wayland_egl_native_window;
|
|
|
|
struct wl_surface *wayland_surface;
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
EGLSurface egl_surface;
|
|
|
|
} CoglOnscreenEGL;
|
|
|
|
|
2011-05-24 18:15:37 -04:00
|
|
|
#ifdef EGL_KHR_image_pixmap
|
|
|
|
typedef struct _CoglTexturePixmapEGL
|
|
|
|
{
|
|
|
|
EGLImageKHR image;
|
|
|
|
CoglHandle texture;
|
|
|
|
} CoglTexturePixmapEGL;
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
/* Define a set of arrays containing the functions required from GL
|
|
|
|
for each winsys feature */
|
|
|
|
#define COGL_WINSYS_FEATURE_BEGIN(name, namespaces, extension_names, \
|
2011-05-24 12:21:28 -04:00
|
|
|
egl_private_flags) \
|
2011-02-24 19:31:41 -05:00
|
|
|
static const CoglFeatureFunction \
|
|
|
|
cogl_egl_feature_ ## name ## _funcs[] = {
|
|
|
|
#define COGL_WINSYS_FEATURE_FUNCTION(ret, name, args) \
|
|
|
|
{ G_STRINGIFY (name), G_STRUCT_OFFSET (CoglRendererEGL, pf_ ## name) },
|
|
|
|
#define COGL_WINSYS_FEATURE_END() \
|
|
|
|
{ NULL, 0 }, \
|
|
|
|
};
|
|
|
|
#include "cogl-winsys-egl-feature-functions.h"
|
|
|
|
|
|
|
|
/* Define an array of features */
|
|
|
|
#undef COGL_WINSYS_FEATURE_BEGIN
|
|
|
|
#define COGL_WINSYS_FEATURE_BEGIN(name, namespaces, extension_names, \
|
2011-05-24 12:21:28 -04:00
|
|
|
egl_private_flags) \
|
2011-07-06 13:59:20 -04:00
|
|
|
{ 255, 255, 0, namespaces, extension_names, \
|
2011-05-24 12:21:28 -04:00
|
|
|
0, egl_private_flags, \
|
|
|
|
0, \
|
2011-02-24 19:31:41 -05:00
|
|
|
cogl_egl_feature_ ## name ## _funcs },
|
|
|
|
#undef COGL_WINSYS_FEATURE_FUNCTION
|
|
|
|
#define COGL_WINSYS_FEATURE_FUNCTION(ret, name, args)
|
|
|
|
#undef COGL_WINSYS_FEATURE_END
|
|
|
|
#define COGL_WINSYS_FEATURE_END()
|
|
|
|
|
|
|
|
static const CoglFeatureData winsys_feature_data[] =
|
|
|
|
{
|
|
|
|
#include "cogl-winsys-egl-feature-functions.h"
|
|
|
|
};
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static CoglFuncPtr
|
2011-07-27 07:30:02 -04:00
|
|
|
_cogl_winsys_renderer_get_proc_address (CoglRenderer *renderer,
|
|
|
|
const char *name)
|
Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.
Currently this is the structure I'm aiming for:
cogl/
cogl/
<put common source here>
winsys/
cogl-glx.c
cogl-wgl.c
driver/
gl/
gles/
os/ ?
utils/
cogl-fixed
cogl-matrix-stack?
cogl-journal?
cogl-primitives?
pango/
The new winsys component is a starting point for migrating window system
code (i.e. x11,glx,wgl,osx,egl etc) from Clutter to Cogl.
The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.
Overview of the planned structure:
* The winsys/ API is the API that binds OpenGL to a specific window system,
be that X11 or win32 etc. Example are glx, wgl and egl. Much of the logic
under clutter/{glx,osx,win32 etc} should migrate here.
* Note there is also the idea of a winsys-base that may represent a window
system for which there are multiple winsys APIs. An example of this is
x11, since glx and egl may both be used with x11. (currently only Clutter
has the idea of a winsys-base)
* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
GLES 1.1 (fixed funciton) and 2.0 (fully shader based)
* Everything under cogl/ should fundamentally be supporting access to the
GPU. Essentially Cogl's most basic requirement is to provide a nice GPU
Graphics API and drawing a line between this and the utility functionality
we add to support Clutter should help keep this lean and maintainable.
* Code under utils/ as suggested builds on cogl/ adding more convenient
APIs or mechanism to optimize special cases. Broadly speaking you can
compare cogl/ to OpenGL and utils/ to GLU.
* clutter/pango will be moved to clutter/cogl/pango
How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"
Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps
As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-07-27 21:02:02 -04:00
|
|
|
{
|
2011-07-27 07:30:02 -04:00
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
ptr = eglGetProcAddress (name);
|
|
|
|
|
|
|
|
/* eglGetProcAddress doesn't support fetching core API so we need to
|
|
|
|
get that separately with GModule */
|
|
|
|
if (ptr == NULL)
|
|
|
|
g_module_symbol (renderer->libgl_module, name, &ptr);
|
|
|
|
|
|
|
|
return ptr;
|
Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.
Currently this is the structure I'm aiming for:
cogl/
cogl/
<put common source here>
winsys/
cogl-glx.c
cogl-wgl.c
driver/
gl/
gles/
os/ ?
utils/
cogl-fixed
cogl-matrix-stack?
cogl-journal?
cogl-primitives?
pango/
The new winsys component is a starting point for migrating window system
code (i.e. x11,glx,wgl,osx,egl etc) from Clutter to Cogl.
The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.
Overview of the planned structure:
* The winsys/ API is the API that binds OpenGL to a specific window system,
be that X11 or win32 etc. Example are glx, wgl and egl. Much of the logic
under clutter/{glx,osx,win32 etc} should migrate here.
* Note there is also the idea of a winsys-base that may represent a window
system for which there are multiple winsys APIs. An example of this is
x11, since glx and egl may both be used with x11. (currently only Clutter
has the idea of a winsys-base)
* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
GLES 1.1 (fixed funciton) and 2.0 (fully shader based)
* Everything under cogl/ should fundamentally be supporting access to the
GPU. Essentially Cogl's most basic requirement is to provide a nice GPU
Graphics API and drawing a line between this and the utility functionality
we add to support Clutter should help keep this lean and maintainable.
* Code under utils/ as suggested builds on cogl/ adding more convenient
APIs or mechanism to optimize special cases. Broadly speaking you can
compare cogl/ to OpenGL and utils/ to GLU.
* clutter/pango will be moved to clutter/cogl/pango
How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"
Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps
As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-07-27 21:02:02 -04:00
|
|
|
}
|
2008-04-25 09:37:36 -04:00
|
|
|
|
2011-05-16 11:43:30 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT
|
|
|
|
static ANativeWindow *android_native_window;
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_android_set_native_window (ANativeWindow *window)
|
|
|
|
{
|
2011-06-14 17:33:44 -04:00
|
|
|
_cogl_init ();
|
|
|
|
|
2011-05-16 11:43:30 -04:00
|
|
|
android_native_window = window;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
static CoglOnscreen *
|
|
|
|
find_onscreen_for_xid (CoglContext *context, guint32 xid)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = context->framebuffers; l; l = l->next)
|
|
|
|
{
|
|
|
|
CoglFramebuffer *framebuffer = l->data;
|
|
|
|
CoglOnscreenXlib *xlib_onscreen;
|
|
|
|
|
|
|
|
if (!framebuffer->type == COGL_FRAMEBUFFER_TYPE_ONSCREEN)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
xlib_onscreen = COGL_ONSCREEN (framebuffer)->winsys;
|
|
|
|
if (xlib_onscreen->xwin == (Window)xid)
|
|
|
|
return COGL_ONSCREEN (framebuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglFilterReturn
|
2011-06-30 10:00:58 -04:00
|
|
|
event_filter_cb (XEvent *xevent, void *data)
|
2011-02-24 19:31:41 -05:00
|
|
|
{
|
|
|
|
CoglContext *context = data;
|
|
|
|
|
|
|
|
if (xevent->type == ConfigureNotify)
|
|
|
|
{
|
|
|
|
CoglOnscreen *onscreen =
|
|
|
|
find_onscreen_for_xid (context, xevent->xconfigure.window);
|
|
|
|
|
|
|
|
if (onscreen)
|
|
|
|
{
|
|
|
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
|
|
|
|
|
|
|
/* XXX: consider adding an abstraction for this... */
|
|
|
|
framebuffer->width = xevent->xconfigure.width;
|
|
|
|
framebuffer->height = xevent->xconfigure.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return COGL_FILTER_CONTINUE;
|
|
|
|
}
|
|
|
|
#endif /* COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT */
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
|
|
|
_cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer = renderer->winsys;
|
|
|
|
|
2011-03-04 07:50:39 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
if (egl_renderer->gdl_initialized)
|
|
|
|
gdl_close ();
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
_cogl_xlib_renderer_disconnect (renderer);
|
2011-02-25 06:29:08 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
eglTerminate (egl_renderer->edpy);
|
|
|
|
|
|
|
|
g_slice_free (CoglRendererEGL, egl_renderer);
|
|
|
|
}
|
|
|
|
|
2011-03-17 15:31:34 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
|
|
|
|
static void
|
|
|
|
display_handle_global_cb (struct wl_display *display,
|
|
|
|
uint32_t id,
|
|
|
|
const char *interface,
|
|
|
|
uint32_t version,
|
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
struct wl_compositor **compositor = data;
|
|
|
|
|
|
|
|
if (strcmp (interface, "wl_compositor") == 0)
|
|
|
|
*compositor = wl_compositor_create (display, id, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
event_mask_update_cb (uint32_t mask, void *user_data)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer = user_data;
|
|
|
|
egl_renderer->wayland_event_mask = mask;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sync_callback(void *data)
|
|
|
|
{
|
|
|
|
int *done = data;
|
|
|
|
|
|
|
|
*done = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
force_roundtrip(struct wl_display *display)
|
|
|
|
{
|
|
|
|
int done = 0;
|
|
|
|
|
|
|
|
wl_display_sync_callback(display, sync_callback, &done);
|
|
|
|
wl_display_iterate(display, WL_DISPLAY_WRITABLE);
|
|
|
|
while (!done)
|
|
|
|
wl_display_iterate(display, WL_DISPLAY_READABLE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-05-24 12:21:28 -04:00
|
|
|
/* Updates all the function pointers */
|
|
|
|
static void
|
|
|
|
check_egl_extensions (CoglRenderer *renderer)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer = renderer->winsys;
|
|
|
|
const char *egl_extensions;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
egl_extensions = eglQueryString (egl_renderer->edpy, EGL_EXTENSIONS);
|
|
|
|
|
|
|
|
COGL_NOTE (WINSYS, " EGL Extensions: %s", egl_extensions);
|
|
|
|
|
|
|
|
egl_renderer->private_features = 0;
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (winsys_feature_data); i++)
|
2011-07-27 07:30:02 -04:00
|
|
|
if (_cogl_feature_check (renderer,
|
2011-07-07 15:44:56 -04:00
|
|
|
"EGL", winsys_feature_data + i, 0, 0,
|
|
|
|
COGL_DRIVER_GL, /* the driver isn't used */
|
2011-05-24 12:21:28 -04:00
|
|
|
egl_extensions,
|
|
|
|
egl_renderer))
|
|
|
|
{
|
|
|
|
egl_renderer->private_features |=
|
2011-07-05 09:03:48 -04:00
|
|
|
winsys_feature_data[i].feature_flags_private;
|
2011-05-24 12:21:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static gboolean
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_renderer_connect (CoglRenderer *renderer,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer;
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibRenderer *xlib_renderer;
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
EGLBoolean status;
|
2011-03-04 07:50:39 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
gdl_ret_t rc = GDL_SUCCESS;
|
|
|
|
gdl_display_info_t gdl_display_info;
|
|
|
|
#endif
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
renderer->winsys = g_slice_new0 (CoglRendererEGL);
|
|
|
|
|
|
|
|
egl_renderer = renderer->winsys;
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
xlib_renderer = renderer->winsys;
|
|
|
|
|
2011-06-28 09:16:24 -04:00
|
|
|
if (!_cogl_xlib_renderer_connect (renderer, error))
|
2011-02-24 19:31:41 -05:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
egl_renderer->edpy =
|
|
|
|
eglGetDisplay ((NativeDisplayType) xlib_renderer->xdpy);
|
|
|
|
|
|
|
|
status = eglInitialize (egl_renderer->edpy,
|
|
|
|
&egl_renderer->egl_version_major,
|
|
|
|
&egl_renderer->egl_version_minor);
|
2011-03-17 15:31:34 -04:00
|
|
|
|
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
|
|
|
|
|
2011-05-10 17:28:13 -04:00
|
|
|
/* The EGL API doesn't provide for a way to explicitly select a
|
|
|
|
* platform when the driver can support multiple. Mesa allows
|
|
|
|
* selection using an environment variable though so that's what
|
|
|
|
* we're doing here... */
|
|
|
|
setenv("EGL_PLATFORM", "wayland", 1);
|
|
|
|
|
2011-03-17 15:31:34 -04:00
|
|
|
if (renderer->foreign_wayland_display)
|
|
|
|
{
|
|
|
|
egl_renderer->wayland_display = renderer->foreign_wayland_display;
|
|
|
|
/* XXX: For now we have to assume that if a foreign display is
|
|
|
|
* given then so is a foreing compositor because there is no way
|
|
|
|
* to retrospectively be notified of the compositor. */
|
|
|
|
g_assert (renderer->foreign_wayland_compositor);
|
|
|
|
egl_renderer->wayland_compositor = renderer->foreign_wayland_compositor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
egl_renderer->wayland_display = wl_display_connect (NULL);
|
|
|
|
if (!egl_renderer->wayland_display)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_INIT,
|
|
|
|
"Failed to connect wayland display");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX: For some reason, this can only be done after calling
|
|
|
|
* eglInitialize otherwise eglInitialize fails in
|
|
|
|
* dri2_initialize_wayland because dri2_dpy->wl_dpy->fd doesn't get
|
|
|
|
* updated.
|
|
|
|
*
|
|
|
|
* XXX: Hmm actually now it seems to work :-/
|
|
|
|
* There seems to be some fragility about when this is called.
|
|
|
|
*/
|
|
|
|
wl_display_add_global_listener (egl_renderer->wayland_display,
|
|
|
|
display_handle_global_cb,
|
|
|
|
&egl_renderer->wayland_compositor);
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_renderer->edpy =
|
|
|
|
eglGetDisplay ((EGLNativeDisplayType)egl_renderer->wayland_display);
|
|
|
|
|
|
|
|
status = eglInitialize (egl_renderer->edpy,
|
|
|
|
&egl_renderer->egl_version_major,
|
|
|
|
&egl_renderer->egl_version_minor);
|
|
|
|
|
|
|
|
wl_display_flush (egl_renderer->wayland_display);
|
|
|
|
|
|
|
|
wl_display_get_fd (egl_renderer->wayland_display,
|
|
|
|
event_mask_update_cb, egl_renderer);
|
|
|
|
|
|
|
|
/* Wait until we have been notified about the compositor object */
|
|
|
|
while (!egl_renderer->wayland_compositor)
|
|
|
|
wl_display_iterate (egl_renderer->wayland_display,
|
|
|
|
egl_renderer->wayland_event_mask);
|
2011-02-24 19:31:41 -05:00
|
|
|
#else
|
|
|
|
egl_renderer->edpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
|
|
|
|
|
|
|
|
status = eglInitialize (egl_renderer->edpy,
|
|
|
|
&egl_renderer->egl_version_major,
|
|
|
|
&egl_renderer->egl_version_minor);
|
2011-03-04 07:50:39 -05:00
|
|
|
#endif
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
if (status != EGL_TRUE)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_INIT,
|
|
|
|
"Failed to initialize EGL");
|
|
|
|
goto error;
|
|
|
|
}
|
2011-03-04 07:50:39 -05:00
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
/* Check we can talk to the GDL library */
|
|
|
|
|
|
|
|
rc = gdl_init (NULL);
|
|
|
|
if (rc != GDL_SUCCESS)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_INIT,
|
|
|
|
"GDL initialize failed. %s",
|
|
|
|
gdl_get_error_string (rc));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &gdl_display_info);
|
|
|
|
if (rc != GDL_SUCCESS)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_INIT,
|
|
|
|
"GDL failed to get display information: %s",
|
|
|
|
gdl_get_error_string (rc));
|
|
|
|
gdl_close ();
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdl_close ();
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
|
2011-05-24 12:21:28 -04:00
|
|
|
check_egl_extensions (renderer);
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
_cogl_winsys_renderer_disconnect (renderer);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-13 13:29:56 -04:00
|
|
|
static gboolean
|
|
|
|
update_winsys_features (CoglContext *context, GError **error)
|
2011-02-24 19:31:41 -05:00
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display = context->display->winsys;
|
|
|
|
CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
|
|
|
|
|
2011-07-13 13:29:56 -04:00
|
|
|
g_return_val_if_fail (egl_display->egl_context, FALSE);
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
memset (context->winsys_features, 0, sizeof (context->winsys_features));
|
|
|
|
|
2011-05-24 12:21:28 -04:00
|
|
|
check_egl_extensions (context->display->renderer);
|
2011-02-24 19:31:41 -05:00
|
|
|
|
2011-07-13 13:29:56 -04:00
|
|
|
if (!_cogl_context_update_features (context, error))
|
|
|
|
return FALSE;
|
2011-02-24 19:31:41 -05:00
|
|
|
|
2011-03-17 15:31:34 -04:00
|
|
|
#if defined (COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT) || \
|
|
|
|
defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
|
2011-02-24 19:31:41 -05:00
|
|
|
context->feature_flags |= COGL_FEATURE_ONSCREEN_MULTIPLE;
|
|
|
|
COGL_FLAGS_SET (context->winsys_features,
|
|
|
|
COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN,
|
|
|
|
TRUE);
|
|
|
|
#endif
|
|
|
|
|
2011-05-24 12:21:28 -04:00
|
|
|
if (egl_renderer->private_features & COGL_EGL_WINSYS_FEATURE_SWAP_REGION)
|
2011-02-24 19:31:41 -05:00
|
|
|
{
|
|
|
|
COGL_FLAGS_SET (context->winsys_features,
|
|
|
|
COGL_WINSYS_FEATURE_SWAP_REGION, TRUE);
|
|
|
|
COGL_FLAGS_SET (context->winsys_features,
|
|
|
|
COGL_WINSYS_FEATURE_SWAP_REGION_THROTTLE, TRUE);
|
|
|
|
}
|
2011-07-13 13:29:56 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2011-02-24 19:31:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
static XVisualInfo *
|
|
|
|
get_visual_info (CoglDisplay *display, EGLConfig egl_config)
|
|
|
|
{
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibRenderer *xlib_renderer = display->renderer->winsys;
|
2011-02-24 19:31:41 -05:00
|
|
|
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
|
|
|
XVisualInfo visinfo_template;
|
|
|
|
int template_mask = 0;
|
|
|
|
XVisualInfo *visinfo = NULL;
|
|
|
|
int visinfos_count;
|
|
|
|
EGLint visualid, red_size, green_size, blue_size, alpha_size;
|
|
|
|
|
|
|
|
eglGetConfigAttrib (egl_renderer->edpy, egl_config,
|
|
|
|
EGL_NATIVE_VISUAL_ID, &visualid);
|
|
|
|
|
|
|
|
if (visualid != 0)
|
|
|
|
{
|
|
|
|
visinfo_template.visualid = visualid;
|
|
|
|
template_mask |= VisualIDMask;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* some EGL drivers don't implement the EGL_NATIVE_VISUAL_ID
|
|
|
|
* attribute, so attempt to find the closest match. */
|
|
|
|
|
|
|
|
eglGetConfigAttrib (egl_renderer->edpy, egl_config,
|
|
|
|
EGL_RED_SIZE, &red_size);
|
|
|
|
eglGetConfigAttrib (egl_renderer->edpy, egl_config,
|
|
|
|
EGL_GREEN_SIZE, &green_size);
|
|
|
|
eglGetConfigAttrib (egl_renderer->edpy, egl_config,
|
|
|
|
EGL_BLUE_SIZE, &blue_size);
|
|
|
|
eglGetConfigAttrib (egl_renderer->edpy, egl_config,
|
|
|
|
EGL_ALPHA_SIZE, &alpha_size);
|
|
|
|
|
|
|
|
visinfo_template.depth = red_size + green_size + blue_size + alpha_size;
|
|
|
|
template_mask |= VisualDepthMask;
|
|
|
|
|
|
|
|
visinfo_template.screen = DefaultScreen (xlib_renderer->xdpy);
|
|
|
|
template_mask |= VisualScreenMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
visinfo = XGetVisualInfo (xlib_renderer->xdpy,
|
|
|
|
template_mask,
|
|
|
|
&visinfo_template,
|
|
|
|
&visinfos_count);
|
|
|
|
|
|
|
|
return visinfo;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
try_create_context (CoglDisplay *display,
|
|
|
|
int retry_cookie,
|
|
|
|
gboolean *try_fallback,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display = display->winsys;
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibDisplay *xlib_display = display->winsys;
|
|
|
|
CoglXlibRenderer *xlib_renderer = display->renderer->winsys;
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
|
|
|
EGLDisplay edpy;
|
|
|
|
EGLConfig config;
|
|
|
|
EGLint config_count = 0;
|
|
|
|
EGLBoolean status;
|
|
|
|
EGLint cfg_attribs[] = {
|
|
|
|
/* NB: This must be the first attribute, since we may
|
|
|
|
* try and fallback to no stencil buffer */
|
|
|
|
EGL_STENCIL_SIZE, 2,
|
|
|
|
|
|
|
|
EGL_RED_SIZE, 1,
|
|
|
|
EGL_GREEN_SIZE, 1,
|
|
|
|
EGL_BLUE_SIZE, 1,
|
|
|
|
EGL_ALPHA_SIZE, EGL_DONT_CARE,
|
|
|
|
|
|
|
|
EGL_DEPTH_SIZE, 1,
|
|
|
|
|
2011-03-04 07:50:39 -05:00
|
|
|
/* XXX: Why does the GDL platform choose these by default? */
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,
|
|
|
|
EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE,
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
EGL_BUFFER_SIZE, EGL_DONT_CARE,
|
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
EGL_RENDERABLE_TYPE, (display->renderer->driver == COGL_DRIVER_GL ?
|
|
|
|
EGL_OPENGL_BIT :
|
|
|
|
display->renderer->driver == COGL_DRIVER_GLES1 ?
|
|
|
|
EGL_OPENGL_ES_BIT :
|
|
|
|
EGL_OPENGL_ES2_BIT),
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
|
|
|
|
|
|
EGL_NONE
|
|
|
|
};
|
2011-07-07 15:44:56 -04:00
|
|
|
EGLint attribs[3];
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
XVisualInfo *xvisinfo;
|
|
|
|
XSetWindowAttributes attrs;
|
2011-03-17 15:31:34 -04:00
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
struct wl_visual *wayland_visual;
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
const char *error_message;
|
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
if (display->renderer->driver == COGL_DRIVER_GLES2)
|
|
|
|
{
|
|
|
|
attribs[0] = EGL_CONTEXT_CLIENT_VERSION;
|
|
|
|
attribs[1] = 2;
|
|
|
|
attribs[2] = EGL_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
attribs[0] = EGL_NONE;
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
edpy = egl_renderer->edpy;
|
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
if (display->renderer->driver == COGL_DRIVER_GL)
|
|
|
|
eglBindAPI (EGL_OPENGL_API);
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
/* Some GLES hardware can't support a stencil buffer: */
|
|
|
|
if (retry_cookie == 1)
|
|
|
|
{
|
|
|
|
g_warning ("Trying with stencil buffer disabled...");
|
|
|
|
cfg_attribs[1 /* EGL_STENCIL_SIZE */] = 0;
|
|
|
|
}
|
|
|
|
/* XXX: at this point we only have one fallback */
|
|
|
|
|
|
|
|
status = eglChooseConfig (edpy,
|
|
|
|
cfg_attribs,
|
|
|
|
&config, 1,
|
|
|
|
&config_count);
|
|
|
|
if (status != EGL_TRUE || config_count == 0)
|
|
|
|
{
|
|
|
|
error_message = "Unable to find a usable EGL configuration";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_display->egl_config = config;
|
|
|
|
|
|
|
|
egl_display->egl_context = eglCreateContext (edpy,
|
|
|
|
config,
|
|
|
|
EGL_NO_CONTEXT,
|
|
|
|
attribs);
|
|
|
|
if (egl_display->egl_context == EGL_NO_CONTEXT)
|
|
|
|
{
|
|
|
|
error_message = "Unable to create a suitable EGL context";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
|
|
|
|
xvisinfo = get_visual_info (display, config);
|
|
|
|
if (xvisinfo == NULL)
|
|
|
|
{
|
|
|
|
error_message = "Unable to find suitable X visual";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
attrs.override_redirect = True;
|
|
|
|
attrs.colormap = XCreateColormap (xlib_renderer->xdpy,
|
|
|
|
DefaultRootWindow (xlib_renderer->xdpy),
|
|
|
|
xvisinfo->visual,
|
|
|
|
AllocNone);
|
|
|
|
attrs.border_pixel = 0;
|
|
|
|
|
|
|
|
xlib_display->dummy_xwin =
|
|
|
|
XCreateWindow (xlib_renderer->xdpy,
|
|
|
|
DefaultRootWindow (xlib_renderer->xdpy),
|
|
|
|
-100, -100, 1, 1,
|
|
|
|
0,
|
|
|
|
xvisinfo->depth,
|
|
|
|
CopyFromParent,
|
|
|
|
xvisinfo->visual,
|
|
|
|
CWOverrideRedirect |
|
|
|
|
CWColormap |
|
|
|
|
CWBorderPixel,
|
|
|
|
&attrs);
|
|
|
|
|
|
|
|
XFree (xvisinfo);
|
|
|
|
|
|
|
|
egl_display->dummy_surface =
|
|
|
|
eglCreateWindowSurface (edpy,
|
|
|
|
egl_display->egl_config,
|
|
|
|
(NativeWindowType) xlib_display->dummy_xwin,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (egl_display->dummy_surface == EGL_NO_SURFACE)
|
|
|
|
{
|
2011-03-17 15:31:34 -04:00
|
|
|
error_message = "Unable to create an EGL surface";
|
2011-02-24 19:31:41 -05:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eglMakeCurrent (edpy,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->egl_context))
|
|
|
|
{
|
2011-03-17 15:31:34 -04:00
|
|
|
error_message = "Unable to eglMakeCurrent with dummy surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
|
|
|
|
|
|
|
|
egl_display->wayland_surface =
|
|
|
|
wl_compositor_create_surface (egl_renderer->wayland_compositor);
|
|
|
|
if (!egl_display->wayland_surface)
|
|
|
|
{
|
|
|
|
error_message= "Failed to create a dummy wayland surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
wayland_visual =
|
|
|
|
wl_display_get_premultiplied_argb_visual (egl_renderer->wayland_display);
|
|
|
|
egl_display->wayland_egl_native_window =
|
|
|
|
wl_egl_window_create (egl_display->wayland_surface,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
wayland_visual);
|
|
|
|
if (!egl_display->wayland_egl_native_window)
|
|
|
|
{
|
|
|
|
error_message= "Failed to create a dummy wayland native egl surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_display->dummy_surface =
|
|
|
|
eglCreateWindowSurface (edpy,
|
|
|
|
egl_display->egl_config,
|
|
|
|
(EGLNativeWindowType)
|
|
|
|
egl_display->wayland_egl_native_window,
|
|
|
|
NULL);
|
|
|
|
if (egl_display->dummy_surface == EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
error_message= "Unable to eglMakeCurrent with dummy surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eglMakeCurrent (edpy,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->egl_context))
|
|
|
|
{
|
|
|
|
error_message = "Unable to eglMakeCurrent with dummy surface";
|
2011-02-24 19:31:41 -05:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2011-05-16 11:43:30 -04:00
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT)
|
|
|
|
{
|
|
|
|
EGLint format;
|
|
|
|
|
|
|
|
if (android_native_window == NULL)
|
|
|
|
{
|
|
|
|
error_message = "No ANativeWindow window specified with "
|
|
|
|
"cogl_android_set_native_window()";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
|
|
|
|
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry ().
|
|
|
|
* As soon as we picked a EGLConfig, we can safely reconfigure the
|
|
|
|
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
|
|
|
|
eglGetConfigAttrib (edpy, config, EGL_NATIVE_VISUAL_ID, &format);
|
|
|
|
|
|
|
|
ANativeWindow_setBuffersGeometry (android_native_window,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
format);
|
|
|
|
|
|
|
|
egl_display->egl_surface =
|
|
|
|
eglCreateWindowSurface (edpy,
|
|
|
|
config,
|
|
|
|
(NativeWindowType) android_native_window,
|
|
|
|
NULL);
|
|
|
|
if (egl_display->egl_surface == EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
error_message = "Unable to create EGL window surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eglMakeCurrent (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
egl_display->egl_context))
|
|
|
|
{
|
|
|
|
error_message = "Unable to eglMakeCurrent with egl surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
eglQuerySurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
EGL_WIDTH,
|
|
|
|
&egl_display->egl_surface_width);
|
|
|
|
|
|
|
|
eglQuerySurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
EGL_HEIGHT,
|
|
|
|
&egl_display->egl_surface_height);
|
|
|
|
}
|
2011-07-26 10:23:37 -04:00
|
|
|
|
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_GDL_SUPPORT)
|
|
|
|
|
|
|
|
egl_display->egl_surface =
|
|
|
|
eglCreateWindowSurface (edpy,
|
|
|
|
config,
|
|
|
|
(NativeWindowType) display->gdl_plane,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (egl_display->egl_surface == EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
error_message = "Unable to create EGL window surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eglMakeCurrent (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
egl_display->egl_context))
|
|
|
|
{
|
|
|
|
error_message = "Unable to eglMakeCurrent with egl surface";
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
eglQuerySurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
EGL_WIDTH,
|
|
|
|
&egl_display->egl_surface_width);
|
|
|
|
|
|
|
|
eglQuerySurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
EGL_HEIGHT,
|
|
|
|
&egl_display->egl_surface_height);
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT)
|
|
|
|
|
|
|
|
egl_display->egl_surface =
|
|
|
|
eglCreateWindowSurface (edpy,
|
|
|
|
config,
|
|
|
|
(NativeWindowType) NULL,
|
|
|
|
NULL);
|
|
|
|
if (egl_display->egl_surface == EGL_NO_SURFACE)
|
|
|
|
{
|
2011-03-17 15:31:34 -04:00
|
|
|
error_message = "Unable to create EGL window surface";
|
2011-02-24 19:31:41 -05:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!eglMakeCurrent (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
egl_display->egl_context))
|
|
|
|
{
|
2011-03-17 15:31:34 -04:00
|
|
|
error_message = "Unable to eglMakeCurrent with egl surface";
|
2011-02-24 19:31:41 -05:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
eglQuerySurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
EGL_WIDTH,
|
|
|
|
&egl_display->egl_surface_width);
|
|
|
|
|
|
|
|
eglQuerySurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_surface,
|
|
|
|
EGL_HEIGHT,
|
|
|
|
&egl_display->egl_surface_height);
|
|
|
|
|
|
|
|
#else
|
|
|
|
#error "Unknown EGL platform"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
|
|
|
|
/* Currently we only have one fallback path... */
|
|
|
|
if (retry_cookie == 0)
|
|
|
|
{
|
|
|
|
*try_fallback = TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*try_fallback = FALSE;
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"%s", error_message);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cleanup_context (CoglDisplay *display)
|
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display = display->winsys;
|
|
|
|
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibDisplay *xlib_display = display->winsys;
|
|
|
|
CoglXlibRenderer *xlib_renderer = display->renderer->winsys;
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (egl_display->egl_context != EGL_NO_CONTEXT)
|
|
|
|
{
|
|
|
|
eglMakeCurrent (egl_renderer->edpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
|
|
|
EGL_NO_CONTEXT);
|
|
|
|
eglDestroyContext (egl_renderer->edpy, egl_display->egl_context);
|
|
|
|
egl_display->egl_context = EGL_NO_CONTEXT;
|
|
|
|
}
|
|
|
|
|
2011-07-26 10:39:44 -04:00
|
|
|
#if defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
|
|
|
|
defined (COGL_HAS_EGL_PLATFORM_GDL_SUPPORT)
|
|
|
|
if (egl_display->egl_surface != EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
eglDestroySurface (egl_renderer->edpy, egl_display->egl_surface);
|
|
|
|
egl_display->egl_surface = EGL_NO_SURFACE;
|
|
|
|
}
|
|
|
|
#elif COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-02-24 19:31:41 -05:00
|
|
|
if (egl_display->dummy_surface != EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
eglDestroySurface (egl_renderer->edpy, egl_display->dummy_surface);
|
|
|
|
egl_display->dummy_surface = EGL_NO_SURFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xlib_display->dummy_xwin)
|
|
|
|
{
|
|
|
|
XDestroyWindow (xlib_renderer->xdpy, xlib_display->dummy_xwin);
|
|
|
|
xlib_display->dummy_xwin = None;
|
|
|
|
}
|
2011-03-17 15:31:34 -04:00
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
|
|
|
|
if (egl_display->dummy_surface != EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
eglDestroySurface (egl_renderer->edpy, egl_display->dummy_surface);
|
|
|
|
egl_display->dummy_surface = EGL_NO_SURFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (egl_display->wayland_egl_native_window)
|
|
|
|
{
|
|
|
|
wl_egl_window_destroy (egl_display->wayland_egl_native_window);
|
|
|
|
egl_display->wayland_egl_native_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (egl_display->wayland_surface)
|
|
|
|
{
|
|
|
|
wl_surface_destroy (egl_display->wayland_surface);
|
|
|
|
egl_display->wayland_surface = NULL;
|
|
|
|
}
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
create_context (CoglDisplay *display, GError **error)
|
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display = display->winsys;
|
|
|
|
gboolean support_transparent_windows;
|
|
|
|
int retry_cookie = 0;
|
|
|
|
gboolean status;
|
|
|
|
gboolean try_fallback;
|
|
|
|
GError *try_error = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (egl_display->egl_context == NULL, TRUE);
|
|
|
|
|
2011-08-21 16:21:34 -04:00
|
|
|
if (display->onscreen_template->swap_chain &&
|
2011-02-24 19:31:41 -05:00
|
|
|
display->onscreen_template->swap_chain->has_alpha)
|
|
|
|
support_transparent_windows = TRUE;
|
|
|
|
else
|
|
|
|
support_transparent_windows = FALSE;
|
|
|
|
|
|
|
|
retry_cookie = 0;
|
|
|
|
while (!(status = try_create_context (display,
|
|
|
|
retry_cookie,
|
|
|
|
&try_fallback,
|
|
|
|
&try_error)) &&
|
|
|
|
try_fallback)
|
|
|
|
{
|
2011-05-16 11:04:33 -04:00
|
|
|
g_clear_error (error);
|
2011-02-24 19:31:41 -05:00
|
|
|
cleanup_context (display);
|
|
|
|
retry_cookie++;
|
|
|
|
}
|
|
|
|
if (!status)
|
|
|
|
g_propagate_error (error, try_error);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
|
|
|
_cogl_winsys_display_destroy (CoglDisplay *display)
|
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display = display->winsys;
|
|
|
|
|
|
|
|
g_return_if_fail (egl_display != NULL);
|
|
|
|
|
|
|
|
cleanup_context (display);
|
|
|
|
|
|
|
|
g_slice_free (CoglDisplayEGL, display->winsys);
|
|
|
|
display->winsys = NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-04 07:50:39 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
static gboolean
|
|
|
|
gdl_plane_init (CoglDisplay *display, GError **error)
|
|
|
|
{
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB;
|
2011-07-26 10:23:37 -04:00
|
|
|
gdl_pixel_format_t pixfmt = GDL_PF_ARGB_32;
|
2011-03-04 07:50:39 -05:00
|
|
|
gdl_rectangle_t dstRect;
|
|
|
|
gdl_display_info_t display_info;
|
|
|
|
gdl_ret_t rc = GDL_SUCCESS;
|
|
|
|
|
|
|
|
if (!display->gdl_plane)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"No GDL plane specified with "
|
|
|
|
"cogl_gdl_display_set_plane");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = gdl_init (NULL);
|
|
|
|
if (rc != GDL_SUCCESS)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"GDL initialize failed. %s", gdl_get_error_string (rc));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &display_info);
|
|
|
|
if (rc != GDL_SUCCESS)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"GDL failed to get display infomation: %s",
|
|
|
|
gdl_get_error_string (rc));
|
|
|
|
gdl_close ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dstRect.origin.x = 0;
|
|
|
|
dstRect.origin.y = 0;
|
|
|
|
dstRect.width = display_info.tvmode.width;
|
|
|
|
dstRect.height = display_info.tvmode.height;
|
|
|
|
|
|
|
|
/* Configure the plane attribute. */
|
2011-07-26 10:23:37 -04:00
|
|
|
rc = gdl_plane_reset (display->gdl_plane);
|
2011-03-04 07:50:39 -05:00
|
|
|
if (rc == GDL_SUCCESS)
|
2011-07-26 10:23:37 -04:00
|
|
|
rc = gdl_plane_config_begin (display->gdl_plane);
|
2011-03-04 07:50:39 -05:00
|
|
|
|
|
|
|
if (rc == GDL_SUCCESS)
|
|
|
|
rc = gdl_plane_set_attr (GDL_PLANE_SRC_COLOR_SPACE, &colorSpace);
|
|
|
|
|
|
|
|
if (rc == GDL_SUCCESS)
|
|
|
|
rc = gdl_plane_set_attr (GDL_PLANE_PIXEL_FORMAT, &pixfmt);
|
|
|
|
|
|
|
|
if (rc == GDL_SUCCESS)
|
|
|
|
rc = gdl_plane_set_attr (GDL_PLANE_DST_RECT, &dstRect);
|
|
|
|
|
2011-08-21 16:21:34 -04:00
|
|
|
/* Default to triple buffering if the swap_chain doesn't have an explicit
|
|
|
|
* length */
|
2011-03-04 07:50:39 -05:00
|
|
|
if (rc == GDL_SUCCESS)
|
2011-08-01 10:23:25 -04:00
|
|
|
{
|
2011-08-21 16:21:34 -04:00
|
|
|
if (display->onscreen_template->swap_chain &&
|
|
|
|
display->onscreen_template->swap_chain->length != -1)
|
2011-08-01 10:23:25 -04:00
|
|
|
rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES,
|
|
|
|
display->onscreen_template->swap_chain->length);
|
|
|
|
else
|
|
|
|
rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES, 3);
|
|
|
|
}
|
2011-03-04 07:50:39 -05:00
|
|
|
|
|
|
|
if (rc == GDL_SUCCESS)
|
|
|
|
rc = gdl_plane_config_end (GDL_FALSE);
|
|
|
|
else
|
|
|
|
gdl_plane_config_end (GDL_TRUE);
|
|
|
|
|
|
|
|
if (rc != GDL_SUCCESS)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
|
|
"GDL configuration failed: %s.", gdl_get_error_string (rc));
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdl_close ();
|
2011-07-26 10:23:37 -04:00
|
|
|
|
|
|
|
return TRUE;
|
2011-03-04 07:50:39 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static gboolean
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_display_setup (CoglDisplay *display,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display;
|
2011-05-24 20:37:56 -04:00
|
|
|
#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT
|
|
|
|
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
|
|
|
#endif
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
g_return_val_if_fail (display->winsys == NULL, FALSE);
|
|
|
|
|
|
|
|
egl_display = g_slice_new0 (CoglDisplayEGL);
|
|
|
|
display->winsys = egl_display;
|
|
|
|
|
2011-03-04 07:50:39 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
if (!gdl_plane_init (display, error))
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
|
2011-05-24 20:37:56 -04:00
|
|
|
#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT
|
|
|
|
if (display->wayland_compositor_display)
|
|
|
|
{
|
|
|
|
struct wl_display *wayland_display = display->wayland_compositor_display;
|
|
|
|
egl_renderer->pf_eglBindWaylandDisplay (egl_renderer->edpy,
|
|
|
|
wayland_display);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
if (!create_context (display, error))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
egl_display->found_egl_config = TRUE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
_cogl_winsys_display_destroy (display);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static gboolean
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_context_init (CoglContext *context, GError **error)
|
|
|
|
{
|
|
|
|
context->winsys = g_new0 (CoglContextEGL, 1);
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 08:38:50 -04:00
|
|
|
cogl_xlib_renderer_add_filter (context->display->renderer,
|
|
|
|
event_filter_cb,
|
|
|
|
context);
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
2011-07-13 13:29:56 -04:00
|
|
|
return update_winsys_features (context, error);
|
2011-02-24 19:31:41 -05:00
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_context_deinit (CoglContext *context)
|
|
|
|
{
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 08:38:50 -04:00
|
|
|
cogl_xlib_renderer_remove_filter (context->display->renderer,
|
|
|
|
event_filter_cb,
|
|
|
|
context);
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
g_free (context->winsys);
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static gboolean
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
|
|
|
CoglContext *context = framebuffer->context;
|
|
|
|
CoglDisplay *display = context->display;
|
|
|
|
CoglDisplayEGL *egl_display = display->winsys;
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibRenderer *xlib_renderer = display->renderer->winsys;
|
2011-02-24 19:31:41 -05:00
|
|
|
CoglOnscreenXlib *xlib_onscreen;
|
|
|
|
Window xwin;
|
2011-03-17 15:31:34 -04:00
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
CoglRendererEGL *egl_renderer = display->renderer->winsys;
|
2011-02-24 19:31:41 -05:00
|
|
|
#endif
|
|
|
|
CoglOnscreenEGL *egl_onscreen;
|
2011-03-17 15:31:34 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
struct wl_visual *wayland_visual;
|
|
|
|
#endif
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
g_return_val_if_fail (egl_display->egl_context, FALSE);
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
|
|
|
|
/* FIXME: We need to explicitly Select for ConfigureNotify events.
|
|
|
|
* For foreign windows we need to be careful not to mess up any
|
|
|
|
* existing event mask.
|
|
|
|
* We need to document that for windows we create then toolkits
|
|
|
|
* must be careful not to clear event mask bits that we select.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* XXX: Note we ignore the user's original width/height when
|
|
|
|
* given a foreign X window. */
|
|
|
|
if (onscreen->foreign_xid)
|
|
|
|
{
|
|
|
|
Status status;
|
|
|
|
CoglXlibTrapState state;
|
|
|
|
XWindowAttributes attr;
|
|
|
|
int xerror;
|
|
|
|
|
|
|
|
xwin = onscreen->foreign_xid;
|
|
|
|
|
2011-06-28 09:16:24 -04:00
|
|
|
_cogl_xlib_renderer_trap_errors (display->renderer, &state);
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
status = XGetWindowAttributes (xlib_renderer->xdpy, xwin, &attr);
|
2011-06-28 09:16:24 -04:00
|
|
|
xerror = _cogl_xlib_renderer_untrap_errors (display->renderer, &state);
|
2011-02-24 19:31:41 -05:00
|
|
|
if (status == 0 || xerror)
|
|
|
|
{
|
|
|
|
char message[1000];
|
|
|
|
XGetErrorText (xlib_renderer->xdpy, xerror,
|
|
|
|
message, sizeof (message));
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"Unable to query geometry of foreign xid 0x%08lX: %s",
|
|
|
|
xwin, message);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_cogl_framebuffer_winsys_update_size (framebuffer,
|
|
|
|
attr.width, attr.height);
|
2011-05-04 12:02:04 -04:00
|
|
|
|
|
|
|
/* Make sure the app selects for the events we require... */
|
|
|
|
onscreen->foreign_update_mask_callback (onscreen,
|
|
|
|
COGL_ONSCREEN_X11_EVENT_MASK,
|
|
|
|
onscreen->foreign_update_mask_data);
|
2011-02-24 19:31:41 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
CoglXlibTrapState state;
|
|
|
|
XVisualInfo *xvisinfo;
|
|
|
|
XSetWindowAttributes xattr;
|
|
|
|
unsigned long mask;
|
|
|
|
int xerror;
|
|
|
|
|
|
|
|
width = cogl_framebuffer_get_width (framebuffer);
|
|
|
|
height = cogl_framebuffer_get_height (framebuffer);
|
|
|
|
|
2011-06-28 09:16:24 -04:00
|
|
|
_cogl_xlib_renderer_trap_errors (display->renderer, &state);
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
xvisinfo = get_visual_info (display, egl_display->egl_config);
|
|
|
|
if (xvisinfo == NULL)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"Unable to retrieve the X11 visual of context's "
|
|
|
|
"fbconfig");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* window attributes */
|
|
|
|
xattr.background_pixel = WhitePixel (xlib_renderer->xdpy,
|
|
|
|
DefaultScreen (xlib_renderer->xdpy));
|
|
|
|
xattr.border_pixel = 0;
|
|
|
|
/* XXX: is this an X resource that we are leaking‽... */
|
|
|
|
xattr.colormap = XCreateColormap (xlib_renderer->xdpy,
|
|
|
|
DefaultRootWindow (xlib_renderer->xdpy),
|
|
|
|
xvisinfo->visual,
|
|
|
|
AllocNone);
|
2011-05-10 11:22:34 -04:00
|
|
|
xattr.event_mask = COGL_ONSCREEN_X11_EVENT_MASK;
|
2011-05-04 12:02:04 -04:00
|
|
|
|
|
|
|
mask = CWBorderPixel | CWColormap | CWEventMask;
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
xwin = XCreateWindow (xlib_renderer->xdpy,
|
|
|
|
DefaultRootWindow (xlib_renderer->xdpy),
|
|
|
|
0, 0,
|
|
|
|
width, height,
|
|
|
|
0,
|
|
|
|
xvisinfo->depth,
|
|
|
|
InputOutput,
|
|
|
|
xvisinfo->visual,
|
|
|
|
mask, &xattr);
|
|
|
|
|
|
|
|
XFree (xvisinfo);
|
|
|
|
|
|
|
|
XSync (xlib_renderer->xdpy, False);
|
2011-06-28 09:16:24 -04:00
|
|
|
xerror = _cogl_xlib_renderer_untrap_errors (display->renderer, &state);
|
2011-02-24 19:31:41 -05:00
|
|
|
if (xerror)
|
|
|
|
{
|
|
|
|
char message[1000];
|
|
|
|
XGetErrorText (xlib_renderer->xdpy, xerror,
|
|
|
|
message, sizeof (message));
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"X error while creating Window for CoglOnscreen: %s",
|
|
|
|
message);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
onscreen->winsys = g_slice_new0 (CoglOnscreenEGL);
|
|
|
|
egl_onscreen = onscreen->winsys;
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
xlib_onscreen = onscreen->winsys;
|
|
|
|
|
|
|
|
xlib_onscreen->xwin = xwin;
|
|
|
|
xlib_onscreen->is_foreign_xwin = onscreen->foreign_xid ? TRUE : FALSE;
|
|
|
|
|
|
|
|
egl_onscreen->egl_surface =
|
|
|
|
eglCreateWindowSurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_config,
|
|
|
|
(NativeWindowType) xlib_onscreen->xwin,
|
|
|
|
NULL);
|
2011-03-17 15:31:34 -04:00
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
|
|
|
|
|
|
|
|
egl_onscreen->wayland_surface =
|
|
|
|
wl_compositor_create_surface (egl_renderer->wayland_compositor);
|
|
|
|
if (!egl_onscreen->wayland_surface)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"Error while creating wayland surface for CoglOnscreen");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
wayland_visual =
|
|
|
|
wl_display_get_premultiplied_argb_visual (egl_renderer->wayland_display);
|
|
|
|
egl_onscreen->wayland_egl_native_window =
|
|
|
|
wl_egl_window_create (egl_onscreen->wayland_surface,
|
|
|
|
cogl_framebuffer_get_width (framebuffer),
|
|
|
|
cogl_framebuffer_get_height (framebuffer),
|
|
|
|
wayland_visual);
|
|
|
|
if (!egl_onscreen->wayland_egl_native_window)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"Error while creating wayland egl native window "
|
|
|
|
"for CoglOnscreen");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_onscreen->egl_surface =
|
|
|
|
eglCreateWindowSurface (egl_renderer->edpy,
|
|
|
|
egl_display->egl_config,
|
|
|
|
(EGLNativeWindowType)
|
|
|
|
egl_onscreen->wayland_egl_native_window,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
wl_surface_map_toplevel (egl_onscreen->wayland_surface);
|
|
|
|
|
2011-05-16 11:43:30 -04:00
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
|
2011-07-26 10:23:37 -04:00
|
|
|
defined (COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT) || \
|
|
|
|
defined (COGL_HAS_EGL_PLATFORM_GDL_SUPPORT)
|
2011-02-24 19:31:41 -05:00
|
|
|
if (egl_display->have_onscreen)
|
|
|
|
{
|
|
|
|
g_set_error (error, COGL_WINSYS_ERROR,
|
|
|
|
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
|
|
|
|
"EGL platform only supports a single onscreen window");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_onscreen->egl_surface = egl_display->egl_surface;
|
|
|
|
|
|
|
|
_cogl_framebuffer_winsys_update_size (framebuffer,
|
|
|
|
egl_display->egl_surface_width,
|
|
|
|
egl_display->egl_surface_height);
|
|
|
|
egl_display->have_onscreen = TRUE;
|
|
|
|
#else
|
|
|
|
#error "Unknown EGL platform"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
|
|
|
CoglContext *context = framebuffer->context;
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibRenderer *xlib_renderer = context->display->renderer->winsys;
|
2011-02-24 19:31:41 -05:00
|
|
|
CoglXlibTrapState old_state;
|
|
|
|
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;
|
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT)
|
|
|
|
CoglDisplayEGL *egl_display = context->display->winsys;
|
|
|
|
#endif
|
|
|
|
CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
|
2011-05-10 15:23:39 -04:00
|
|
|
/* If we never successfully allocated then there's nothing to do */
|
|
|
|
if (egl_onscreen == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-02-24 19:31:41 -05:00
|
|
|
if (egl_onscreen->egl_surface != EGL_NO_SURFACE)
|
|
|
|
{
|
|
|
|
if (eglDestroySurface (egl_renderer->edpy, egl_onscreen->egl_surface)
|
|
|
|
== EGL_FALSE)
|
|
|
|
g_warning ("Failed to destroy EGL surface");
|
|
|
|
egl_onscreen->egl_surface = EGL_NO_SURFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT
|
|
|
|
egl_display->have_onscreen = FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-06-28 09:16:24 -04:00
|
|
|
_cogl_xlib_renderer_trap_errors (context->display->renderer, &old_state);
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
if (!xlib_onscreen->is_foreign_xwin && xlib_onscreen->xwin != None)
|
|
|
|
{
|
|
|
|
XDestroyWindow (xlib_renderer->xdpy, xlib_onscreen->xwin);
|
|
|
|
xlib_onscreen->xwin = None;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
xlib_onscreen->xwin = None;
|
|
|
|
|
|
|
|
XSync (xlib_renderer->xdpy, False);
|
|
|
|
|
2011-06-28 09:16:24 -04:00
|
|
|
if (_cogl_xlib_renderer_untrap_errors (context->display->renderer,
|
2011-05-25 17:23:06 -04:00
|
|
|
&old_state) != Success)
|
2011-02-24 19:31:41 -05:00
|
|
|
g_warning ("X Error while destroying X window");
|
|
|
|
#endif
|
2011-03-17 15:31:34 -04:00
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
if (egl_onscreen->wayland_egl_native_window)
|
|
|
|
{
|
|
|
|
wl_egl_window_destroy (egl_onscreen->wayland_egl_native_window);
|
|
|
|
egl_onscreen->wayland_egl_native_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (egl_onscreen->wayland_surface)
|
|
|
|
{
|
|
|
|
wl_surface_destroy (egl_onscreen->wayland_surface);
|
|
|
|
egl_onscreen->wayland_surface = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2011-05-10 15:23:39 -04:00
|
|
|
|
|
|
|
g_slice_free (CoglOnscreenEGL, onscreen->winsys);
|
|
|
|
onscreen->winsys = NULL;
|
2011-02-24 19:31:41 -05:00
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
|
|
|
CoglContextEGL *egl_context = context->winsys;
|
|
|
|
CoglDisplayEGL *egl_display = context->display->winsys;
|
|
|
|
CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
|
|
|
|
if (egl_context->current_surface == egl_onscreen->egl_surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (!onscreen))
|
|
|
|
{
|
2011-03-17 15:31:34 -04:00
|
|
|
#if defined (COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT) || \
|
|
|
|
defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
|
2011-02-24 19:31:41 -05:00
|
|
|
eglMakeCurrent (egl_renderer->edpy,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->dummy_surface,
|
|
|
|
egl_display->egl_context);
|
|
|
|
egl_context->current_surface = egl_display->dummy_surface;
|
2011-05-16 11:43:30 -04:00
|
|
|
#elif defined (COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT) || \
|
2011-07-26 10:23:37 -04:00
|
|
|
defined (COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT) || \
|
|
|
|
defined (COGL_HAS_EGL_PLATFORM_GDL_SUPPORT)
|
2011-02-24 19:31:41 -05:00
|
|
|
return;
|
|
|
|
#else
|
|
|
|
#error "Unknown EGL platform"
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eglMakeCurrent (egl_renderer->edpy,
|
|
|
|
egl_onscreen->egl_surface,
|
|
|
|
egl_onscreen->egl_surface,
|
|
|
|
egl_display->egl_context);
|
|
|
|
egl_context->current_surface = egl_onscreen->egl_surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onscreen->swap_throttled)
|
|
|
|
eglSwapInterval (egl_renderer->edpy, 1);
|
|
|
|
else
|
|
|
|
eglSwapInterval (egl_renderer->edpy, 0);
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
2011-07-22 07:23:40 -04:00
|
|
|
const int *user_rectangles,
|
2011-02-24 19:31:41 -05:00
|
|
|
int n_rectangles)
|
|
|
|
{
|
|
|
|
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
|
|
|
CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
2011-07-22 07:23:40 -04:00
|
|
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
|
|
|
int framebuffer_height = cogl_framebuffer_get_height (framebuffer);
|
|
|
|
int *rectangles = g_alloca (sizeof (int) * n_rectangles * 4);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* eglSwapBuffersRegion expects rectangles relative to the bottom left corner
|
|
|
|
* but we are given rectangles relative to the top left so we need to flip
|
|
|
|
* them... */
|
|
|
|
memcpy (rectangles, user_rectangles, sizeof (int) * n_rectangles * 4);
|
|
|
|
for (i = 0; i < n_rectangles; i++)
|
|
|
|
{
|
|
|
|
int *rect = &rectangles[4 * i];
|
|
|
|
rect[1] = framebuffer_height - rect[1] - rect[3];
|
|
|
|
}
|
2011-02-24 19:31:41 -05:00
|
|
|
|
|
|
|
if (egl_renderer->pf_eglSwapBuffersRegion (egl_renderer->edpy,
|
|
|
|
egl_onscreen->egl_surface,
|
|
|
|
n_rectangles,
|
|
|
|
rectangles) == EGL_FALSE)
|
|
|
|
g_warning ("Error reported by eglSwapBuffersRegion");
|
|
|
|
}
|
|
|
|
|
2011-05-04 06:10:54 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
static void
|
|
|
|
_cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
|
|
|
|
gboolean visibility)
|
|
|
|
{
|
|
|
|
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
2011-06-28 09:16:24 -04:00
|
|
|
CoglXlibRenderer *xlib_renderer = context->display->renderer->winsys;
|
2011-05-04 06:10:54 -04:00
|
|
|
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;
|
|
|
|
|
|
|
|
if (visibility)
|
|
|
|
XMapWindow (xlib_renderer->xdpy, xlib_onscreen->xwin);
|
|
|
|
else
|
|
|
|
XUnmapWindow (xlib_renderer->xdpy, xlib_onscreen->xwin);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
|
|
|
CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
|
|
|
|
eglSwapBuffers (egl_renderer->edpy, egl_onscreen->egl_surface);
|
2011-03-17 15:31:34 -04:00
|
|
|
#if 0
|
|
|
|
/* XXX: I think really this should be done automatically for
|
|
|
|
* us in eglSwapBuffers since the spec says eglSwapBuffers
|
|
|
|
* implicitly flushes client commands. */
|
|
|
|
while (egl_renderer->wayland_event_mask & WL_DISPLAY_WRITABLE)
|
|
|
|
wl_display_iterate (egl_renderer->wayland_display,
|
|
|
|
WL_DISPLAY_WRITABLE);
|
|
|
|
#endif
|
2011-02-24 19:31:41 -05:00
|
|
|
}
|
|
|
|
|
2011-03-17 15:31:34 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-02-25 06:29:08 -05:00
|
|
|
static guint32
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_onscreen_x11_get_window_xid (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;
|
|
|
|
return xlib_onscreen->xwin;
|
|
|
|
}
|
2011-03-17 15:31:34 -04:00
|
|
|
#endif
|
2011-02-24 19:31:41 -05:00
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static void
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_onscreen_update_swap_throttled (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglContext *context = COGL_FRAMEBUFFER (onscreen)->context;
|
|
|
|
CoglContextEGL *egl_context = context->winsys;
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
|
|
|
|
if (egl_context->current_surface != egl_onscreen->egl_surface)
|
|
|
|
return;
|
|
|
|
|
|
|
|
egl_context->current_surface = EGL_NO_SURFACE;
|
|
|
|
_cogl_winsys_onscreen_bind (onscreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
/* XXX: This is a particularly hacky _cogl_winsys interface... */
|
2011-02-25 06:29:08 -05:00
|
|
|
static XVisualInfo *
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_xlib_get_visual_info (void)
|
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display;
|
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctx, NULL);
|
|
|
|
|
|
|
|
g_return_val_if_fail (ctx->display->winsys, FALSE);
|
|
|
|
|
|
|
|
egl_display = ctx->display->winsys;
|
|
|
|
|
|
|
|
if (!egl_display->found_egl_config)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return get_visual_info (ctx->display, egl_display->egl_config);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static EGLDisplay
|
2011-02-24 19:31:41 -05:00
|
|
|
_cogl_winsys_context_egl_get_egl_display (CoglContext *context)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
|
|
|
|
|
|
|
|
return egl_renderer->edpy;
|
|
|
|
}
|
2011-03-01 09:43:43 -05:00
|
|
|
|
2011-05-24 18:15:37 -04:00
|
|
|
#if defined (COGL_HAS_XLIB_SUPPORT) && defined (EGL_KHR_image_pixmap)
|
|
|
|
static gboolean
|
|
|
|
_cogl_winsys_texture_pixmap_x11_create (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapEGL *egl_tex_pixmap;
|
|
|
|
EGLint attribs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
|
|
|
|
CoglPixelFormat texture_format;
|
2011-07-05 09:10:31 -04:00
|
|
|
CoglRendererEGL *egl_renderer;
|
2011-05-24 18:15:37 -04:00
|
|
|
|
|
|
|
/* FIXME: It should be possible to get to a CoglContext from any
|
|
|
|
* CoglTexture pointer. */
|
|
|
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
|
|
|
2011-07-05 09:10:31 -04:00
|
|
|
egl_renderer = ctx->display->renderer->winsys;
|
|
|
|
|
|
|
|
if (!(egl_renderer->private_features &
|
|
|
|
COGL_EGL_WINSYS_FEATURE_EGL_IMAGE_FROM_X11_PIXMAP) ||
|
2011-05-24 18:15:37 -04:00
|
|
|
!(ctx->private_feature_flags &
|
|
|
|
COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE))
|
|
|
|
{
|
|
|
|
tex_pixmap->winsys = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
egl_tex_pixmap = g_new0 (CoglTexturePixmapEGL, 1);
|
|
|
|
|
|
|
|
egl_tex_pixmap->image =
|
|
|
|
_cogl_egl_create_image (ctx,
|
|
|
|
EGL_NATIVE_PIXMAP_KHR,
|
|
|
|
(EGLClientBuffer)tex_pixmap->pixmap,
|
|
|
|
attribs);
|
|
|
|
if (egl_tex_pixmap->image == EGL_NO_IMAGE_KHR)
|
2011-07-18 06:03:29 -04:00
|
|
|
{
|
|
|
|
g_free (egl_tex_pixmap);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-05-24 18:15:37 -04:00
|
|
|
|
|
|
|
texture_format = (tex_pixmap->depth >= 32 ?
|
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE :
|
|
|
|
COGL_PIXEL_FORMAT_RGB_888);
|
|
|
|
|
|
|
|
egl_tex_pixmap->texture =
|
|
|
|
_cogl_egl_texture_2d_new_from_image (ctx,
|
|
|
|
tex_pixmap->width,
|
|
|
|
tex_pixmap->height,
|
|
|
|
texture_format,
|
|
|
|
egl_tex_pixmap->image,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
tex_pixmap->winsys = egl_tex_pixmap;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_winsys_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapEGL *egl_tex_pixmap;
|
|
|
|
|
|
|
|
/* FIXME: It should be possible to get to a CoglContext from any
|
|
|
|
* CoglTexture pointer. */
|
|
|
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
|
|
|
|
|
|
if (!tex_pixmap->winsys)
|
|
|
|
return;
|
|
|
|
|
|
|
|
egl_tex_pixmap = tex_pixmap->winsys;
|
|
|
|
|
|
|
|
if (egl_tex_pixmap->texture)
|
|
|
|
cogl_handle_unref (egl_tex_pixmap->texture);
|
|
|
|
|
|
|
|
if (egl_tex_pixmap->image != EGL_NO_IMAGE_KHR)
|
|
|
|
_cogl_egl_destroy_image (ctx, egl_tex_pixmap->image);
|
|
|
|
|
|
|
|
tex_pixmap->winsys = NULL;
|
|
|
|
g_free (egl_tex_pixmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
|
|
|
|
gboolean needs_mipmap)
|
|
|
|
{
|
|
|
|
if (needs_mipmap)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_cogl_winsys_texture_pixmap_x11_damage_notify (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglHandle
|
|
|
|
_cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap)
|
|
|
|
{
|
|
|
|
CoglTexturePixmapEGL *egl_tex_pixmap = tex_pixmap->winsys;
|
|
|
|
|
|
|
|
return egl_tex_pixmap->texture;
|
|
|
|
}
|
|
|
|
#endif /* defined (COGL_HAS_XLIB_SUPPORT) && defined (EGL_KHR_image_pixmap) */
|
|
|
|
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static CoglWinsysVtable _cogl_winsys_vtable =
|
|
|
|
{
|
2011-06-20 08:29:12 -04:00
|
|
|
.id = COGL_WINSYS_ID_EGL,
|
2011-04-18 11:24:51 -04:00
|
|
|
.name = "EGL",
|
2011-07-27 07:30:02 -04:00
|
|
|
.renderer_get_proc_address = _cogl_winsys_renderer_get_proc_address,
|
2011-02-25 06:29:08 -05:00
|
|
|
.renderer_connect = _cogl_winsys_renderer_connect,
|
|
|
|
.renderer_disconnect = _cogl_winsys_renderer_disconnect,
|
|
|
|
.display_setup = _cogl_winsys_display_setup,
|
|
|
|
.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,
|
2011-05-24 20:57:20 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-02-25 06:29:08 -05:00
|
|
|
.xlib_get_visual_info = _cogl_winsys_xlib_get_visual_info,
|
|
|
|
#endif
|
|
|
|
.onscreen_init = _cogl_winsys_onscreen_init,
|
|
|
|
.onscreen_deinit = _cogl_winsys_onscreen_deinit,
|
|
|
|
.onscreen_bind = _cogl_winsys_onscreen_bind,
|
|
|
|
.onscreen_swap_buffers = _cogl_winsys_onscreen_swap_buffers,
|
|
|
|
.onscreen_swap_region = _cogl_winsys_onscreen_swap_region,
|
2011-05-04 06:10:54 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
|
|
|
.onscreen_set_visibility = _cogl_winsys_onscreen_set_visibility,
|
|
|
|
#endif
|
2011-02-25 06:29:08 -05:00
|
|
|
.onscreen_update_swap_throttled =
|
|
|
|
_cogl_winsys_onscreen_update_swap_throttled,
|
2011-05-24 20:57:20 -04:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
2011-02-25 06:29:08 -05:00
|
|
|
.onscreen_x11_get_window_xid =
|
|
|
|
_cogl_winsys_onscreen_x11_get_window_xid,
|
2011-03-17 15:31:34 -04:00
|
|
|
#endif
|
2011-05-24 18:15:37 -04:00
|
|
|
#if defined (COGL_HAS_XLIB_SUPPORT) && defined (EGL_KHR_image_pixmap)
|
|
|
|
/* X11 tfp support... */
|
|
|
|
/* XXX: instead of having a rather monolithic winsys vtable we could
|
|
|
|
* perhaps look for a way to separate these... */
|
|
|
|
.texture_pixmap_x11_create =
|
|
|
|
_cogl_winsys_texture_pixmap_x11_create,
|
|
|
|
.texture_pixmap_x11_free =
|
|
|
|
_cogl_winsys_texture_pixmap_x11_free,
|
|
|
|
.texture_pixmap_x11_update =
|
|
|
|
_cogl_winsys_texture_pixmap_x11_update,
|
|
|
|
.texture_pixmap_x11_damage_notify =
|
|
|
|
_cogl_winsys_texture_pixmap_x11_damage_notify,
|
|
|
|
.texture_pixmap_x11_get_texture =
|
|
|
|
_cogl_winsys_texture_pixmap_x11_get_texture,
|
|
|
|
#endif /* defined (COGL_HAS_XLIB_SUPPORT) && defined (EGL_KHR_image_pixmap) */
|
2011-02-25 06:29:08 -05:00
|
|
|
};
|
2011-03-01 09:43:43 -05:00
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
/* XXX: we use a function because no doubt someone will complain
|
|
|
|
* about using c99 member initializers because they aren't portable
|
|
|
|
* to windows. We want to avoid having to rigidly follow the real
|
|
|
|
* order of members since some members are #ifdefd and we'd have
|
|
|
|
* to mirror the #ifdefing to add padding etc. For any winsys that
|
|
|
|
* can assume the platform has a sane compiler then we can just use
|
|
|
|
* c99 initializers for insane platforms they can initialize
|
|
|
|
* the members by name in a function.
|
|
|
|
*/
|
|
|
|
const CoglWinsysVtable *
|
|
|
|
_cogl_winsys_egl_get_vtable (void)
|
2011-03-01 09:43:43 -05:00
|
|
|
{
|
2011-02-25 06:29:08 -05:00
|
|
|
return &_cogl_winsys_vtable;
|
2011-03-01 09:43:43 -05:00
|
|
|
}
|
2011-05-11 09:07:02 -04:00
|
|
|
|
|
|
|
/* FIXME: we should have a separate wayland file for these entry
|
|
|
|
* points... */
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
void
|
2011-06-28 09:57:05 -04:00
|
|
|
cogl_wayland_renderer_set_foreign_display (CoglRenderer *renderer,
|
2011-05-11 09:07:02 -04:00
|
|
|
struct wl_display *display)
|
|
|
|
{
|
|
|
|
g_return_if_fail (cogl_is_renderer (renderer));
|
|
|
|
|
|
|
|
/* NB: Renderers are considered immutable once connected */
|
|
|
|
g_return_if_fail (!renderer->connected);
|
|
|
|
|
|
|
|
renderer->foreign_wayland_display = display;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wl_display *
|
2011-06-28 09:57:05 -04:00
|
|
|
cogl_wayland_renderer_get_display (CoglRenderer *renderer)
|
2011-05-11 09:07:02 -04:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
|
|
|
|
|
|
|
|
if (renderer->foreign_wayland_display)
|
|
|
|
return renderer->foreign_wayland_display;
|
|
|
|
else if (renderer->connected)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer = renderer->winsys;
|
|
|
|
return egl_renderer->wayland_display;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-06-28 09:57:05 -04:00
|
|
|
cogl_wayland_renderer_set_foreign_compositor (CoglRenderer *renderer,
|
2011-05-11 09:07:02 -04:00
|
|
|
struct wl_compositor *compositor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (cogl_is_renderer (renderer));
|
|
|
|
|
|
|
|
/* NB: Renderers are considered immutable once connected */
|
|
|
|
g_return_if_fail (!renderer->connected);
|
|
|
|
|
|
|
|
renderer->foreign_wayland_compositor = compositor;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wl_compositor *
|
2011-06-28 09:57:05 -04:00
|
|
|
cogl_wayland_renderer_get_compositor (CoglRenderer *renderer)
|
2011-05-11 09:07:02 -04:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
|
|
|
|
|
|
|
|
if (renderer->foreign_wayland_compositor)
|
|
|
|
return renderer->foreign_wayland_compositor;
|
|
|
|
else if (renderer->connected)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer = renderer->winsys;
|
|
|
|
return egl_renderer->wayland_compositor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct wl_surface *
|
|
|
|
cogl_wayland_onscreen_get_surface (CoglOnscreen *onscreen)
|
|
|
|
{
|
|
|
|
CoglFramebuffer *fb;
|
|
|
|
|
|
|
|
fb = COGL_FRAMEBUFFER (onscreen);
|
|
|
|
if (fb->allocated)
|
|
|
|
{
|
|
|
|
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
|
|
|
return egl_onscreen->wayland_surface;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT */
|
2011-05-24 17:34:10 -04:00
|
|
|
|
|
|
|
#ifdef EGL_KHR_image_base
|
|
|
|
EGLImageKHR
|
|
|
|
_cogl_egl_create_image (CoglContext *ctx,
|
|
|
|
EGLenum target,
|
|
|
|
EGLClientBuffer buffer,
|
|
|
|
const EGLint *attribs)
|
|
|
|
{
|
|
|
|
CoglDisplayEGL *egl_display = ctx->display->winsys;
|
|
|
|
CoglRendererEGL *egl_renderer = ctx->display->renderer->winsys;
|
2011-07-20 19:52:07 -04:00
|
|
|
EGLContext egl_ctx;
|
2011-05-24 17:34:10 -04:00
|
|
|
|
|
|
|
g_return_val_if_fail (egl_renderer->pf_eglCreateImage, EGL_NO_IMAGE_KHR);
|
|
|
|
|
2011-07-20 19:52:07 -04:00
|
|
|
/* The EGL_KHR_image_pixmap spec explicitly states that EGL_NO_CONTEXT must
|
|
|
|
* always be used in conjunction with the EGL_NATIVE_PIXMAP_KHR target */
|
|
|
|
#ifdef EGL_KHR_image_pixmap
|
|
|
|
if (target == EGL_NATIVE_PIXMAP_KHR)
|
|
|
|
egl_ctx = EGL_NO_CONTEXT;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
egl_ctx = egl_display->egl_context;
|
|
|
|
|
2011-05-24 17:34:10 -04:00
|
|
|
return egl_renderer->pf_eglCreateImage (egl_renderer->edpy,
|
2011-07-20 19:52:07 -04:00
|
|
|
egl_ctx,
|
2011-05-24 17:34:10 -04:00
|
|
|
target,
|
|
|
|
buffer,
|
|
|
|
attribs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_cogl_egl_destroy_image (CoglContext *ctx,
|
|
|
|
EGLImageKHR image)
|
|
|
|
{
|
|
|
|
CoglRendererEGL *egl_renderer = ctx->display->renderer->winsys;
|
|
|
|
|
|
|
|
g_return_if_fail (egl_renderer->pf_eglDestroyImage);
|
|
|
|
|
|
|
|
egl_renderer->pf_eglDestroyImage (egl_renderer->edpy, image);
|
|
|
|
}
|
|
|
|
#endif
|