1
0
Fork 0
Commit graph

19 commits

Author SHA1 Message Date
Neil Roberts
45e18e0fb7 wayland: Don't delay resize if nothing is drawn since last swap
After discussing with Kristian Høgsberg it seems that the semantics of
wl_egl_window_resize is meant to be that if nothing has been drawn to
the framebuffer since the last swap then the resize will take effect
immediately. Cogl was previously always delaying the call to
wl_egl_window_resize until the next swap. That meant that if you
wanted to resize the surface you would have to call
cogl_wayland_onscreen_resize and then redundantly draw a frame at the
old size so that you can swap to get the resize to occur before
drawing again at the right size. Typically an application would decide
to resize at the start of its paint sequence so it should be able to
just resize immediately.

In current Mesa master it seems that there is a bug which means that
it won't actually delay a resize that is done mid-scene and instead it
will just discard what came before. To get consistent behaviour in
Cogl, the code to delay the call to wl_egl_window_resize is still used
if it determines that the buffer is dirty. There is an existing
_cogl_framebuffer_mark_mid_scene call which was being used to track
when the framebuffer becomes dirty since the last clear. This function
is now also used to track a new flag to track whether something has
been drawn since the last swap. It is called ‘mid_scene’ under the
assumption that this may also be useful for other things later.

cogl_framebuffer_clear has been slightly altered to always call
_cogl_framebuffer_mark_mid_scene even if it determines that it doesn't
need to clear because the framebuffer should still be considered to be
in the middle of a scene. Adding a quad to the journal now also begins
the scene.

This also fixes a potential bug where it looks like pending_dx/dy were
never cleared so they would always be accumulated even after the
resize is flushed.

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

(cherry picked from commit 945689a62903990a20abb87a85d2c96eb3985fe7)
2013-05-30 13:42:11 +01:00
Neil Roberts
0b2b46ce4c wayland: Don't set the surface to toplevel until it is shown
If we delay setting the surface to toplevel until it is shown then
that gives the application an opportunity to avoid calling show so
that it can set its own surface type.

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

(cherry picked from commit ab59c3a421968d7f159d89ca2f0ba8a9f098cbf6)
2013-05-30 13:42:11 +01:00
Robert Bragg
7b14b5e3da poll: Add general way to hook into mainloop without fd
This adds a _cogl_poll_renderer_add_source() function that we can use
within cogl to hook into the mainloop without necessarily having a file
descriptor to poll. Since the intention is to use this to support
polling for fence completions this also updates the
CoglPollCheckCallback type to take a timeout pointer so sources can
optionally update the timeout that will be passed to poll.

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

(cherry picked from commit 81c1ce0ffce4e75e08622e20848405987e00b3cc)
2013-05-28 21:36:03 +01:00
Robert Bragg
3a7c1263f1 onscreen: Adds swap_buffers_with_damage api
This adds api to be able requests a swap_buffers and also pass a list of
damage rectangles that can be passed on to a compositor to enable it to
minimize how much of the screen it needs to recompose.

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

(cherry picked from commit 0d9684c7b7c2018bb42715c369555330d38514a2)
2013-04-30 16:39:31 +01:00
Robert Bragg
95a41e177a Associate check and dispatch funcs with poll fds
Instead of driving event dispatching through a per winsys poll_dispatch
vfunc its now possible to associate a check and dispatch function with
each file descriptor that is registered for polling. This means we can
remove the winsys get_dispatch_timeout and poll_dispatch vfuncs and it
also makes it easier for more orthogonal internal components to add file
descriptors for polling to the mainloop.

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

(cherry picked from commit 627947622df36dd529b9dc60a3ae9e6083532b19)
2013-04-30 16:39:31 +01:00
Robert Bragg
ed90c6fed9 Move event polling into CoglRenderer
This updates the cogl_poll_ apis to allow dispatching events before we
have a CoglContext and to also enables pollfd state to be changed in a
more add-hoc way by different Cogl components by replacing the
winsys->get_poll_info with _cogl_poll_renderer_add/remove_fd functions
and a winsys->get_dispatch_timeout vfunc.

One of the intentions here is that applications should be able to run
their mainloop before creating a CoglContext to potentially get events
relating to CoglOutputs.

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

(cherry picked from commit 667e58c9cb2662aef5f44e580a9eda42dc8d0176)
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
Chris Cummins
4327b7a364 wayland: free framebuffer's shell surface on destroy
This prevents leaking the Wayland shell surface associated with a Cogl
OnScreen when it is finalised.

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

(cherry picked from commit 760fc9f3af5475530262b82a55df311fceca358a)
2013-04-26 17:52:57 +01:00
Andreas Oberritter
b5e57c914b wayland: implement poll_get_info and poll_dispatch
Call wl_display_dispatch on POLLIN. This follows the implementation
in weston/clients/window.c and improves integration of input events,
at least.

Signed-off-by: Andreas Oberritter <obi@saftware.de>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 323fe1887487f19c3e26aa6b7644de31d8d0a532)
2013-04-24 22:23:49 +01:00
Robert Bragg
df21e20f65 Adds CoglError api
Although we use GLib internally in Cogl we would rather not leak GLib
api through Cogl's own api, except through explicitly namespaced
cogl_glib_ / cogl_gtype_ feature apis.

