Commit Graph

87 Commits

Author SHA1 Message Date
Robert Bragg
f0366907d3 build: egl fix typo introduced by 3b64a439f0
The XEvent argument for event_filter_cb was named "event" but the rest
of the function is expecting a variable named "xevent".
2011-06-30 15:00:58 +01:00
Robert Bragg
cd6e1d183d Updates wayland symbol names to be consistent
This updates the public wayland symbols to follow the pattern
cogl_wayland_blah instead of cogl_blah_wayland.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:34:46 +01:00
Robert Bragg
89562dda73 work towards consistent platform file/symbol naming
we've got into a bit of a mess with how we name platform specific
symbols and files, so this is a first pass at trying to tidy that up.

All platform specific symbols should be named like
cogl_<platform>_symbol_name and similarly files should be named like
cogl-<platform>-filename.c

This patch tackles the X11 specific renderer/display APIs as a start.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:34:33 +01:00
Robert Bragg
3b64a439f0 replace public native_event APIs with typesafe APIs
This adds Xlib and Win32 typesafe replacements for
cogl_renderer_handle_native_event, cogl_renderer_add_native_filter,
cogl_renderer_remove_native_filter. The old functions are kept as an
implementation detail so we can share code.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:13 +01:00
Robert Bragg
b3a105c576 renderer: Expose winsys ID setter/getters
This adds API to let you override the choice of Cogl's winsys backend.
Previously it was only possible to override the winsys using the
COGL_RENDERER environment variable, but it's useful for something like
Clutter to be able to control the winsys via API without needing
environment variable tricks. This also adds API to query back the
winsys chosen by Cogl, in case you don't set an explicit override.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:11 +01:00
Robert Bragg
a1234ee8d1 Add internal _cogl_init() function
This adds a _cogl_init function for Cogl that we expect to be the first
thing called before anything else is done with Cogl. It's not a public
API so it's expected that all entry points for Cogl that might be the
first function used should call _cogl_init().

We currently call _cogl_init() in these functions:
  cogl_renderer_new
  cogl_display_new
  cogl_context_new
  cogl_android_set_native_window

_cogl_init() can be called multiple times, and only the first call has
any affect.

For example _cogl_init() gives us a place check and parse the COGL_DEBUG
environment variable.

Since we don't have any need to parse command line arguments (we can
always get user configuration options from the environment) our init
function doesn't require argc/argv pointers.

By saying up front that we aren't interested in command line arguments
that means we can avoid the mess that is GOption based library
initialization which is extremely fragile due to its lack of dependency
tracking between modules.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-06-30 14:33:11 +01:00
Neil Roberts
6d1371e0e9 cogl-texture-pixmap-x11: Fix the can_hardware_repeat wrapper
The wrapper for the can_hardware_repeat had a cut and paste error so
it would call the wrong function on the child texture.

