Commit Graph

133 Commits

Author SHA1 Message Date
Emmanuele Bassi
ce7015bdb0 examples: Fix compiler warnings 2015-06-10 15:15:59 +01:00
Emmanuele Bassi
0294fc27ed examples: Do not use deprecated Cogl API
Examples should be as idiomatic as possible.
2015-06-10 15:15:20 +01:00
Marco Trevisan (Treviño)
672eff0c6c cogl: add Mir EGL platform 2014-11-17 15:49:20 +01:00
Owen W. Taylor
0d7d4fe14e examples/cogl-texture-pixmap-x11: Add a --stereo command line option
If --stereo is passed, then the texture pixmap is created as a stereo
texture pixmap, and also, if passed in conjunction with --gears,
glxgears is also run with the -stereo option.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-17 19:27:21 -04:00
Owen W. Taylor
7f3960e94d examples/cogl-x11-tfp: Add a --gears option to run glxgears
If --gears is passed on the command line, glxgears is run, and
is used for the source window rather than drawing solid rectangles
into a window we create outselves.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-17 19:27:17 -04:00
Owen W. Taylor
1b5beef5e5 Add a simple example of stereo drawing
Add a new example that draws a triangle floating in the air in
front of the screen.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-17 19:27:10 -04:00
Owen W. Taylor
157c1a090c examples/cogl-x11-tfp: Fix compilation
Fix a couple of minor compilation problems from a bad rebase - a
missing label and a missing variable.
2014-07-03 14:07:32 -04:00
Owen W. Taylor
baa2fba8e2 examples/cogl-x11-tfp.c: Handle WM_DELETE_WINDOW
Clean up cleanly when closed rather than dying with an X Error -
we do this by advertising support for the WM_DELETE_WINDOW protocol
and handling the client message.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-03 13:35:39 -04:00
Owen W. Taylor
a4bc66325e examples/cogl-x11-tfp.c: Wait for the window to be mapped
Wait for the main window (and hence the window we create within
the main window to redirect) to be mapped and become viewable
before we try to call XCompositeNameWindowPixmap() -
XComposeNameWindowPixmap() produces a BadMatch error on a
non-viewable window.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-03 13:35:02 -04:00
Lionel Landwerlin
12ece8e4a1 examples: add gjs example
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-21 14:28:27 +00:00
Lionel Landwerlin
b7017ed5b0 example: add emscripten files to dist
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-21 14:28:27 +00:00
Robert Bragg
0e2771a4a4 basic-video-player: don't try and sample mipmap
Since we don't generate a mipmap chain for uploaded video frames this
avoids setting the min filter to COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR.

Since COGL_PIPELINE_FILTER_LINEAR is the default and since it is also
dubious that cogl-basic-video-player is directly manipulating layers
that are conceptually internal to cogl-gst this removes the loop that
updates the filtering for cogl-gst layers.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Neil Roberts
3abbcabdf6 cogl-basic-video-player: Allow passing a GStreamer pipeline
If the URI argument given on the command line doesn't look like a URI
then the basic video player will now try to parse it as a GStreamer
pipeline description. The pipeline must contain a coglsink element
which the player will look for. This can be used to test Cogl GST. For
example, to test NV12 this can be used:

./cogl-basic-video-player 'videotestsrc !
                           video/x-raw,format=(string)NV12 !
                           coglsink'

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 49e47c8329d50774e365fc7c3a7504b5fc005dc7)
2014-01-31 12:42:03 +00:00
Robert Bragg
af7398788a remove internal_format and redundant error arguments
Texture allocation is now consistently handled lazily such that the
internal format can now be controlled using
cogl_texture_set_components() and cogl_texture_set_premultiplied()
before allocating the texture with cogl_texture_allocate(). This means
that the internal_format arguments to texture constructors are now
redundant and since most of the texture constructors now can't ever fail
the error arguments are also redundant. This now means we no longer
use CoglPixelFormat in the public api for describing the internal format
of textures which had been bad solution originally due to how specific
CoglPixelFormat is which is missleading when we don't support such
explicit control over the internal format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 99a53c82e9ab0a1e5ee35941bf83dc334b1fbe87)

