[PATCH 1/2] rpi: Remove dangling reference to weston_view

2013-10-25 Thread Tomeu Vizoso
This also marks the rpir_view for destroy in rpi_renderer_finish_frame()
---
 src/rpi-renderer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
index 812e6e7..7f79410 100644
--- a/src/rpi-renderer.c
+++ b/src/rpi-renderer.c
@@ -1501,6 +1501,8 @@ rpi_renderer_destroy_view(struct weston_view *base)
if (!view)
return;
 
+   view-view = NULL;
+
/* If guaranteed to not be on screen, just detroy it. */
if (wl_list_empty(view-link))
rpir_view_destroy(view);
-- 
1.8.3.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 2/2] rpi: Protect in-use DispmanX resources from premature deletion

2013-10-25 Thread Tomeu Vizoso
The compositor will check if the client destroyed the wl_buffer
while it was in use in a display update, and delete the resource
itself once the update has finished.
---
 src/rpi-bcm-stubs.h |  5 
 src/rpi-renderer.c  | 74 +
 2 files changed, 46 insertions(+), 33 deletions(-)

diff --git a/src/rpi-bcm-stubs.h b/src/rpi-bcm-stubs.h
index 703cd77..31b9b1c 100644
--- a/src/rpi-bcm-stubs.h
+++ b/src/rpi-bcm-stubs.h
@@ -303,6 +303,11 @@ vc_dispmanx_get_handle_from_wl_buffer(struct wl_resource 
*_buffer)
return DISPMANX_NO_HANDLE;
 }
 