Many thanks to Owen Taylor for finding this bug.
2011-06-10 18:43:56 +01:00
Robert Bragg
5022ec54d2 replace _xlib_add_filter use with _cogl_renderer API
Instead of using _cogl_xlib_add/remove_filter we now use
_cogl_renderer_add/remove_native_filter. The _cogl_xlib_add_filter API
was only required as a stop gap while EGL support was still in Clutter
because in that case we were using the stub winsys and didn't have a
CoglRenderer.
2011-06-01 20:44:42 +01:00
Robert Bragg
8c35a6bb7c remove _cogl_xlib_trap/untrap_errors wrappers
This removes the redundant _cogl_xlib_trap/untrap_errors functions that
simply wrap equivalent functions in the _cogl_renderer_xlib namespace.
These were originally only required while the EGL winsys was being
handled in clutter and so there wasn't a CoglRenderer in all cases.
2011-06-01 20:44:42 +01:00
Robert Bragg
4a97fc0a1e egl: fix some #ifdef guards
In the winsys vtable .xlib_get_visual_info and
.onscreen_x11_get_window_xid should be guarded by the
COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT because they need to be there
if cogl is configured with --enable-xlib-egl-platform but not if just
configured with --enable-xlib.
2011-06-01 20:44:42 +01:00
Robert Bragg
656f28de2f glx: make sure _cogl_winsys_get_proc_address is static
Make sure not to export _cogl_winsys_get_proc_address outside of
cogl-winsys-glx.c
2011-06-01 20:44:42 +01:00
Robert Bragg
a29a76dbab Adds _cogl_wayland_texture_2d_new_from_buffer API
This adds internal API to be able to wrap a wayland buffer as a
CoglTexture2D. There is a --enable-wayland-egl-server option to decide
if Cogl should support this feature and potentially any EGL based winsys
could support this through the EGL_KHR_image_base and
EGL_WL_bind_display extensions.
2011-06-01 20:44:42 +01:00
Robert Bragg
8714d99300 egl: Add x11 texture-from-pixmap support
By using the EGL_KHR_image_base/pixmap extensions this adds support for
wrapping X11 pixmaps as CoglTexture2D textures. Clutter will
automatically take advantage of this if using the
ClutterX11TexturePixmap actor.
2011-06-01 20:44:42 +01:00
Robert Bragg
60b25615fd Add _cogl_egl_texture_2d_new_from_image API
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.
2011-06-01 20:44:42 +01:00
Robert Bragg
52aada8442 egl: Check EGL extension as early as possible
Instead of waiting until initializing a CoglContext we now check EGL
extensions after calling eglInitialize.
2011-06-01 20:44:41 +01:00
Robert Bragg
be15bf75e4 Add internal _cogl_get_proc_address
This adds an internal _cogl_get_proc_address that doesn't need a
CoglContext. This will enable us to check driver features earlier.
2011-06-01 20:44:41 +01:00
Robert Bragg
b380fed23d Make stub winsys into a proper winsys backend
Instead of the stub winsys being a special case set of #ifdef'd code
used when COGL_HAS_FULL_WINSYS wasn't defined, the stub winsys now
implements a CoglWinsysVtable like all other winsys backends (it's just
that everything is a NOP). This way we can get rid of the
COGL_HAS_FULL_WINSYS define and also the stub winsys can be runtime
selected whereas before it was incompatible with all other winsys
backends.
2011-06-01 20:44:41 +01:00
Robert Bragg
ee7cc9e788 Make CoglTexture2D public as experimental API
This exposes a CoglTexture2D typedef and adds the following experimental
API:
    cogl_is_texture_2d
    cogl_texture_2d_new_with_size
    cogl_texture_2d_new_from_data
    cogl_texture_2d_new_from_foreign

Since this is experimental API you need to define
COGL_ENABLE_EXPERIMENTAL_API before including cogl.h.

Note: With these new entrypoints we now expect a CoglContext pointer to
be passed in, instead of assuming there is a default context. The aim is
that for Cogl 2.0 we won't have a default context so this is a step in
that direction.
2011-06-01 20:44:41 +01:00
Robert Bragg
5a9b92a4a5 Revert "Initial build of a Quartz winsys stub"
This reverts commit b2e41f1bfa.

We are backing out the quartz specific stub winsys since we can simply
use the generic stub winsys on quartz until we develop a standalone
winsys. Since we plan on removing all special cases for the stub winsys
by handling with a winsys vtable like all the others it's better if we
don't introduce a quartz specific stub.
2011-06-01 20:21:59 +01:00
Robert Bragg
891a9c33c5 Revert "quartz: Remove X11 ifdefs"
This reverts commit eb81ec945c.