Note: there are numerous API changes for functions currently marked
as 'unstable' which we don't think are in use by anyone depending on
a stable 1.x api. Compared to the original patch though this avoids
changing the cogl_texture_rectangle_new_with_size() api which we know
is used by Mutter.
2014-01-09 15:49:47 +00:00
Robert Bragg
cbd6951134 introduce texture loaders to make allocations lazy
This introduces the internal idea of texture loaders that track the
state for loading and allocating a texture. This defers a lot more work
until the texture is allocated.

There are several intentions to this change:

- provides a means for extending how textures are allocated without
  requiring all the parameters to be supplied in a single _texture_new()
  function call.

- allow us to remove the internal_format argument from all
  _texture_new() apis since using CoglPixelFormat is bad way of
  expressing the internal format constraints because it is too specific.

  For now the internal_format arguments haven't actually been removed
  but this patch does introduce replacement apis for controlling the
  internal format:

    cogl_texture_set_components() lets you specify what components your
    texture needs when it is allocated.
    cogl_texture_set_premultiplied() lets you specify whether a texture
    data should be interpreted as premultiplied or not.

- Enable us to support asynchronous texture loading + allocation in the
  future.

Of note, the _new_from_data() texture constructors all continue to
allocate textures immediately so that existing code doesn't need to be
adapted to manage the lifetime of the data being uploaded.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6a83de9ef4210f380a31f410797447b365a8d02c)

Note: Compared to the original patch, the ->premultipled state for
textures isn't forced to be %TRUE in _cogl_texture_init since that
effectively ignores the users explicitly given internal_format which was
a mistake and on master that change should have been made in the patch
that followed. The gtk-doc comments for cogl_texture_set_premultiplied()
and cogl_texture_set_components() have also been updated in-line with
this fix.
2014-01-09 15:49:46 +00:00
Robert Bragg
a0bc2d96be Make cogl-sdl.h a top-level header
This makes it so that cogl-sdl.h is a top-level header no longer
automatically included by cogl.h. This avoids lots of warnings building
the conformance tests and examples due to SDL.h warning when
__STRICT_ANSI__ isn't defined.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f7536985437dc85c26b33d1bbe1b7f3d4b32476a)
2013-12-11 18:49:19 +00:00
Neil Roberts
a29b8c475e wayland: Add a convenience function to update a region from SHM buffer
Adds cogl_wayland_texture_set_region_from_shm_buffer which is a
convenience wrapper around cogl_texture_set_region but it uses the
correct format to copy the data from a Wayland SHM buffer. This will
typically be used by compositors to update the texture for a surface
when an SHM buffer is attached. The ordering of the arguments is based
on cogl_texture_set_region_from_bitmap.

Based on a patch by Jasper St. Pierre.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit c76c1d136d2cac7f3d1331a4d1dc0dd0f06e812c)

Conflicts:
	examples/cogland.c
2013-11-28 18:12:22 +00:00
Robert Bragg
6436cd073d Declare interface types as void and remove cast macros
This declares the interface types CoglFramebuffer, CoglBuffer,
CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when
including the public cogl.h header so that users don't have to use lots
of C type casts between instance types and interface types.

This also removes all of the COGL_XYZ() type cast macros since they do
nothing more than compile time type casting but it's less readable if
you haven't seen that coding pattern before.

Unlike with gobject based apis that use per-type macros for casting and
performing runtime type checking we instead prefer to do our runtime
type checking internally within the front-end public apis when objects
are passed into Cogl. This greatly reduces the verbosity for users of
the api and may help reduce the chance of excessive runtime type
checking that can sometimes be a problem.

(cherry picked from commit 248a76f5eac7e5ae4fb45208577f9a55360812a7)

Since we can't break the 1.x api this version of the patch actually
defines compatible NOP macros within deprecated/cogl-type-casts.h
2013-11-27 19:33:44 +00:00
Neil Roberts
cd9291f511 Add a cogl-point-sprites example
This updates the old point sprites interactive test from Clutter to be
a standalone Cogl example using the 2.0 API.