One of the benefits we see to not leaking GLib through Cogl's public API
is that documentation for Cogl won't need to first introduce the Glib
API to newcomers, thus hopefully lowering the barrier to learning Cogl.

This patch provides a Cogl specific typedef for reporting runtime errors
which by no coincidence matches the typedef for GError exactly.  If Cogl
is built with --enable-glib (default) then developers can even safely
assume that a CoglError is a GError under the hood.

This patch also enforces a consistent policy for when NULL is passed as
an error argument and an error is thrown. In this case we log the error
and abort the application, instead of silently ignoring it. In common
cases where nothing has been implemented to handle a particular error
and/or where applications are just printing the error and aborting
themselves then this saves some typing. This also seems more consistent
with language based exceptions which usually cause a program to abort if
they are not explicitly caught (which passing a non-NULL error signifies
in this case)

Since this policy for NULL error pointers is stricter than the standard
GError convention, there is a clear note in the documentation to warn
developers that are used to using the GError api.

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

(cherry picked from commit b068d5ea09ab32c37e8c965fc8582c85d1b2db46)

Note: Since we can't change the Cogl 1.x api the patch was changed to
not rename _error_quark() functions to be _error_domain() functions and
although it's a bit ugly, instead of providing our own CoglError type
that's compatible with GError we simply #define CoglError to GError
unless Cogl is built with glib disabled.

Note: this patch does technically introduce an API break since it drops
the cogl_error_get_type() symbol generated by glib-mkenum (Since the
CoglError enum was replaced by a CoglSystemError enum) but for now we
are assuming that this will not affect anyone currently using the Cogl
API. If this does turn out to be a problem in practice then we would be
able to fix this my manually copying an implementation of
cogl_error_get_type() generated by glib-mkenum into a compatibility
source file and we could also define the original COGL_ERROR_ enums for
compatibility too.

Note: another minor concern with cherry-picking this patch to the 1.14
branch is that an api scanner would be lead to believe that some APIs
have changed, and for example the gobject-introspection parser which
understands the semantics of GError will not understand the semantics of
CoglError. We expect most people that have tried to use
gobject-introspection with Cogl already understand though that it is not
well suited to generating bindings of the Cogl api anyway and we aren't
aware or anyone depending on such bindings for apis involving GErrors.
(GnomeShell only makes very-very minimal use of Cogl via the gjs
bindings for the cogl_rectangle and cogl_color apis.)

The main reason we have cherry-picked this patch to the 1.14 branch
even given the above concerns is that without it it would become very
awkward for us to cherry-pick other beneficial patches from master.
2013-01-22 17:47:39 +00:00
Rob Bradford
0e33654efb wayland: Port to new Wayland protocol
Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit db50c3015c589375029a4c26c58db8295bb17bca)
2012-10-18 17:25:21 +01:00
Robert Bragg
010d16f647 Adds initial GLES2 integration support
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)
2012-08-06 14:27:42 +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
Neil Roberts
933db01833 cogl-winsys-egl-wayland: Include cogl-wayland-renderer.h
The Wayland winsys defines functions declared in
cogl-wayland-renderer.h so it should include the header to make sure
the declarations are right. This was breaking because currently the
header #defines the _EXP suffixes on to the function names so it would
end up exporting the wrong symbol names.
2012-02-29 17:45:43 +00:00
Robert Bragg
87ce1b21f9 wayland: perform buffer resizes lazily at swap buffers
Resizing a wayland client framebuffer should not affect the viewport
of additional primitives drawn to that framebuffer before the next swap
buffers request nor should querying the framebuffer's width and height
be affected until the next swap buffers request completes.

This patch changes cogl_wayland_onscreen_resize() so it only saves the
new geometry as "pending" state internal to the given CoglOnscreen. Only
when cogl_framebuffer_swap_buffers() is next called will the pending
size be flushed to the wayland egl api.
2012-01-16 18:27:20 +00:00
Robert Bragg
e1bd0b2090 Swaps a few uses of gint for int
We've avoiding using the redundant glib typedefs such as guint, gint
gpointer etc and prefer to use the equivalent C types so this patch
removes a few uses of gint that slipped past review.
2012-01-16 18:27:20 +00:00
Rob Bradford
8632c65e79 wayland: Add a cogl_wayland_onscreen_resize function
This function will call into the Wayland EGL platform API and resize the
surface that the window is using and update the internal dimensions for
framebuffer and viewport to reflect the change.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-13 13:56:12 +00:00
Neil Roberts
4dbef01ec3 winsys: Move Wayland-specific code out of the EGL winsys
All of the Wayland-specific code now lives in the EGL_WAYLAND winsys.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-12 17:41:43 +00:00
Neil Roberts
a1e1527b69 Add a separate winsys vtable for each EGL platform
Instead of just having an "EGL" renderer, there is now a separate
winsys for each platform. Currently they just directly copy the vtable
for the EGL platform so it is still only possible to have one EGL
platform compiled into Cogl. However the intention is that the
winsys-specific code for each platform will be moved into override
functions in the corresponding platform winsys.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-08 17:38:25 +00:00