We are backing out the quartz specific stub winsys since we can simply
use the generic stub winsys on quartz until we develop a standalone
winsys. Since we plan on removing all special cases for the stub winsys
by handling with a winsys vtable like all the others it's better if we
don't introduce a quartz specific stub.
2011-06-01 20:21:59 +01:00
Emmanuele Bassi
eb81ec945c quartz: Remove X11 ifdefs 2011-05-25 16:47:38 +01:00
Emmanuele Bassi
b2e41f1bfa Initial build of a Quartz winsys stub 2011-05-24 23:08:59 +01:00
Damien Lespiau
f436582114 android: Add support for an EGL/Android winsys
The native window type of the EGL/Android winsys is ANativeWinow*. The
Android NDK gives you a pointer to this ANativeWindow and you just need
to configure that window using the EGLConfig you are choosing when
creating the context.

This means you have to know the ANativeWindow* window before creating
the context. This is solved here by just having a global variable you
can set with cogl_android_set_native_window() before creating the
context. This is a bit ugly though, and it conceptually belongs to the
OnScreen creation to know which ANativeWindow* to use. This would need a
"lazy context creation" mechanism, waiting for the user to create the
OnScreen to initialize the GL context.
2011-05-17 15:24:54 +01:00
Damien Lespiau
d384466a58 winsys-egl: Use g_clear_error() between two context creation tries
When try_create_context() returns saying that it has to be run again to
try to create a context with an alternate configuration, it might not
have a GError set (and in fact it does not right now).
g_clear_error() handles that case where error is still NULL;
2011-05-17 15:24:54 +01:00
Damien Lespiau
dd5a1c888b gles1: Include GLES/egl.h or EGL/egl.h depending on the implementation
Early implementations provided only a GLES/egl.h while Khronos's
implementer guide now states EGL/egl.h is the One. Some implementations
keep a GLES/egl.h wrapper around EGL/egl.h for backward compatibility
while others provide EGL/egl.h only.

Also took the opportunity to factorize a bit this inclusion in
cogl-defines.h.
2011-05-17 15:24:54 +01:00
Robert Bragg
2282455f27 wayland: Allow setting foreign display/compositor
To support toolkits targeting wayland and using Cogl we allow toolkits
to be responsible for connecting to a wayland display and asking Cogl to
use the toolkit owned display and compositor object. Note: eventually
the plan is that wayland will allow retrospective querying of objects so
we won't need the foreign compositor API when Cogl can simply query it
from the foreign display.
2011-05-11 16:46:52 +01:00
Robert Bragg
653d59af04 Explicitly set EGL_PLATFORM=wayland for wayland winsys
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
EGL_PLATFORM environment variable though so we set that to "wayland"
when we know that's what we want.
2011-05-11 16:44:08 +01:00
Neil Roberts
463603f1a0 cogl-winsys: Fix freeing a CoglOnscreen
All of the winsys backends didn't handle cleaning up the CoglOnscreen
properly so that they would assert in cogl_onscreen_free because the
winsys pointer is never freed. They also didn't cope if deinit is
called before init (which will be the case if an onscreen is created
and freed without being allocated).
2011-05-10 20:23:39 +01:00
Neil Roberts
6654533e40 cogl-winsys-wgl: Plug leak on error from SetPixelFormat
When SetPixelFormat fails, the DC would get released but none of the
other resources would be freed. This patch makes it call
_cogl_winsys_onscreen_deinit on failure to clean up all of the
resources. The patch looks big because it moves the onscreen_deinit
and onscreen_bind functions.
2011-05-10 19:53:00 +01:00
Neil Roberts
6788c80342 Add a WGL winsys
This adds a full winsys to handle WGL and Win32.
2011-05-10 17:58:41 +01:00
Neil Roberts
14d1303259 cogl-winsys: Explicitly comment which vfuncs are optional
Some of the virtual functions in CoglWinsysVtable only need to be
implemented for specific backends or when a specific feature is
advertised. This splits the vtable struct into two commented sections
marking which are optional and which are required. Wherever an
optional function is used there is now a g_return_if_fail to ensure
there is an implementation.
2011-05-10 17:15:22 +01:00
Neil Roberts
614efb190b cogl-winsys: Remove the get_vsync_counter virtual
This function is only used internally within the GLX winsys so there
doesn't seem to be much point in it being a virtual winsys backend
function.
2011-05-10 17:13:23 +01:00
Neil Roberts
f2a37b27f9 CoglWinsysVtable: Remove 'has_feature'
This virtual function is no longer used or defined anywhere since the
function was moved to the common backend code in 16bfa27d43.
2011-05-10 17:13:23 +01:00
Robert Bragg
e8b83f2880 Adds wayland support to the cogl EGL winsys
Wayland now supports integration via standard eglSurfaces which makes it
possible to share more code with other EGL platforms. (though at some
point cogl-winsys-egl.c really needs to gain a more formal
CoglEGLPlatform abstraction so we can rein back on the amount of #ifdefs
we have.)
2011-05-10 16:36:40 +01:00
Robert Bragg
4b6169267c winsys-egl: fix typo in _cogl_winsys_onscreen_init
We were trying to set attr.event_mask instead of xattr.event mask which
was causing a compilation error.
2011-05-10 16:36:40 +01:00
Robert Bragg
6c23f27801 Adds a way for Cogl to control event_mask of foreign wins
This extends cogl_onscreen_x11_set_foreign_xid to take a callback to a
function that details the event mask the Cogl requires the application
to select on foreign windows. This is required because Cogl, for
example, needs to track size changes of a window and may also in the
future want other notifications such as map/unmap.