(cherry picked from commit e7ede458fde7207896e507d64b52b77777b3c872)
2013-08-21 15:40:09 +01:00
Robert Bragg
1317a25a91 offscreen: rename _new_to_texture to _new_with_texture
This renames cogl_offscreen_new_to_texture to
cogl_offscreen_new_with_texture. The intention is to then cherry-pick
this back to the cogl-1.16 branch so we can maintain a parallel
cogl_offscreen_new_to_texture() function which keeps the synchronous
allocation semantics that some clutter applications are currently
relying on.

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

(cherry picked from commit ecc6d2f64481626992b2fe6cdfa7b999270b28f5)

Note: Since we can't break the 1.x api on this branch this keeps a
thin shim around cogl_offscreen_new_with_texture to implement
cogl_offscreen_new_to_texture with its synchronous allocation
semantics.
2013-08-19 22:44:44 +01:00
Robert Bragg
e9f721216e Add _primitive_draw to replace _framebuffer_draw_primitive
When splitting out the CoglPath api we saw that we would be left with
inconsistent drawing apis if the drawing apis in core Cogl were lumped
into the cogl_framebuffer_ api considering other Cogl sub-libraries or
that others will want to create higher level drawing apis outside of
Cogl but can't use the same namespace.

So that we can aim for a more consistent style this adds a
cogl_primitive_draw() api, comparable to cogl_path_fill() or
cogl_pango_show_layout() that's intended to replace
cogl_framebuffer_draw_primitive()

Note: the attribute and rectangle drawing apis are still in the
cogl_framebuffer_ namespace and this might potentially change but in
these cases there is no single object representing the thing being drawn
so it seems a more reasonable they they live in the framebuffer
namespace for now.

Note: the cogl_framebuffer_draw_primitive() api isn't removed by this
patch so it can more conveniently be cherry picked to the 1.16 branch so
we can mark it deprecated for a short while. Even though it's marked as
experimental api we know that there are people using the api so we'd
like to give them a chance to switch to the new api.

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

(cherry picked from commit 418912b93ff81a47f9b38114d05335ab76277c48)

Conflicts:
	cogl-pango/cogl-pango-display-list.c
	cogl/Makefile.am
	cogl/cogl-framebuffer.c
	cogl/cogl-pipeline-layer-state.h
	cogl/cogl2-path.c
	cogl/driver/gl/cogl-clip-stack-gl.c
2013-07-29 18:31:36 +01:00
Robert Bragg
5580baeffb examples: avoid using the auto-texture apis
Instead of using cogl_texture_new_from_file/with_size in the example we
now use the cogl_texture_2d_ equivalents. This is in preparation for
removing the cogl-auto-texture apis.

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

(cherry picked from commit 815a1c80db4132fff6ccf97fc08396e61fc31ebb)

Conflicts:
	examples/cogl-crate.c
	examples/cogl-gles2-context.c
	examples/cogl-msaa.c
2013-07-29 17:57:23 +01:00
Neil Roberts
7b645d51cc cogland: Use wl_resource_get_user_data instead of resource->data
wl_resource may become an opaque type in future so we should probably
be using the accessors instead of directly prodding into the struct.

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

(cherry picked from commit 8ab07725734b8b2151470cc44bb3f88798ac5538)
2013-07-04 11:50:31 +01:00
Neil Roberts
2d5a84fc35 cogland: Use wl_client_add_object instead of wl_client_add_resource
wl_client_add_resource has been deprecated in the Wayland API in
favour of wl_client_add_object which returns a pointer to a
wl_resource which it allocates instead of the compositor having to
embed it in a larger struct. As far as I understand the idea is to
eventually make wl_resource completely opaque. This patch changes
Cogland accordingly.

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

(cherry picked from commit adb971954757dffb9ddecf8c9091b96756424800)
2013-07-01 13:48:24 +01:00
Neil Roberts
1ad0e81b7b wayland-server: Update because wl_shm_buffer is no longer a wl_buffer
The Wayland server API has changed so that wl_shm_buffer is no longer
a type of wl_buffer and it instead must be retrieved directly from the
resource.

