mutter/examples/cogland.c

1117 lines
30 KiB
C
Raw Normal View History

#include <cogl/cogl.h>
#include <cogl/cogl-wayland-server.h>
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
#include <wayland-server.h>
typedef struct _CoglandCompositor CoglandCompositor;
typedef struct
{
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
2012-12-19 08:42:52 -05:00
int x1, y1, x2, y2;
} CoglandRegion;
typedef struct
{
struct wl_resource resource;
CoglandRegion region;
} CoglandSharedRegion;
typedef struct
{
CoglandCompositor *compositor;
struct wl_surface wayland_surface;
int x;
int y;
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
2012-12-19 08:42:52 -05:00
struct wl_buffer *buffer;
struct wl_listener buffer_destroy_listener;
CoglTexture2D *texture;
CoglBool has_shell_surface;
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
2012-12-19 08:42:52 -05:00
/* All the pending state, that wl_surface.commit will apply. */
struct
{
/* wl_surface.attach */
struct wl_buffer *buffer;
struct wl_listener buffer_destroy_listener;
int32_t sx;
int32_t sy;
/* wl_surface.damage */
CoglandRegion damage;
/* wl_surface.frame */
struct wl_list frame_callback_list;
} pending;
} CoglandSurface;
typedef struct
{
CoglandSurface *surface;
struct wl_resource resource;
struct wl_listener surface_destroy_listener;
} CoglandShellSurface;
typedef struct
{
uint32_t flags;
int width;
int height;
int refresh;
} CoglandMode;
typedef struct
{
struct wl_object wayland_output;
int32_t x;
int32_t y;
int32_t width_mm;
int32_t height_mm;
CoglOnscreen *onscreen;
GList *modes;
} CoglandOutput;
typedef struct
{
GSource source;
GPollFD pfd;
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
2012-12-19 08:42:52 -05:00
struct wl_display *display;
} WaylandEventSource;
struct _CoglandCompositor
{
struct wl_display *wayland_display;
struct wl_event_loop *wayland_loop;
CoglDisplay *cogl_display;
CoglContext *cogl_context;
int virtual_width;
int virtual_height;
GList *outputs;
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
2012-12-19 08:42:52 -05:00
struct wl_list frame_callbacks;
CoglPrimitive *triangle;
CoglPipeline *triangle_pipeline;
GSource *wayland_event_source;
GList *surfaces;
unsigned int redraw_idle;
};
static CoglBool option_multiple_outputs = FALSE;
static GOptionEntry
options[] =
{
{
"multiple", 'm', 0, G_OPTION_ARG_NONE, &option_multiple_outputs,
"Split the compositor into four outputs", NULL
},
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
static CoglBool
process_arguments (int *argc, char ***argv,
GError **error)
{
GOptionContext *context;
CoglBool ret;
GOptionGroup *group;
group = g_option_group_new (NULL, /* name */
NULL, /* description */
NULL, /* help_description */
NULL, /* user_data */
NULL /* destroy notify */);
g_option_group_add_entries (group, options);
context = g_option_context_new ("- An example Wayland compositor using Cogl");
g_option_context_set_main_group (context, group);
ret = g_option_context_parse (context, argc, argv, error);
g_option_context_free (context);
if (ret && *argc > 1)
{
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION,
"Unknown option '%s'", (* argv)[1]);
ret = FALSE;
}
return ret;
}
static uint32_t
get_time (void)
{
struct timeval tv;
gettimeofday (&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
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
2012-12-19 08:42:52 -05:00
static void
region_init (CoglandRegion *region)
{
memset (region, 0, sizeof (*region));
}
static CoglBool
region_is_empty (const CoglandRegion *region)
{
return region->x1 == region->x2 || region->y1 == region->y2;
}
static void
region_add (CoglandRegion *region,
int x,
int y,
int w,
int h)
{
if (region_is_empty (region))
{
region->x1 = x;
region->y1 = y;
region->x2 = x + w;
region->y2 = y + h;
}
else
{
if (x < region->x1)
region->x1 = x;
if (y < region->y1)
region->y1 = y;
if (x + w > region->x2)
region->x2 = x + w;
if (y + h > region->y2)
region->y2 = y + h;
}
}
static void
region_subtract (CoglandRegion *region,
int x,
int y,
int w,
int h)
{
/* FIXME */
}
static CoglBool
wayland_event_source_prepare (GSource *base, int *timeout)
{
WaylandEventSource *source = (WaylandEventSource *)base;
*timeout = -1;
wl_display_flush_clients (source->display);
return FALSE;
}
static CoglBool
wayland_event_source_check (GSource *base)
{
WaylandEventSource *source = (WaylandEventSource *)base;
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
2012-12-19 08:42:52 -05:00
return source->pfd.revents;
}
static CoglBool
wayland_event_source_dispatch (GSource *base,
GSourceFunc callback,
void *data)
{
WaylandEventSource *source = (WaylandEventSource *)base;
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
2012-12-19 08:42:52 -05:00
struct wl_event_loop *loop = wl_display_get_event_loop (source->display);
wl_event_loop_dispatch (loop, 0);
return TRUE;
}
static GSourceFuncs wayland_event_source_funcs =
{
wayland_event_source_prepare,
wayland_event_source_check,
wayland_event_source_dispatch,
NULL
};
Add -Wmissing-declarations to maintainer flags and fix problems This option to GCC makes it give a warning whenever a global function is defined without a declaration. This should catch cases were we've defined a function but forgot to put it in a header. In that case it is either only used within one file so we should make it static or we should declare it in a header. The following changes where made to fix problems: • Some functions were made static • cogl-path.h (the one containing the 1.0 API) was split into two files, one defining the functions and one defining the enums so that cogl-path.c can include the enum and function declarations from the 2.0 API as well as the function declarations from the 1.0 API. • cogl2-clip-state has been removed. This only had one experimental function called cogl_clip_push_from_path but as this is unstable we might as well remove it favour of the equivalent cogl_framebuffer_* API. • The GLX, SDL and WGL winsys's now have a private header to define their get_vtable function instead of directly declaring in the C file where it is called. • All places that were calling COGL_OBJECT_DEFINE need to have the cogl_is_whatever function declared so these have been added either as a public function or in a private header. • Some files that were not including the header containing their function declarations have been fixed to do so. • Any unused error quark functions have been removed. If we later want them we should add them back one by one and add a declaration for them in a header. • _cogl_is_framebuffer has been renamed to cogl_is_framebuffer and made a public function with a declaration in cogl-framebuffer.h • Similarly for CoglOnscreen. • cogl_vdraw_indexed_attributes is called cogl_framebuffer_vdraw_indexed_attributes in the header. The definition has been changed to match the header. • cogl_index_buffer_allocate has been removed. This had no declaration and I'm not sure what it's supposed to do. • CoglJournal has been changed to use the internal CoglObject macro so that it won't define an exported cogl_is_journal symbol. • The _cogl_blah_pointer_from_handle functions have been removed. CoglHandle isn't used much anymore anyway and in the few places where it is used I think it's safe to just use the implicit cast from void* to the right type. • The test-utils.h header for the conformance tests explicitly disables the -Wmissing-declaration option using a pragma because all of the tests declare their main function without a header. Any mistakes relating to missing declarations aren't really important for the tests. • cogl_quaternion_init_from_quaternion and init_from_matrix have been given declarations in cogl-quaternion.h Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-06 13:21:28 -05:00
static GSource *
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
2012-12-19 08:42:52 -05:00
wayland_event_source_new (struct wl_display *display)
{
WaylandEventSource *source;
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
2012-12-19 08:42:52 -05:00
struct wl_event_loop *loop =
wl_display_get_event_loop (display);
source = (WaylandEventSource *) g_source_new (&wayland_event_source_funcs,
sizeof (WaylandEventSource));
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
2012-12-19 08:42:52 -05:00
source->display = display;
source->pfd.fd = wl_event_loop_get_fd (loop);
source->pfd.events = G_IO_IN | G_IO_ERR;
g_source_add_poll (&source->source, &source->pfd);
return &source->source;
}
typedef struct _CoglandFrameCallback
{
struct wl_list link;
/* Pointer back to the compositor */
CoglandCompositor *compositor;
struct wl_resource resource;
} CoglandFrameCallback;
static CoglBool
paint_cb (void *user_data)
{
CoglandCompositor *compositor = user_data;
GList *l;
for (l = compositor->outputs; l; l = l->next)
{
CoglandOutput *output = l->data;
CoglFramebuffer *fb = COGL_FRAMEBUFFER (output->onscreen);
GList *l2;
cogl_push_framebuffer (fb);
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
cogl_framebuffer_draw_primitive (fb, compositor->triangle_pipeline,
compositor->triangle);
for (l2 = compositor->surfaces; l2; l2 = l2->next)
{
CoglandSurface *surface = l2->data;
if (surface->texture)
{
CoglTexture2D *texture = surface->texture;
cogl_set_source_texture (COGL_TEXTURE (texture));
cogl_rectangle (-1, 1, 1, -1);
}
}
cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb));
cogl_pop_framebuffer ();
}
while (!wl_list_empty (&compositor->frame_callbacks))
{
CoglandFrameCallback *callback =
wl_container_of (compositor->frame_callbacks.next, callback, link);
wl_resource_post_event (&callback->resource,
WL_CALLBACK_DONE, get_time ());
wl_resource_destroy (&callback->resource);
}
compositor->redraw_idle = 0;
return G_SOURCE_REMOVE;
}
static void
cogland_queue_redraw (CoglandCompositor *compositor)
{
if (compositor->redraw_idle == 0)
compositor->redraw_idle = g_idle_add (paint_cb, compositor);
}
static void
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
2012-12-19 08:42:52 -05:00
shm_buffer_damaged (CoglandSurface *surface,
int32_t x,
int32_t y,
int32_t width,
int32_t height)
{
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
2012-12-19 08:42:52 -05:00
struct wl_buffer *wayland_buffer = surface->buffer;
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
2012-12-19 08:42:52 -05:00
if (surface->texture)
{
CoglPixelFormat format;
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
2012-12-19 08:42:52 -05:00
int stride = wl_shm_buffer_get_stride (wayland_buffer);
const uint8_t *data = wl_shm_buffer_get_data (wayland_buffer);
switch (wl_shm_buffer_get_format (wayland_buffer))
{
#if G_BYTE_ORDER == G_BIG_ENDIAN
case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888_PRE;
break;
case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_ARGB_8888;
break;
#elif G_BYTE_ORDER == G_LITTLE_ENDIAN
case WL_SHM_FORMAT_ARGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888_PRE;
break;
case WL_SHM_FORMAT_XRGB8888:
format = COGL_PIXEL_FORMAT_BGRA_8888;
break;
#endif
default:
g_warn_if_reached ();
format = COGL_PIXEL_FORMAT_ARGB_8888;
}
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
2012-12-19 08:42:52 -05:00
cogl_texture_set_region (COGL_TEXTURE (surface->texture),
x, y, /* src_x/y */
x, y, /* dst_x/y */
width, height, /* dst_width/height */
width, height, /* width/height */
format,
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
2012-12-19 08:42:52 -05:00
stride,
data);
}
}
static void
cogland_surface_destroy (struct wl_client *wayland_client,
struct wl_resource *wayland_resource)
{
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
2012-12-19 08:42:52 -05:00
wl_resource_destroy (wayland_resource);
}
static void
cogland_surface_detach_buffer (CoglandSurface *surface)
{
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
2012-12-19 08:42:52 -05:00
struct wl_buffer *buffer = surface->buffer;
if (buffer)
{
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
2012-12-19 08:42:52 -05:00
wl_list_remove (&surface->buffer_destroy_listener.link);
surface->buffer = NULL;
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
2012-12-19 08:42:52 -05:00
if (surface->texture)
{
cogl_object_unref (surface->texture);
surface->texture = NULL;
}
cogland_queue_redraw (surface->compositor);
}
}
static void
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
2012-12-19 08:42:52 -05:00
surface_handle_buffer_destroy (struct wl_listener *listener,
void *data)
{
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
2012-12-19 08:42:52 -05:00
CoglandSurface *surface =
wl_container_of (listener, surface, buffer_destroy_listener);
cogland_surface_detach_buffer (surface);
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
2012-12-19 08:42:52 -05:00
}
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
2012-12-19 08:42:52 -05:00
static void
cogland_surface_detach_buffer_and_notify (CoglandSurface *surface)
{
struct wl_buffer *buffer = surface->buffer;
if (buffer)
{
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
2012-12-19 08:42:52 -05:00
g_assert (buffer->resource.client != NULL);
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
2012-12-19 08:42:52 -05:00
wl_resource_queue_event (&buffer->resource, WL_BUFFER_RELEASE);
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
2012-12-19 08:42:52 -05:00
cogland_surface_detach_buffer (surface);
}
}
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
2012-12-19 08:42:52 -05:00
static void
cogland_surface_attach (struct wl_client *wayland_client,
struct wl_resource *wayland_surface_resource,
struct wl_resource *wayland_buffer_resource,
int32_t sx, int32_t sy)
{
CoglandSurface *surface = wayland_surface_resource->data;
struct wl_buffer *buffer =
wayland_buffer_resource ? wayland_buffer_resource->data : NULL;
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
2012-12-19 08:42:52 -05:00
/* Attach without commit in between does not went wl_buffer.release */
if (surface->pending.buffer)
wl_list_remove (&surface->pending.buffer_destroy_listener.link);
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
2012-12-19 08:42:52 -05:00
surface->pending.sx = sx;
surface->pending.sy = sy;
surface->pending.buffer = buffer;
if (buffer)
wl_signal_add (&buffer->resource.destroy_signal,
&surface->pending.buffer_destroy_listener);
}
static void
cogland_surface_damage (struct wl_client *client,
struct wl_resource *resource,
int32_t x,
int32_t y,
int32_t width,
int32_t height)
{
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
2012-12-19 08:42:52 -05:00
CoglandSurface *surface = resource->data;
region_add (&surface->pending.damage, x, y, width, height);
}
static void
destroy_frame_callback (struct wl_resource *callback_resource)
{
CoglandFrameCallback *callback = callback_resource->data;
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
2012-12-19 08:42:52 -05:00
wl_list_remove (&callback->link);
g_slice_free (CoglandFrameCallback, callback);
}
static void
cogland_surface_frame (struct wl_client *client,
struct wl_resource *surface_resource,
uint32_t callback_id)
{
CoglandFrameCallback *callback;
CoglandSurface *surface = surface_resource->data;
callback = g_slice_new0 (CoglandFrameCallback);
callback->compositor = surface->compositor;
callback->resource.object.interface = &wl_callback_interface;
callback->resource.object.id = callback_id;
callback->resource.destroy = destroy_frame_callback;
callback->resource.data = callback;
wl_client_add_resource (client, &callback->resource);
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
2012-12-19 08:42:52 -05:00
wl_list_insert (surface->pending.frame_callback_list.prev, &callback->link);
}
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
2012-12-19 08:42:52 -05:00
static void
cogland_surface_set_opaque_region (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *region)
{
}
static void
cogland_surface_set_input_region (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *region)
{
}
static void
cogland_surface_commit (struct wl_client *client,
struct wl_resource *resource)
{
CoglandSurface *surface = resource->data;
CoglandCompositor *compositor = surface->compositor;
/* wl_surface.attach */
if (surface->buffer != surface->pending.buffer)
{
CoglError *error = NULL;
cogland_surface_detach_buffer_and_notify (surface);
if (surface->pending.buffer)
{
surface->texture =
cogl_wayland_texture_2d_new_from_buffer (compositor->cogl_context,
surface->pending.buffer,
&error);
if (!surface->texture)
{
g_error ("Failed to create texture_2d from wayland buffer: %s",
error->message);
cogl_error_free (error);
}
surface->buffer = surface->pending.buffer;
wl_signal_add (&surface->buffer->resource.destroy_signal,
&surface->buffer_destroy_listener);
}
}
if (surface->pending.buffer)
{
wl_list_remove (&surface->pending.buffer_destroy_listener.link);
surface->pending.buffer = NULL;
}
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
2012-12-19 08:42:52 -05:00
surface->pending.sx = 0;
surface->pending.sy = 0;
/* wl_surface.damage */
if (surface->buffer &&
wl_buffer_is_shm (surface->buffer) &&
surface->texture &&
!region_is_empty (&surface->pending.damage))
{
CoglandRegion *region = &surface->pending.damage;
CoglTexture *texture = COGL_TEXTURE (surface->texture);
if (region->x2 > cogl_texture_get_width (texture))
region->x2 = cogl_texture_get_width (texture);
if (region->y2 > cogl_texture_get_height (texture))
region->y2 = cogl_texture_get_height (texture);
if (region->x1 < 0)
region->x1 = 0;
if (region->y1 < 0)
region->y1 = 0;
shm_buffer_damaged (surface,
region->x1,
region->y1,
region->x2 - region->x1,
region->y2 - region->y1);
}
region_init (&surface->pending.damage);
/* wl_surface.frame */
wl_list_insert_list (&compositor->frame_callbacks,
&surface->pending.frame_callback_list);
wl_list_init (&surface->pending.frame_callback_list);
cogland_queue_redraw (compositor);
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
2012-12-19 08:42:52 -05:00
}
static void
cogland_surface_set_buffer_transform (struct wl_client *client,
struct wl_resource *resource,
int32_t transform)
{
}
const struct wl_surface_interface cogland_surface_interface = {
cogland_surface_destroy,
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
2012-12-19 08:42:52 -05:00
cogland_surface_attach,
cogland_surface_damage,
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
2012-12-19 08:42:52 -05:00
cogland_surface_frame,
cogland_surface_set_opaque_region,
cogland_surface_set_input_region,
cogland_surface_commit,
cogland_surface_set_buffer_transform
};
static void
cogland_surface_free (CoglandSurface *surface)
{
CoglandCompositor *compositor = surface->compositor;
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
2012-12-19 08:42:52 -05:00
CoglandFrameCallback *cb, *next;
compositor->surfaces = g_list_remove (compositor->surfaces, surface);
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
2012-12-19 08:42:52 -05:00
cogland_surface_detach_buffer_and_notify (surface);
if (surface->pending.buffer)
wl_list_remove (&surface->pending.buffer_destroy_listener.link);
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
2012-12-19 08:42:52 -05:00
wl_list_for_each_safe (cb, next,
&surface->pending.frame_callback_list, link)
wl_resource_destroy (&cb->resource);
g_slice_free (CoglandSurface, surface);
}
static void
cogland_surface_resource_destroy_cb (struct wl_resource *resource)
{
CoglandSurface *surface = resource->data;
cogland_surface_free (surface);
}
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
2012-12-19 08:42:52 -05:00
static void
surface_handle_pending_buffer_destroy (struct wl_listener *listener,
void *data)
{
CoglandSurface *surface =
wl_container_of (listener, surface, pending.buffer_destroy_listener);
surface->pending.buffer = NULL;
}
static void
cogland_compositor_create_surface (struct wl_client *wayland_client,
struct wl_resource *wayland_compositor_resource,
uint32_t id)
{
CoglandCompositor *compositor = wayland_compositor_resource->data;
CoglandSurface *surface = g_slice_new0 (CoglandSurface);
surface->compositor = compositor;
surface->wayland_surface.resource.destroy =
cogland_surface_resource_destroy_cb;
surface->wayland_surface.resource.object.id = id;
surface->wayland_surface.resource.object.interface = &wl_surface_interface;
surface->wayland_surface.resource.object.implementation =
(void (**)(void)) &cogland_surface_interface;
surface->wayland_surface.resource.data = surface;
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
2012-12-19 08:42:52 -05:00
surface->buffer_destroy_listener.notify =
surface_handle_buffer_destroy;
surface->pending.buffer_destroy_listener.notify =
surface_handle_pending_buffer_destroy;
wl_list_init (&surface->pending.frame_callback_list);
region_init (&surface->pending.damage);
wl_client_add_resource (wayland_client, &surface->wayland_surface.resource);
compositor->surfaces = g_list_prepend (compositor->surfaces,
surface);
}
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
2012-12-19 08:42:52 -05:00
static void
cogland_region_destroy (struct wl_client *client,
struct wl_resource *resource)
{
wl_resource_destroy (resource);
}
static void
cogland_region_add (struct wl_client *client,
struct wl_resource *resource,
int32_t x,
int32_t y,
int32_t width,
int32_t height)
{
CoglandSharedRegion *shared_region = resource->data;
region_add (&shared_region->region, x, y, width, height);
}
static void
cogland_region_subtract (struct wl_client *client,
struct wl_resource *resource,
int32_t x,
int32_t y,
int32_t width,
int32_t height)
{
CoglandSharedRegion *shared_region = resource->data;
region_subtract (&shared_region->region, x, y, width, height);
}
const struct wl_region_interface cogland_region_interface = {
cogland_region_destroy,
cogland_region_add,
cogland_region_subtract
};
static void
cogland_region_resource_destroy_cb (struct wl_resource *resource)
{
CoglandSharedRegion *region = resource->data;
g_slice_free (CoglandSharedRegion, region);
}
static void
cogland_compositor_create_region (struct wl_client *wayland_client,
struct wl_resource *compositor_resource,
uint32_t id)
{
CoglandSharedRegion *region = g_slice_new0 (CoglandSharedRegion);
region->resource.destroy =
cogland_region_resource_destroy_cb;
region->resource.object.id = id;
region->resource.object.interface = &wl_region_interface;
region->resource.object.implementation =
(void (**)(void)) &cogland_region_interface;
region->resource.data = region;
region_init (&region->region);
wl_client_add_resource (wayland_client, &region->resource);
}
static void
bind_output (struct wl_client *client,
void *data,
uint32_t version,
uint32_t id)
{
CoglandOutput *output = data;
struct wl_resource *resource =
wl_client_add_object (client, &wl_output_interface, NULL, id, data);
GList *l;
wl_resource_post_event (resource,
WL_OUTPUT_GEOMETRY,
output->x, output->y,
output->width_mm,
output->height_mm,
0, /* subpixel: unknown */
"unknown", /* make */
"unknown"); /* model */
for (l = output->modes; l; l = l->next)
{
CoglandMode *mode = l->data;
wl_resource_post_event (resource,
WL_OUTPUT_MODE,
mode->flags,
mode->width,
mode->height,
mode->refresh);
}
}
static void
cogland_compositor_create_output (CoglandCompositor *compositor,
int x,
int y,
int width_mm,
int height_mm)
{
CoglandOutput *output = g_slice_new0 (CoglandOutput);
CoglFramebuffer *fb;
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.
2012-08-31 14:28:27 -04:00
CoglError *error = NULL;
CoglandMode *mode;
output->x = x;
output->y = y;
output->width_mm = width_mm;
output->height_mm = height_mm;
output->wayland_output.interface = &wl_output_interface;
wl_display_add_global (compositor->wayland_display,
&wl_output_interface,
output,
bind_output);
output->onscreen = cogl_onscreen_new (compositor->cogl_context,
width_mm, height_mm);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
fb = COGL_FRAMEBUFFER (output->onscreen);
if (!cogl_framebuffer_allocate (fb, &error))
g_error ("Failed to allocate framebuffer: %s\n", error->message);
cogl_onscreen_show (output->onscreen);
#if 0
cogl_framebuffer_set_viewport (fb, x, y, width, height);
#else
cogl_push_framebuffer (fb);
cogl_set_viewport (-x, -y,
compositor->virtual_width,
compositor->virtual_height);
cogl_pop_framebuffer ();
#endif
mode = g_slice_new0 (CoglandMode);
mode->flags = 0;
mode->width = width_mm;
mode->height = height_mm;
mode->refresh = 60;
output->modes = g_list_prepend (output->modes, mode);
compositor->outputs = g_list_prepend (compositor->outputs, output);
}
const static struct wl_compositor_interface cogland_compositor_interface =
{
cogland_compositor_create_surface,
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
2012-12-19 08:42:52 -05:00
cogland_compositor_create_region
};
static void
compositor_bind (struct wl_client *client,
void *data,
uint32_t version,
uint32_t id)
{
CoglandCompositor *compositor = data;
wl_client_add_object (client, &wl_compositor_interface,
&cogland_compositor_interface, id, compositor);
}
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
2012-12-19 08:42:52 -05:00
static void
shell_surface_pong (struct wl_client *client,
struct wl_resource *resource,
uint32_t serial)
{
}
static void
shell_surface_move (struct wl_client *client,
struct wl_resource *resource,
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
2012-12-19 08:42:52 -05:00
struct wl_resource *seat,
uint32_t serial)
{
}
static void
shell_surface_resize (struct wl_client *client,
struct wl_resource *resource,
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
2012-12-19 08:42:52 -05:00
struct wl_resource *seat,
uint32_t serial,
uint32_t edges)
{
}
static void
shell_surface_set_toplevel (struct wl_client *client,
struct wl_resource *resource)
{
}
static void
shell_surface_set_transient (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *parent,
int32_t x,
int32_t y,
uint32_t flags)
{
}
static void
shell_surface_set_fullscreen (struct wl_client *client,
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
2012-12-19 08:42:52 -05:00
struct wl_resource *resource,
uint32_t method,
uint32_t framerate,
struct wl_resource *output)
{
}
static void
shell_surface_set_popup (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *seat,
uint32_t serial,
struct wl_resource *parent,
int32_t x,
int32_t y,
uint32_t flags)
{
}
static void
shell_surface_set_maximized (struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *output)
{
}
static void
shell_surface_set_title (struct wl_client *client,
struct wl_resource *resource,
const char *title)
{
}
static void
shell_surface_set_class (struct wl_client *client,
struct wl_resource *resource,
const char *class_)
{
}
static const struct wl_shell_surface_interface cogl_shell_surface_interface =
{
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
2012-12-19 08:42:52 -05:00
shell_surface_pong,
shell_surface_move,
shell_surface_resize,
shell_surface_set_toplevel,
shell_surface_set_transient,
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
2012-12-19 08:42:52 -05:00
shell_surface_set_fullscreen,
shell_surface_set_popup,
shell_surface_set_maximized,
shell_surface_set_title,
shell_surface_set_class
};
static void
shell_handle_surface_destroy (struct wl_listener *listener,
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
2012-12-19 08:42:52 -05:00
void *data)
{
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
2012-12-19 08:42:52 -05:00
CoglandShellSurface *shell_surface =
wl_container_of (listener, shell_surface, surface_destroy_listener);
shell_surface->surface->has_shell_surface = FALSE;
shell_surface->surface = NULL;
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
2012-12-19 08:42:52 -05:00
wl_resource_destroy (&shell_surface->resource);
}
static void
destroy_shell_surface (struct wl_resource *resource)
{
CoglandShellSurface *shell_surface = resource->data;
/* In case cleaning up a dead client destroys shell_surface first */
if (shell_surface->surface)
{
wl_list_remove (&shell_surface->surface_destroy_listener.link);
shell_surface->surface->has_shell_surface = FALSE;
}
g_free (shell_surface);
}
static void
get_shell_surface (struct wl_client *client,
struct wl_resource *resource,
uint32_t id,
struct wl_resource *surface_resource)
{
CoglandSurface *surface = surface_resource->data;
CoglandShellSurface *shell_surface;
if (surface->has_shell_surface)
{
wl_resource_post_error (surface_resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"wl_shell::get_shell_surface already requested");
return;
}
shell_surface = g_new0 (CoglandShellSurface, 1);
shell_surface->resource.destroy = destroy_shell_surface;
shell_surface->resource.object.id = id;
shell_surface->resource.object.interface = &wl_shell_surface_interface;
shell_surface->resource.object.implementation =
(void (**) (void)) &cogl_shell_surface_interface;
shell_surface->resource.data = shell_surface;
shell_surface->surface = surface;
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
2012-12-19 08:42:52 -05:00
shell_surface->surface_destroy_listener.notify = shell_handle_surface_destroy;
wl_signal_add (&surface->wayland_surface.resource.destroy_signal,
&shell_surface->surface_destroy_listener);
surface->has_shell_surface = TRUE;
wl_client_add_resource (client, &shell_surface->resource);
}
static const struct wl_shell_interface cogland_shell_interface =
{
get_shell_surface
};
static void
bind_shell (struct wl_client *client,
void *data,
uint32_t version,
uint32_t id)
{
wl_client_add_object (client, &wl_shell_interface,
&cogland_shell_interface, id, data);
}
int
main (int argc, char **argv)
{
CoglandCompositor compositor;
GMainLoop *loop;
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.
2012-08-31 14:28:27 -04:00
CoglError *error = NULL;
GError *gerror = NULL;
CoglVertexP2C4 triangle_vertices[] = {
{0, 0.7, 0xff, 0x00, 0x00, 0x80},
{-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
{0.7, -0.7, 0x00, 0x00, 0xff, 0xff}
};
GSource *cogl_source;
if (!process_arguments (&argc, &argv, &gerror))
{
fprintf (stderr, "%s\n", gerror->message);
return EXIT_FAILURE;
}
memset (&compositor, 0, sizeof (compositor));
compositor.wayland_display = wl_display_create ();
if (compositor.wayland_display == NULL)
g_error ("failed to create wayland display");
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
2012-12-19 08:42:52 -05:00
wl_list_init (&compositor.frame_callbacks);
if (!wl_display_add_global (compositor.wayland_display,
&wl_compositor_interface,
&compositor,
compositor_bind))
g_error ("Failed to register wayland compositor object");
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
2012-12-19 08:42:52 -05:00
wl_display_init_shm (compositor.wayland_display);
loop = g_main_loop_new (NULL, FALSE);
compositor.wayland_loop =
wl_display_get_event_loop (compositor.wayland_display);
compositor.wayland_event_source =
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
2012-12-19 08:42:52 -05:00
wayland_event_source_new (compositor.wayland_display);
g_source_attach (compositor.wayland_event_source, NULL);
compositor.cogl_display = cogl_display_new (NULL, NULL);
cogl_wayland_display_set_compositor_display (compositor.cogl_display,
compositor.wayland_display);
compositor.cogl_context = cogl_context_new (compositor.cogl_display, &error);
if (!compositor.cogl_context)
g_error ("Failed to create a Cogl context: %s\n", error->message);
compositor.virtual_width = 800;
compositor.virtual_height = 600;
if (option_multiple_outputs)
{
int hw = compositor.virtual_width / 2;
int hh = compositor.virtual_height / 2;
/* Emulate compositing with multiple monitors... */
cogland_compositor_create_output (&compositor, 0, 0, hw, hh);
cogland_compositor_create_output (&compositor, hw, 0, hw, hh);
cogland_compositor_create_output (&compositor, 0, hh, hw, hh);
cogland_compositor_create_output (&compositor, hw, hh, hw, hh);
}
else
{
cogland_compositor_create_output (&compositor,
0, 0,
compositor.virtual_width,
compositor.virtual_height);
}
if (wl_display_add_global (compositor.wayland_display, &wl_shell_interface,
&compositor, bind_shell) == NULL)
g_error ("Failed to register a global shell object");
if (wl_display_add_socket (compositor.wayland_display, "wayland-0"))
g_error ("Failed to create socket");
compositor.triangle = cogl_primitive_new_p2c4 (compositor.cogl_context,
COGL_VERTICES_MODE_TRIANGLES,
3, triangle_vertices);
compositor.triangle_pipeline = cogl_pipeline_new (compositor.cogl_context);
cogl_source = cogl_glib_source_new (compositor.cogl_context,
G_PRIORITY_DEFAULT);
g_source_attach (cogl_source, NULL);
cogland_queue_redraw (&compositor);
g_main_loop_run (loop);
return 0;
}