Most applications wont need to use the foreign xwindow apis, but those
that do are required to pass a valid callback and update the event mask
of their window according to Cogl's requirements.
2011-05-05 15:05:42 +01:00
Robert Bragg
97243ad9ac Adds cogl_onscreen_show/hide functions
This adds Cogl API to show and hide onscreen framebuffers. We don't want
to go too far down the road of abstracting window system APIs with Cogl
since that would be out of its scope but the previous idea that we would
automatically map framebuffers on allocation except for those made from
foreign windows wasn't good enough. The problem is that we don't want to
make Clutter always create stages from foreign windows but with the
automatic map semantics then Clutter doesn't get an opportunity to
select for all the events it requires before mapping. This meant that we
wouldn't be delivered a mouse enter event for windows mapped underneath
the cursor which would break Clutters handling of button press events.
2011-05-05 15:05:42 +01:00
Robert Bragg
ad56c00f7a Add missing _cogl_winsys_has_feature prototype
This adds a private prototype for _cogl_winsys_has_feature in
cogl-winsys-private.h to avoid compilation warnings.
2011-05-05 15:05:42 +01:00
Robert Bragg
b3a7ee5930 cogl: remove OSX/WIN32 specific bits in favour of a stub winsys
Until Cogl gains native win32/OSX support this remove the osx and win32
winsys files and instead we'll just rely on the stub-winsys.c to handle
these platforms. Since the only thing the platform specific files were
providing anyway was a get_proc_address function; it was trivial to
simply update the clutter backend code to handle this directly for now.
2011-05-05 15:05:41 +01:00
Robert Bragg
cd6d561f6f winsys-glx: map X window automatically if not foreign
For now we are going for the semantics that when a CoglOnscreen is first
allocated then it will automatically be mapped. This is for convenience
and if you don't want that behaviour then it is possible to instead
create an Onscreen from a foreign X window and in that case it wont be
mapped automatically.