cogl_wayland_texture_2d_new_from_buffer now takes a resource pointer
instead of directly taking a wl_buffer and it will do different things
depending on whether it can get a wl_shm_buffer out of the resource
instead of trying to query the buffer type.

Cogland has also been updated so that it tracks a resource for buffers
of surfaces instead of directly tracking a wl_buffer. This are pointed
to by a new CoglandBuffer struct which can be referenced by a
CoglandBufferReference. The WL_BUFFER_RELEASE event will be posted
when the last reference to the buffer is removed instead of directly
whenever a new buffer is attached. This is similar to how Weston
works.

https://bugzilla.gnome.org/show_bug.cgi?id=702999

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

(cherry picked from commit 9b35e1651ad0e46ed489893b60563e2c25457701)

Conflicts:
	examples/cogland.c
2013-07-01 13:48:22 +01:00
Robert Bragg
5faed43f29 cogl-gst: expose aspect ratio apis
This adds several utility apis that aim to make it as easy as possible
for an application to determine what size a video should be drawn at.

The important detail here is that these apis take into account the
pixel-aspect-ratio in addition to the video's own aspect ratio.

This patch updates the cogl-basic-video-player example to use the
cogl_gst_video_sink_fit_size() api to perform letterboxing.

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

(cherry picked from commit d26f17c97ff6b9f6d6211e0527d5965a85305a56)
2013-06-21 19:06:59 +01:00
Plamena Manolova
1eca1631a7 Include CoglGst
CoglGst is a GStreamer integration library that facilitates
video playback using the Cogl API. It works by retrieving
each video frame from the GStreamer pipeline and attaching
it to a Cogl pipeline in the form of a Cogl texture along
with possible color model conversion shaders. The pipeline
is then retrieved by the user during each draw. An example
use of the CoglGst API is included in the examples directory.

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

(cherry picked from commit dfb94cf4b0b6b42d6465df362a0c0af780596890)
2013-06-21 18:57:24 +01:00
Neil Roberts
6d51a18e7c Add support for per-vertex point sizes
This adds a new function to enable per-vertex point size on a
pipeline. This can be set with
cogl_pipeline_set_per_vertex_point_size(). Once enabled the point size
can be set either by drawing with an attribute named
'cogl_point_size_in' or by writing to the 'cogl_point_size_out'
builtin from a snippet.

There is a feature flag which must be checked for before using
per-vertex point sizes. This will only be set on GL >= 2.0 or on GLES
2.0. GL will only let you set a per-vertex point size from GLSL by
writing to gl_PointSize. This is only available in GL2 and not in the
older GLSL extensions.

The per-vertex point size has its own pipeline state flag so that it
can be part of the state that affects vertex shader generation.

Having to enable the per vertex point size with a separate function is
a bit awkward. Ideally it would work like the color attribute where
you can just set it for every vertex in your primitive with
cogl_pipeline_set_color or set it per-vertex by just using the
attribute. This is harder to get working with the point size because
we need to generate a different vertex shader depending on what
attributes are bound. I think if we wanted to make this work
transparently we would still want to internally have a pipeline
property describing whether the shader was generated with per-vertex
support so that it would work with the shader cache correctly.
Potentially we could make the per-vertex property internal and
automatically make a weak pipeline whenever the attribute is bound.
However we would then also need to automatically detect when an
application is writing to cogl_point_size_out from a snippet.

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

(cherry picked from commit 8495d9c1c15ce389885a9356d965eabd97758115)

Conflicts:
	cogl/cogl-context.c
	cogl/cogl-pipeline-private.h
	cogl/cogl-pipeline.c
	cogl/cogl-private.h
	cogl/driver/gl/cogl-pipeline-progend-fixed.c
	cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
2013-06-07 16:53:29 +01:00
Neil Roberts
8282cee367 Update some of the examples to use the dirty callback
This updates Cogland and the three hello examples to use the dirty
callback. For Cogland, this removes the manual handling of X events
and for the other examples it removes the need to redraw continously.

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