+static inline void
+vc_dispmanx_set_wl_buffer_in_use(struct wl_resource *_buffer, int in_use)
+{
+}
+
 /* from /opt/vc/include/EGL/eglplatform.h */
 
 typedef struct {
diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
index 7f79410..7cbb4e8 100644
--- a/src/rpi-renderer.c
+++ b/src/rpi-renderer.c
@@ -362,6 +362,28 @@ rpi_resource_update(struct rpi_resource *resource, struct 
weston_buffer *buffer,
return ret ? -1 : 0;
 }
 
+static void
+rpir_egl_buffer_destroy(struct rpir_egl_buffer *egl_buffer)
+{
+   struct weston_buffer *buffer;
+
+   if (egl_buffer == NULL)
+   return;
+
+   buffer = egl_buffer-buffer_ref.buffer;
+   if (buffer == NULL) {
+   /* The client has already destroyed the wl_buffer, the
+* compositor has the responsibility to delete the resource.
+*/
+   vc_dispmanx_resource_delete(egl_buffer-resource_handle);
+   } else {
+   vc_dispmanx_set_wl_buffer_in_use(buffer-resource, 0);
+   weston_buffer_reference(egl_buffer-buffer_ref, NULL);
+   }
+
+   free(egl_buffer);
+}
+
 static struct rpir_surface *
 rpir_surface_create(struct rpi_renderer *renderer)
 {
@@ -404,23 +426,9 @@ rpir_surface_destroy(struct rpir_surface *surface)
rpi_resource_release(surface-resources[1]);
DBG(rpir_surface %p destroyed (%u)\n, surface, 
surface-visible_views);
 
-   if (surface-egl_back != NULL) {
-   weston_buffer_reference(surface-egl_back-buffer_ref, NULL);
-   free(surface-egl_back);
-   surface-egl_back = NULL;
-   }
-
-   if (surface-egl_front != NULL) {
-   weston_buffer_reference(surface-egl_front-buffer_ref, NULL);
-   free(surface-egl_front);
-   surface-egl_front = NULL;
-   }
-
-   if (surface-egl_old_front != NULL) {
-   weston_buffer_reference(surface-egl_old_front-buffer_ref, 
NULL);
-   free(surface-egl_old_front);
-   surface-egl_old_front = NULL;
-   }
+   rpir_egl_buffer_destroy(surface-egl_back);
+   rpir_egl_buffer_destroy(surface-egl_front);
+   rpir_egl_buffer_destroy(surface-egl_old_front);
 
free(surface);
 }
@@ -1002,7 +1010,6 @@ rpir_view_update(struct rpir_view *view, struct 
rpir_output *output,
int ret;
int obscured;
 
-
obscured = is_view_not_visible(view-view);
if (obscured) {
DBG(rpir_view %p totally obscured.\n, view);
@@ -1260,17 +1267,22 @@ rpi_renderer_repaint_output(struct weston_output *base,
rpir_surface_swap_pointers(view-surface);
}
 
-   if (view-surface-buffer_type == BUFFER_TYPE_EGL 
-   view-surface-egl_front-buffer_ref.buffer == NULL) {
-   weston_log(warning: client destroyed current front 
buffer\n);
-
-   wl_list_remove(view-link);
-   if (view-handle == DISPMANX_NO_HANDLE) {
-   wl_list_init(view-link);
+   if (view-surface-buffer_type == BUFFER_TYPE_EGL) {
+   struct weston_buffer *buffer;
+   buffer = view-surface-egl_front-buffer_ref.buffer;
+   if (buffer != NULL) {
+   
vc_dispmanx_set_wl_buffer_in_use(buffer-resource, 1);
} else {
-   rpir_view_dmx_remove(view, output-update);
-   wl_list_insert(output-view_cleanup_list,
-  view-link);
+   weston_log(warning: client destroyed current 
front buffer\n);
+
+   wl_list_remove(view-link);
+   if (view-handle == DISPMANX_NO_HANDLE) {
+   wl_list_init(view-link);
+   } else {
+   rpir_view_dmx_remove(view, 
output-update);
+   
wl_list_insert(output-view_cleanup_list,
+  view-link);
+   }
}
}
}
@@ -1695,11 +1707,7 @@ rpi_renderer_finish_frame(struct weston_output 

[PATCH 1/7] pixman-renderer: Initialize pixman-renderer struct with zeros

2013-10-25 Thread Ander Conselvan de Oliveira
Othrewise a crash may happen because of an unitialized value of the
create_view field.
---
 src/pixman-renderer.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 85fcd4c..d6f638d 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -660,7 +660,7 @@ pixman_renderer_init(struct weston_compositor *ec)
 {
struct pixman_renderer *renderer;
 
-   renderer = malloc(sizeof *renderer);
+   renderer = calloc(1, sizeof *renderer);
if (renderer == NULL)
return -1;
 
-- 
1.7.9.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 2/7] pixman-renderer, gl-renderer: Destroy debug bindings on clean up

2013-10-25 Thread Ander Conselvan de Oliveira
Also make sure backends destroy the renderers before shutting down the
compositor to avoid a double call to weston_binding_destroy().

This is a step towards making renderers switchable during runtime.
---
 src/compositor-drm.c   |4 ++--
 src/compositor-fbdev.c |3 ++-
 src/compositor-rpi.c   |3 ++-
 src/compositor-x11.c   |4 ++--
 src/gl-renderer.c  |   17 +
 src/pixman-renderer.c  |   13 ++---
 6 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 461fce7..b929728 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2312,10 +2312,10 @@ drm_destroy(struct weston_compositor *ec)
 
destroy_sprites(d);
 
-   weston_compositor_shutdown(ec);
-
ec-renderer-destroy(ec);
 
+   weston_compositor_shutdown(ec);
+
if (d-gbm)
gbm_device_destroy(d-gbm);
 
diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index dc650f0..09f165b 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -798,11 +798,12 @@ fbdev_compositor_destroy(struct weston_compositor *base)
 
udev_input_destroy(compositor-input);
 
+   compositor-base.renderer-destroy(compositor-base);
+
/* Destroy the output. */
weston_compositor_shutdown(compositor-base);
 
/* Chain up. */
-   compositor-base.renderer-destroy(compositor-base);
weston_launcher_destroy(compositor-base.launcher);
 
free(compositor);
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index cd24a08..f163e01 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -652,10 +652,11 @@ rpi_compositor_destroy(struct weston_compositor *base)
wl_list_for_each_safe(seat, next, compositor-base.seat_list, link)
evdev_input_destroy(seat);
 
+   compositor-base.renderer-destroy(compositor-base);
+
/* destroys outputs, too */
weston_compositor_shutdown(compositor-base);
 
-   compositor-base.renderer-destroy(compositor-base);
weston_launcher_destroy(compositor-base.launcher);
 
bcm_host_deinit();
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index d99bde5..ee3df31 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -1443,10 +1443,10 @@ x11_destroy(struct weston_compositor *ec)
wl_event_source_remove(compositor-xcb_source);
x11_input_destroy(compositor);
 
-   weston_compositor_shutdown(ec); /* destroys outputs, too */
-
ec-renderer-destroy(ec);
 
+   weston_compositor_shutdown(ec); /* destroys outputs, too */
+
XCloseDisplay(compositor-dpy);
free(ec);
 }
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 2cb24fa..0f0b5f7 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -85,6 +85,8 @@ struct gl_renderer {
struct weston_renderer base;
int fragment_shader_debug;
int fan_debug;
+   struct weston_binding *fragment_binding;
+   struct weston_binding *fan_binding;
 
EGLDisplay egl_display;
EGLContext egl_context;
@@ -1567,6 +1569,9 @@ gl_renderer_destroy(struct weston_compositor *ec)
wl_array_release(gr-indices);
wl_array_release(gr-vtxcnt);
 
+   weston_binding_destroy(gr-fragment_binding);
+   weston_binding_destroy(gr-fan_binding);
+
free(gr);
 }
 
@@ -1859,10 +1864,14 @@ gl_renderer_setup(struct weston_compositor *ec, 
EGLSurface egl_surface)
if (compile_shaders(ec))
return -1;
 
-   weston_compositor_add_debug_binding(ec, KEY_S,
-   fragment_debug_binding, ec);
-   weston_compositor_add_debug_binding(ec, KEY_F,
-   fan_debug_repaint_binding, ec);
+   gr-fragment_binding =
+   weston_compositor_add_debug_binding(ec, KEY_S,
+   fragment_debug_binding,
+   ec);
+   gr-fan_binding =
+   weston_compositor_add_debug_binding(ec, KEY_F,
+   fan_debug_repaint_binding,
+   ec);
 
weston_log(GL ES 2 renderer features:\n);
weston_log_continue(STAMP_SPACE read-back format: %s\n,
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index d6f638d..0d85e07 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -43,8 +43,10 @@ struct pixman_surface_state {
 
 struct pixman_renderer {
struct weston_renderer base;
+
int repaint_debug;
pixman_image_t *debug_color;
+   struct weston_binding *debug_binding;
 };
 
 static inline struct pixman_output_state *
@@ -630,7 +632,11 @@ pixman_renderer_destroy_surface(struct weston_surface 
*surface)
 static void
 pixman_renderer_destroy(struct weston_compositor *ec)
 {
-   free(ec-renderer);
+   struct 

[PATCH 3/7] compositor: Let renderers create and destroy surface state on their own

2013-10-25 Thread Ander Conselvan de Oliveira
Remove create_surface() and destroy_surface() from the renderer
interface and change the renderers to create surface state on demand
and destroy it using the weston_surface's destroy signal.

Also make sure the surfaces' renderer state is reset to NULL on
destruction.

This is a step towards runtime switchable renderers.

(rpi-renderer changes are only compile-tested)
---
 src/compositor.c  |8 ---
 src/compositor.h  |2 --
 src/gl-renderer.c |   61 ++---
 src/noop-renderer.c   |   13 ---
 src/pixman-renderer.c |   50 
 src/rpi-renderer.c|   54 ---
 6 files changed, 112 insertions(+), 76 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 2ed6b1e..563bade 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -407,11 +407,6 @@ weston_surface_create(struct weston_compositor *compositor)
surface-compositor = compositor;
surface-ref_count = 1;
 
-   if (compositor-renderer-create_surface(surface)  0) {
-   free(surface);
-   return NULL;
-   }
-
surface-buffer_transform = WL_OUTPUT_TRANSFORM_NORMAL;
surface-buffer_scale = 1;
surface-pending.buffer_transform = surface-buffer_transform;
@@ -1220,7 +1215,6 @@ weston_view_destroy(struct weston_view *view)
 WL_EXPORT void
 weston_surface_destroy(struct weston_surface *surface)
 {
-   struct weston_compositor *compositor = surface-compositor;
struct weston_frame_callback *cb, *next;
struct weston_view *ev, *nv;
 
@@ -1248,8 +1242,6 @@ weston_surface_destroy(struct weston_surface *surface)
 
weston_buffer_reference(surface-buffer_ref, NULL);
 
-   compositor-renderer-destroy_surface(surface);
-
pixman_region32_fini(surface-damage);
pixman_region32_fini(surface-opaque);
pixman_region32_fini(surface-input);
diff --git a/src/compositor.h b/src/compositor.h
index 73722b5..e60a512 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -521,12 +521,10 @@ struct weston_renderer {
   pixman_region32_t *output_damage);
void (*flush_damage)(struct weston_surface *surface);
void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
-   int (*create_surface)(struct weston_surface *surface);
int (*create_view)(struct weston_view *view);
void (*surface_set_color)(struct weston_surface *surface,
   float red, float green,
   float blue, float alpha);
-   void (*destroy_surface)(struct weston_surface *surface);
void (*destroy_view)(struct weston_view *view);
void (*destroy)(struct weston_compositor *ec);
 };
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 0f0b5f7..d792530 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -79,6 +79,10 @@ struct gl_surface_state {
int pitch; /* in pixels */
int height; /* in pixels */
int y_inverted;
+
+   struct weston_surface *surface;
+
+   struct wl_listener surface_destroy_listener;
 };
 
 struct gl_renderer {
@@ -134,9 +138,15 @@ get_output_state(struct weston_output *output)
return (struct gl_output_state *)output-renderer_state;
 }
 
+static int
+gl_renderer_create_surface(struct weston_surface *surface);
+
 static inline struct gl_surface_state *
 get_surface_state(struct weston_surface *surface)
 {
+   if (!surface-renderer_state)
+   gl_renderer_create_surface(surface);
+
return (struct gl_surface_state *)surface-renderer_state;
 }
 
@@ -997,6 +1007,8 @@ gl_renderer_attach_shm(struct weston_surface *es, struct 
weston_buffer *buffer,
gs-needs_full_upload = 1;
gs-y_inverted = 1;
 
+   gs-surface = surface;
+
ensure_textures(gs, 1);
glBindTexture(GL_TEXTURE_2D, gs-textures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
@@ -1136,6 +1148,31 @@ gl_renderer_surface_set_color(struct weston_surface 
*surface,
gs-shader = gr-solid_shader;
 }
 
+static void
+surface_state_handle_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct gl_surface_state *gs;
+   struct gl_renderer *gr;
+   struct weston_surface *surface = data;
+   int i;
+
+   gr = get_renderer(surface-compositor);
+
+   gs = container_of(listener, struct gl_surface_state,
+ surface_destroy_listener);
+
+   gs-surface-renderer_state = NULL;
+
+   glDeleteTextures(gs-num_textures, gs-textures);
+
+   for (i = 0; i  gs-num_images; i++)
+   gr-destroy_image(gr-egl_display, gs-images[i]);
+
+   weston_buffer_reference(gs-buffer_ref, NULL);
+   pixman_region32_fini(gs-texture_damage);
+   free(gs);
+}
+
 static int
 gl_renderer_create_surface(struct 

[PATCH 7/7] compositor-drm: Add option to delay the loading of the gl-renderer

2013-10-25 Thread Ander Conselvan de Oliveira
When using the renderer switch feature, the normal start up path and
the loading of gl-renderer and dependency libraries will compete for
IO bandwidth. In systems where that is limited, this may impact the
time it takes to get an image to the screen negatively.

This patch adds an option to delay the loading of the gl-renderer for
a number of seconds, to avoid the competition for IO. The delay is
chosen instead of simply starting the load as soon as the system is
running to provide more flexibility to system integrators. That way
they can choose this delay based on other factors on the system.
---
 man/weston-drm.man   |7 +++
 src/compositor-drm.c |   12 ++--
 src/compositor.c |1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/man/weston-drm.man b/man/weston-drm.man
index 035bace..2b97b39 100644
--- a/man/weston-drm.man
+++ b/man/weston-drm.man
@@ -111,6 +111,13 @@ instead of using the current tty.
 Start using the pixman renderer and later switch to the GL one. This
 should cause the system to able to render earlier when running from
 cold boot and slow storage.
+.TP
+\fB \-\-gl\-delay\fR=\fIdelay\fR
+When running with
+.BR \-\-fast\-start ,
+wait for
+.I delay
+seconds before loading the gl renderer.
 .
 .\ ***
 .SH ENVIRONMENT
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 5130278..00fcede 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -209,6 +209,7 @@ struct drm_parameters {
int tty;
int use_pixman;
int fast_start;
+   int gl_delay;
const char *seat_id;
 };
 
@@ -2645,6 +2646,7 @@ switch_to_gl_renderer(struct drm_compositor *c)
 struct gl_loader_thread_data {
int drm_fd;
int done_fd;
+   int delay;
 };
 
 static void *
@@ -2653,6 +2655,10 @@ gl_loader_thread_func(void *data)
struct gl_loader_thread_data *gl_data = data;
struct gbm_device *gbm;
 
+   /* Wait for a few seconds so that the loading doesn't steal the IO
+* bandwidth from the rest of the start up */
+   sleep(gl_data-delay);
+
gbm = create_gbm_device(gl_data-drm_fd);
 
if (write(gl_data-done_fd, done, 4) != 4)
@@ -2687,7 +2693,7 @@ done:
 }
 
 static int
-prepare_renderer_switch(struct drm_compositor *ec)
+prepare_renderer_switch(struct drm_compositor *ec, int delay)
 {
struct gl_loader_thread_data *gl_data;
struct wl_event_loop *loop;
@@ -2702,6 +2708,7 @@ prepare_renderer_switch(struct drm_compositor *ec)
 
gl_data-drm_fd = ec-drm.fd;
gl_data-done_fd = sv[1];
+   gl_data-delay = delay;
 
pthread_create(ec-gl_loader_thread, NULL,
   gl_loader_thread_func, gl_data);
@@ -2798,7 +2805,7 @@ drm_compositor_create(struct wl_display *display,
 
if (ec-use_pixman) {
if (param-fast_start)
-   prepare_renderer_switch(ec);
+   prepare_renderer_switch(ec, param-gl_delay);
 
if (init_pixman(ec)  0) {
weston_log(failed to initialize pixman renderer\n);
@@ -2908,6 +2915,7 @@ backend_init(struct wl_display *display, int *argc, char 
*argv[],
{ WESTON_OPTION_BOOLEAN, current-mode, 0, 
option_current_mode },
{ WESTON_OPTION_BOOLEAN, use-pixman, 0, param.use_pixman },
{ WESTON_OPTION_BOOLEAN, fast-start, 0, param.fast_start },
+   { WESTON_OPTION_INTEGER, gl-delay, 0, param.gl_delay },
};
 
param.seat_id = default_seat;
diff --git a/src/compositor.c b/src/compositor.c
index d11f765..f97da69 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3601,6 +3601,7 @@ usage(int error_code)
  --tty=TTY\t\tThe tty to use\n
  --use-pixman\t\tUse the pixman (CPU) renderer\n
  --fast-start\t\tStart with pixman renderer and later switch 
to GL\n
+ --gl-delay=S\t\tWait for S secs to load gl renderer (needs 
--fast-start)\n
  --current-mode\tPrefer current KMS mode over EDID preferred 
mode\n\n);
 
fprintf(stderr,
-- 
1.7.9.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH 4/7] pixman-renderer, gl-renderer: Destroy surface state with the renderer

2013-10-25 Thread Ander Conselvan de Oliveira
Previously the renderers destroy function assumed they are only called
when the compositor is shutting down and that the compositor had
already destroyed all the surfaces. However, if a runtime renderer
switch would be done, the surface state would be leaked.

This patch adds a destroy_signal to the pixman and gl renderers. The
surface state objects will listen for that signal and destroy
themselves if needed.

This is a step towards runtime switchable renderers.
---
 src/gl-renderer.c |   54 +
 src/pixman-renderer.c |   41 +
 2 files changed, 83 insertions(+), 12 deletions(-)

diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index d792530..c3c6ae9 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -83,6 +83,7 @@ struct gl_surface_state {
struct weston_surface *surface;
 
struct wl_listener surface_destroy_listener;
+   struct wl_listener renderer_destroy_listener;
 };
 
 struct gl_renderer {
@@ -130,6 +131,8 @@ struct gl_renderer {
struct gl_shader invert_color_shader;
struct gl_shader solid_shader;
struct gl_shader *current_shader;
+
+   struct wl_signal destroy_signal;
 };
 
 static inline struct gl_output_state *
@@ -1149,17 +1152,12 @@ gl_renderer_surface_set_color(struct weston_surface 
*surface,
 }
 
 static void
-surface_state_handle_surface_destroy(struct wl_listener *listener, void *data)
+surface_state_destroy(struct gl_surface_state *gs, struct gl_renderer *gr)
 {
-   struct gl_surface_state *gs;
-   struct gl_renderer *gr;
-   struct weston_surface *surface = data;
int i;
 
-   gr = get_renderer(surface-compositor);
-
-   gs = container_of(listener, struct gl_surface_state,
- surface_destroy_listener);
+   wl_list_remove(gs-surface_destroy_listener.link);
+   wl_list_remove(gs-renderer_destroy_listener.link);
 
gs-surface-renderer_state = NULL;
 
@@ -1173,10 +1171,39 @@ surface_state_handle_surface_destroy(struct wl_listener 
*listener, void *data)
free(gs);
 }
 
+static void
+surface_state_handle_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct gl_surface_state *gs;
+   struct gl_renderer *gr;
+
+   gs = container_of(listener, struct gl_surface_state,
+ surface_destroy_listener);
+
+   gr = get_renderer(gs-surface-compositor);
+
+   surface_state_destroy(gs, gr);
+}
+
+static void
+surface_state_handle_renderer_destroy(struct wl_listener *listener, void *data)
+{
+   struct gl_surface_state *gs;
+   struct gl_renderer *gr;
+
+   gr = data;
+
+   gs = container_of(listener, struct gl_surface_state,
+ renderer_destroy_listener);
+
+   surface_state_destroy(gs, gr);
+}
+
 static int
 gl_renderer_create_surface(struct weston_surface *surface)
 {
struct gl_surface_state *gs;
+   struct gl_renderer *gr = get_renderer(surface-compositor);
 
gs = calloc(1, sizeof *gs);
if (!gs)
@@ -1189,6 +1216,8 @@ gl_renderer_create_surface(struct weston_surface *surface)
gs-pitch = 1;
gs-y_inverted = 1;
 
+   gs-surface = surface;
+
pixman_region32_init(gs-texture_damage);
surface-renderer_state = gs;
 
@@ -1197,6 +1226,11 @@ gl_renderer_create_surface(struct weston_surface 
*surface)
wl_signal_add(surface-destroy_signal,
  gs-surface_destroy_listener);
 
+   gs-renderer_destroy_listener.notify =
+   surface_state_handle_renderer_destroy;
+   wl_signal_add(gr-destroy_signal,
+ gs-renderer_destroy_listener);
+
return 0;
 }
 
@@ -1579,6 +1613,8 @@ gl_renderer_destroy(struct weston_compositor *ec)
 {
struct gl_renderer *gr = get_renderer(ec);
 
+   wl_signal_emit(gr-destroy_signal, gr);
+
if (gr-has_bind_display)
gr-unbind_display(gr-egl_display, ec-wl_display);
 
@@ -1705,6 +1741,8 @@ gl_renderer_create(struct weston_compositor *ec, 
EGLNativeDisplayType display,
 
wl_display_add_shm_format(ec-wl_display, WL_SHM_FORMAT_RGB565);
 
+   wl_signal_init(gr-destroy_signal);
+
return 0;
 
 err_egl:
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 98a910c..79c1d5b 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -43,6 +43,7 @@ struct pixman_surface_state {
struct weston_buffer_reference buffer_ref;
 
struct wl_listener surface_destroy_listener;
+   struct wl_listener renderer_destroy_listener;
 };
 
 struct pixman_renderer {
@@ -51,6 +52,8 @@ struct pixman_renderer {
int repaint_debug;
pixman_image_t *debug_color;
struct weston_binding *debug_binding;
+
+   struct wl_signal destroy_signal;
 };
 
 static inline struct pixman_output_state *
@@ -593,12 +596,11 @@ pixman_renderer_attach(struct weston_surface *es, struct 

[PATCH 5/7] compositor-drm: Add option to start with pixman and switch to GL later

2013-10-25 Thread Ander Conselvan de Oliveira
Option --fast-start will cause the backend to start using the pixman
renderer and at the same time spawn a thread to do the loading of the
gl renderer and creation of the gbm device (which loads a dri driver).
Once that thread signal it is done, a runtime switch to the gl renderer
happens.
---
 man/weston-drm.man   |5 ++
 src/compositor-drm.c |  153 +++---
 src/compositor.c |1 +
 src/gl-renderer.c|6 ++
 4 files changed, 156 insertions(+), 9 deletions(-)

diff --git a/man/weston-drm.man b/man/weston-drm.man
index 35d62ae..035bace 100644
--- a/man/weston-drm.man
+++ b/man/weston-drm.man
@@ -106,6 +106,11 @@ instead of the default seat
 Launch Weston on tty
 .I x
 instead of using the current tty.
+.TP
+.B \-\-fast\-start
+Start using the pixman renderer and later switch to the GL one. This
+should cause the system to able to render earlier when running from
+cold boot and slow storage.
 .
 .\ ***
 .SH ENVIRONMENT
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index b929728..96065bd 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -51,6 +51,10 @@
 #include launcher-util.h
 #include vaapi-recorder.h
 
+#include pthread.h
+#include sys/types.h
+#include sys/socket.h
+
 #ifndef DRM_CAP_TIMESTAMP_MONOTONIC
 #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
 #endif
@@ -108,6 +112,10 @@ struct drm_compositor {
 
clockid_t clock;
struct udev_input input;
+
+   pthread_t gl_loader_thread;
+   struct wl_event_source *gl_loader_thread_ev_source;
+   int gl_loader_fd;
 };
 
 struct drm_mode {
@@ -199,6 +207,7 @@ struct drm_parameters {
int connector;
int tty;
int use_pixman;
+   int fast_start;
const char *seat_id;
 };
 
@@ -596,7 +605,8 @@ drm_output_repaint(struct weston_output *output_base,
return -1;
 
mode = container_of(output-base.current_mode, struct drm_mode, base);
-   if (!output-current) {
+   if (!output-current ||
+   output-current-stride != output-next-stride) {
ret = drmModeSetCrtc(compositor-drm.fd, output-crtc_id,
 output-next-fb_id, 0, 0,
 output-connector_id, 1,
@@ -1281,15 +1291,15 @@ init_drm(struct drm_compositor *ec, struct udev_device 
*device)
return 0;
 }
 
-static int
-init_egl(struct drm_compositor *ec)
+static struct gbm_device *
+create_gbm_device(int fd)
 {
-   EGLint format;
+   struct gbm_device *gbm;
 
gl_renderer = weston_load_module(gl-renderer.so,
 gl_renderer_interface);
if (!gl_renderer)
-   return -1;
+   return NULL;
 
/* GBM will load a dri driver, but even though they need symbols from
 * libglapi, in some version of Mesa they are not linked to it. Since
@@ -1298,14 +1308,34 @@ init_egl(struct drm_compositor *ec)
 * Workaround this by dlopen()'ing libglapi with RTLD_GLOBAL. */
dlopen(libglapi.so.0, RTLD_LAZY | RTLD_GLOBAL);
 
-   ec-gbm = gbm_create_device(ec-drm.fd);
+   gbm = gbm_create_device(fd);
 
-   if (!ec-gbm)
-   return -1;
+   return gbm;
+}
+
+static int
+drm_compositor_create_gl_renderer(struct drm_compositor *ec)
+{
+   EGLint format;
 
format = ec-format;
if (gl_renderer-create(ec-base, ec-gbm,
   gl_renderer-opaque_attribs, format)  0) {
+   return -1;
+   }
+
+   return 0;
+}
+
+static int
+init_egl(struct drm_compositor *ec)
+{
+   ec-gbm = create_gbm_device(ec-drm.fd);
+
+   if (!ec-gbm)
+   return -1;
+
+   if (drm_compositor_create_gl_renderer(ec)  0) {
gbm_device_destroy(ec-gbm);
return -1;
}
@@ -2580,6 +2610,107 @@ recorder_binding(struct weston_seat *seat, uint32_t 
time, uint32_t key,
 }
 #endif
 
+static void
+switch_to_gl_renderer(struct drm_compositor *c)
+{
+   struct drm_output *output;
+
+   if (!c-use_pixman)
+   return;
+
+   weston_log(Switching to GL renderer\n);
+
+   wl_list_for_each(output, c-base.output_list, base.link)
+   pixman_renderer_output_destroy(output-base);
+
+   c-base.renderer-destroy(c-base);
+
+   if (drm_compositor_create_gl_renderer(c)  0) {
+   gbm_device_destroy(c-gbm);
+   weston_log(Failed to create GL renderer. Quitting.\n);
+   /* FIXME: we need a function to shutdown cleanly */
+   assert(0);
+   }
+
+   wl_list_for_each(output, c-base.output_list, base.link)
+   drm_output_init_egl(output, c);
+
+   c-use_pixman = 0;
+}
+
+struct gl_loader_thread_data {
+   int drm_fd;
+   int done_fd;
+};
+
+static void *
+gl_loader_thread_func(void *data)
+{
+   struct gl_loader_thread_data 

[PATCH 6/7] gl-renderer: Attach buffer during surface state creation if possible

2013-10-25 Thread Ander Conselvan de Oliveira
When a renderer switch happen, it is possible that when the surface
state is created, a buffer for the given surface is already available.
In that case, run the attach routine so that the pixel contents are
properly set before a new attach request is made for that surface.

Also, make sure the DRM backend keeps the buffers around until it
switches from pixman to GL.

This makes the renderer transition seamless, without leaving a black
screen as before.
---
 src/compositor-drm.c |   26 --
 src/gl-renderer.c|8 +++-
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 96065bd..5130278 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -107,6 +107,7 @@ struct drm_compositor {
int cursors_are_broken;
 
int use_pixman;
+   int renderer_switch_pending;
 
uint32_t prev_state;
 
@@ -1060,18 +1061,20 @@ drm_assign_planes(struct weston_output *output)
pixman_region32_init(overlap);
primary = c-base.primary_plane;
 
-   /* Flag all visible surfaces as keep_buffer = 1 */
-   wl_list_for_each(ev, c-base.view_list, link)
-   ev-surface-keep_buffer = 1;
-
wl_list_for_each_safe(ev, next, c-base.view_list, link) {
-   /* test whether this buffer can ever go into a plane:
-* non-shm, or small enough to be a cursor
+   struct weston_surface *es = ev-surface;
+
+   /* Test whether this buffer can ever go into a plane:
+* non-shm, or small enough to be a cursor. Also keep
+* the buffer around if we plan to switch renderers.
 */
-   if (!ev-surface-buffer_ref.buffer ||
-   
(wl_shm_buffer_get(ev-surface-buffer_ref.buffer-resource) 
-   (ev-geometry.width  64 || ev-geometry.height  64)))
-   ev-surface-keep_buffer = 0;
+   if ((es-buffer_ref.buffer 
+   (!wl_shm_buffer_get(es-buffer_ref.buffer-resource) ||
+(ev-geometry.width = 64  ev-geometry.height = 64) ||
+c-renderer_switch_pending)))
+   es-keep_buffer = 1;
+   else
+   es-keep_buffer = 0;
 
pixman_region32_init(surface_overlap);
pixman_region32_intersect(surface_overlap, overlap,
@@ -2636,6 +2639,7 @@ switch_to_gl_renderer(struct drm_compositor *c)
drm_output_init_egl(output, c);
 
c-use_pixman = 0;
+   c-renderer_switch_pending = 0;
 }
 
 struct gl_loader_thread_data {
@@ -2708,6 +2712,8 @@ prepare_renderer_switch(struct drm_compositor *ec)
 gl_loader_thread_done, ec);
ec-gl_loader_fd = sv[0];
 
+   ec-renderer_switch_pending = 1;
+
return 0;
 }
 
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 06815b4..e1f9841 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -886,7 +886,8 @@ gl_renderer_flush_damage(struct weston_surface *surface)
if (!texture_used)
return;
 
-   if (!pixman_region32_not_empty(gs-texture_damage))
+   if (!pixman_region32_not_empty(gs-texture_damage) 
+   !gs-needs_full_upload)
goto done;
 
switch (wl_shm_buffer_get_format(buffer-shm_buffer)) {
@@ -1237,6 +1238,11 @@ gl_renderer_create_surface(struct weston_surface 
*surface)
wl_signal_add(gr-destroy_signal,
  gs-renderer_destroy_listener);
 
+   if (surface-buffer_ref.buffer) {
+   gl_renderer_attach(surface, surface-buffer_ref.buffer);
+   gl_renderer_flush_damage(surface);
+   }
+
return 0;
 }
 
-- 
1.7.9.5

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH mesa v4] wayland: Add support for eglSwapInterval

2013-10-25 Thread Neil Roberts
Ok, here is version 4 of the patch taking into account the discussion
with Jason Ekstrand. The assumption is that if we have enough buffer
slots then we should always get a release event immediately after one
of the attaches. That means we can just rely on sending a sync request
after the commit in order to get a buffer release and we don't need to
bother with the request to disable the queuing mechanism.

The previous version of the patch would block in a loop calling
wl_dispatch_queue if it couldn't find a buffer. This is only a
sensible option if we know that the compositor isn't queueing the
release events. If not this loop would just block indefinitely. If the
theory about getting release events is correct then we should never
actually hit this loop so it probably doesn't really matter what it
does. However, I didn't like the idea of having a loop there that
would just block forever so I changed it to poll the compositor with a
sync request every 10ms in order to force it to flush the queue. It
prints a warning if this case is hit so that we will know there is a
problem.

I made the change to make it use 4 buffer slots in this patch and
tested that it does use exactly all 4 of them when the application is
fullscreen. This does work and it doesn't hit the polling path. I
guess we could change to be five in order to cope with the subsurface
case but I'm a bit reluctant to do that because it seems like quite a
corner case and maybe it's better to just let it hit the warning path
in that case.

In the previous versions of the patch it would only do a sync request
if the swap interval is zero. In this version I've changed it so that
it always installs it. This is necessary because if an application is
doing swap interval 1 but isn't installing a frame callback it would
end up rendering and calling get_back_bo before we've handled any data
from the compositor and it would use a redundant third buffer.

Regards,
- Neil

--- 8 --- (use git am --scissors to automatically chop here)

The Wayland EGL platform now respects the eglSwapInterval value. The value is
clamped to either 0 or 1 because it is difficult (and probably not useful) to
sync to more than 1 redraw.

The main change is that if the swap interval is 0 then Mesa won't install a
frame callback so that eglSwapBuffers can be executed as often as necessary.
However it now always does a sync request after the swap buffers and blocks
until this is complete in get_back_bo. The compositor is likely to send a
release event while processing the new buffer attach and this makes sure we
will receive that before deciding whether to allocate a new buffer. This is
done even if the application is using swap interval 1 because otherwise if the
application is not installing its own frame callback it may end up calling
get_back_bo before we've handled any data from the compositor and it would end
up using a redundant extra buffer.

If there are no buffers available then instead of returning with an error,
get_back_bo will now poll the compositor by repeatedly sending sync requests
every 10ms. This is a last resort and in theory this shouldn't happen because
there should be no reason for the compositor to hold on to more than three
buffers. That means whenever we attach the fourth buffer we should always get
an immediate release event which should come in with the notification for the
first sync request that we are throttled to.

When the compositor is directly scanning out from the application's buffer it
may end up holding on to three buffers. These are the one that is is currently
scanning out from, one that has been given to DRM as the next buffer to flip
to, and one that has been attached and will be given to DRM as soon as the
previous flip completes. When we attach a fourth buffer to the compositor it
should replace that third buffer so we should get a release event immediately
after that. This patch therefore also changes the number of buffer slots to 4
so that we can accomodate that situation.

If DRM eventually gets a way to cancel a pending page flip then the compositors
can be changed to only need to hold on to two buffers and this value can be
put back to 3.

This also moves the vblank configuration defines from platform_x11.c to the
common egl_dri2.h header so they can be shared by both platforms.
---
 src/egl/drivers/dri2/egl_dri2.h |   9 +-
 src/egl/drivers/dri2/platform_wayland.c | 204 +---
 src/egl/drivers/dri2/platform_x11.c |   6 -
 3 files changed, 193 insertions(+), 26 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 7a2e098..7de5916 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -174,6 +174,7 @@ struct dri2_egl_surface
intdx;
intdy;
struct wl_callback*frame_callback;
+   struct wl_callback*sync_callback;
int   format;
 

Re: [PATCH 3/7] compositor: Let renderers create and destroy surface state on their own

2013-10-25 Thread Jason Ekstrand
Ander,
When I was working on views, I really wanted to get rid of the
create_surface functions too... Thanks.  That said, you should probably
also get rid of create_view (It's only used by rpi).
--Jason Ekstrand


On Fri, Oct 25, 2013 at 8:26 AM, Ander Conselvan de Oliveira 
ander.conselvan.de.olive...@intel.com wrote:

 Remove create_surface() and destroy_surface() from the renderer
 interface and change the renderers to create surface state on demand
 and destroy it using the weston_surface's destroy signal.

 Also make sure the surfaces' renderer state is reset to NULL on
 destruction.

 This is a step towards runtime switchable renderers.

 (rpi-renderer changes are only compile-tested)
 ---
  src/compositor.c  |8 ---
  src/compositor.h  |2 --
  src/gl-renderer.c |   61
 ++---
  src/noop-renderer.c   |   13 ---
  src/pixman-renderer.c |   50 
  src/rpi-renderer.c|   54 ---
  6 files changed, 112 insertions(+), 76 deletions(-)

 diff --git a/src/compositor.c b/src/compositor.c
 index 2ed6b1e..563bade 100644
 --- a/src/compositor.c
 +++ b/src/compositor.c
 @@ -407,11 +407,6 @@ weston_surface_create(struct weston_compositor
 *compositor)
 surface-compositor = compositor;
 surface-ref_count = 1;

 -   if (compositor-renderer-create_surface(surface)  0) {
 -   free(surface);
 -   return NULL;
 -   }
 -
 surface-buffer_transform = WL_OUTPUT_TRANSFORM_NORMAL;
 surface-buffer_scale = 1;
 surface-pending.buffer_transform = surface-buffer_transform;
 @@ -1220,7 +1215,6 @@ weston_view_destroy(struct weston_view *view)
  WL_EXPORT void
  weston_surface_destroy(struct weston_surface *surface)
  {
 -   struct weston_compositor *compositor = surface-compositor;
 struct weston_frame_callback *cb, *next;
 struct weston_view *ev, *nv;

 @@ -1248,8 +1242,6 @@ weston_surface_destroy(struct weston_surface
 *surface)

 weston_buffer_reference(surface-buffer_ref, NULL);

 -   compositor-renderer-destroy_surface(surface);
 -
 pixman_region32_fini(surface-damage);
 pixman_region32_fini(surface-opaque);
 pixman_region32_fini(surface-input);
 diff --git a/src/compositor.h b/src/compositor.h
 index 73722b5..e60a512 100644
 --- a/src/compositor.h
 +++ b/src/compositor.h
 @@ -521,12 +521,10 @@ struct weston_renderer {
pixman_region32_t *output_damage);
 void (*flush_damage)(struct weston_surface *surface);
 void (*attach)(struct weston_surface *es, struct weston_buffer
 *buffer);
 -   int (*create_surface)(struct weston_surface *surface);
 int (*create_view)(struct weston_view *view);
 void (*surface_set_color)(struct weston_surface *surface,
float red, float green,
float blue, float alpha);
 -   void (*destroy_surface)(struct weston_surface *surface);
 void (*destroy_view)(struct weston_view *view);
 void (*destroy)(struct weston_compositor *ec);
  };
 diff --git a/src/gl-renderer.c b/src/gl-renderer.c
 index 0f0b5f7..d792530 100644
 --- a/src/gl-renderer.c
 +++ b/src/gl-renderer.c
 @@ -79,6 +79,10 @@ struct gl_surface_state {
 int pitch; /* in pixels */
 int height; /* in pixels */
 int y_inverted;
 +
 +   struct weston_surface *surface;
 +
 +   struct wl_listener surface_destroy_listener;
  };

  struct gl_renderer {
 @@ -134,9 +138,15 @@ get_output_state(struct weston_output *output)
 return (struct gl_output_state *)output-renderer_state;
  }

 +static int
 +gl_renderer_create_surface(struct weston_surface *surface);
 +
  static inline struct gl_surface_state *
  get_surface_state(struct weston_surface *surface)
  {
 +   if (!surface-renderer_state)
 +   gl_renderer_create_surface(surface);
 +
 return (struct gl_surface_state *)surface-renderer_state;
  }

 @@ -997,6 +1007,8 @@ gl_renderer_attach_shm(struct weston_surface *es,
 struct weston_buffer *buffer,
 gs-needs_full_upload = 1;
 gs-y_inverted = 1;

 +   gs-surface = surface;
 +
 ensure_textures(gs, 1);
 glBindTexture(GL_TEXTURE_2D, gs-textures[0]);
 glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
 @@ -1136,6 +1148,31 @@ gl_renderer_surface_set_color(struct weston_surface
 *surface,
 gs-shader = gr-solid_shader;
  }

 +static void
 +surface_state_handle_surface_destroy(struct wl_listener *listener, void
 *data)
 +{
 +   struct gl_surface_state *gs;
 +   struct gl_renderer *gr;
 +   struct weston_surface *surface = data;
 +   int i;
 +
 +   gr = get_renderer(surface-compositor);
 +
 +   gs = container_of(listener, struct gl_surface_state,
 +

Re: [PATCH v2 wayland] protocol: validate the protocol against a dtd

2013-10-25 Thread Kristian Høgsberg
On Wed, Oct 23, 2013 at 02:56:04PM +1000, Peter Hutterer wrote:
 The scanner is not very forgiving if the protocol doesn't match it's
 expectations and crashes without much of a notice. Thus, validate the protocol
 against a DTD.
 
 Move the protocol subdir forward so we validate first before trying anything
 else, and install the DTD so we can validate weston's protocols as well.
 ---
 First time this didn't get any reactions.
 Changes to v1:
 - create .xml.valid files to only run xmllint when needed
 - rebased to master

Sorry, was busy with the 1.3 release the first time you sent these
out.  Having a DTD is good and I'm fine with xmllint, but I'd like to
also fix any crashes we hit in the scanner.

Both patches applied, thanks.
Kristian

  Makefile.am  |  2 +-
  configure.ac |  3 +++
  protocol/Makefile.am | 15 ++-
  protocol/wayland.dtd | 29 +
  4 files changed, 47 insertions(+), 2 deletions(-)
  create mode 100644 protocol/wayland.dtd
 
 diff --git a/Makefile.am b/Makefile.am
 index ddf39d1..99607b0 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -2,7 +2,7 @@ if BUILD_DOCS
  doc_subdir = doc
  endif
  
 -SUBDIRS = src protocol $(doc_subdir) tests cursor
 +SUBDIRS = protocol src $(doc_subdir) tests cursor
  
  ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
  
 diff --git a/configure.ac b/configure.ac
 index fa924ae..7b3787f 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -87,6 +87,9 @@ fi
  AC_PATH_PROG(XSLTPROC, xsltproc)
  AM_CONDITIONAL([HAVE_XSLTPROC], [test x$XSLTPROC != x])
  
 +AC_PATH_PROG(XMLLINT, xmllint)
 +AM_CONDITIONAL([HAVE_XMLLINT], [test x$XMLLINT != x])
 +
  AC_MSG_CHECKING([for docbook manpages stylesheet])
  
 MANPAGES_STYLESHEET=http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
  AC_PATH_PROGS_FEATURE_CHECK([XSLTPROC_TMP], [xsltproc],
 diff --git a/protocol/Makefile.am b/protocol/Makefile.am
 index cc9cd1c..e8b6290 100644
 --- a/protocol/Makefile.am
 +++ b/protocol/Makefile.am
 @@ -1 +1,14 @@
 -dist_pkgdata_DATA = wayland.xml
 +dist_pkgdata_DATA = wayland.xml wayland.dtd
 +
 +if HAVE_XMLLINT
 +.PHONY: validate
 +
 +.%.xml.valid: %.xml
 + $(AM_V_GEN)$(XMLLINT) --noout --dtdvalid $(srcdir)/wayland.dtd $^  $@
 +
 +validate: .wayland.xml.valid
 +
 +all-local: validate
 +
 +CLEANFILES = .wayland.xml.valid
 +endif
 diff --git a/protocol/wayland.dtd b/protocol/wayland.dtd
 new file mode 100644
 index 000..b8b1573
 --- /dev/null
 +++ b/protocol/wayland.dtd
 @@ -0,0 +1,29 @@
 +!ELEMENT protocol (copyright?, interface+)
 +  !ATTLIST protocol name CDATA #REQUIRED
 +!ELEMENT copyright (#PCDATA)
 +!ELEMENT interface (description?,(request|event|enum)+)
 +  !ATTLIST interface name CDATA #REQUIRED
 +  !ATTLIST interface version CDATA #REQUIRED
 +!ELEMENT request (description?,arg*)
 +  !ATTLIST request name CDATA #REQUIRED
 +  !ATTLIST request type CDATA #IMPLIED
 +  !ATTLIST request since CDATA #IMPLIED
 +!ELEMENT event (description?,arg*)
 +  !ATTLIST event name CDATA #REQUIRED
 +  !ATTLIST event since CDATA #IMPLIED
 +!ELEMENT enum (description?,entry*)
 +  !ATTLIST enum name CDATA #REQUIRED
 +  !ATTLIST enum since CDATA #IMPLIED
 +!ELEMENT entry (description?)
 +  !ATTLIST entry name CDATA #REQUIRED
 +  !ATTLIST entry value CDATA #REQUIRED
 +  !ATTLIST entry summary CDATA #IMPLIED
 +  !ATTLIST entry since CDATA #IMPLIED
 +!ELEMENT arg (description?)
 +  !ATTLIST arg name CDATA #REQUIRED
 +  !ATTLIST arg type CDATA #REQUIRED
 +  !ATTLIST arg summary CDATA #IMPLIED
 +  !ATTLIST arg interface CDATA #IMPLIED
 +  !ATTLIST arg allow-null CDATA #IMPLIED
 +!ELEMENT description (#PCDATA)
 +  !ATTLIST description summary CDATA #REQUIRED
 -- 
 1.8.3.1
 
 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [RFC wayland v2] Add libwayland-glib for GLib main loop integration

2013-10-25 Thread Kristian Høgsberg
On Wed, Oct 23, 2013 at 02:10:26PM +0200, Quentin Glidic wrote:
 From: Quentin Glidic sardemff7+...@sardemff7.net
 
 Signed-off-by: Quentin Glidic sardemff7+...@sardemff7.net
 ---
 
 Here is a new version of my GLib main loop integration for Wayland.
 Now everything is in libwayland-client (I didn’t work on the server
 side) and package detection can be done using the pkg-config file
 or the header if needed.

I'm not convinced we need a separate glib shared library for this.
It's only 150 lines of code and gtk+ already has integration code for
this.  Further, any glib use of wayland that isn't also a gtk+ user
seems very niche, so I don't expect a lot of user of this library.

Kristian

  configure.ac  |  22 -
  src/Makefile.am   |  17 
  src/wayland-client-glib.c | 182 
 ++
  src/wayland-client-glib.h |  46 +++
  src/wayland-client-glib.pc.in |   9 +++
  5 files changed, 275 insertions(+), 1 deletion(-)
  create mode 100644 src/wayland-client-glib.c
  create mode 100644 src/wayland-client-glib.h
  create mode 100644 src/wayland-client-glib.pc.in
 
 diff --git a/configure.ac b/configure.ac
 index fa924ae..ca50c65 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -50,7 +50,7 @@ AC_CHECK_DECL(TFD_CLOEXEC,[],
  AC_CHECK_DECL(CLOCK_MONOTONIC,[],
 [AC_MSG_ERROR(CLOCK_MONOTONIC is needed to compile wayland)],
 [[#include time.h]])
 -AC_CHECK_HEADERS([execinfo.h])
 +AC_CHECK_HEADERS([execinfo.h errno.h])
  
  AC_ARG_ENABLE([scanner],
[AC_HELP_STRING([--disable-scanner],
 @@ -126,6 +126,25 @@ if test x$enable_documentation = xyes; then
  fi
  AM_CONDITIONAL([HAVE_PUBLICAN], [test x$PUBLICAN != x])
  
 +
 +# GLib main loop integration library
 +
 +glib_min_major=2
 +glib_min_minor=36
 +glib_min_version=${glib_min_major}.${glib_min_minor}
 +
 +AC_ARG_ENABLE([glib],
 +  [AC_HELP_STRING([--enable-glib],
 +  [Enable GLib main loop integration library])],
 +  [],
 +  [enable_glib=no])
 +if test x$enable_glib = xyes; then
 + PKG_CHECK_MODULES(GLIB, [glib-2.0 = $glib_min_version])
 + AC_DEFINE_UNQUOTED([GLIB_VERSION_MIN_REQUIRED], 
 [(G_ENCODE_VERSION(${glib_min_major},${glib_min_minor}))], [The lower GLib 
 version supported])
 +fi
 +AM_CONDITIONAL([ENABLE_GLIB], [test x$enable_glib = xyes])
 +
 +
  AC_CONFIG_FILES([Makefile
cursor/Makefile
cursor/wayland-cursor.pc
 @@ -140,6 +159,7 @@ AC_CONFIG_FILES([Makefile
src/wayland-scanner-uninstalled.pc
src/wayland-server.pc
src/wayland-client.pc
 +  src/wayland-client-glib.pc
src/wayland-scanner.pc
src/wayland-version.h
protocol/Makefile
 diff --git a/src/Makefile.am b/src/Makefile.am
 index 4226f63..9026e5a 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -28,6 +28,8 @@ libwayland_server_la_SOURCES =  \
  
  libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-util.la -lrt -lm
  libwayland_client_la_LDFLAGS = -version-info 1:0:1
 +libwayland_client_la_CFLAGS = $(AM_CFLAGS)
 +libwayland_client_la_CPPFLAGS = $(AM_CPPFLAGS)
  libwayland_client_la_SOURCES =   \
   wayland-protocol.c  \
   wayland-client.c
 @@ -35,6 +37,21 @@ libwayland_client_la_SOURCES = \
  pkgconfigdir = $(libdir)/pkgconfig
  pkgconfig_DATA = wayland-client.pc wayland-server.pc
  
 +if ENABLE_GLIB
 +pkgconfig_DATA += wayland-client-glib.pc
 +
 +include_HEADERS +=   \
 + wayland-client-glib.h
 +
 +libwayland_client_la_SOURCES += \
 + wayland-client-glib.h   \
 + wayland-client-glib.c
 +
 +libwayland_client_la_CPPFLAGS += -DG_LOG_DOMAIN=\GWayland\
 +libwayland_client_la_CFLAGS += $(GLIB_CFLAGS)
 +libwayland_client_la_LIBADD += $(GLIB_LIBS)
 +endif
 +
  AM_CPPFLAGS = $(FFI_CFLAGS)
  AM_CFLAGS = $(GCC_CFLAGS)
  
 diff --git a/src/wayland-client-glib.c b/src/wayland-client-glib.c
 new file mode 100644
 index 000..1577abb
 --- /dev/null
 +++ b/src/wayland-client-glib.c
 @@ -0,0 +1,182 @@
 +/*
 + * wayland-client-glib - Wayland integration to GLib main loop
 + *
 + * Copyright © 2012-2013 Quentin Sardem FF7 Glidic
 + *
 + * Permission to use, copy, modify, distribute, and sell this software and 
 its
 + * documentation for any purpose is hereby granted without fee, provided that
 + * the above copyright notice appear in all copies and that both that 
 copyright
 + * notice and this permission notice appear in supporting documentation, and
 + * that the name of the copyright holders not be used in advertising or
 + * publicity pertaining to distribution of the software without specific,
 + * written prior permission.  The copyright holders make no representations
 + * about the suitability of this software for any purpose.  It is provided 
 as
 + * is without 

Re: Misc. fixes for the rpi backend

2013-10-25 Thread Kristian Høgsberg
On Thu, Oct 24, 2013 at 03:38:28PM +0200, Tomeu Vizoso wrote:
 Except for the first one, all are intended to fix the RPi backend after
 the landing of the views work.
 
 Most EGL clients won't work yet because of wl_buffer.release events being
 always queued, though.

Thanks for fixing it up, all applied.

Kristian
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 1/2] rpi: Remove dangling reference to weston_view

2013-10-25 Thread Kristian Høgsberg
On Fri, Oct 25, 2013 at 10:34:37AM +0200, Tomeu Vizoso wrote:
 This also marks the rpir_view for destroy in rpi_renderer_finish_frame()
 ---
  src/rpi-renderer.c | 2 ++
  1 file changed, 2 insertions(+)

These two applied, thanks.

Kristian

 diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
 index 812e6e7..7f79410 100644
 --- a/src/rpi-renderer.c
 +++ b/src/rpi-renderer.c
 @@ -1501,6 +1501,8 @@ rpi_renderer_destroy_view(struct weston_view *base)
   if (!view)
   return;
  
 + view-view = NULL;
 +
   /* If guaranteed to not be on screen, just detroy it. */
   if (wl_list_empty(view-link))
   rpir_view_destroy(view);
 -- 
 1.8.3.1
 
 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] configure.ac: Check the version of libxkb = 0.3.0

2013-10-25 Thread Brian Lovin
When we would build weston with libxkb 0.2.0 it would succesfully
compile, but the keybaord and desktop-shell wouldn't load, and
Weston wouldn't run.

Signed-off-by: Brian Lovin brian.j.lo...@intel.com
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 80a5d69..c695f7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,7 +75,7 @@ AC_ARG_ENABLE(xkbcommon,
  enable_xkbcommon=yes)
 if test x$enable_xkbcommon = xyes; then
AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon 
support])
-   COMPOSITOR_MODULES=$COMPOSITOR_MODULES xkbcommon
+   COMPOSITOR_MODULES=$COMPOSITOR_MODULES xkbcommon = 0.3.0
 fi
 
 AC_ARG_ENABLE(setuid-install, [  --enable-setuid-install],,
-- 
1.8.1.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 3/7] compositor: Let renderers create and destroy surface state on their own

2013-10-25 Thread Kristian Høgsberg
On Fri, Oct 25, 2013 at 04:26:33PM +0300, Ander Conselvan de Oliveira wrote:
 Remove create_surface() and destroy_surface() from the renderer
 interface and change the renderers to create surface state on demand
 and destroy it using the weston_surface's destroy signal.
 
 Also make sure the surfaces' renderer state is reset to NULL on
 destruction.
 
 This is a step towards runtime switchable renderers.
 
 (rpi-renderer changes are only compile-tested)
 ---
  src/compositor.c  |8 ---
  src/compositor.h  |2 --
  src/gl-renderer.c |   61 
 ++---
  src/noop-renderer.c   |   13 ---
  src/pixman-renderer.c |   50 
  src/rpi-renderer.c|   54 ---
  6 files changed, 112 insertions(+), 76 deletions(-)
 
 diff --git a/src/compositor.c b/src/compositor.c
 index 2ed6b1e..563bade 100644
 --- a/src/compositor.c
 +++ b/src/compositor.c
 @@ -407,11 +407,6 @@ weston_surface_create(struct weston_compositor 
 *compositor)
   surface-compositor = compositor;
   surface-ref_count = 1;
  
 - if (compositor-renderer-create_surface(surface)  0) {
 - free(surface);
 - return NULL;
 - }
 -
   surface-buffer_transform = WL_OUTPUT_TRANSFORM_NORMAL;
   surface-buffer_scale = 1;
   surface-pending.buffer_transform = surface-buffer_transform;
 @@ -1220,7 +1215,6 @@ weston_view_destroy(struct weston_view *view)
  WL_EXPORT void
  weston_surface_destroy(struct weston_surface *surface)
  {
 - struct weston_compositor *compositor = surface-compositor;
   struct weston_frame_callback *cb, *next;
   struct weston_view *ev, *nv;
  
 @@ -1248,8 +1242,6 @@ weston_surface_destroy(struct weston_surface *surface)
  
   weston_buffer_reference(surface-buffer_ref, NULL);
  
 - compositor-renderer-destroy_surface(surface);
 -
   pixman_region32_fini(surface-damage);
   pixman_region32_fini(surface-opaque);
   pixman_region32_fini(surface-input);
 diff --git a/src/compositor.h b/src/compositor.h
 index 73722b5..e60a512 100644
 --- a/src/compositor.h
 +++ b/src/compositor.h
 @@ -521,12 +521,10 @@ struct weston_renderer {
  pixman_region32_t *output_damage);
   void (*flush_damage)(struct weston_surface *surface);
   void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
 - int (*create_surface)(struct weston_surface *surface);
   int (*create_view)(struct weston_view *view);
   void (*surface_set_color)(struct weston_surface *surface,
  float red, float green,
  float blue, float alpha);
 - void (*destroy_surface)(struct weston_surface *surface);
   void (*destroy_view)(struct weston_view *view);
   void (*destroy)(struct weston_compositor *ec);
  };
 diff --git a/src/gl-renderer.c b/src/gl-renderer.c
 index 0f0b5f7..d792530 100644
 --- a/src/gl-renderer.c
 +++ b/src/gl-renderer.c
 @@ -79,6 +79,10 @@ struct gl_surface_state {
   int pitch; /* in pixels */
   int height; /* in pixels */
   int y_inverted;
 +
 + struct weston_surface *surface;
 +
 + struct wl_listener surface_destroy_listener;
  };
  
  struct gl_renderer {
 @@ -134,9 +138,15 @@ get_output_state(struct weston_output *output)
   return (struct gl_output_state *)output-renderer_state;
  }
  
 +static int
 +gl_renderer_create_surface(struct weston_surface *surface);
 +
  static inline struct gl_surface_state *
  get_surface_state(struct weston_surface *surface)
  {
 + if (!surface-renderer_state)
 + gl_renderer_create_surface(surface);
 +
   return (struct gl_surface_state *)surface-renderer_state;
  }
  
 @@ -997,6 +1007,8 @@ gl_renderer_attach_shm(struct weston_surface *es, struct 
 weston_buffer *buffer,
   gs-needs_full_upload = 1;
   gs-y_inverted = 1;
  
 + gs-surface = surface;
 +

I had to change this to gs-surface = es to make it compile, but other
than that it looks good.

   ensure_textures(gs, 1);
   glBindTexture(GL_TEXTURE_2D, gs-textures[0]);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
 @@ -1136,6 +1148,31 @@ gl_renderer_surface_set_color(struct weston_surface 
 *surface,
   gs-shader = gr-solid_shader;
  }
  
 +static void
 +surface_state_handle_surface_destroy(struct wl_listener *listener, void 
 *data)
 +{
 + struct gl_surface_state *gs;
 + struct gl_renderer *gr;
 + struct weston_surface *surface = data;
 + int i;
 +
 + gr = get_renderer(surface-compositor);
 +
 + gs = container_of(listener, struct gl_surface_state,
 +   surface_destroy_listener);
 +
 + gs-surface-renderer_state = NULL;
 +
 + glDeleteTextures(gs-num_textures, gs-textures);
 +
 + for (i = 0; i  gs-num_images; i++)
 + 

Re: [RFC wayland v2] Add libwayland-glib for GLib main loop integration

2013-10-25 Thread Quentin Glidic

On 25/10/2013 20:01, Kristian Høgsberg wrote:

On Wed, Oct 23, 2013 at 02:10:26PM +0200, Quentin Glidic wrote:

From: Quentin Glidic sardemff7+...@sardemff7.net

Signed-off-by: Quentin Glidic sardemff7+...@sardemff7.net
---

Here is a new version of my GLib main loop integration for Wayland.
Now everything is in libwayland-client (I didn’t work on the server
side) and package detection can be done using the pkg-config file
or the header if needed.


I'm not convinced we need a separate glib shared library for this.
It's only 150 lines of code and gtk+ already has integration code for
this.  Further, any glib use of wayland that isn't also a gtk+ user
seems very niche, so I don't expect a lot of user of this library.

Kristian


This is why this v2 is just the GSource included directly in 
libwayland-client (I forgot to change the commit message).


The idea is inspired by PulseAudio, which has a few main loop helpers 
shipped with libpulse (GLib integration, simple and threaded loops).


I would understand if you do not want to include this code in 
libwayland-client though, but I am willing to maintain it if you decide 
to do so.


Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH 3/7] compositor: Let renderers create and destroy surface state on their own

2013-10-25 Thread Kristian Høgsberg
On Fri, Oct 25, 2013 at 10:27:08AM -0500, Jason Ekstrand wrote:
 Ander,
 When I was working on views, I really wanted to get rid of the
 create_surface functions too... Thanks.  That said, you should probably
 also get rid of create_view (It's only used by rpi).
 --Jason Ekstrand

Yeah, I agree, this patch is a nice simplification in itself.  Maybe
Tomeu could take a look at the rpi renderer and see if we can drop
create_view patch?

Kristian

 On Fri, Oct 25, 2013 at 8:26 AM, Ander Conselvan de Oliveira 
 ander.conselvan.de.olive...@intel.com wrote:
 
  Remove create_surface() and destroy_surface() from the renderer
  interface and change the renderers to create surface state on demand
  and destroy it using the weston_surface's destroy signal.
 
  Also make sure the surfaces' renderer state is reset to NULL on
  destruction.
 
  This is a step towards runtime switchable renderers.
 
  (rpi-renderer changes are only compile-tested)
  ---
   src/compositor.c  |8 ---
   src/compositor.h  |2 --
   src/gl-renderer.c |   61
  ++---
   src/noop-renderer.c   |   13 ---
   src/pixman-renderer.c |   50 
   src/rpi-renderer.c|   54 ---
   6 files changed, 112 insertions(+), 76 deletions(-)
 
  diff --git a/src/compositor.c b/src/compositor.c
  index 2ed6b1e..563bade 100644
  --- a/src/compositor.c
  +++ b/src/compositor.c
  @@ -407,11 +407,6 @@ weston_surface_create(struct weston_compositor
  *compositor)
  surface-compositor = compositor;
  surface-ref_count = 1;
 
  -   if (compositor-renderer-create_surface(surface)  0) {
  -   free(surface);
  -   return NULL;
  -   }
  -
  surface-buffer_transform = WL_OUTPUT_TRANSFORM_NORMAL;
  surface-buffer_scale = 1;
  surface-pending.buffer_transform = surface-buffer_transform;
  @@ -1220,7 +1215,6 @@ weston_view_destroy(struct weston_view *view)
   WL_EXPORT void
   weston_surface_destroy(struct weston_surface *surface)
   {
  -   struct weston_compositor *compositor = surface-compositor;
  struct weston_frame_callback *cb, *next;
  struct weston_view *ev, *nv;
 
  @@ -1248,8 +1242,6 @@ weston_surface_destroy(struct weston_surface
  *surface)
 
  weston_buffer_reference(surface-buffer_ref, NULL);
 
  -   compositor-renderer-destroy_surface(surface);
  -
  pixman_region32_fini(surface-damage);
  pixman_region32_fini(surface-opaque);
  pixman_region32_fini(surface-input);
  diff --git a/src/compositor.h b/src/compositor.h
  index 73722b5..e60a512 100644
  --- a/src/compositor.h
  +++ b/src/compositor.h
  @@ -521,12 +521,10 @@ struct weston_renderer {
 pixman_region32_t *output_damage);
  void (*flush_damage)(struct weston_surface *surface);
  void (*attach)(struct weston_surface *es, struct weston_buffer
  *buffer);
  -   int (*create_surface)(struct weston_surface *surface);
  int (*create_view)(struct weston_view *view);
  void (*surface_set_color)(struct weston_surface *surface,
 float red, float green,
 float blue, float alpha);
  -   void (*destroy_surface)(struct weston_surface *surface);
  void (*destroy_view)(struct weston_view *view);
  void (*destroy)(struct weston_compositor *ec);
   };
  diff --git a/src/gl-renderer.c b/src/gl-renderer.c
  index 0f0b5f7..d792530 100644
  --- a/src/gl-renderer.c
  +++ b/src/gl-renderer.c
  @@ -79,6 +79,10 @@ struct gl_surface_state {
  int pitch; /* in pixels */
  int height; /* in pixels */
  int y_inverted;
  +
  +   struct weston_surface *surface;
  +
  +   struct wl_listener surface_destroy_listener;
   };
 
   struct gl_renderer {
  @@ -134,9 +138,15 @@ get_output_state(struct weston_output *output)
  return (struct gl_output_state *)output-renderer_state;
   }
 
  +static int
  +gl_renderer_create_surface(struct weston_surface *surface);
  +
   static inline struct gl_surface_state *
   get_surface_state(struct weston_surface *surface)
   {
  +   if (!surface-renderer_state)
  +   gl_renderer_create_surface(surface);
  +
  return (struct gl_surface_state *)surface-renderer_state;
   }
 
  @@ -997,6 +1007,8 @@ gl_renderer_attach_shm(struct weston_surface *es,
  struct weston_buffer *buffer,
  gs-needs_full_upload = 1;
  gs-y_inverted = 1;
 
  +   gs-surface = surface;
  +
  ensure_textures(gs, 1);
  glBindTexture(GL_TEXTURE_2D, gs-textures[0]);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
  @@ -1136,6 +1148,31 @@ gl_renderer_surface_set_color(struct weston_surface
  *surface,
  gs-shader = gr-solid_shader;
   }
 
  +static void
  

[PATCH] DirectFB clients (fix unconditional build)

2013-10-25 Thread Denis Oliver Kropp
Hi,

this is an update to the patch set posted earlier.

It fixes unconditional build of DirectFB clients.
From 85397933453e3d080b740ac74c2180ad87fdc012 Mon Sep 17 00:00:00 2001
From: Denis Oliver Kropp d...@directfb.org
Date: Fri, 25 Oct 2013 23:07:16 +0200
Subject: [PATCH] clients: fix unconditional build of DirectFB programs

---
 clients/Makefile.am | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/clients/Makefile.am b/clients/Makefile.am
index edf8489..cc507bb 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -1,7 +1,5 @@
 bin_PROGRAMS =	\
 	weston-info\
-	weston-dfb-adapter			\
-	weston-dfb-test1			\
 	$(terminal)
 
 demo_clients = \
@@ -11,6 +9,12 @@ demo_clients = \
 	$(simple_clients_programs)		\
 	$(simple_egl_clients_programs)
 
+if ENABLE_DIRECTFB_COMPOSITOR
+bin_PROGRAMS +=	\
+	weston-dfb-adapter			\
+	weston-dfb-test1
+endif
+
 if ENABLE_DEMO_CLIENTS
 bin_PROGRAMS += $(demo_clients)
 else
-- 
1.8.1.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/6] tests/.gitignore: Add *.trs

2013-10-25 Thread Jonas Ådahl
Signed-off-by: Jonas Ådahl jad...@gmail.com
---
 tests/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index 28d6576..aba378c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,4 +1,5 @@
 *.test
+*.trs
 *.weston
 logs
 matrix-test
-- 
1.8.1.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 0/6] Canceling grabs

2013-10-25 Thread Jonas Ådahl
Hi,

This series contains, except for some minor fixes, a patch that fixes
some issues related with ending grabs, for example when unplugging some
input device.

I have only tested with with a pointer device (since I don't have an
external keyboard nor touch device to unplug).

Jonas



Jonas Ådahl (6):
  tests/.gitignore: Add *.trs
  compositor-x11: Hide update_xkb_keymap behind #ifdef HAVE_XCB_XKB
  configure.ac: Report if we build with XCB-XKB or not
  input: Remove unused variable
  shell: Don't leak weston_touch_move_grab structs
  Add cancel function to grab interfaces

 configure.ac |  1 +
 src/bindings.c   | 11 ++
 src/compositor-x11.c |  2 ++
 src/compositor.h |  3 ++
 src/data-device.c| 13 
 src/input.c  | 50 +++-
 src/shell.c  | 94 
 src/text-backend.c   |  7 
 tests/.gitignore |  1 +
 9 files changed, 168 insertions(+), 14 deletions(-)

-- 
1.8.1.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 3/6] configure.ac: Report if built with XCB-XKB or not

2013-10-25 Thread Jonas Ådahl
Signed-off-by: Jonas Ådahl jad...@gmail.com
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index ac3878b..51c6a8e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -506,6 +506,7 @@ AC_MSG_RESULT([
Cairo Renderer  ${with_cairo}
EGL ${enable_egl}
libxkbcommon${enable_xkbcommon}
+   xcb_xkb ${have_xcb_xkb}
XWayland${enable_xwayland}
dbus${enable_dbus}
 
-- 
1.8.1.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 4/6] input: Remove unused variable

2013-10-25 Thread Jonas Ådahl
Signed-off-by: Jonas Ådahl jad...@gmail.com
---
 src/input.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/input.c b/src/input.c
index 49788b2..ffb7b35 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1062,8 +1062,6 @@ WL_EXPORT void
 notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
 wl_fixed_t x, wl_fixed_t y)
 {
-   struct weston_compositor *compositor = seat-compositor;
-
if (output) {
move_pointer(seat, x, y);
} else {
-- 
1.8.1.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 5/6] shell: Don't leak weston_touch_move_grab structs

2013-10-25 Thread Jonas Ådahl
Signed-off-by: Jonas Ådahl jad...@gmail.com
---
 src/shell.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index a5e653e..badfd0c 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1130,12 +1130,14 @@ touch_move_grab_down(struct weston_touch_grab *grab, 
uint32_t time,
 static void
 touch_move_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id)
 {
-   struct shell_touch_grab *shell_grab = container_of(grab, 
-  struct 
shell_touch_grab,
-  grab);
+   struct weston_touch_move_grab *move =
+   (struct weston_touch_move_grab *) container_of(
+   grab, struct shell_touch_grab, grab);
 
-   if (grab-touch-seat-num_tp == 0)
-   shell_touch_grab_end(shell_grab);
+   if (grab-touch-seat-num_tp == 0) {
+   shell_touch_grab_end(move-base);
+   free(move);
+   }
 }
 
 static void
-- 
1.8.1.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 6/6] Add cancel function to grab interfaces

2013-10-25 Thread Jonas Ådahl
A grab can potentially allocate memory and would normally end the grab
itself, freeing the allocated memory in the process. However at in some
situations the compositor may want to abort a grab. The grab owner still
needs to free some memory and abort the grab properly. To do this a new
function 'cancel' is introduced in all the grab interfaces instructing
the grabs owner to abort the grab.

This patch also hooks up grab cancelling to seat device releasing and
when the compositor looses focus, which would potentially leak memory
before.

Signed-off-by: Jonas Ådahl jad...@gmail.com
---
 src/bindings.c | 11 
 src/compositor.h   |  3 ++
 src/data-device.c  | 13 +
 src/input.c| 48 
 src/shell.c| 82 +-
 src/text-backend.c |  7 +
 6 files changed, 157 insertions(+), 7 deletions(-)

diff --git a/src/bindings.c b/src/bindings.c
index 03c9238..7cbded9 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -210,9 +210,20 @@ binding_modifiers(struct weston_keyboard_grab *grab, 
uint32_t serial,
}
 }
 
+static void
+binding_cancel(struct weston_keyboard_grab *grab)
+{
+   struct binding_keyboard_grab *binding_grab =
+   container_of(grab, struct binding_keyboard_grab, grab);
+
+   weston_keyboard_end_grab(grab-keyboard);
+   free(binding_grab);
+}
+
 static const struct weston_keyboard_grab_interface binding_grab = {
binding_key,
binding_modifiers,
+   binding_cancel,
 };
 
 static void
diff --git a/src/compositor.h b/src/compositor.h
index e60a512..175d08f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -240,6 +240,7 @@ struct weston_pointer_grab_interface {
void (*motion)(struct weston_pointer_grab *grab, uint32_t time);
void (*button)(struct weston_pointer_grab *grab,
   uint32_t time, uint32_t button, uint32_t state);
+   void (*cancel)(struct weston_pointer_grab *grab);
 };
 
 struct weston_pointer_grab {
@@ -254,6 +255,7 @@ struct weston_keyboard_grab_interface {
void (*modifiers)(struct weston_keyboard_grab *grab, uint32_t serial,
  uint32_t mods_depressed, uint32_t mods_latched,
  uint32_t mods_locked, uint32_t group);
+   void (*cancel)(struct weston_keyboard_grab *grab);
 };
 
 struct weston_keyboard_grab {
@@ -276,6 +278,7 @@ struct weston_touch_grab_interface {
int touch_id,
wl_fixed_t sx,
wl_fixed_t sy);
+   void (*cancel)(struct weston_touch_grab *grab);
 };
 
 struct weston_touch_grab {
diff --git a/src/data-device.c b/src/data-device.c
index 3e22b51..888e606 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -344,10 +344,23 @@ drag_grab_button(struct weston_pointer_grab *grab,
}
 }
 
+static void
+drag_grab_cancel(struct weston_pointer_grab *grab)
+{
+   struct weston_drag *drag =
+   container_of(grab, struct weston_drag, grab);
+
+   if (drag-data_source)
+   wl_list_remove(drag-data_source_listener.link);
+
+   data_device_end_drag_grab(drag);
+}
+
 static const struct weston_pointer_grab_interface drag_grab_interface = {
drag_grab_focus,
drag_grab_motion,
drag_grab_button,
+   drag_grab_cancel,
 };
 
 static void
diff --git a/src/input.c b/src/input.c
index ffb7b35..e265efd 100644
--- a/src/input.c
+++ b/src/input.c
@@ -162,11 +162,17 @@ default_grab_button(struct weston_pointer_grab *grab,
}
 }
 
+static void
+default_grab_pointer_cancel(struct weston_pointer_grab *grab)
+{
+}
+
 static const struct weston_pointer_grab_interface
default_pointer_grab_interface = {
default_grab_focus,
default_grab_motion,
-   default_grab_button
+   default_grab_button,
+   default_grab_pointer_cancel,
 };
 
 static void
@@ -225,10 +231,16 @@ default_grab_touch_motion(struct weston_touch_grab *grab, 
uint32_t time,
}
 }
 
+static void
+default_grab_touch_cancel(struct weston_touch_grab *grab)
+{
+}
+
 static const struct weston_touch_grab_interface default_touch_grab_interface = 
{
default_grab_touch_down,
default_grab_touch_up,
-   default_grab_touch_motion
+   default_grab_touch_motion,
+   default_grab_touch_cancel,
 };
 
 static void
@@ -329,10 +341,16 @@ default_grab_modifiers(struct weston_keyboard_grab *grab, 
uint32_t serial,
}
 }
 
+static void
+default_grab_keyboard_cancel(struct weston_keyboard_grab *grab)
+{
+}
+
 static const struct weston_keyboard_grab_interface
default_keyboard_grab_interface = {
default_grab_key,
default_grab_modifiers,
+   default_grab_keyboard_cancel,
 };
 
 static void
@@ -601,6 +619,12 @@ weston_keyboard_end_grab(struct weston_keyboard *keyboard)
keyboard-grab = 

Re: [RFC wayland v2] Add libwayland-glib for GLib main loop integration

2013-10-25 Thread Tarnyko
Quentin Glidic writes: 


On 25/10/2013 20:01, Kristian Høgsberg wrote:

On Wed, Oct 23, 2013 at 02:10:26PM +0200, Quentin Glidic wrote:
From: Quentin Glidic sardemff7+...@sardemff7.net 


Signed-off-by: Quentin Glidic sardemff7+...@sardemff7.net
--- 


Here is a new version of my GLib main loop integration for Wayland.
Now everything is in libwayland-client (I didn’t work on the server
side) and package detection can be done using the pkg-config file
or the header if needed.


I'm not convinced we need a separate glib shared library for this.
It's only 150 lines of code and gtk+ already has integration code for
this.  Further, any glib use of wayland that isn't also a gtk+ user
seems very niche, so I don't expect a lot of user of this library. 


Kristian


This is why this v2 is just the GSource included directly in 
libwayland-client (I forgot to change the commit message). 

The idea is inspired by PulseAudio, which has a few main loop helpers 
shipped with libpulse (GLib integration, simple and threaded loops). 

I would understand if you do not want to include this code in 
libwayland-client though, but I am willing to maintain it if you decide to 
do so. 

Thanks, 

--  


Quentin “Sardem FF7” Glidic


Hi Quentin, 

Just to let you know that there are people interested in your work 
(including me). I'm currently backporting your patches to 1.2 to test some 
command-line apps using GLib with libwayland-client. 


Regards,
Tarnyko
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [RFC wayland v2] Add libwayland-glib for GLib main loop integration

2013-10-25 Thread Quentin Glidic

On 25/10/2013 23:26, Tarnyko wrote:

Hi Quentin,
Just to let you know that there are people interested in your work
(including me). I'm currently backporting your patches to 1.2 to test
some command-line apps using GLib with libwayland-client.
Regards,
Tarnyko


In this case you should simply use the original project:
http://libwayland-glib.sardemff7.net/
I’ll probably change the licence to LGPL-2.1 or MIT though.

Thanks for your interest,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] event-loop: fix blocking timerfd read

2013-10-25 Thread Kristian Høgsberg
On Thu, Oct 17, 2013 at 02:20:31PM +0200, David Herrmann wrote:
 If we call wl_event_source_check() on a timerfd, our dispatcher will block
 on the timerfd read(). Avoid calling read() if no epoll-event was
 reported.
 
 Note: The internal tick-count of a timerfd is never decreased. So once we
 get signaled a read event, a following read() is guaranteed to succeed
 _if_ no other operation is called on the timerfd in between. Therefore,
 there is no need for us to make the read() non-blocking (even with
 clock-changes we never block). However, to be safe for future changed,
 just ignore EAGAIN safely.
 
 Also remove the comment about read() failure. The only reasons the read
 can currently fail is EINTR or invalid parameters. The latter cannot
 happen in our setup so ignore it. EINTR shouldn't happen as
 syscall-restart is the default behavior so we simply return if a user
 changed it. Better safe than sorry.

We should never need to check timer or signal sources.  The checked
source are only for things like xlib or wayland-client where we may
read events into an event queue and empty the fd.  Then when we go to
sleep we have events pending, but the fd is not readable.  The check
is there to let us check whether those sources have events to dispatch
before going to sleep.

If anything, maybe we should just fail if somebody calls
wl_event_source_check() on a timer or signal source.

Kristian

 Signed-off-by: David Herrmann dh.herrm...@gmail.com
 ---
  src/event-loop.c | 13 +
  1 file changed, 9 insertions(+), 4 deletions(-)
 
 diff --git a/src/event-loop.c b/src/event-loop.c
 index d323601..d340e3c 100644
 --- a/src/event-loop.c
 +++ b/src/event-loop.c
 @@ -172,10 +172,15 @@ wl_event_source_timer_dispatch(struct wl_event_source 
 *source,
   uint64_t expires;
   int len;
  
 - len = read(source-fd, expires, sizeof expires);
 - if (len != sizeof expires)
 - /* Is there anything we can do here?  Will this ever happen? */
 - fprintf(stderr, timerfd read error: %m\n);
 + if (ep-events != 0) {
 + len = read(source-fd, expires, sizeof expires);
 + if (len != sizeof expires) {
 + if (len = 0 || (errno != EINTR  errno != EAGAIN))
 + fprintf(stderr,
 + timerfd read error (%d): %m\n, len);
 + return 0;
 + }
 + }
  
   return timer_source-func(timer_source-base.data);
  }
 -- 
 1.8.4
 
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH mesa v4] wayland: Add support for eglSwapInterval

2013-10-25 Thread Jason Ekstrand
My knowledge of mesa and of the wl_display_prepare_read stuff is a bit
lacking.  From what I can see, it looks good.


On Fri, Oct 25, 2013 at 9:50 AM, Neil Roberts n...@linux.intel.com wrote:

 Ok, here is version 4 of the patch taking into account the discussion
 with Jason Ekstrand. The assumption is that if we have enough buffer
 slots then we should always get a release event immediately after one
 of the attaches. That means we can just rely on sending a sync request
 after the commit in order to get a buffer release and we don't need to
 bother with the request to disable the queuing mechanism.

 The previous version of the patch would block in a loop calling
 wl_dispatch_queue if it couldn't find a buffer. This is only a
 sensible option if we know that the compositor isn't queueing the
 release events. If not this loop would just block indefinitely. If the
 theory about getting release events is correct then we should never
 actually hit this loop so it probably doesn't really matter what it
 does. However, I didn't like the idea of having a loop there that
 would just block forever so I changed it to poll the compositor with a
 sync request every 10ms in order to force it to flush the queue. It
 prints a warning if this case is hit so that we will know there is a
 problem.

 I made the change to make it use 4 buffer slots in this patch and
 tested that it does use exactly all 4 of them when the application is
 fullscreen. This does work and it doesn't hit the polling path. I
 guess we could change to be five in order to cope with the subsurface
 case but I'm a bit reluctant to do that because it seems like quite a
 corner case and maybe it's better to just let it hit the warning path
 in that case.

 In the previous versions of the patch it would only do a sync request
 if the swap interval is zero. In this version I've changed it so that
 it always installs it. This is necessary because if an application is
 doing swap interval 1 but isn't installing a frame callback it would
 end up rendering and calling get_back_bo before we've handled any data
 from the compositor and it would use a redundant third buffer.

 Regards,
 - Neil

 --- 8 --- (use git am --scissors to automatically chop
 here)

 The Wayland EGL platform now respects the eglSwapInterval value. The value
 is
 clamped to either 0 or 1 because it is difficult (and probably not useful)
 to
 sync to more than 1 redraw.

 The main change is that if the swap interval is 0 then Mesa won't install a
 frame callback so that eglSwapBuffers can be executed as often as
 necessary.
 However it now always does a sync request after the swap buffers and blocks
 until this is complete in get_back_bo. The compositor is likely to send a
 release event while processing the new buffer attach and this makes sure we
 will receive that before deciding whether to allocate a new buffer. This is
 done even if the application is using swap interval 1 because otherwise if
 the
 application is not installing its own frame callback it may end up calling
 get_back_bo before we've handled any data from the compositor and it would
 end
 up using a redundant extra buffer.

 If there are no buffers available then instead of returning with an error,
 get_back_bo will now poll the compositor by repeatedly sending sync
 requests
 every 10ms. This is a last resort and in theory this shouldn't happen
 because
 there should be no reason for the compositor to hold on to more than three
 buffers. That means whenever we attach the fourth buffer we should always
 get
 an immediate release event which should come in with the notification for
 the
 first sync request that we are throttled to.

 When the compositor is directly scanning out from the application's buffer
 it
 may end up holding on to three buffers. These are the one that is is
 currently
 scanning out from, one that has been given to DRM as the next buffer to
 flip
 to, and one that has been attached and will be given to DRM as soon as the
 previous flip completes. When we attach a fourth buffer to the compositor
 it
 should replace that third buffer so we should get a release event
 immediately
 after that. This patch therefore also changes the number of buffer slots
 to 4
 so that we can accomodate that situation.

 If DRM eventually gets a way to cancel a pending page flip then the
 compositors
 can be changed to only need to hold on to two buffers and this value can be
 put back to 3.

 This also moves the vblank configuration defines from platform_x11.c to the
 common egl_dri2.h header so they can be shared by both platforms.
 ---
  src/egl/drivers/dri2/egl_dri2.h |   9 +-
  src/egl/drivers/dri2/platform_wayland.c | 204
 +---
  src/egl/drivers/dri2/platform_x11.c |   6 -
  3 files changed, 193 insertions(+), 26 deletions(-)

 diff --git a/src/egl/drivers/dri2/egl_dri2.h
 b/src/egl/drivers/dri2/egl_dri2.h
 index 7a2e098..7de5916 100644
 ---