This approach means that Cogl doesn't need onscreen_map/unmap functions
but it's possible we'll decide later that we can't avoid adding such
functions and we'll have to change these semantics.
2011-05-05 14:46:03 +01:00
Robert Bragg
7037812ae6 EGL: Updates GDL platform support
The GDL API is used for example on intel ce4100 (aka Sodaville) based
systems as a way to allocate memory that can be composited using the
platforms overlay hardware. This updates the Cogl EGL winsys and the
support in Clutter so we can continue to support these platforms.
2011-05-05 14:46:02 +01:00
Robert Bragg
31ee65784d winsys: Expose environment variable to choose winsys
This makes it possible to override the winsys that cogl uses by setting
the COGL_RENDERER environment variable e.g. to "GLX" or "EGL"
2011-05-05 14:46:01 +01:00
Robert Bragg
dc7383b714 Add a vtable of indirection to the winsys code
So that we can dynamically select what winsys backend to use at runtime
we need to have some indirection to how code accesses the winsys instead
of simply calling _cogl_winsys* functions that would collide if we
wanted to compile more than one backend into Cogl.
2011-05-05 14:46:01 +01:00
Robert Bragg
d52e3f0cc2 texture-pixmap-x11: Move GLX code to cogl-winsys-glx.c
This moves the GLX specific code from cogl-texture-pixmap-x11.c into
cogl-winsys-glx.c. If we want the winsys components to by dynamically
loadable then we can't have GLX code scattered outside of
cogl-winsys-glx.c. This also sets us up for supporting the
EGL_texture_from_pixmap extension which is almost identical to the
GLX_texture_from_pixmap extension.
2011-05-05 14:46:01 +01:00
Robert Bragg
d5d11f1878 Moves all EGL code down from Clutter to Cogl
As was recently done for the GLX window system code, this commit moves
the EGL window system code down from the Clutter backend code into a
Cogl winsys.

Note: currently the cogl/configure.ac is hard coded to only build the GLX
winsys so currently this is only available when building Cogl as part
of Clutter.
2011-05-05 14:46:01 +01:00
Neil Roberts
14b6c0459f cogl-winsys-stub: Remove _cogl_winsys_has_feature
Commit b061f737 moved _cogl_winsys_has_feature to the common winsys
code so there's no need to define it in the stub winsys any more. This
was breaking builds for backends using the stub winsys.
2011-04-20 18:43:02 +01:00
Neil Roberts
dcd23dc220 cogl-winsys-glx: Fix the comparison in find_onscreen_for_xid
The comparison for finding onscreen framebuffers in
find_onscreen_for_xid had a small thinko so that it would ignore
framebuffers when the negation of the type is onscreen. This ends up
doing the right thing anyway because the onscreen type has the value 0
and the offscreen type has the value 1 but presumably it would fail if
we ever added any other framebuffer types.
2011-04-20 18:20:25 +01:00
Neil Roberts
16bfa27d43 cogl-winsys: Move _cogl_winsys_has_feature to cogl-winsys.c
The code for _cogl_winsys_has_feature will be identical in all of the
winsys backends for the time being, so it seems to make sense to have
it in the common cogl-winsys.c file.
2011-04-20 18:20:20 +01:00
Neil Roberts
4a7762d6d7 cogl-context: Store winsys features in an array of unsigned ints
Previously the mask of available winsys features was stored in a
CoglBitmask. That isn't the ideal type to use for this because it is
intended for a growable array of bits so it can allocate extra memory
if there are more than 31 flags set. For the winsys feature flags the
highest used bit is known at compile time so it makes sense to
allocate a fixed array instead. This is conceptually similar to the
CoglDebugFlags which are stored in an array of integers with macros to
test a bit in the array. This moves the macros used for CoglDebugFlags
to cogl-flags.h and makes them more generic so they can be shared with
CoglContext.
2011-04-20 18:20:10 +01:00
Neil Roberts
f6ae9decaa cogl-renderer: Move the XEvent filters to be generic for all renderers
Instead of having cogl_renderer_xlib_add_filter and friends there is
now cogl_renderer_add_native_filter which can be used regardless of
the backend. The callback function for the filter now just takes a
void pointer instead of an XEvent pointer which should be interpreted
differently depending on the backend. For example, on Xlib it would
still be an XEvent but on Windows it could be a MSG. This simplifies
the code somewhat because the _cogl_xlib_add_filter no longer needs to
have its own filter list when a stub renderer is used because there is
always a renderer available.

cogl_renderer_xlib_handle_event has also been renamed to
cogl_renderer_handle_native_event. This just forwards the event on to
all of the listeners. The backend renderer is expected to register its
own event filter if it wants to process the events in some way.
2011-04-20 18:17:06 +01:00