(cherry picked from commit 108e3c548b7866190845f163c84a05212718bd70)
2013-05-30 13:43:00 +01:00
Robert Bragg
9ef37423fc emscripten-hello: improve mainloop integration
Instead of simply relying on the emscripten mainloop api to wake us up
periodically so that we can poll for SDL events we now pause the
emscripten mainloop whenever no redraw is queued and instead hook an
input event listener into the real browser mainloop to resume the
emscripten mainloop whenever input is received. This way the example
can go to sleep while there's no input to handle.

This provides a simple example of binding custom javascript into native
code.

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

(cherry picked from commit a8b1e2eda491dc7c44c84cd47e160c7b8ba0f792)
2013-05-29 19:30:44 +01:00
Robert Bragg
0e7a632e13 Adds initial Emscripten support to Cogl
This enables basic Emscripten support in Cogl via the SDL winsys.
Assuming you have setup an emscripten toolchain you can configure Cogl
like this:

 emconfigure ./configure --enable-debug --enable-emscripten

Building the examples will build .html files that can be loaded directly
by a WebGL enabled browser.

Note: at this point the emscripten support has just barely been smoke
tested so it's expected that as we continue to build on this we will
learn about more things we need to change in Cogl to full support this
environment.

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

(cherry picked from commit a3bc2e7539391b074e697839dfae60b69c37cf10)
2013-05-29 19:30:44 +01:00
Neil Roberts
f7c3c2dc95 cogland: Listen for Expose events when Cogl is using X
Since 906e1b5eb535a86 Cogland no longer redraws constantly but instead
only draws once at startup and then again whenever a client attaches a
new buffer. Sometimes however it seems that the first paint will get
lost perhaps because it is sent before the window is fully mapped. As
it was previously not handling expose events it would not paint again
until the first client is connected so there would be a blank window
which looks broken.

This patch makes it handle Expose events when it detects that Cogl is
using an X backend. On other backends it will resort to queuing a
redraw every 16ms as it did before.

Although this is probably a bit overkill for such a small example, it
seems like a good idea to only redraw when we think it's necessary so
that we can be sure that the mechanism works. Handling the expose
events means we can have at least one platform where we can test this.

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

(cherry picked from commit 99cf15b285302243395873d78f05a5895c173eef)
2013-05-13 17:32:34 +01:00
Neil Roberts
f002e4e78f cogland: Embed the wl_surface struct directly into CoglandSurface
The wl_surface struct has been removed from libwayland-server so
instead we can just embed its only memeber, the resource, directly
into CoglandSurface.

http://cgit.freedesktop.org/wayland/wayland/commit/?id=508dd69b5654

https://bugzilla.gnome.org/show_bug.cgi?id=700088

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

(cherry picked from commit 15c58ce03ce97df659dade0e10be7807eb7b2296)
2013-05-13 17:32:34 +01:00
Neil Roberts
32a0f88b04 cogland: Correctly handle commits without attaching a new buffer
Previously if a client sent a commit message without attaching a new
buffer then it would end up detaching the existing buffer because
surface->pending.buffer would be NULL. This patch makes it explicitly
track when an attach is sent for a commit and so that it can avoid
making any changes otherwise. This fixes cases where GTK apps would
send a damage event without a new buffer.

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

(cherry picked from commit aa412b9c709120bd8d88a014010c448f3b9fcfb7)
2013-05-13 17:32:34 +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
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
Robert Bragg
afbb13e1a4 Add compiler deprecation warnings
This adds compiler symbol deprecation declarations for old Cogl APIs so
that users can easily see via compiler warning when they are using these
symbols, and also see a hint for what the apis should be replaced with.

So that users of Cogl can manage when to show these warnings this
introduces a scheme borrowed from glib whereby you can declare what
version of the Cogl api you are using:

COGL_VERSION_MIN_REQUIRED can be defined to indicate the oldest Cogl api
that the application wants to use. Cogl will only warn about
deprecations for symbols that were deprecated earlier than this required
version. If this is left undefined then by default Cogl will warn about
all deprecations.

