Commit Graph

10 Commits

Author SHA1 Message Date
Robert Bragg
04a1655804 Adds internal cogl closure list utility
This adds some utility code to help us manage lists of closures
consistently within Cogl. The utilities are from Rig and were originally
written by Neil Roberts.

This adapts the way we track CoglOnscreen resize and frame closures to
use the new utilities.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 2e15fc76eb29bf5932418f7ee80f1fcb2f6a816c)
2013-04-30 16:39:31 +01:00
Neil Roberts
816a5bc437 onscreen: Make the resize callback work the same as the frame callback
When adding the frame callback API in 70040166 we decided on a common
idiom for adding callbacks which would return an opaque pointer
representing the closure for the callback. This pointer can then be
used to later remove the callback. The closure can also contain an
optional callback to invoke when the user data parameter is destroyed.
The resize callback didn't work this way and instead had an integer
handle to identify the closure. This patch changes it to work the same
way as the frame callback.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 33164c4b04d253ebe0ff41b12c1e90232c519274)
2013-04-30 16:39:31 +01:00
Chris Cummins
59a04cd0e6 wayland: implement foreign surfaces for CoglOnscreen
This adds support for optionally providing a foreign Wayland surface to
a CoglOnscreen before allocation. Setting a foreign surface prevents
Cogl from creating a toplevel Wayland shell surface for the OnScreen.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit e447d9878f3bcfe5fe336d367238383b02879223)
2013-04-26 17:53:07 +01:00
Owen W. Taylor
24733abf68 onscreen: Add CoglFrameInfo and _add_frame_callback() api
Add a CoglFrameInfo object that tracks timing information for frames
that are drawn. We track a frame counter and frame timing information
for each CoglOnscreen. Internally a CoglFrameInfo is automatically
created for each frame, delimited by cogl_onscreen_swap_buffers() or
cogl_onscreen_swap_region() calls.

CoglFrameInfos are delivered to applications via frame event callbacks
that can be registered with a new cogl_onscreen_add_frame_callback()
api. Two initial event types (dispatched on all platforms) have been
defined; a _SYNC event used for throttling the frame rate of
applications and a _COMPLETE event used so signify the end of a frame.

Note: This new _add_frame_callback() api makes the
cogl_onscreen_add_swap_complete_callback() api redundant and so it
should be considered deprecated. Since the _add_swap_complete_callback()
api is still experimental api, we will be looking to quickly migrate
users to the new api so we can remove the old api.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 700401667db2522045e4623d78797b17f9184501)
2013-01-30 20:09:49 +00:00
Robert Bragg
df51574116 onscreen: Adds support for resizable windows
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)
2012-08-06 18:51:32 +01:00
Robert Bragg
54735dec84 Switch use of primitive glib types to c99 equivalents
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)
2012-08-06 14:27:39 +01:00
Emmanuele Bassi
3f561b1fbe Fix build on OSX
A missing include prevents Cogl from building on OSX.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-15 14:57:59 +00:00
Neil Roberts
99c651d2b4 Move the add_swap_buffers_callback functions out of the winsys
Instead of having each winsys implement its own list of callbacks the
list is now just attached directly to the CoglOnscreen using code in
cogl-onscreen.c. The winsys's can invoke this list of callbacks by
calling _cogl_onscreen_notify_swap_buffers(). All of the winsys's
would probably have a very similar implementation for this anyway and
I don't think it makes much sense to try and save the cost of a list
pointer in the CoglOnscreen struct.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-08 17:00:25 +00:00
Neil Roberts
139421de19 object: Remove the type member of CoglObjectClass
Unlike in GObject the type number for a CoglObject is entirely an
internal implementation detail so there is no need to make a GQuark to
make it safe to export out of the library. Instead we can just
directly use a fixed pointer address as the identifier for the type.
This patch makes it use the address of the class struct of the
identifier. This should make it faster to do type checks because it
does not need to call a function every time it wants to get the type
number.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-27 17:18:32 +00:00
Robert Bragg
79719347c8 framebuffer: split out CoglOnscreen code
This factors out the CoglOnscreen code from cogl-framebuffer.c so we now
have cogl-onscreen.c, cogl-onscreen.h and cogl-onscreen-private.h.
Notably some of the functions pulled out are currently namespaced as
cogl_framebuffer but we know we are planning on renaming them to be in
the cogl_onscreen namespace; such as cogl_framebuffer_swap_buffers().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:02 +00:00