The surfaceless extension that Mesa advertises has been renamed to
EGL_KHR_surfaceless_context instead of a separate extension for the
GLES, GLES2 and GL APIs and the new extension has been ratified by
Khronos. Therefore the KMS backend no longer runs against Mesa master.
We could just rename the extension we check for, however Weston (the
sample Wayland compositor) has switched to just creating a dummy GBM
surface and not using the surfaceless extension at all. We should
probably do the same thing.
Using the surfaceless extension could be a good idea but we don't
really need to rely on it for KMS and we would want to do it for all
EGL backends, not just the KMS backend.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit d4f22f8cb013d417c99ba03924538924191c2fe6)
This adds api to be able to request that the window system allows a
given onscreen framebuffer to be resizable, and api to add and remove
resize handlers to be called whenever the framebuffer does actually
change size.
The new functions are:
cogl_onscreen_{get,set}_resizable()
cogl_onscreen_{add,remove}_resize_handler()
The examples cogl-hello and cogl-x11-foreign have been updated to use
the new api. To smoke test how Cogl updates the viewport automatically
in response to window resizes the cogl-hello test doesn't explicitly
respond to resize events by setting the viewport and cogl-x11-foreign
responds by setting a viewport that is offset by a quarter of the
window's width/height and half the width and height of the window.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit a1a8cc00bfa2cecaf1007aec5f3dd95dc07b1786)
This makes it possible to integrate existing GLES2 code with
applications using Cogl as the rendering api.
Currently all GLES2 usage is handled with separate GLES2 contexts to
ensure that GLES2 api usage doesn't interfere with Cogl's own use of
OpenGL[ES]. The api has been designed though so we can provide tighter
integration later.
The api would allow us to support GLES2 virtualized on top of an
OpenGL/GLX driver as well as GLES2 virtualized on the core rendering api
of Cogl itself. Virtualizing the GLES2 support on Cogl will allow us to
take advantage of Cogl debugging facilities as well as let us optimize
the cost of allocating multiple GLES2 contexts and switching between
them which can both be very expensive with many drivers.
As as a side effect of this patch Cogl can also now be used as a
portable window system binding API for GLES2 as an alternative to EGL.
Parts of this patch are based on work done by Tomeu Vizoso
<tomeu.vizoso@collabora.com> who did the first iteration of adding GLES2
API support to Cogl so that WebGL support could be added to
webkit-clutter.
This patch adds a very minimal cogl-gles2-context example that shows how
to create a gles2 context, clear the screen to a random color and also
draw a triangle with the cogl api.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 4bb6eff3dbd50d8fef7d6bdbed55c5aaa70036a8)
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
Instead of creating FBOs on the GL side, the KMS EGL platform uses the
latest changes to Mesa to create an EGL surface using a GBM surface as
the native surface type. This removes some of the special vtable hooks
that the KMS platform needed because it is now much more similar to
the other platforms.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This moves all of the code specific to the Android platform out of
cogl-winsys-egl. It is completely untested apart from that it
compiles using a dummy android/native_window.h header.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This moves all of the code specific to the gdl winsys out of
cogl-winsys-egl. It is completely untested apart from that it
compiles.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The egl_surface_width/height properties in CoglDisplayEGL were
accidentally being conditionally defined depending on KMS
support. They are not necessary because CoglDisplayKMS also already
stores the width/height and this was just copied over to the EGL
dipslay.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
CoglXlibDisplay just contained one member called dummy_xwin. This was
not shared outside of the respective winsys's so I don't think it
really makes sense to have a separate shared struct for it. It seems
more like an implementation detail that is specific to the winsys
because for example it may be that the EGL winsys could use the
surfaceless extension and not bother with a dummy window. This will
also make it easier to factor out the Xlib-specific data in
CoglDisplayEGL to the platform data.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Previously the Xlib renderer data was meant to be the first member of
whatever the winsys data is. This doesn't work well for the EGL winsys
because it only needs the Xlib data if the X11 platform is used. The
Xlib renderer data is now instead created on demand and connected to
the object using cogl_object_set_user_data. There is a new function to
get access to it.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Instead of having #ifdefs to hook into the normal EGL winsys, the KMS
winsys now overrides any winsys functions that it wants. Where the
winsys wants to hook into a point within a function provided by the
EGL winsys there is a EGL-platform vtable which gets set on the EGL
renderer data during renderer_connect. The KMS-specific data on all of
the structures is now allocated separately by the KMS winsys and is
pointed to by a new 'platform' pointer in the EGL data.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
The #ifdefs in cogl-winsys-egl have been changed so that they
additionally check renderer->winsys_vtable->id for the corresponding
winsys ID so that multiple EGL platforms can be enabled.
The is a stop-gap solution until we can move all of the EGL platforms
into their own winsys files with overrides of the EGL vtable. However
with this approach we can move one platform at a time which will make
it easier.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
There are three separate EGL_KHR_surfaceless_* extensions depending on
which GL API is being used so we should probably check the right one
depending on which driver Cogl has selected.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
We were missing various platform header includes in
cogl-winsys-egl-private.h when building support for non KMS egl
platforms.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds a check for the EGL_KHR_surfaceless_opengl extension which we
depend on for being able to MakeCurrent (NO_SURFACE) as well as create a
context without and EGLConfig.
Reviewed-by: Rob Bradford <rob@linux.intel.com>
So that the various internal Cogl*EGL typedefs can be available to
cogl-winsys-kms.c this moves them into cogl-winsys-egl-private.h
Reviewed-by: Rob Bradford <rob@linux.intel.com>
This adds an internal texture_2d constructor that can wrap an EGLImage
as a CoglTexture2D. The plan is to utilize this for texture-from-pixmap
support with EGL as well as creating textures from wayland buffers.