COGL_VERSION_MAX_ALLOWED can be defined to indicate the newest api
that the application uses. If the application uses symbols newer than
this then Cogl will give a warning about that.

This patch removes the need to maintain the COGL_DISABLE_DEPRECATED
guards around deprecated symbols.

This patch fixes a few uses of deprecated symbols in the examples/

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-04-24 22:23:50 +01:00
Neil Roberts
abaca02235 Add $(LIBM) to the LDADD for all of the examples and tests
Some of the examples and tests are using functions from -lm. With some
linkers, if we don't expicitly link against it an error will be
reported. This patch adds the library to all of the examples even
though not all of them use math functions because I don't think it
will do any harm and it will save us having to remember to add it if
an example later starts using some math functions.

https://bugzilla.gnome.org/show_bug.cgi?id=697330

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

(cherry picked from commit 66a1aeaee1f7cdcdd505f5745277723a43d714b6)

Conflicts:
	examples/Makefile.am
	tests/conform/Makefile.am
	tests/micro-perf/Makefile.am
2013-04-23 18:32:47 +01:00
Neil Roberts
95fe636a53 Fix a warning about ‘sincos’ in examples/cogl-gles2-gears
‘sincos’ is a GNU extension. cogl-gles2-gears was using it without
defining _GNU_SOURCE so it was generating some annoying warnings. This
patch fixes it by making the example include config.h which will end
up defining _GNU_SOURCE.

In addition this patch adds a configure check for the function and
provides a fallback if it's not available.

https://bugzilla.gnome.org/show_bug.cgi?id=697330

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

(cherry picked from commit eb5c92952e1882c95cfd6debc69a2c9efff096b9)
2013-04-23 18:30:54 +01:00
Neil Roberts
08b0d2d63e examples: Fix the first colour in the triangle_vertices
The first vertex in the triangle vertices used in the cogl-hello
example (which were copied into a few other examples) for some reason
has a semi-transparent alpha component. However the colour needs to be
pre-multiplied and the red component was still 0xff so the colour is
effectively invalid and the transparency isn't shown. This patch just
sets the alpha component to 0xff to make it less confusing.

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

(cherry picked from commit 461879986ec012556b4e680b73e36d440927faaa)
2013-04-22 13:01:45 +01:00
Neil Roberts
856e9aa5f4 cogland: Try forcing an EGL context
Cogland works a lot better with an EGL context because then Mesa will
automatically set up the wl_drm object and it can accept DRM buffers.
However Cogland is still useful with GLX because it can gracefully
fallback to accepting only SHM buffers. This patch therefore makes it
first try creating and connecting a renderer with the EGL constraint,
but if that doesn't work it will try again without it.

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

(cherry picked from commit 05ddc7d75e77538b5de22d4336d4a444d122063b)
2013-04-22 13:00:25 +01:00
Neil Roberts
20d64cbb39 cogland: Handle damage events for non-shm buffers too
When a Wayland compositor gets a commit it only needs to redraw the
region specified by the pending damage event. Previously Cogland was
ignoring damage events for non-shm buffers and just always queuing a
redraw after a commit event. This patch changes it to queue a redraw
only in response to a damage event. In practice this doesn't really
make much difference because Cogland doesn't do anything clever to
handle updating a sub-region of the screen, but it more costly matches
the model a compositor should use.

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

(cherry picked from commit 15f00609e41f689234ee8d5b2f9e95fb74612d12)
2013-04-22 13:00:25 +01:00
Neil Roberts
efa3bd03c5 cogland: Don't leak the shell surface struct if requested twice
If the shell surface is requested twice then Cogland will hit an error
path but it would end up leaking the CoglandShellSurface struct it
allocated.

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

(cherry picked from commit 622d41b04c2689a8e4fb6e1769aaf887a04242e8)
2013-04-22 13:00:25 +01:00
Neil Roberts
2f3591ace0 cogland: Fix handling the destroy listener for the pending buffer
The handler for the destroy signal on the pending buffer was not
correctly being removed if the same buffer is committed twice to the
surface. It was also not being cleared if the surface is destroyed
before the pending buffer is committed.

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

(cherry picked from commit 11683476a7a62cd14a10d84fd52f2cb4b47e33a0)
2013-04-22 13:00:25 +01:00
Neil Roberts
003886661c cogland: Flush the clients in prepare, not check
The clients should be flushed before going idle, not after so the call
to wl_display_flush_clients was in the wrong place.

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

(cherry picked from commit a191366fbababd5b551140ef9297a9c6e3852c59)
2013-03-22 15:51:58 +00:00
Neil Roberts
53a684bf9e cogland: Don't redraw constantly
Instead of always drawing at 60FPS without ever going idle, Cogland
now only redraws when a client commits a frame or a surface is
destroyed. This is acheived using an idle handler on the glib main
loop.

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

(cherry picked from commit 906e1b5eb535a86a849bed7a363f800ad71ab9bc)

Conflicts:
	examples/cogland.c
2013-03-22 15:51:52 +00:00
Neil Roberts
666d0e100c cogland: Increase the display size to 800x600
The previous display size of 640x480 was a bit small to test with.

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

(cherry picked from commit 835626e220137765df5acf7419036218e3fc7c97)
2013-03-22 00:13:37 +00:00
Neil Roberts
73b95dd451 cogland: Add an option to split the desktop into four outputs
Previously Cogland would always split the desktop into four outputs.
Although this is quite neat to demonstrate that it's possible, it's
quite annoying in practice while testing. This patch turns it into a
command line option which defaults to off.

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

(cherry picked from commit 5570bf892268c8d2ea36bc26473aeb607c0e2c1d)
2013-03-22 00:13:36 +00:00
Neil Roberts
5334547c00 cogland: Update to the Wayland 1.0 API
This updates Cogland example compositor to use the stable Wayland 1.0
API.

• When the client attaches a new buffer to a surface it is now added
  to a struct contaning pending the state instead of immediately
  switching to the new buffer. This state is then flushed when the
  surface is committed.

• The frame callbacks are now queued in a pending list and only added
  to the compositor's main list when the surface is committed. Both
  lists are now a wl_list instead of a GQueue because it makes it
  easier to remove the callback without knowing which list it is in.

• When the buffer is destroyed for a surface the resource for the
  buffer is now sent a release event.

• It now flushes the clients in the prepare for the for the Wayland
  event GSource. This is part of the multi-threaded API in this
  Wayland patch:

  http://cgit.freedesktop.org/wayland/wayland/commit/?id=53d24713a31d59

• Implements a dummy wl_region interface. The only interfaces that
  actually use regions (the opaque and input regions) are ignored but
  we need the interface to create a resource.

• Most the of the SHM interface is now implemented directly in
  libwayland-server except that it still needs to copy the data to the
  subregion of the texture when the damage region is committed.

• The callback list for when a resource is destroyed has been unified
  into a generic wl_signal implementation so the signature for the
  functions has been changed.

  http://cgit.freedesktop.org/wayland/wayland/commit/?h=6802eaa68af9022

• The wl_buffer struct no longer has a user_data parameter so we can't
  attach our own CoglandBuffer data to it. Instead the CoglandSurface
  now just keeps track of the wl_buffer directly.

• The Cogland example is now unconditionally built instead of checking
  the Wayland version number in the configure script. It looks like
  this check was broken anyway because it was checking the version of
  the gbm package rather than a Wayland package.

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

(cherry picked from commit 4cbbc0f8e3de1fd44dee08b487f1c3f97dda8ede)

Conflicts:
	examples/Makefile.am
	examples/cogland.c
2013-03-22 00:13:32 +00:00
Robert Bragg
7ab54be3b7 avoid redundant idle if using FRAME_SYNC to throttle
This updates the examples and test-journal which now use the _FRAME_SYNC
events to throttle rendering so that they don't install a redundant idle
handler to paint when they get a FRAME_SYNC event and instead they now
directly paint when the event is received.

(cherry picked from commit 579eb75e6ac6f50d7a9cfe5093435126158b3c96)
2013-02-15 17:44:49 +00:00