[PATCH wayland] protocol: when buffer transform and scale change

2014-02-07 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Clarify when the pending and current buffer transform and scale values
change, and what exactly happens on commit.

This matches what Weston currently does.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 protocol/wayland.xml | 9 +
 1 file changed, 9 insertions(+)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index bf6acd1..e1edbe5 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1201,6 +1201,11 @@
 
A newly created surface has its buffer transformation set to normal.
 
+   wl_surface.set_buffer_transform changes the pending buffer
+   transformation. wl_surface.commit copies the pending buffer
+   transformation to the current one. Otherwise, the pending and current
+   values are never changed.
+
The purpose of this request is to allow clients to render content
according to the output transform, thus permiting the compositor to
use certain optimizations even if the display is rotated. Using
@@ -1227,6 +1232,10 @@
 
A newly created surface has its buffer scale set to 1.
 
+   wl_surface.set_buffer_scale changes the pending buffer scale.
+   wl_surface.commit copies the pending buffer scale to the current one.
+   Otherwise, the pending and current values are never changed.
+
The purpose of this request is to allow clients to supply higher
resolution buffer data for use on high resolution outputs. Its
intended that you pick the same buffer scale as the scale of the
-- 
1.8.3.2

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


[PATCH weston 1/2] build: pass client flags to test programs

2014-02-03 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Fix build failures of the kind:

  CC   tests/bad-buffer-test.o
In file included from tests/weston-test-client-helper.h:28:0,
 from tests/bad-buffer-test.c:28:
./protocol/wayland-test-client-protocol.h:35:28: fatal error: wayland-client.h: 
No such file or directory
compilation terminated.
make[1]: *** [tests/bad-buffer-test.o] Error 1

These are only triggerable if libwayland has not been installed
system-wide, but only in a custom prefix.

Since the Makefile already uses AM_CPPFLAGS, simply add
TEST_CLIENT_CFLAGS to test programs instead of dropping AM_CPPFLAGS.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk

---

Is this the right thing nowadays?
Or should the AM_CPPFLAGS content be dropped?
---
 Makefile.am | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 753ff83..1de22c9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -834,27 +834,34 @@ libtest_client_la_SOURCES =   \
 nodist_libtest_client_la_SOURCES = \
protocol/wayland-test-protocol.c\
protocol/wayland-test-client-protocol.h
+libtest_client_la_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CLIENT_CFLAGS)
 libtest_client_la_LIBADD = $(TEST_CLIENT_LIBS) libshared.la libtest-runner.la
 
 bad_buffer_weston_SOURCES = tests/bad-buffer-test.c
+bad_buffer_weston_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CLIENT_CFLAGS)
 bad_buffer_weston_LDADD = libtest-client.la
 
 keyboard_weston_SOURCES = tests/keyboard-test.c
+keyboard_weston_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CLIENT_CFLAGS)
 keyboard_weston_LDADD = libtest-client.la
 
 event_weston_SOURCES = tests/event-test.c
+event_weston_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CLIENT_CFLAGS)
 event_weston_LDADD = libtest-client.la
 
 button_weston_SOURCES = tests/button-test.c
+button_weston_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CLIENT_CFLAGS)
 button_weston_LDADD = libtest-client.la
 
 text_weston_SOURCES = tests/text-test.c
 nodist_text_weston_SOURCES =   \
protocol/text-protocol.c\
protocol/text-client-protocol.h
+text_weston_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CLIENT_CFLAGS)
 text_weston_LDADD = libtest-client.la
 
 subsurface_weston_SOURCES = tests/subsurface-test.c
+subsurface_weston_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CLIENT_CFLAGS)
 subsurface_weston_LDADD = libtest-client.la
 
 if ENABLE_EGL
-- 
1.8.3.2

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


[PATCH weston] protocol: rename wl_surface_scaler to wl_viewport

2014-01-08 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

This seems like a better name, and will not conflict if someone later
extends wl_surface with a request scaler_set (yeah, unlikely).

This code was written by Jonny Lamb, I just diffed his branches and made
a patch for Weston.

Cc: Jonny Lamb jonny.l...@collabora.co.uk
Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---

Personally I just like this name better, and now would be a good time to
rename it. Up to your preference.
---
 clients/scaler.c  | 10 +++
 protocol/scaler.xml   | 28 +--
 src/compositor.c  | 76 +--
 src/compositor.h  | 10 +++
 src/pixman-renderer.c | 20 +++---
 5 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/clients/scaler.c b/clients/scaler.c
index f5ae226..9753096 100644
--- a/clients/scaler.c
+++ b/clients/scaler.c
@@ -47,7 +47,7 @@ struct box {
int width, height;
 
struct wl_scaler *scaler;
-   struct wl_surface_scaler *surface_scaler;
+   struct wl_viewport *viewport;
 };
 
 static void
@@ -138,12 +138,12 @@ global_handler(struct display *display, uint32_t name,
box-scaler = display_bind(display, name,
   wl_scaler_interface, 1);
 
-   box-surface_scaler = wl_scaler_get_surface_scaler(box-scaler,
+   box-viewport = wl_scaler_get_viewport(box-scaler,
widget_get_wl_surface(box-widget));
 
-   wl_surface_scaler_set(box-surface_scaler,
- src_x, src_y, src_width, src_height,
- SURFACE_WIDTH, SURFACE_HEIGHT); /* dst */
+   wl_viewport_set(box-viewport,
+   src_x, src_y, src_width, src_height,
+   SURFACE_WIDTH, SURFACE_HEIGHT); /* dst */
}
 }
 
diff --git a/protocol/scaler.xml b/protocol/scaler.xml
index d98215a..dfe44b8 100644
--- a/protocol/scaler.xml
+++ b/protocol/scaler.xml
@@ -40,31 +40,31 @@
   description summary=unbind from the cropping and scaling interface
Informs the server that the client will not be using this
protocol object anymore. This does not affect any other objects,
-   wl_surface_scaler objects included.
+   wl_viewport objects included.
   /description
 /request
 
 enum name=error
-  entry name=scaler_exists value=0
- summary=the surface already has a scaler object associated/
+  entry name=viewport_exists value=0
+ summary=the surface already has a viewport object associated/
 /enum
 
-request name=get_surface_scaler
+request name=get_viewport
   description summary=extend surface interface for crop and scale
Instantiate an interface extension for the given wl_surface to
crop and scale its content. If the given wl_surface already has
-   a wl_surface_scaler object associated, the scaler_exists
+   a wl_viewport object associated, the viewport_exists
protocol error is raised.
   /description
 
-  arg name=id type=new_id interface=wl_surface_scaler
-   summary=the new scaler interface id/
+  arg name=id type=new_id interface=wl_viewport
+   summary=the new viewport interface id/
   arg name=surface type=object interface=wl_surface
summary=the surface/
 /request
   /interface
 
-  interface name=wl_surface_scaler version=1
+  interface name=wl_viewport version=1
 description summary=crop and scale interface to a wl_surface
   An additional interface to a wl_surface object, which allows the
   client to specify the cropping and scaling of the surface
@@ -89,7 +89,7 @@
   the surface-local coordinates happen in the following order:
 1. buffer_transform (wl_surface.set_buffer_transform)
 2. buffer_scale (wl_surface.set_buffer_scale)
-3. crop and scale (wl_surface_scaler.set)
+3. crop and scale (wl_viewport.set)
   This means, that the source rectangle coordinates of crop and scale
   are given in the coordinates after the buffer transform and scale,
   i.e. in the coordinates that would be the surface-local coordinates
@@ -105,10 +105,10 @@
   still in the surface-local coordinate system, just like dst_width
   and dst_height are.
 
-  If the wl_surface associated with the wl_surface_scaler is
-  destroyed, the wl_surface_scaler object becomes inert.
+  If the wl_surface associated with the wl_viewport is destroyed,
+  the wl_viewport object becomes inert.
 
-  If the wl_surface_scaler object is destroyed, the crop and scale
+  If the wl_viewport object is destroyed, the crop and scale
   state is removed from the wl_surface. The change will be applied
   on the next wl_surface.commit.
 /description
@@ -128,8 +128,8 @@
 request name=set
   

[PATCH weston] screenshooter: silence a warning

2014-01-08 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

screenshooter.c: In function ‘recorder_binding’:
screenshooter.c:509:5: warning: ‘listener’ may be used uninitialized in
this function [-Wuninitialized]

This was not really a problem so far, because the variable was
uninitialized only in the case where Weston had no outputs.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/screenshooter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/screenshooter.c b/src/screenshooter.c
index 0489f92..26e503c 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -495,7 +495,7 @@ recorder_binding(struct weston_seat *seat, uint32_t time, 
uint32_t key, void *da
struct weston_seat *ws = (struct weston_seat *) seat;
struct weston_compositor *ec = ws-compositor;
struct weston_output *output;
-   struct wl_listener *listener;
+   struct wl_listener *listener = NULL;
struct weston_recorder *recorder;
static const char filename[] = capture.wcap;
 
-- 
1.8.3.2

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


[PATCH weston] tests: Only run buffer-count test on Mesa = 10.1

2014-01-08 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Comment #2 in the bug report says Mesa 10.0 branch does not have the
fix, and indeed buffer-count test fails on Mesa 10.0.1. Fix the test to
require Mesa 10.1 or later.

Now I correctly get:
mesa version too old (OpenGL ES 3.0 Mesa 10.0.1 (git-12484d2))

https://bugs.freedesktop.org/show_bug.cgi?id=72835

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 tests/buffer-count-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/buffer-count-test.c b/tests/buffer-count-test.c
index 3b66e31..c7ddeb6 100644
--- a/tests/buffer-count-test.c
+++ b/tests/buffer-count-test.c
@@ -97,7 +97,7 @@ init_egl(struct test_data *test_data)
 test_data-egl_surface, test_data-egl_ctx);
assert(ret == EGL_TRUE);
 
-   /* This test is specific to mesa 10.0 and later, which is the
+   /* This test is specific to mesa 10.1 and later, which is the
 * first release that doesn't accidentally triple-buffer. */
str = (const char *) glGetString(GL_VERSION);
mesa = strstr(str, Mesa );
@@ -105,7 +105,7 @@ init_egl(struct test_data *test_data)
skip(unknown EGL implementation (%s)\n, str);
if (sscanf(mesa + 5, %d.%d, major, minor) != 2)
skip(unrecognized mesa version (%s)\n, str);
-   if (major  10)
+   if (major  10 || (major == 10  minor  1))
skip(mesa version too old (%s)\n, str);
 
 }
-- 
1.8.3.2

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


[PATCH wayland-web] update xserver and wayland DDX branches

2013-12-11 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

After the update, you get the latest xserver branch, which at the time
of writing is based on xserver 1.14.99.

You also get the latest xf86-video-wayland, which was renamed from
xf86-video-wlshm.

---

Hi,

is there any reason to not have these up-to-date(?) branches in the
website, rather than the old 1.12 xserver versions?

What is the intended Weston compatibility here? Are Weston 1.3.1 and
master supposed to work with both xwayland and xwayland-1.12 branches
of xserver?

What about the various DDXes vs. xserver vs. weston?
I assume there is no direct dependence between the video DDXes and
Weston.
---
 xserver.html | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/xserver.html b/xserver.html
index 899ba50..db99dd0 100644
--- a/xserver.html
+++ b/xserver.html
@@ -44,13 +44,15 @@
 
 h2X.org/h2
 
-pregit clone git://anongit.freedesktop.org/xorg/xserver -b xwayland-1.12
+pregit clone git://anongit.freedesktop.org/xorg/xserver -b xwayland
 cd xserver
 ./autogen.sh --prefix=$WLD
 make
 make install
 cd ..
 /pre
+pThis gets you the latest Wayland enabled X server, until the Wayland 
enablement
+gets merged into the master branch./p
 
 h2DDX/h2
 
@@ -58,7 +60,7 @@
   The Device Dependent part of X.  Only one of these is necessary.
   xf86-video-intel works with Intel open source video drivers.
   xf86-video-ati works with AMD Radeon open source drivers.
-  xf86-video-wlshm is implemented in software, so it works on all
+  xf86-video-wayland is implemented in software, so it works on all
   hardware, but is somewhat less complete.  xf86-video-nouveau works
   with Nvidia / Nouveau.
 /p
@@ -79,8 +81,8 @@
 cd ..
 /pre
 
-pregit clone git://people.freedesktop.org/~iksaif/xf86-video-wlshm
-cd xf86-video-wlshm
+pregit clone git://anongit.freedesktop.org/xorg/driver/xf86-video-wayland
+cd xf86-video-wayland
 ./autogen.sh --prefix=$WLD
 make
 make install
-- 
1.8.3.2

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


[PATCH weston 1/4] gl: fix fallback definition of EGL_DEFAULT_DISPLAY

2013-12-04 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Compiling fbdev backend on RaspberryPi caused the following warning:

compositor-fbdev.c: In function 'fbdev_compositor_create':
compositor-fbdev.c:929:6: warning: passing argument 2 of
'gl_renderer-create' makes integer from pointer without a cast [enabled
by default]
compositor-fbdev.c:929:6: note: expected 'EGLNativeDisplayType' but
argument is of type 'void *'

Fix the definition of EGL_DEFAULT_DISPLAY to match the definition in
EGL/egl.h (of Mesa).

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/gl-renderer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gl-renderer.h b/src/gl-renderer.h
index 63b371c..dcdf69d 100644
--- a/src/gl-renderer.h
+++ b/src/gl-renderer.h
@@ -35,7 +35,7 @@ typedef void *EGLDisplay;
 typedef void *EGLSurface;
 typedef intptr_t EGLNativeDisplayType;
 typedef intptr_t EGLNativeWindowType;
-#define EGL_DEFAULT_DISPLAY NULL
+#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
 
 #endif
 
-- 
1.8.3.2

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


[PATCH weston 2/4] rpi: compile in the common udev code

2013-12-04 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

In a recent commit 37d38d932cea8a642e644d091747d0d9c046a00a, rpi: Use
common udev_input for input device handling, the rpi-backend was made
to use the common udev code.

It just forgot to actually build the common udev code into the
rpi-backend.

Cc: Jonas Ådahl jad...@gmail.com
Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/Makefile.am b/src/Makefile.am
index f6f277d..6dcd6c5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -227,6 +227,8 @@ rpi_backend_la_SOURCES =\
rpi-renderer.c  \
rpi-renderer.h  \
rpi-bcm-stubs.h \
+   udev-seat.c \
+   udev-seat.h \
evdev.c \
evdev.h \
evdev-touchpad.c
-- 
1.8.3.2

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


[PATCH weston 3/4] rpi: seat quick fix

2013-12-04 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Fix the default seat name, so that we can find the input devices by
default.

This is just a quick fix. Further enhancement would be to make the
default seat on rpi taken from a command line option like the other
backends do. Furthermore, udev_input_init() should accept NULL as seat
to use the default seat, avoiding us hardcoding seat0 all over.

Cc: Jonas Ådahl jad...@gmail.com
Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/compositor-rpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index c3dda2e..7d95e83 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -513,7 +513,7 @@ rpi_compositor_create(struct wl_display *display, int 
*argc, char *argv[],
 
if (udev_input_init(compositor-input,
compositor-base,
-   compositor-udev, ID_SEAT) != 0) {
+   compositor-udev, seat0) != 0) {
weston_log(Failed to initialize udev input.\n);
goto out_udev;
}
-- 
1.8.3.2

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


[PATCH weston 4/4] rpi: launcher must init before udev-seat

2013-12-04 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

udev-seat will call weston_launcher_open(), so we better init launcher
first. Fixes a segfault.

Cc: Jonas Ådahl jad...@gmail.com
Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/compositor-rpi.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 7d95e83..88ea8e0 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -511,13 +511,6 @@ rpi_compositor_create(struct wl_display *display, int 
*argc, char *argv[],
goto out_compositor;
}
 
-   if (udev_input_init(compositor-input,
-   compositor-base,
-   compositor-udev, seat0) != 0) {
-   weston_log(Failed to initialize udev input.\n);
-   goto out_udev;
-   }
-
compositor-session_listener.notify = session_notify;
wl_signal_add(compositor-base.session_signal,
  compositor -session_listener);
@@ -525,7 +518,7 @@ rpi_compositor_create(struct wl_display *display, int 
*argc, char *argv[],
weston_launcher_connect(compositor-base, param-tty, seat0);
if (!compositor-base.launcher) {
weston_log(Failed to initialize tty.\n);
-   goto out_udev_input;
+   goto out_udev;
}
 
compositor-base.destroy = rpi_compositor_destroy;
@@ -537,6 +530,13 @@ rpi_compositor_create(struct wl_display *display, int 
*argc, char *argv[],
weston_log(Dispmanx planes are %s buffered.\n,
   compositor-single_buffer ? single : double);
 
+   if (udev_input_init(compositor-input,
+   compositor-base,
+   compositor-udev, seat0) != 0) {
+   weston_log(Failed to initialize udev input.\n);
+   goto out_launcher;
+   }
+
for (key = KEY_F1; key  KEY_F9; key++)
weston_compositor_add_key_binding(compositor-base, key,
  MODIFIER_CTRL | MODIFIER_ALT,
@@ -552,7 +552,7 @@ rpi_compositor_create(struct wl_display *display, int 
*argc, char *argv[],
bcm_host_init();
 
if (rpi_renderer_create(compositor-base, param-renderer)  0)
-   goto out_launcher;
+   goto out_udev_input;
 
if (rpi_output_create(compositor, param-output_transform)  0)
goto out_renderer;
@@ -562,12 +562,12 @@ rpi_compositor_create(struct wl_display *display, int 
*argc, char *argv[],
 out_renderer:
compositor-base.renderer-destroy(compositor-base);
 
-out_launcher:
-   weston_launcher_destroy(compositor-base.launcher);
-
 out_udev_input:
udev_input_destroy(compositor-input);
 
+out_launcher:
+   weston_launcher_destroy(compositor-base.launcher);
+
 out_udev:
udev_unref(compositor-udev);
 
-- 
1.8.3.2

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


[PATCH wayland-web] rpi: update the build guide

2013-12-04 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Updates necessary for building and using Weston from upstream master
branch.

- note that recent raspberrypi.org images come with an old Weston
- update the dependency list
- update the env setup to match the general guide
- libxkbcommon is available as packages, no need to build it manually
- update weston configure flags: need weston-launch, enable fbdev
  backend (untested), ensure cairo-image
- explain how to set up groups for weston-launch
- remove reference to previous guide contents
- using weston-launch is now mandatory at least for VT setup
- note the gfx device permissions
- remove outdated example of configure output

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 raspberrypi.html | 76 +---
 1 file changed, 40 insertions(+), 36 deletions(-)

diff --git a/raspberrypi.html b/raspberrypi.html
index 153b8a2..442a694 100644
--- a/raspberrypi.html
+++ b/raspberrypi.html
@@ -27,10 +27,17 @@ packages./p
 pThere are pre-built Wayland and Weston packages for the
 a href=http://www.raspbian.org/;Raspbian/a distribution./p
 
-pAdd the following line to tt/etc/apt/sources.list/tt file:/p
+pRecent versions of the Raspbian image
+a href=http://www.raspberrypi.org/downloads;downloaded from
+raspberrypi.org/a already have the raspberrypi.collabora.com repository
+enabled. At least version 2013-09-25 is confirmed to have it, and
+in fact that image comes with Weston 1.1.0 pre-installed./p
+
+pIf you need to add the repository manually,
+add the following line to tt/etc/apt/sources.list/tt file:/p
 predeb http://raspberrypi.collabora.com wheezy rpi
 /pre
-pThen just issue:/p
+pTo install Weston, just issue:/p
 presudo apt-get update
 sudo apt-get install weston/pre
 
@@ -50,9 +57,14 @@ below are still worth checking, though./p
 build dependencies:/p
 pre$ sudo apt-get install build-essential automake libtool bison flex \
 xutils-dev libcairo2-dev libffi-dev libmtdev-dev libjpeg-dev \
-libudev-dev libxcb-xfixes0-dev libxcursor-dev libraspberrypi-dev
+libudev-dev libxcb-xfixes0-dev libxcursor-dev libraspberrypi-dev \
+libxkbcommon-dev libxcb-composite0-dev libpam-dev
 /pre
 
+pOn December 4th, 2013, libxkbcommon-dev is not yet found in Raspbian
+itself, but it is available from the raspberrypi.collabora.com repository,
+see above./p
+
 h2Firmware/h2
 
 pYou may need the latest Raspberry Pi firmware, which you can get with the
@@ -87,7 +99,9 @@ first, but if you encounter graphics problems, see if it 
fixes them./p
 export PATH=$WLD/bin:$PATH
 export LD_LIBRARY_PATH=$WLD/lib:/opt/vc/lib
 export PKG_CONFIG_PATH=$WLD/lib/pkgconfig/:$WLD/share/pkgconfig/
-export ACLOCAL=aclocal -I $WLD/share/aclocal
+export ACLOCAL_PATH=$WLD/share/aclocal
+export ACLOCAL=aclocal -I $ACLOCAL_PATH
+
 export XDG_RUNTIME_DIR=/run/shm/wayland
 export XDG_CONFIG_HOME=$WLD/etc
 export XORGCONFIG=$WLD/etc/xorg.conf
@@ -128,48 +142,41 @@ contains similar files for Android, and will not work./p
 /pre
 pThe tt--disable-documentation/tt makes it not require Doxygen./p
 
-h2libxkbcommon/h2
-
-pLibxkbcommon is built and installed the same way as in
-a href=building.htmlthe generic build guide/a, too./p
-
-pre$ git clone git://people.freedesktop.org/xorg/lib/libxkbcommon.git
-$ cd libxkbcommon/
-$ ./autogen.sh --prefix=$WLD
-$ make amp;amp; make install
-/pre
-
-
 h2Weston and demo applications/h2
 
 pWeston is configured slightly differently compared to the normal build:/p
 pre$ git clone git://anongit.freedesktop.org/wayland/weston
 $ cd weston
 
-$ ./autogen.sh --prefix=$WLD --disable-setuid-install \
+$ ./autogen.sh --prefix=$WLD \
 --disable-x11-compositor --disable-drm-compositor \
---disable-fbdev-compositor --disable-wayland-compositor \
---disable-weston-launch --disable-simple-egl-clients --disable-egl \
+--disable-wayland-compositor \
+--enable-weston-launch --disable-simple-egl-clients --disable-egl \
 --disable-libunwind --disable-colord --disable-resize-optimization \
---disable-xwayland-test \
+--disable-xwayland-test --with-cairo=image \
 WESTON_NATIVE_BACKEND=rpi-backend.so
 
 $ make
-$ make install
+$ sudo make install
+/pre
+
+pTo use ttweston-launch/tt, the user must be in the
+emweston-launch/em group. Create the group and add the user empi/em
+to it:/p
+pre$ sudo addgroup weston-launch
+$ sudo adduser pi weston-launch
+$ logout
 /pre
+pYou need to log out and then back in to make the group addition effective.
+You can check that it succeeded with the command ttid/tt which should
+now list emweston-launch/em. This needs to be done only once, unlike the
+environment setup./p
 
-pIf you decide to use the tt--disable-wayland-compositor/tt
-flag supplied above you can remove the dummy ttwayland-egl.pc/tt
-pkg-config file which you may have installed from following an older
-version of this 

[PATCH wayland 1/2] os: use posix_fallocate in creating sharable buffers

2013-11-29 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 configure.ac  |  2 +-
 cursor/os-compatibility.c | 19 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index f8be456..b289567 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,7 +39,7 @@ if test x$GCC = xyes; then
 fi
 AC_SUBST(GCC_CFLAGS)
 
-AC_CHECK_FUNCS([accept4 mkostemp])
+AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate])
 
 AC_CHECK_DECL(SFD_CLOEXEC,[],
  [AC_MSG_ERROR(SFD_CLOEXEC is needed to compile wayland)],
diff --git a/cursor/os-compatibility.c b/cursor/os-compatibility.c
index 418b0d3..0c41242 100644
--- a/cursor/os-compatibility.c
+++ b/cursor/os-compatibility.c
@@ -90,6 +90,12 @@ create_tmpfile_cloexec(char *tmpname)
  * The file is suitable for buffer sharing between processes by
  * transmitting the file descriptor over Unix sockets using the
  * SCM_RIGHTS methods.
+ *
+ * If the C library implements posix_fallocate(), it is used to
+ * guarantee that disk space is available for the file at the
+ * given size. If disk space is insufficent, errno is set to ENOSPC.
+ * If posix_fallocate() is not supported, program may receive
+ * SIGBUS on accessing mmap()'ed file contents instead.
  */
 int
 os_create_anonymous_file(off_t size)
@@ -98,6 +104,7 @@ os_create_anonymous_file(off_t size)
const char *path;
char *name;
int fd;
+   int ret;
 
path = getenv(XDG_RUNTIME_DIR);
if (!path) {
@@ -119,10 +126,20 @@ os_create_anonymous_file(off_t size)
if (fd  0)
return -1;
 
-   if (ftruncate(fd, size)  0) {
+#ifdef HAVE_POSIX_FALLOCATE
+   ret = posix_fallocate(fd, 0, size);
+   if (ret != 0) {
+   close(fd);
+   errno = ret;
+   return -1;
+   }
+#else
+   ret = ftruncate(fd, size);
+   if (ret  0) {
close(fd);
return -1;
}
+#endif
 
return fd;
 }
-- 
1.8.1.5

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


[PATCH wayland 2/2] cursor: handle running out of buffer space

2013-11-29 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

If posix_fallocate is available, use it to detect when we are running
out of buffer space.

Propagate the failure properly through the various functions, stopping
loading cursors but keeping the cursors that were already successfully
loaded.

This may result in an animated cursor not having all of its images, or a
cursor theme not having all of its cursors. When that happens, the
failure is NOT communicated to the application. Instead, the application
will get NULL from wl_cursor_theme_get_cursor() for a cursor that was
not loaded successfully. If an animated cursor is missing only some
images, the animation is truncated but the cursor is still available.

This patch relies on the commit os: use posix_fallocate in creating
sharable buffers for defining HAVE_POSIX_FALLOCATE.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 cursor/wayland-cursor.c | 67 +
 1 file changed, 51 insertions(+), 16 deletions(-)

diff --git a/cursor/wayland-cursor.c b/cursor/wayland-cursor.c
index 25e51c2..3dadbdd 100644
--- a/cursor/wayland-cursor.c
+++ b/cursor/wayland-cursor.c
@@ -20,6 +20,7 @@
  * OF THIS SOFTWARE.
  */
 
+#include config.h
 #include xcursor.h
 #include wayland-cursor.h
 #include wayland-client.h
@@ -28,6 +29,8 @@
 #include string.h
 #include unistd.h
 #include sys/mman.h
+#include fcntl.h
+#include errno.h
 
 #include os-compatibility.h
 
@@ -79,6 +82,12 @@ shm_pool_resize(struct shm_pool *pool, int size)
if (ftruncate(pool-fd, size)  0)
return 0;
 
+#ifdef HAVE_POSIX_FALLOCATE
+   errno = posix_fallocate(pool-fd, 0, size);
+   if (errno != 0)
+   return 0;
+#endif
+
wl_shm_pool_resize(pool-pool, size);
 
munmap(pool-data, pool-size);
@@ -199,21 +208,15 @@ wl_cursor_create_from_data(struct cursor_metadata 
*metadata,
 
cursor-cursor.image_count = 1;
cursor-cursor.images = malloc(sizeof *cursor-cursor.images);
-   if (!cursor-cursor.images) {
-   free(cursor);
-   return NULL;
-   }
+   if (!cursor-cursor.images)
+   goto err_free_cursor;
 
cursor-cursor.name = strdup(metadata-name);
cursor-total_delay = 0;
 
image = malloc(sizeof *image);
-   if (!image) {
-   free(cursor-cursor.name);
-   free(cursor-cursor.images);
-   free(cursor);
-   return NULL;
-   }
+   if (!image)
+   goto err_free_images;
 
cursor-cursor.images[0] = (struct wl_cursor_image *) image;
image-theme = theme;
@@ -226,10 +229,25 @@ wl_cursor_create_from_data(struct cursor_metadata 
*metadata,
 
size = metadata-width * metadata-height * sizeof(uint32_t);
image-offset = shm_pool_allocate(theme-pool, size);
+
+   if (image-offset  0)
+   goto err_free_image;
+
memcpy(theme-pool-data + image-offset,
   cursor_data + metadata-offset, size);
 
return cursor-cursor;
+
+err_free_image:
+   free(image);
+
+err_free_images:
+   free(cursor-cursor.name);
+   free(cursor-cursor.images);
+
+err_free_cursor:
+   free(cursor);
+   return NULL;
 }
 
 static void
@@ -240,12 +258,17 @@ load_default_theme(struct wl_cursor_theme *theme)
free(theme-name);
theme-name = strdup(default);
 
-   theme-cursor_count = ARRAY_LENGTH(cursor_metadata);;
+   theme-cursor_count = ARRAY_LENGTH(cursor_metadata);
theme-cursors = malloc(theme-cursor_count * sizeof(*theme-cursors));
 
-   for (i = 0; i  theme-cursor_count; ++i)
+   for (i = 0; i  theme-cursor_count; ++i) {
theme-cursors[i] =
wl_cursor_create_from_data(cursor_metadata[i], theme);
+
+   if (theme-cursors[i] == NULL)
+   break;
+   }
+   theme-cursor_count = i;
 }
 
 static struct wl_cursor *
@@ -260,7 +283,6 @@ wl_cursor_create_from_xcursor_images(XcursorImages *images,
if (!cursor)
return NULL;
 
-   cursor-cursor.image_count = images-nimage;
cursor-cursor.images =
malloc(images-nimage * sizeof cursor-cursor.images[0]);
if (!cursor-cursor.images) {
@@ -273,7 +295,6 @@ wl_cursor_create_from_xcursor_images(XcursorImages *images,
 
for (i = 0; i  images-nimage; i++) {
image = malloc(sizeof *image);
-   cursor-cursor.images[i] = (struct wl_cursor_image *) image;
 
image-theme = theme;
image-buffer = NULL;
@@ -283,13 +304,27 @@ wl_cursor_create_from_xcursor_images(XcursorImages 
*images,
image-image.hotspot_x = images-images[i]-xhot;
image-image.hotspot_y = images-images[i]-yhot;
image-image.delay = images-images[i]-delay;
-   cursor-total_delay += image-image.delay;
 
-   /* 

[PATCH weston 1/2] os: use posix_fallocate in creating sharable buffers

2013-11-29 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

If posix_fallocate is available, use it instead of ftruncate. Unlike
ftruncate, when posix_fallocate succeeds, it guarantees that you cannot
run out of disk space, when later writing to the mmap()'ed file.

With posix_fallocate, if os_create_anonymous_file() succeeds, the
program cannot get a SIGBUS later from accessing this file via mmap. If
there is insufficient disk space, the function fails and errno is set to
ENOSPC.

This is useful on systems, that limit the available buffer space by
having XDG_RUNTIME_DIR on a small tmpfs.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 configure.ac  |  2 +-
 shared/os-compatibility.c | 19 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index a460d3b..362bce0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,7 +53,7 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
  [[#include time.h]])
 AC_CHECK_HEADERS([execinfo.h])
 
-AC_CHECK_FUNCS([mkostemp strchrnul initgroups])
+AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
 
 COMPOSITOR_MODULES=wayland-server = 1.3.90 pixman-1
 
diff --git a/shared/os-compatibility.c b/shared/os-compatibility.c
index 4f96dd4..611e7c8 100644
--- a/shared/os-compatibility.c
+++ b/shared/os-compatibility.c
@@ -132,6 +132,12 @@ create_tmpfile_cloexec(char *tmpname)
  * The file is suitable for buffer sharing between processes by
  * transmitting the file descriptor over Unix sockets using the
  * SCM_RIGHTS methods.
+ *
+ * If the C library implements posix_fallocate(), it is used to
+ * guarantee that disk space is available for the file at the
+ * given size. If disk space is insufficent, errno is set to ENOSPC.
+ * If posix_fallocate() is not supported, program may receive
+ * SIGBUS on accessing mmap()'ed file contents instead.
  */
 int
 os_create_anonymous_file(off_t size)
@@ -140,6 +146,7 @@ os_create_anonymous_file(off_t size)
const char *path;
char *name;
int fd;
+   int ret;
 
path = getenv(XDG_RUNTIME_DIR);
if (!path) {
@@ -161,10 +168,20 @@ os_create_anonymous_file(off_t size)
if (fd  0)
return -1;
 
-   if (ftruncate(fd, size)  0) {
+#ifdef HAVE_POSIX_FALLOCATE
+   ret = posix_fallocate(fd, 0, size);
+   if (ret != 0) {
close(fd);
+   errno = ret;
return -1;
}
+#else
+   ret = ftruncate(fd, size);
+   if (ret  0) {
+   close(fd);
+   return -1;
+   }
+#endif
 
return fd;
 }
-- 
1.8.1.5

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


[PATCH weston 2/2] window: handle insufficient buffer space

2013-11-29 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

It is quite possible for os_create_anonymous_file() to fail when trying
to allocate a new wl_shm buffer. Propagate this failure out from
shm_surface_prepare. Most parts of toytoolkit are already avoiding NULL
cairo surfaces.

If cairo surface allocation fails, do not try to call the widget redraw
functions, those are not prepared to deal with NULL. Also do not
schedule a frame callback, this allows us to retry drawing the next
time.

If redraw fails for the main_surface of a window, restore the widget
geometry to what the compositor currently is showing. This keeps the
window visual appearance in sync with application state, so interacting
with the application does not break too badly.

If the very first draw of any window fails, then forcefully exit the
program. E.g. if weston-desktop-shell fails to allocate buffers for the
unlock dialog, w-d-s exits, and weston unlocks the screen automatically.

This patch allows e.g. weston-terminal to stop from enlarging while
resizing, if new sized buffers can no longer the allocated. Even then,
the application stays usable, as it can often repaint in the last
successful size. It does not crash, and the user is able to resize it
smaller, too.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 clients/window.c | 93 +---
 1 file changed, 76 insertions(+), 17 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index a201ebb..0e40ab4 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1083,6 +1083,9 @@ shm_surface_prepare(struct toysurface *base, int dx, int 
dy,
   surface-flags,
   leaf-resize_pool,
   leaf-data);
+   if (!leaf-cairo_surface)
+   return NULL;
+
wl_buffer_add_listener(leaf-data-buffer,
   shm_surface_buffer_listener, surface);
 
@@ -3724,21 +3727,10 @@ hack_prevent_EGL_sub_surface_deadlock(struct window 
*window)
 }
 
 static void
-idle_resize(struct window *window)
+window_do_resize(struct window *window)
 {
struct surface *surface;
 
-   window-resize_needed = 0;
-   window-redraw_needed = 1;
-
-   DBG(from %dx%d to %dx%d\n,
-   window-main_surface-server_allocation.width,
-   window-main_surface-server_allocation.height,
-   window-pending_allocation.width,
-   window-pending_allocation.height);
-
-   hack_prevent_EGL_sub_surface_deadlock(window);
-
widget_set_allocation(window-main_surface-widget,
  window-pending_allocation.x,
  window-pending_allocation.y,
@@ -3761,6 +3753,46 @@ idle_resize(struct window *window)
}
 }
 
+static void
+idle_resize(struct window *window)
+{
+   window-resize_needed = 0;
+   window-redraw_needed = 1;
+
+   DBG(from %dx%d to %dx%d\n,
+   window-main_surface-server_allocation.width,
+   window-main_surface-server_allocation.height,
+   window-pending_allocation.width,
+   window-pending_allocation.height);
+
+   hack_prevent_EGL_sub_surface_deadlock(window);
+
+   window_do_resize(window);
+}
+
+static void
+undo_resize(struct window *window)
+{
+   window-pending_allocation.width =
+   window-main_surface-server_allocation.width;
+   window-pending_allocation.height =
+   window-main_surface-server_allocation.height;
+
+   DBG(back to %dx%d\n,
+   window-main_surface-server_allocation.width,
+   window-main_surface-server_allocation.height);
+
+   window_do_resize(window);
+
+   if (window-pending_allocation.width == 0 
+   window-pending_allocation.height == 0) {
+   fprintf(stderr, Error: Could not draw a surface, 
+   most likely due to insufficient disk space in 
+   %s (XDG_RUNTIME_DIR).\n, getenv(XDG_RUNTIME_DIR));
+   exit(EXIT_FAILURE);
+   }
+}
+
 void
 window_schedule_resize(struct window *window, int width, int height)
 {
@@ -3885,25 +3917,30 @@ static const struct wl_callback_listener listener = {
frame_callback
 };
 
-static void
+static int
 surface_redraw(struct surface *surface)
 {
DBG_OBJ(surface-surface, begin\n);
 
if (!surface-window-redraw_needed  !surface-redraw_needed)
-   return;
+   return 0;
 
/* Whole-window redraw forces a redraw even if the previous has
 * not yet hit the screen.
 */
if (surface-frame_cb) {
if (!surface-window-redraw_needed)
-   return;
+   return 0;
 
DBG_OBJ(surface-frame_cb, cancelled\n);
wl_callback_destroy(surface-frame_cb);
}
 
+   if (!widget_get_cairo_surface(surface-widget)) 

[PATCH weston] tests: add a test causing SIGBUS to the compositor

2013-11-21 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

This tests the wl_shm buffer access wrappers, that are supposed to catch
the invalid accesses to a memory-mapped file beyond EOF.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---

v2: call it bad-buffer instead
---
 tests/Makefile.am   |  4 +++
 tests/bad-buffer-test.c | 77 +
 2 files changed, 81 insertions(+)
 create mode 100644 tests/bad-buffer-test.c

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8e08375..c018db4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -11,6 +11,7 @@ module_tests =\
 weston_test = weston-test.la
 
 weston_tests = \
+   bad_buffer.weston   \
keyboard.weston \
event.weston\
button.weston   \
@@ -97,6 +98,9 @@ weston_test_client_libs = \
../shared/libshared.la  \
libshared-test.la
 
+bad_buffer_weston_SOURCES = bad-buffer-test.c $(weston_test_client_src)
+bad_buffer_weston_LDADD = $(weston_test_client_libs)
+
 keyboard_weston_SOURCES = keyboard-test.c $(weston_test_client_src)
 keyboard_weston_LDADD = $(weston_test_client_libs)
 
diff --git a/tests/bad-buffer-test.c b/tests/bad-buffer-test.c
new file mode 100644
index 000..4f5f810
--- /dev/null
+++ b/tests/bad-buffer-test.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ * Copyright © 2013 Collabora, Ltd.
+ *
+ * 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 express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include unistd.h
+#include sys/types.h
+
+#include ../shared/os-compatibility.h
+#include weston-test-client-helper.h
+
+/* tests, that attempt to crash the compositor on purpose */
+
+static struct wl_buffer *
+create_bad_shm_buffer(struct client *client, int width, int height)
+{
+   struct wl_shm *shm = client-wl_shm;
+   int stride = width * 4;
+   int size = stride * height;
+   struct wl_shm_pool *pool;
+   struct wl_buffer *buffer;
+   int fd;
+
+   fd = os_create_anonymous_file(size);
+   assert(fd = 0);
+
+   pool = wl_shm_create_pool(shm, fd, size);
+   buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride,
+  WL_SHM_FORMAT_ARGB);
+   wl_shm_pool_destroy(pool);
+
+   /* Truncate the file to a small size, so that the compositor
+* will access it out-of-bounds, and hit SIGBUS.
+*/
+   assert(ftruncate(fd, 12) == 0);
+   close(fd);
+
+   return buffer;
+}
+
+FAIL_TEST(test_truncated_shm_file)
+{
+   struct client *client;
+   struct wl_buffer *bad_buffer;
+   struct wl_surface *surface;
+   int frame;
+
+   client = client_create(46, 76, 111, 134);
+   assert(client);
+   surface = client-surface-wl_surface;
+
+   bad_buffer = create_bad_shm_buffer(client, 200, 200);
+
+   wl_surface_attach(surface, bad_buffer, 0, 0);
+   wl_surface_damage(surface, 0, 0, 200, 200);
+   frame_callback_set(surface, frame);
+   wl_surface_commit(surface);
+   frame_callback_wait(client, frame);
+}
-- 
1.8.1.5

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


[PATCH weston 2/3] tests: allow weston test plugin to keep on running

2013-11-21 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

If the environment variable WESTON_TEST_CLIENT_PATH is not set, do not
quit Weston in the test plugin.

This allows one to start Weston with the test plugin manually, and then
run any tests also manually, while observing Weston's behaviour over
time. This is useful for:
- Running a test multiple times and checking if Weston leaks (e.g. with
  Valgrind)
- Running tests manually on a backend that is not x11 or wayland,
  especially the backends that require weston-launch, and therefore
  cannot be used with the 'make check' machinery.

This change should not affect 'make check' behaviour, because there
WESTON_TEST_CLIENT_PATH is always set.

Cc: U. Artie Eoff ullysses.a.e...@intel.com
Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 tests/weston-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/weston-test.c b/tests/weston-test.c
index 0536be4..aebe57d 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -213,7 +213,7 @@ idle_launch_client(void *data)
 
path = getenv(WESTON_TEST_CLIENT_PATH);
if (path == NULL)
-   exit(EXIT_FAILURE);
+   return;
pid = fork();
if (pid == -1)
exit(EXIT_FAILURE);
-- 
1.8.1.5

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


[PATCH weston] compositor: fix sub-surface view stacking order

2013-11-19 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

If you opened a window with sub-surfaces, and then raised another window
on top of that, the underlaying window's main surface was stacked
properly, but the sub-surfaces remained on top of the raised window.
IOW, the raised window was in between the other window and its
sub-surfaces.

This got broken in a7af70436b7dccfacd736626d6719b3e751fd985, Split the
geometry information from weston_surface out into weston_view.

Fix the issues:

In view_list_add_subsurface_view(), the views need to be added to the
end of the list, not to the head. This alone fixes the above problem,
but causes the sub-surface views to be stacked irrespective of their
surface stacking order. The stacking order in this test case is fixed by
the changes to view_list_add(), but for sub-sub-surfaces a similar
change is needed in view_list_add_subsurface_view() too.

In view_list_add(), build the view list in the sub-surface stacking
order, instead of pulling the parent surface always on top. Also handle
the case, when the subsurface_list is completely empty: the parent
surface's view must still be added.

Reported-by: Julien Isorce julien.iso...@collabora.com
Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
Cc: Jason Ekstrand ja...@jlekstrand.net
---
 src/compositor.c | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index b8e0c6e..7c688ef 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1612,11 +1612,18 @@ view_list_add_subsurface_view(struct weston_compositor 
*compositor,
}
 
weston_view_update_transform(view);
-   wl_list_insert(compositor-view_list.next, view-link);
 
-   wl_list_for_each(child, sub-surface-subsurface_list, parent_link)
-   if (child-surface != sub-surface)
+   if (wl_list_empty(sub-surface-subsurface_list)) {
+   wl_list_insert(compositor-view_list.prev, view-link);
+   return;
+   }
+
+   wl_list_for_each(child, sub-surface-subsurface_list, parent_link) {
+   if (child-surface == sub-surface)
+   wl_list_insert(compositor-view_list.prev, view-link);
+   else
view_list_add_subsurface_view(compositor, child, view);
+   }
 }
 
 static void
@@ -1626,11 +1633,18 @@ view_list_add(struct weston_compositor *compositor,
struct weston_subsurface *sub;
 
weston_view_update_transform(view);
-   wl_list_insert(compositor-view_list.prev, view-link);
 
-   wl_list_for_each(sub, view-surface-subsurface_list, parent_link)
-   if (sub-surface != view-surface)
+   if (wl_list_empty(view-surface-subsurface_list)) {
+   wl_list_insert(compositor-view_list.prev, view-link);
+   return;
+   }
+
+   wl_list_for_each(sub, view-surface-subsurface_list, parent_link) {
+   if (sub-surface == view-surface)
+   wl_list_insert(compositor-view_list.prev, view-link);
+   else
view_list_add_subsurface_view(compositor, sub, view);
+   }
 }
 
 static void
-- 
1.8.1.5

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


[PATCH wayland] protocol: add sub-surfaces to the core

2013-11-15 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

The sub-surface protocol was originally committed into Weston on May
10th, 2013, in commit 2396aec6842c709a714f3825dbad9fd88478f2e6. The
design for the protocol had started in the beginning of December 2012. I
think it is high time to move this into the core now.

This patch copies the sub-surface protocol as it was in Weston on Nov
15th, 2013, into Wayland. Weston gets a patch to remove the protocol from
there.

Sub-surface is a wl_surface role. You create a wl_surface as usual, and
assign it the sub-surface role and a parent wl_surface. Sub-surfaces are
an integral part of the parent surface, and stay glued to the parent.
For window management, a window is the union of the top-level
wl_surface and all its sub-surfaces. Sub-surfaces are not clipped to the
parent, and the union of the surface tree can be larger than the
(top-level) wl_surface at its root.

The representative use case for sub-surfaces is a video player window.
When the video content is given its own wl_surface, there is no need to
modify the video frame contents after decoding or copy them into a whole
window sized buffer before submitting it to the compositor. This allows
efficient, zero-copy video presentation paths, where video decoding
hardware produces a (YUV) buffer, which eventually ends up in a
(YUV-capable) hardware overlay and is scanned out directly.

This can also be used for zero-copy presentation of windowed OpenGL
content, where the OpenGL rendering engine does not need to draw or
avoid window decorations.

Sub-surfaces allow mixing different buffer types into the same window,
e.g. software-rendered decorations in wl_shm buffers, and live content
in EGL-based buffers.

However, the sub-surface extension does not offer clipping or scaling
facilities, or accurate presentation timing. Those are topics for
additional extensions.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 protocol/wayland.xml | 217 +++
 1 file changed, 217 insertions(+)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index a1df007..61fde84 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -4,6 +4,7 @@
   copyright
 Copyright © 2008-2011 Kristian Høgsberg
 Copyright © 2010-2011 Intel Corporation
+Copyright © 2012-2013 Collabora, Ltd.
 
 Permission to use, copy, modify, distribute, and sell this
 software and its documentation for any purpose is hereby granted
@@ -1795,4 +1796,220 @@
 
   /interface
 
+  interface name=wl_subcompositor version=1
+description summary=sub-surface compositing
+  The global interface exposing sub-surface compositing capabilities.
+  A wl_surface, that has sub-surfaces associated, is called the
+  parent surface. Sub-surfaces can be arbitrarily nested and create
+  a tree of sub-surfaces.
+
+  The root surface in a tree of sub-surfaces is the main
+  surface. The main surface cannot be a sub-surface, because
+  sub-surfaces must always have a parent.
+
+  A main surface with its sub-surfaces forms a (compound) window.
+  For window management purposes, this set of wl_surface objects is
+  to be considered as a single window, and it should also behave as
+  such.
+
+  The aim of sub-surfaces is to offload some of the compositing work
+  within a window from clients to the compositor. A prime example is
+  a video player with decorations and video in separate wl_surface
+  objects. This should allow the compositor to pass YUV video buffer
+  processing to dedicated overlay hardware when possible.
+/description
+
+request name=destroy type=destructor
+  description summary=unbind from the subcompositor interface
+   Informs the server that the client will not be using this
+   protocol object anymore. This does not affect any other
+   objects, wl_subsurface objects included.
+  /description
+/request
+
+enum name=error
+  entry name=bad_surface value=0
+ summary=the to-be sub-surface is invalid/
+/enum
+
+request name=get_subsurface
+  description summary=give a surface the role sub-surface
+   Create a sub-surface interface for the given surface, and
+   associate it with the given parent surface. This turns a
+   plain wl_surface into a sub-surface.
+
+   The to-be sub-surface must not already have a dedicated
+   purpose, like any shell surface type, cursor image, drag icon,
+   or sub-surface. Otherwise a protocol error is raised.
+  /description
+
+  arg name=id type=new_id interface=wl_subsurface
+   summary=the new subsurface object id/
+  arg name=surface type=object interface=wl_surface
+   summary=the surface to be turned into a sub-surface/
+  arg name=parent type=object interface=wl_surface
+   summary=the parent surface/
+/request
+  /interface
+
+  interface 

[PATCH weston] protocol: move sub-surfaces to Wayland

2013-11-15 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

This reverts commit 2396aec6842c709a714f3825dbad9fd88478f2e6.

This exact version of the sub-surface protocol has been copied into
Wayland core. Therefore it must be removed from here to avoid build
conflicts and useless duplication.

No other changes to sub-surface protocol consumers are needed, the
identical API is now offered by libwayland-client and libwayland-server.

The commit adding sub-surfaces to Wayland is:
Author: Pekka Paalanen pekka.paala...@collabora.co.uk

protocol: add sub-surfaces to the core

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 clients/.gitignore  |   2 -
 clients/Makefile.am |   4 -
 clients/window.h|   1 -
 protocol/Makefile.am|   1 -
 protocol/subsurface.xml | 244 
 src/.gitignore  |   3 -
 src/Makefile.am |   4 -
 src/compositor.c|   1 -
 tests/.gitignore|   2 -
 tests/Makefile.am   |   6 +-
 tests/subsurface-test.c |   1 -
 11 files changed, 1 insertion(+), 268 deletions(-)
 delete mode 100644 protocol/subsurface.xml

diff --git a/clients/.gitignore b/clients/.gitignore
index 23959cc..92e1659 100644
--- a/clients/.gitignore
+++ b/clients/.gitignore
@@ -27,8 +27,6 @@ weston-keyboard
 libtoytoolkit.a
 screenshooter-client-protocol.h
 screenshooter-protocol.c
-subsurface-client-protocol.h
-subsurface-protocol.c
 tablet-shell-client-protocol.h
 tablet-shell-protocol.c
 text-client-protocol.h
diff --git a/clients/Makefile.am b/clients/Makefile.am
index 4f9dc48..032d900 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -97,8 +97,6 @@ libtoytoolkit_la_SOURCES =\
window.h\
text-cursor-position-protocol.c \
text-cursor-position-client-protocol.h  \
-   subsurface-protocol.c   \
-   subsurface-client-protocol.h\
workspaces-protocol.c   \
workspaces-client-protocol.h
 
@@ -227,8 +225,6 @@ BUILT_SOURCES = \
desktop-shell-protocol.c\
tablet-shell-client-protocol.h  \
tablet-shell-protocol.c \
-   subsurface-client-protocol.h\
-   subsurface-protocol.c   \
workspaces-client-protocol.h\
workspaces-protocol.c
 
diff --git a/clients/window.h b/clients/window.h
index 838ea4e..66cf985 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -28,7 +28,6 @@
 #include cairo.h
 #include ../shared/config-parser.h
 #include ../shared/zalloc.h
-#include subsurface-client-protocol.h
 
 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
 
diff --git a/protocol/Makefile.am b/protocol/Makefile.am
index d09d8eb..14a4b5a 100644
--- a/protocol/Makefile.am
+++ b/protocol/Makefile.am
@@ -6,7 +6,6 @@ protocol_sources =  \
text.xml\
input-method.xml\
workspaces.xml  \
-   subsurface.xml  \
text-cursor-position.xml\
wayland-test.xml
 
diff --git a/protocol/subsurface.xml b/protocol/subsurface.xml
deleted file mode 100644
index 9e4a658..000
--- a/protocol/subsurface.xml
+++ /dev/null
@@ -1,244 +0,0 @@
-?xml version=1.0 encoding=UTF-8?
-protocol name=subsurface
-
-  copyright
-Copyright © 2012-2013 Collabora, Ltd.
-
-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 express or implied
-warranty.
-
-THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
-SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
-AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
-THIS SOFTWARE.
-  /copyright
-
-  interface name=wl_subcompositor version=1
-description summary=sub-surface compositing
-  The global interface exposing sub-surface compositing capabilities.
-  A wl_surface, that has sub-surfaces 

[PATCH weston] shared: build fix for config-parser test

2013-06-05 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

One more wayland-util.h not found issue, triggered by having libwayland
installed to a custom prefix.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 shared/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/shared/Makefile.am b/shared/Makefile.am
index 6778b35..edef416 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -36,6 +36,7 @@ TESTS = config-parser-test
 check_PROGRAMS = $(TESTS)
 
 config_parser_test_LDADD = $(COMPOSITOR_LIBS)
+config_parser_test_CFLAGS = $(COMPOSITOR_CFLAGS)
 config_parser_test_SOURCES =   \
config-parser.c \
config-parser.h \
-- 
1.8.1.5

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


[PATCH weston] shared: fix build of libshared-cairo

2013-06-04 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Another case of missing wayland-util.h, as we didn't pass any libwayland
CFLAGS. This is triggerable on a system, where libwayland is installed
in a custom prefix, and pixman, cairo, libpng, and webp are either
not installed or are installed in the standard path.

CONPOSITOR_CFLAGS contains more than just the libwayland CFLAGS, though.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 shared/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/shared/Makefile.am b/shared/Makefile.am
index 323f838..6778b35 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -11,6 +11,7 @@ libshared_la_SOURCES =\
 
 libshared_cairo_la_CFLAGS =\
$(GCC_CFLAGS)   \
+   $(COMPOSITOR_CFLAGS)\
$(PIXMAN_CFLAGS)\
$(CAIRO_CFLAGS) \
$(PNG_CFLAGS)   \
-- 
1.8.1.5

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


[PATCH wayland-web] raspberrypi: more accurate on dependencies

2013-06-03 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Either libraspberrypi-dev package or running rpi-update is needed to get
the display API libraries.

It's not strictly necessary to use rpi-update, but I don't know how old
firmware and libs are in the Raspbian packages, so recommend it still.
---
 raspberrypi.html | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/raspberrypi.html b/raspberrypi.html
index d77a9e1..b1c2a87 100644
--- a/raspberrypi.html
+++ b/raspberrypi.html
@@ -22,14 +22,17 @@ compiling are done directly on the Pi./p
 build dependencies:/p
 pre$ sudo apt-get install build-essential automake libtool bison flex \
 xutils-dev libcairo2-dev libffi-dev libmtdev-dev libjpeg-dev \
-libudev-dev libxcb-xfixes0-dev libxcursor-dev
+libudev-dev libxcb-xfixes0-dev libxcursor-dev libraspberrypi-dev
 /pre
 
 h2Firmware/h2
 
-pMake sure you have the latest Raspberry Pi firmware with the
+pYou may need the latest Raspberry Pi firmware, which you can get with the
 a href=https://github.com/Hexxeh/rpi-update;rpi-update/a tool. A too
-old firmware may cause rpi-backend to malfunction on Raspberry Pi./p
+old firmware may cause rpi-backend to malfunction on Raspberry Pi. Running
+ttrpi-update/tt will overwrite files installed by some raspbian packages
+like libraspberrypi-dev. You can safely try Weston without ttrpi-update/tt
+first, but if you encounter graphics problems, see if it fixes them./p
 
 pYou may want to tweak the following options in
 tt/boot/config.txt/tt:/p
@@ -44,7 +47,7 @@ old firmware may cause rpi-backend to malfunction on 
Raspberry Pi./p
elements. With off-line enabled, an off-screen buffer
is allocated for compositing. When scene complexity
(number and sizes of elements) is high, compositing will
-   happen off-line into the buffer./dd
+   happen off-line into the buffer. bHeavily recommended./b/dd
 /dl
 
 h2Setting up the environment/h2
-- 
1.8.1.5

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


[PATCH wayland-web] raspberrypi: mention Raspbian packages

2013-06-03 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
Cc: Daniel Stone dan...@fooishbar.org
Cc: Alex Bradbury a...@asbradbury.org

---

Darxus, could you wait till tomorrow until pushing this, so Daniel and
Alex can comment, if there's anything to add?

Thanks,
pq
---
 raspberrypi.html | 25 +
 1 file changed, 25 insertions(+)

diff --git a/raspberrypi.html b/raspberrypi.html
index b1c2a87..620a0a8 100644
--- a/raspberrypi.html
+++ b/raspberrypi.html
@@ -16,6 +16,31 @@
 a href=http://www.raspberrypi.org/;Raspberry Pi/a. All commands and
 compiling are done directly on the Pi./p
 
+pHowever, if you just want to try Weston and not build it, there are
+packages./p
+
+blockquote
+h3Raspbian packages/h3
+
+pThere are pre-built Wayland and Weston packages for the
+a href=http://www.raspbian.org/;Raspbian/a distribution./p
+
+pAdd the following line to tt/etc/apt/sources.list/tt file:/p
+predeb http://raspberrypi.collabora.com wheezy rpi
+/pre
+pThen just issue:/p
+presudo apt-get install weston/pre
+
+pThis will install also a script called ttweston-launch/tt
+(not the real ttweston-launch/tt program), which will automatically
+set up ttXDG_RUNTIME_DIR/tt for you and run ttweston/tt.
+Running Weston with this package is as simple as:/p
+preweston-launch/pre
+pNo need to manually set up environment variables. The firmware notes
+below are still worth checking, though./p
+/blockquote
+
+
 h2Build dependencies/h2
 
 pAssuming you are using the Raspbian distribution, install the
-- 
1.8.1.5

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


[PATCH weston] compositor-x11: fix default output scale

2013-05-23 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Default output scale of 256 makes little sense. Actually this is a type
mismatch between wl_fixed and int, probably a leftover from when the
scale factor was proposed as a fixed point number.

Scale 256 probably causes the Window creation to fail, but that actually
leads to a segfault in Mesa libEGL later:

Program received signal SIGSEGV, Segmentation fault.
0  dri2_create_window_surface (drv=0x645060, disp=0x646610, conf=optimized 
out, window=optimized out, attrib_list=optimized out)
at platform_x11.c:291

291surf-SwapInterval = 1;
Here 'surf' is NULL.

1  0x776c0709 in eglCreateWindowSurface (dpy=0x646610, 
config=optimized out, window=58720261, attrib_list=0x0) at eglapi.c:534
2  0x00421549 in gl_renderer_output_create (output=0x673ae0, 
window=58720261) at gl-renderer.c:1661
3  0x741c456b in x11_compositor_create_output (c=0x6388b0, x=0, y=0, 
width=1024, height=640, fullscreen=0, no_input=0,
configured_name=0x0, transform=0, scale=256) at compositor-x11.c:928
4  0x741c5ca0 in x11_compositor_create (display=0x631950, fullscreen=0, 
no_input=0, use_pixman=0, argc=0x7fffda7c,
argv=0x7fffdd18, config_fd=14) at compositor-x11.c:1596
5  0x741c63db in backend_init (display=0x631950, argc=0x7fffda7c, 
argv=0x7fffdd18, config_fd=14) at compositor-x11.c:1746
6  0x0040fcb7 in main (argc=1, argv=0x7fffdd18) at compositor.c:3293

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
Cc: Alexander Larsson al...@redhat.com
---

I guess this could use a companion fix to compositor-x11.c to exit if
the window creation or whatever fails, but I've no idea how to do that
with XCB. Mesa master already checks for NULL 'surf', I am just using an
older version.
---
 src/compositor-x11.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 9d6b6e7..9d106a9 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -1595,7 +1595,7 @@ x11_compositor_create(struct wl_display *display,
for (i = output_count; i  count; i++) {
output = x11_compositor_create_output(c, x, 0, width, height,
  fullscreen, no_input, 
NULL,
- 
WL_OUTPUT_TRANSFORM_NORMAL, wl_fixed_from_int(1));
+ 
WL_OUTPUT_TRANSFORM_NORMAL, 1);
if (output == NULL)
goto err_x11_input;
x = pixman_region32_extents(output-base.region)-x2;
-- 
1.8.1.5

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


[PATCH weston] window: avoid a gcc warning in buffer release handler

2013-05-22 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Apparently some compilers complain about set but not used variables
'available' and 'bufs', but I don't get the warning. Still, separate the
debugging code from shm_surface_buffer_release(), so that we only
compute 'bufs' when it is printed. This should fix the warnings.

The debugging code now prints the shm_surface buffer state before and
after, instead of just after.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 clients/window.c | 48 +++-
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 40c0ef4..627f1e8 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -420,7 +420,9 @@ enum window_location {
 
 static const cairo_user_data_key_t shm_surface_data_key;
 
-#if 0
+/* #define DEBUG */
+
+#ifdef DEBUG
 
 static void
 debug_print(void *proxy, int line, const char *func, const char *fmt, ...)
@@ -893,20 +895,43 @@ to_shm_surface(struct toysurface *base)
 }
 
 static void
+shm_surface_buffer_state_debug(struct shm_surface *surface, const char *msg)
+{
+#ifdef DEBUG
+   struct shm_surface_leaf *leaf;
+   char bufs[MAX_LEAVES + 1];
+   int i;
+
+   for (i = 0; i  MAX_LEAVES; i++) {
+   leaf = surface-leaf[i];
+
+   if (leaf-busy)
+   bufs[i] = 'b';
+   else if (leaf-cairo_surface)
+   bufs[i] = 'a';
+   else
+   bufs[i] = ' ';
+   }
+
+   bufs[MAX_LEAVES] = '\0';
+   DBG_OBJ(surface-surface, %s, leaves [%s]\n, msg, bufs);
+#endif
+}
+
+static void
 shm_surface_buffer_release(void *data, struct wl_buffer *buffer)
 {
struct shm_surface *surface = data;
struct shm_surface_leaf *leaf;
int i;
int free_found;
-   int available = MAX_LEAVES;
-   char bufs[MAX_LEAVES + 1];
+
+   shm_surface_buffer_state_debug(surface, buffer_release before);
 
for (i = 0; i  MAX_LEAVES; i++) {
leaf = surface-leaf[i];
if (leaf-data  leaf-data-buffer == buffer) {
leaf-busy = 0;
-   available = i;
break;
}
}
@@ -917,27 +942,16 @@ shm_surface_buffer_release(void *data, struct wl_buffer 
*buffer)
for (i = 0; i  MAX_LEAVES; i++) {
leaf = surface-leaf[i];
 
-   if (leaf-busy)
-   bufs[i] = 'b';
-   else if (leaf-cairo_surface)
-   bufs[i] = 'a';
-   else
-   bufs[i] = ' ';
-
if (!leaf-cairo_surface || leaf-busy)
continue;
 
if (!free_found)
free_found = 1;
-   else {
+   else
shm_surface_leaf_release(leaf);
-   bufs[i] = '*';
-   }
}
 
-   bufs[MAX_LEAVES] = '\0';
-   DBG_OBJ(surface-surface, leaf %d released, leaves [%s]\n,
-   available, bufs);
+   shm_surface_buffer_state_debug(surface, buffer_release  after);
 }
 
 static const struct wl_buffer_listener shm_surface_buffer_listener = {
-- 
1.8.1.5

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


[PATCH weston 00/18] Raspberry Pi: a new renderer and demos

2013-05-22 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Hi all,

this patch series consists of several independent features, which all come
together in demonstrating the capabilities of Raspberry Pi for running a
desktop.

We add a new rpi-renderer, that replaces the gl-renderer + weston_planes
on RPi. Since it is not as flexible as the gl-renderer, we add some
capability bits to disable incompatible features in Weston.

Weston-desktop-shell gets new features. The major new feature is
exposay, a window overview mode with animated transitions. Another new
feature is optional keyboard-focus animation, which dims unfocused
surfaces. Smaller enhancements include a new wallpaper scaling mode, and
ensuring weston-desktop-shell has finished starting up before the
compositor fades in.

Then there are various smaller fixes and enhancements.

This work is joint effort of the Raspberry Pi foundation and Collabora. I
will later (tomorrow) reply with an email with links to all the related
announcements and blog posts. More details behind those links, and the
individual commits.

Beware of the rough edges, there are some bugs we didn't have time to fix
yet. Most of them need a little effort to discover, though, that's why we
didn't see them earlier. ;-)

This series is also available as a branch:

git://git.collabora.co.uk/git/user/pq/weston.git raspberrypi-dispmanx
http://cgit.collabora.com/git/user/pq/weston.git/log/?h=raspberrypi-dispmanx

There is also a patch for the RPi building guide on the Wayland website.


Daniel Stone (4):
  Add modifier-only binding
  Add move/scale animation
  Shell: Add Exposay
  configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS

Louis-Francis Ratté-Boulianne (3):
  animation: Make zoom animation renders better and smoother
  compositor, shell: Add animation to measure desktop fps
  xwayland: Fix the race condition when mapping a surface

Louis-Francis Ratté-Boulianne (3):
  toytoolkit: Make the window resizing optimization optional
  animation, shell: add kbd focus change animation
  shell: Fix calculation of center point in surface rotation

Pekka Paalanen (8):
  compositor: add capability flag for arbitrary surface rotation
  compositor: add capability CAPTURE_YFLIP
  rpi: add a Dispmanx renderer
  rpi: switch to rpi-renderer
  rpi: remove weston_plane support
  shell: wait for desktop-shell init before fade in
  desktop-shell: new wallpaper mode scale-crop
  screenshooter: print info to log

 clients/desktop-shell.c   |   73 ++-
 clients/window.c  |6 +-
 configure.ac  |   13 +-
 man/weston.ini.man|9 +-
 protocol/desktop-shell.xml|   13 +-
 shared/cairo-util.c   |2 +-
 shared/config-parser.c|3 +-
 shared/image-loader.c |2 +-
 shared/matrix.c   |2 +
 shared/option-parser.c|2 +
 shared/os-compatibility.c |2 +-
 src/Makefile.am   |2 +
 src/animation.c   |  128 +++-
 src/bindings.c|   60 ++
 src/clipboard.c   |2 +-
 src/cms-helper.c  |4 +-
 src/cms-static.c  |5 +-
 src/compositor-drm.c  |6 +-
 src/compositor-fbdev.c|2 +-
 src/compositor-headless.c |4 +-
 src/compositor-rdp.c  |4 +-
 src/compositor-rpi.c  |  898 +++
 src/compositor-wayland.c  |5 +-
 src/compositor-x11.c  |4 +-
 src/compositor.c  |   71 ++-
 src/compositor.h  |   48 ++
 src/evdev-touchpad.c  |2 +
 src/evdev.c   |2 +
 src/filter.c  |2 +
 src/gl-renderer.c |4 +-
 src/gl-renderer.h |7 +-
 src/input.c   |   38 ++
 src/launcher-util.c   |2 +
 src/libbacklight.c|2 +-
 src/log.c |2 +
 src/noop-renderer.c   |2 +-
 src/pixman-renderer.c |4 +-
 src/rpi-bcm-stubs.h   |   39 ++
 src/rpi-renderer.c| 1370 +
 src/rpi-renderer.h|   48 ++
 src/screenshooter.c   |  103 +++-
 src/shell.c   | 1078 ++--
 src/tablet-shell.c|2 +
 src/text-backend.c|2 +
 src/tty.c |2 +
 src/udev-seat.c   |2 +
 src/weston-launch.c   |2 -
 src/xwayland/launcher.c   |2 +-
 src/xwayland/selection.c  |2 +-
 src/xwayland/window-manager.c |   20 +-
 src/zoom.c|2 +
 51 files changed, 3166 insertions(+), 945 deletions(-)
 create mode 100644 src/rpi-renderer.c
 create mode 100644 src/rpi-renderer.h

-- 
1.8.1.5


Thanks,
pq

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


[PATCH weston 01/18] compositor: add capability flag for arbitrary surface rotation

2013-05-22 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

The upcoming rpi-renderer cannot handle arbitrary rotations. Introduce
Weston capability bits, and add a bit for arbitrary rotation. GL and
Pixman renderers support it.

Shell or any other module must not produce surface transformations with
rotation, if the capability bit is not set. Do not register the surface
rotation binding in desktop shell, if arbitary rotation is not
supported.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/compositor.c  | 24 
 src/compositor.h  |  6 ++
 src/gl-renderer.c |  1 +
 src/pixman-renderer.c |  1 +
 src/shell.c   |  7 +--
 5 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index f67028e..657e134 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2820,6 +2820,28 @@ weston_version(int *major, int *minor, int *micro)
*micro = WESTON_VERSION_MICRO;
 }
 
+static const struct {
+   uint32_t bit;
+   const char *desc;
+} capability_strings[] = {
+   { WESTON_CAP_ROTATION_ANY, arbitrary surface rotation: },
+};
+
+static void
+weston_compositor_log_capabilities(struct weston_compositor *compositor)
+{
+   unsigned i;
+   int yes;
+
+   weston_log(Compositor capabilities:\n);
+   for (i = 0; i  ARRAY_LENGTH(capability_strings); i++) {
+   yes = compositor-capabilities  capability_strings[i].bit;
+   weston_log_continue(STAMP_SPACE %s %s\n,
+   capability_strings[i].desc,
+   yes ? yes : no);
+   }
+}
+
 static int on_term_signal(int signal_number, void *data)
 {
struct wl_display *display = data;
@@ -3214,6 +3236,8 @@ int main(int argc, char *argv[])
goto out;
}
 
+   weston_compositor_log_capabilities(ec);
+
if (wl_display_add_socket(display, socket_name)) {
weston_log(fatal: failed to add socket: %m\n);
ret = EXIT_FAILURE;
diff --git a/src/compositor.h b/src/compositor.h
index 318fc0d..e7d19b0 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -484,6 +484,11 @@ struct weston_renderer {
void (*destroy)(struct weston_compositor *ec);
 };
 
+enum weston_capability {
+   /* backend/renderer supports arbitrary rotation */
+   WESTON_CAP_ROTATION_ANY = 0x0001,
+};
+
 struct weston_compositor {
struct wl_signal destroy_signal;
 
@@ -525,6 +530,7 @@ struct weston_compositor {
 
/* Repaint state. */
struct weston_plane primary_plane;
+   uint32_t capabilities; /* combination of enum weston_capability */
 
uint32_t focus;
 
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index be74eba..87b3be0 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1837,6 +1837,7 @@ gl_renderer_create(struct weston_compositor *ec, 
EGLNativeDisplayType display,
}
 
ec-renderer = gr-base;
+   ec-capabilities |= WESTON_CAP_ROTATION_ANY;
 
return 0;
 
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index 60800bc..ad79c95 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -496,6 +496,7 @@ pixman_renderer_init(struct weston_compositor *ec)
renderer-base.destroy_surface = pixman_renderer_destroy_surface;
renderer-base.destroy = pixman_renderer_destroy;
ec-renderer = renderer-base;
+   ec-capabilities |= WESTON_CAP_ROTATION_ANY;
 
weston_compositor_add_debug_binding(ec, KEY_R,
debug_binding, ec);
diff --git a/src/shell.c b/src/shell.c
index 7261570..e23c09b 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -4247,8 +4247,11 @@ shell_add_bindings(struct weston_compositor *ec, struct 
desktop_shell *shell)
 shell);
weston_compositor_add_button_binding(ec, BTN_MIDDLE, mod,
 resize_binding, shell);
-   weston_compositor_add_button_binding(ec, BTN_RIGHT, mod,
-rotate_binding, NULL);
+
+   if (ec-capabilities  WESTON_CAP_ROTATION_ANY)
+   weston_compositor_add_button_binding(ec, BTN_RIGHT, mod,
+rotate_binding, NULL);
+
weston_compositor_add_key_binding(ec, KEY_TAB, mod, switcher_binding,
  shell);
weston_compositor_add_key_binding(ec, KEY_F9, mod, backlight_binding,
-- 
1.8.1.5

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


[PATCH weston 02/18] compositor: add capability CAPTURE_YFLIP

2013-05-22 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

Both GL and pixman renderer (pixman probably only because GL did?)
return the screen capture image as y-flipped, therefore Weston y-flips
it again. However, the future rpi-renderer can produce only right-way-up
(non-flipped) screen captures, and does not need an y-flip.

Add a capability flag for y-flip, which the rpi-renderer will not set,
to get screen captures the right way up.

The wcap recording code needs yet another temporary buffer for the
non-flipped case, since the WCAP format is flipped, and the code
normally overwrites the input image as it compresses it. This becomes
difficult, if the compressor is supposed to flip while processing.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/compositor.c  |  3 +-
 src/compositor.h  |  3 ++
 src/gl-renderer.c |  1 +
 src/pixman-renderer.c |  1 +
 src/screenshooter.c   | 96 ---
 5 files changed, 83 insertions(+), 21 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 657e134..33010dd 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2821,10 +2821,11 @@ weston_version(int *major, int *minor, int *micro)
 }
 
 static const struct {
-   uint32_t bit;
+   uint32_t bit; /* enum weston_capability */
const char *desc;
 } capability_strings[] = {
{ WESTON_CAP_ROTATION_ANY, arbitrary surface rotation: },
+   { WESTON_CAP_CAPTURE_YFLIP, screen capture uses y-flip: },
 };
 
 static void
diff --git a/src/compositor.h b/src/compositor.h
index e7d19b0..efc4102 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -487,6 +487,9 @@ struct weston_renderer {
 enum weston_capability {
/* backend/renderer supports arbitrary rotation */
WESTON_CAP_ROTATION_ANY = 0x0001,
+
+   /* screencaptures need to be y-flipped */
+   WESTON_CAP_CAPTURE_YFLIP= 0x0002,
 };
 
 struct weston_compositor {
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 87b3be0..4915b90 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1838,6 +1838,7 @@ gl_renderer_create(struct weston_compositor *ec, 
EGLNativeDisplayType display,
 
ec-renderer = gr-base;
ec-capabilities |= WESTON_CAP_ROTATION_ANY;
+   ec-capabilities |= WESTON_CAP_CAPTURE_YFLIP;
 
return 0;
 
diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
index ad79c95..36563c6 100644
--- a/src/pixman-renderer.c
+++ b/src/pixman-renderer.c
@@ -497,6 +497,7 @@ pixman_renderer_init(struct weston_compositor *ec)
renderer-base.destroy = pixman_renderer_destroy;
ec-renderer = renderer-base;
ec-capabilities |= WESTON_CAP_ROTATION_ANY;
+   ec-capabilities |= WESTON_CAP_CAPTURE_YFLIP;
 
weston_compositor_add_debug_binding(ec, KEY_R,
debug_binding, ec);
diff --git a/src/screenshooter.c b/src/screenshooter.c
index ae97b4e..6f53fad 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -62,6 +62,13 @@ copy_bgra_yflip(uint8_t *dst, uint8_t *src, int height, int 
stride)
 }
 
 static void
+copy_bgra(uint8_t *dst, uint8_t *src, int height, int stride)
+{
+   /* TODO: optimize this out */
+   memcpy(dst, src, height * stride);
+}
+
+static void
 copy_row_swap_RB(void *vdst, void *vsrc, int bytes)
 {
uint32_t *dst = vdst;
@@ -92,18 +99,32 @@ copy_rgba_yflip(uint8_t *dst, uint8_t *src, int height, int 
stride)
 }
 
 static void
+copy_rgba(uint8_t *dst, uint8_t *src, int height, int stride)
+{
+   uint8_t *end;
+
+   end = dst + height * stride;
+   while (dst  end) {
+   copy_row_swap_RB(dst, src, stride);
+   dst += stride;
+   src += stride;
+   }
+}
+
+static void
 screenshooter_frame_notify(struct wl_listener *listener, void *data)
 {
struct screenshooter_frame_listener *l =
container_of(listener,
 struct screenshooter_frame_listener, listener);
struct weston_output *output = data;
+   struct weston_compositor *compositor = output-compositor;
int32_t stride;
uint8_t *pixels, *d, *s;
 
output-disable_planes--;
wl_list_remove(listener-link);
-   stride = l-buffer-width * 
(PIXMAN_FORMAT_BPP(output-compositor-read_format) / 8);
+   stride = l-buffer-width * (PIXMAN_FORMAT_BPP(compositor-read_format) 
/ 8);
pixels = malloc(stride * l-buffer-height);
 
if (pixels == NULL) {
@@ -112,8 +133,8 @@ screenshooter_frame_notify(struct wl_listener *listener, 
void *data)
return;
}
 
-   output-compositor-renderer-read_pixels(output,
-output-compositor-read_format, pixels,
+   compositor-renderer-read_pixels(output,
+compositor-read_format, pixels,
 0, 0, output-current-width,
 

[PATCH weston 04/18] rpi: switch to rpi-renderer

2013-05-22 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

Replace the GL renderer with the new rpi-renderer on the Raspberry Pi
backend. This makes Weston on rpi not use EGL or GL anymore, at all.

The weston_plane feature is disabled, since the rpi-renderer does the
same, but better.

Add a command line option to select the output transform. It is not a
weston.ini option for now, since the rpi backend does not read the
configuration file yet. Hopefully that will be done later with some
shared code.

Add the rpi options to 'weston --help' output.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 configure.ac |   4 +-
 src/compositor-rpi.c | 171 +--
 src/compositor.c |  10 +++
 3 files changed, 97 insertions(+), 88 deletions(-)

diff --git a/configure.ac b/configure.ac
index 93a6720..2aec1bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -146,9 +146,9 @@ AC_ARG_ENABLE(rpi-compositor,
  AS_HELP_STRING([--disable-rpi-compositor],
 [do not build the Raspberry Pi backend]),,
  enable_rpi_compositor=yes)
-AM_CONDITIONAL(ENABLE_RPI_COMPOSITOR, test x$enable_rpi_compositor = xyes 
-a x$enable_egl = xyes)
+AM_CONDITIONAL(ENABLE_RPI_COMPOSITOR, test x$enable_rpi_compositor = xyes)
 have_bcm_host=no
-if test x$enable_rpi_compositor = xyes -a x$enable_egl = xyes; then
+if test x$enable_rpi_compositor = xyes; then
   AC_DEFINE([BUILD_RPI_COMPOSITOR], [1], [Build the compositor for Raspberry 
Pi])
   PKG_CHECK_MODULES(RPI_COMPOSITOR, [libudev = 136 mtdev = 1.1.0])
   PKG_CHECK_MODULES(RPI_BCM_HOST, [bcm_host],
diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index 3cb2b56..f83e55c 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2008-2011 Kristian Høgsberg
  * Copyright © 2011 Intel Corporation
- * Copyright © 2012 Raspberry Pi Foundation
+ * Copyright © 2012-2013 Raspberry Pi Foundation
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
@@ -44,7 +44,7 @@
 #endif
 
 #include compositor.h
-#include gl-renderer.h
+#include rpi-renderer.h
 #include evdev.h
 
 /*
@@ -148,8 +148,6 @@ struct rpi_output {
struct rpi_flippipe flippipe;
 
DISPMANX_DISPLAY_HANDLE_T display;
-   EGL_DISPMANX_WINDOW_T egl_window;
-   DISPMANX_ELEMENT_HANDLE_T egl_element;
 
struct wl_list element_list; /* struct rpi_element */
struct wl_list old_element_list; /* struct rpi_element */
@@ -910,9 +908,12 @@ rpi_output_repaint(struct weston_output *base, 
pixman_region32_t *damage)
DISPMANX_UPDATE_HANDLE_T update;
int layer = 1;
 
-   DBG(%s\n, __func__);
+   DBG(frame update start\n);
 
-   update = vc_dispmanx_update_start(0);
+   /* Update priority higher than in rpi-renderer's
+* output destroy function, see rpi_output_destroy().
+*/
+   update = vc_dispmanx_update_start(1);
 
/* update all live elements */
wl_list_for_each(element, output-element_list, link) {
@@ -923,20 +924,16 @@ rpi_output_repaint(struct weston_output *base, 
pixman_region32_t *damage)
/* remove all unused elements */
rpi_remove_elements(output-old_element_list, update);
 
-   /* schedule callback to rpi_output_update_complete() */
-   rpi_dispmanx_update_submit(update, output);
-
-   /* XXX: if there is anything to composite in GL,
-* framerate seems to suffer */
-   /* XXX: optimise the renderer for the case of nothing to render */
-   /* XXX: if nothing to render, remove the element...
-* but how, is destroying the EGLSurface a bad performance hit?
-*/
+   rpi_renderer_set_update_handle(output-base, update);
compositor-base.renderer-repaint_output(output-base, damage);
 
pixman_region32_subtract(primary_plane-damage,
 primary_plane-damage, damage);
 
+   /* schedule callback to rpi_output_update_complete() */
+   rpi_dispmanx_update_submit(update, output);
+   DBG(frame update submitted\n);
+
/* Move the list of elements into the old_element_list. */
wl_list_insert_list(output-old_element_list, output-element_list);
wl_list_init(output-element_list);
@@ -945,7 +942,9 @@ rpi_output_repaint(struct weston_output *base, 
pixman_region32_t *damage)
 static void
 rpi_output_update_complete(struct rpi_output *output, uint64_t time)
 {
+   DBG(frame update complete(% PRIu64 )\n, time);
rpi_output_destroy_old_elements(output);
+   rpi_renderer_finish_frame(output-base);
weston_output_finish_frame(output-base, time);
 }
 
@@ -958,15 +957,12 @@ rpi_output_destroy(struct weston_output *base)
 
DBG(%s\n, __func__);
 
-   rpi_flippipe_release(output-flippipe);
-
update = vc_dispmanx_update_start(0);

[PATCH weston 05/18] rpi: remove weston_plane support

2013-05-22 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

There is no need to support weston_plane anymore.
The max-planes option is removed as unused.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/compositor-rpi.c | 727 ---
 1 file changed, 727 deletions(-)

diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c
index f83e55c..64ef0ff 100644
--- a/src/compositor-rpi.c
+++ b/src/compositor-rpi.c
@@ -47,51 +47,6 @@
 #include rpi-renderer.h
 #include evdev.h
 
-/*
- * Dispmanx API offers alpha-blended overlays for hardware compositing.
- * The final composite consists of dispmanx elements, and their contents:
- * the dispmanx resource assigned to the element. The elements may be
- * scanned out directly, or composited to a temporary surface, depending on
- * how the firmware decides to handle the scene. Updates to multiple elements
- * may be queued in a single dispmanx update object, resulting in atomic and
- * vblank synchronized display updates.
- *
- * To avoid tearing and display artifacts, the current dispmanx resource in a
- * dispmanx element must not be touched. Therefore each element must be
- * double-buffered, using two resources, the front and the back. The update
- * sequence is:
- * 0. the front resource is already in-use, the back resource is unused
- * 1. write data into the back resource
- * 2. submit an element update, back becomes in-use
- * 3. swap back and front pointers (both are in-use now)
- * 4. wait for update_submit completion, the new back resource becomes unused
- *
- * A resource may be destroyed only, when the update removing the element has
- * completed. Otherwise you risk showing an incomplete composition.
- *
- * The dispmanx element used as the native window for EGL does not need
- * manually allocated resources, EGL does double-buffering internally.
- * Unfortunately it also means, that we cannot alternate between two
- * buffers like the DRM backend does, since we have no control over what
- * resources EGL uses. We are forced to use EGL_BUFFER_PRESERVED as the
- * EGL_SWAP_BEHAVIOR to avoid repainting the whole output every frame.
- *
- * We also cannot bundle eglSwapBuffers into our own display update, which
- * means that Weston's primary plane updates and the overlay updates may
- * happen unsynchronized.
- */
-
-#ifndef ELEMENT_CHANGE_LAYER
-/* copied from interface/vmcs_host/vc_vchi_dispmanx.h of userland.git */
-#define ELEMENT_CHANGE_LAYER  (10)
-#define ELEMENT_CHANGE_OPACITY(11)
-#define ELEMENT_CHANGE_DEST_RECT  (12)
-#define ELEMENT_CHANGE_SRC_RECT   (13)
-#define ELEMENT_CHANGE_MASK_RESOURCE  (14)
-#define ELEMENT_CHANGE_TRANSFORM  (15)
-#endif
-
-/* Enabling this debugging incurs a significant performance hit */
 #if 0
 #define DBG(...) \
weston_log(__VA_ARGS__)
@@ -99,40 +54,9 @@
 #define DBG(...) do {} while (0)
 #endif
 
-/* If we had a fully featured vc_dispmanx_resource_write_data()... */
-/*#define HAVE_RESOURCE_WRITE_DATA_RECT 1*/
-
 struct rpi_compositor;
 struct rpi_output;
 
-struct rpi_resource {
-   DISPMANX_RESOURCE_HANDLE_T handle;
-   int width;
-   int height; /* height of the image (valid pixel data) */
-   int stride; /* bytes */
-   int buffer_height; /* height of the buffer */
-   VC_IMAGE_TYPE_T ifmt;
-};
-
-struct rpi_element {
-   struct wl_list link;
-   struct weston_plane plane;
-   struct rpi_output *output;
-
-   DISPMANX_ELEMENT_HANDLE_T handle;
-   int layer;
-   int need_swap;
-   int single_buffer;
-
-   struct rpi_resource resources[2];
-   struct rpi_resource *front;
-   struct rpi_resource *back;
-   pixman_region32_t prev_damage;
-
-   struct weston_surface *surface;
-   struct wl_listener surface_destroy_listener;
-};
-
 struct rpi_flippipe {
int readfd;
int writefd;
@@ -148,9 +72,6 @@ struct rpi_output {
struct rpi_flippipe flippipe;
 
DISPMANX_DISPLAY_HANDLE_T display;
-
-   struct wl_list element_list; /* struct rpi_element */
-   struct wl_list old_element_list; /* struct rpi_element */
 };
 
 struct rpi_seat {
@@ -169,7 +90,6 @@ struct rpi_compositor {
struct udev *udev;
struct tty *tty;
 
-   int max_planes; /* per output, really */
int single_buffer;
 };
 
@@ -191,425 +111,6 @@ to_rpi_compositor(struct weston_compositor *base)
return container_of(base, struct rpi_compositor, base);
 }
 
-static inline int
-int_max(int a, int b)
-{
-   return a  b ? a : b;
-}
-
-static void
-rpi_resource_init(struct rpi_resource *resource)
-{
-   resource-handle = DISPMANX_NO_HANDLE;
-}
-
-static void
-rpi_resource_release(struct rpi_resource *resource)
-{
-   if (resource-handle == DISPMANX_NO_HANDLE)
-   return;
-
-   vc_dispmanx_resource_delete(resource-handle);
-   DBG(resource %p release\n, resource);
-   resource-handle = DISPMANX_NO_HANDLE;
-}
-

[PATCH weston 06/18] shell: wait for desktop-shell init before fade in

2013-05-22 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

On Raspberry Pi, weston-desktop-shell is so slow to start, that the
compositor has time to run the fade-in before the wallpaper is up. The
user launching Weston sees the screen flipping to black, the fbcon
fading in, and then the desktop popping up.

To fix this, wait for the weston-desktop-shell to draw
everything before starting the initial fade-in. A new request is
added to the private desktop-shell protocol to signal it. If a
desktop-shell client does not support the new request, the fade-in
happens already at bind time.

If weston-desktop-shell crashes, or does not send the 'desktop_ready'
request in 15 seconds, the compositor will fade in anyway. This should
avoid a blocked screen in case weston-desktop-shell malfunction.

shell_fade_startup() does not directly start the fade-in but schedules
an idle callback, so that the compositor can process all pending events
before starting the fade clock. Otherwise (on RPi) we risk skipping part
of the animation. Yes, it is a hack, that should have been done in
window.c and weston-desktop-shell instead.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 clients/desktop-shell.c|  46 +-
 protocol/desktop-shell.xml |  13 -
 src/shell.c| 119 +++--
 3 files changed, 162 insertions(+), 16 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 3949975..4a39653 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -49,6 +49,7 @@ extern char **environ; /* defined by libc */
 struct desktop {
struct display *display;
struct desktop_shell *shell;
+   uint32_t interface_version;
struct unlock_dialog *unlock_dialog;
struct task unlock_task;
struct wl_list outputs;
@@ -57,6 +58,8 @@ struct desktop {
struct widget *grab_widget;
 
enum cursor_type grab_cursor;
+
+   int painted;
 };
 
 struct surface {
@@ -72,12 +75,14 @@ struct panel {
struct widget *widget;
struct wl_list launcher_list;
struct panel_clock *clock;
+   int painted;
 };
 
 struct background {
struct surface base;
struct window *window;
struct widget *widget;
+   int painted;
 };
 
 struct output {
@@ -175,6 +180,38 @@ show_menu(struct panel *panel, struct input *input, 
uint32_t time)
 x - 10, y - 10, menu_func, entries, 4);
 }
 
+static int
+is_desktop_painted(struct desktop *desktop)
+{
+   struct output *output;
+
+   wl_list_for_each(output, desktop-outputs, link) {
+   if (output-panel  !output-panel-painted)
+   return 0;
+   if (output-background  !output-background-painted)
+   return 0;
+   }
+
+   return 1;
+}
+
+static void
+check_desktop_ready(struct window *window)
+{
+   struct display *display;
+   struct desktop *desktop;
+
+   display = window_get_display(window);
+   desktop = display_get_user_data(display);
+
+   if (!desktop-painted  is_desktop_painted(desktop)) {
+   desktop-painted = 1;
+
+   if (desktop-interface_version = 2)
+   desktop_shell_desktop_ready(desktop-shell);
+   }
+}
+
 static void
 panel_launcher_activate(struct panel_launcher *widget)
 {
@@ -263,6 +300,8 @@ panel_redraw_handler(struct widget *widget, void *data)
 
cairo_destroy(cr);
cairo_surface_destroy(surface);
+   panel-painted = 1;
+   check_desktop_ready(panel-window);
 }
 
 static int
@@ -694,6 +733,9 @@ background_draw(struct widget *widget, void *data)
  allocation.width, allocation.height);
wl_surface_set_opaque_region(window_get_wl_surface(background-window), 
opaque);
wl_region_destroy(opaque);
+
+   background-painted = 1;
+   check_desktop_ready(background-window);
 }
 
 static void
@@ -1046,8 +1088,10 @@ global_handler(struct display *display, uint32_t id,
struct desktop *desktop = data;
 
if (!strcmp(interface, desktop_shell)) {
+   desktop-interface_version = (version  2) ? version : 2;
desktop-shell = display_bind(desktop-display,
- id, desktop_shell_interface, 1);
+ id, desktop_shell_interface,
+ desktop-interface_version);
desktop_shell_add_listener(desktop-shell, listener, desktop);
} else if (!strcmp(interface, wl_output)) {
create_output(desktop, id);
diff --git a/protocol/desktop-shell.xml b/protocol/desktop-shell.xml
index d48c3dd..65e44a7 100644
--- a/protocol/desktop-shell.xml
+++ b/protocol/desktop-shell.xml
@@ -1,6 +1,6 @@
 protocol name=desktop
 
-  interface name=desktop_shell version=1
+  interface name=desktop_shell version=2
 description 

[PATCH weston 07/18] desktop-shell: new wallpaper mode scale-crop

2013-05-22 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

Scale-crop mode scales the wallpaper to tightly fill the whole output,
but preserving wallpaper aspect ratio. If aspect ratio differs from the
output's, the wallpaper is centered cutting it from top/bottom or
left/right.

Add this to the weston.ini man page, and explain all three modes.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 clients/desktop-shell.c | 27 ++-
 man/weston.ini.man  |  9 +++--
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 4a39653..1fc8753 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -664,6 +664,7 @@ panel_add_launcher(struct panel *panel, const char *icon, 
const char *path)
 
 enum {
BACKGROUND_SCALE,
+   BACKGROUND_SCALE_CROP,
BACKGROUND_TILE
 };
 
@@ -675,7 +676,9 @@ background_draw(struct widget *widget, void *data)
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
cairo_t *cr;
-   double sx, sy;
+   double im_w, im_h;
+   double sx, sy, s;
+   double tx, ty;
struct rectangle allocation;
int type = -1;
struct display *display;
@@ -695,6 +698,8 @@ background_draw(struct widget *widget, void *data)
 
if (strcmp(key_background_type, scale) == 0)
type = BACKGROUND_SCALE;
+   else if (strcmp(key_background_type, scale-crop) == 0)
+   type = BACKGROUND_SCALE_CROP;
else if (strcmp(key_background_type, tile) == 0)
type = BACKGROUND_TILE;
else
@@ -702,20 +707,32 @@ background_draw(struct widget *widget, void *data)
key_background_type);
 
if (image  type != -1) {
+   im_w = cairo_image_surface_get_width(image);
+   im_h = cairo_image_surface_get_height(image);
+   sx = im_w / allocation.width;
+   sy = im_h / allocation.height;
+
pattern = cairo_pattern_create_for_surface(image);
+
switch (type) {
case BACKGROUND_SCALE:
-   sx = (double) cairo_image_surface_get_width(image) /
-   allocation.width;
-   sy = (double) cairo_image_surface_get_height(image) /
-   allocation.height;
cairo_matrix_init_scale(matrix, sx, sy);
cairo_pattern_set_matrix(pattern, matrix);
break;
+   case BACKGROUND_SCALE_CROP:
+   s = (sx  sy) ? sx : sy;
+   /* align center */
+   tx = (im_w - s * allocation.width) * 0.5;
+   ty = (im_h - s * allocation.height) * 0.5;
+   cairo_matrix_init_translate(matrix, tx, ty);
+   cairo_matrix_scale(matrix, s, s);
+   cairo_pattern_set_matrix(pattern, matrix);
+   break;
case BACKGROUND_TILE:
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
break;
}
+
cairo_set_source(cr, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy(image);
diff --git a/man/weston.ini.man b/man/weston.ini.man
index d37654a..c3e5747 100644
--- a/man/weston.ini.man
+++ b/man/weston.ini.man
@@ -118,8 +118,13 @@ The entries that can appear in this section are:
 sets the path for the background image file (string).
 .TP 7
 .BI background-type= tile
-determines how the background image is drawn (string). Can be scale or
-tile (default).
+determines how the background image is drawn (string). Can be
+.BR scale ,  scale-crop  or  tile  (default).
+Scale means scaled to fit the output precisely, not preserving aspect ratio.
+Scale-crop preserves aspect ratio, scales the background image just big
+enough to cover the output, and centers it. The image ends up cropped from
+left and right, or top and bottom, if the aspect ratio does not match the
+output. Tile repeats the background image to fill the output.
 .TP 7
 .BI background-color= 0xAARRGGBB
 sets the color of the background (unsigned integer). The hexadecimal
-- 
1.8.1.5

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


[PATCH weston 08/18] toytoolkit: Make the window resizing optimization optional

2013-05-22 Thread ppaalanen
From: Louis-Francis Ratté-Boulianne l...@collabora.com

Whether or not a shm pool is used for resizing is now configurable at
build time (--disable-resize-optimization).

[pq: removed an unnecessary hunk from the patch]
---
 clients/window.c | 2 ++
 configure.ac | 7 +++
 2 files changed, 9 insertions(+)

diff --git a/clients/window.c b/clients/window.c
index 627f1e8..3f54111 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1004,6 +1004,7 @@ shm_surface_prepare(struct toysurface *base, int dx, int 
dy,
if (leaf-cairo_surface)
cairo_surface_destroy(leaf-cairo_surface);
 
+#ifdef USE_RESIZE_POOL
if (resize_hint  !leaf-resize_pool) {
/* Create a big pool to allocate from, while continuously
 * resizing. Mmapping a new pool in the server
@@ -1014,6 +1015,7 @@ shm_surface_prepare(struct toysurface *base, int dx, int 
dy,
leaf-resize_pool = shm_pool_create(surface-display,
6 * 1024 * 1024);
}
+#endif
 
leaf-cairo_surface =
display_create_shm_surface(surface-display, rect,
diff --git a/configure.ac b/configure.ac
index 2aec1bb..323bd87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -239,6 +239,13 @@ if test x$enable_clients = xyes; then
   PKG_CHECK_MODULES(PANGO, [pangocairo], [have_pango=yes], [have_pango=no])
 fi
 
+AC_ARG_ENABLE(resize-optimization,
+  AS_HELP_STRING([--disable-resize-optimization],
+ [disable resize optimization allocating a big 
buffer in toytoolkit]),,
+  enable_resize_optimization=yes)
+AS_IF([test x$enable_resize_optimization = xyes],
+  [AC_DEFINE([USE_RESIZE_POOL], [1], [Use resize memory pool as a 
performance optimization])])
+
 AC_ARG_ENABLE(weston-launch, [  --enable-weston-launch],, 
enable_weston_launch=yes)
 AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes)
 if test x$enable_weston_launch == xyes; then
-- 
1.8.1.5

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


[PATCH weston 09/18] screenshooter: print info to log

2013-05-22 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

Print the recording info to Weston log, not stderr.

Also fix the frame counter.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/screenshooter.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/screenshooter.c b/src/screenshooter.c
index 6f53fad..dde052f 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -432,6 +432,7 @@ weston_recorder_frame_notify(struct wl_listener *listener, 
void *data)
}
 
pixman_region32_fini(damage);
+   recorder-count++;
 }
 
 static void
@@ -525,13 +526,13 @@ recorder_binding(struct weston_seat *seat, uint32_t time, 
uint32_t key, void *da
recorder = container_of(listener, struct weston_recorder,
frame_listener);
 
-   fprintf(stderr,
+   weston_log(
stopping recorder, total file size %dM, %d frames\n,
recorder-total / (1024 * 1024), recorder-count);
 
weston_recorder_destroy(recorder);
} else {
-   fprintf(stderr, starting recorder, file %s\n, filename);
+   weston_log(starting recorder, file %s\n, filename);
weston_recorder_create(output, filename);
}
 }
-- 
1.8.1.5

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


[PATCH weston 10/18] animation, shell: add kbd focus change animation

2013-05-22 Thread ppaalanen
From: Louis-Francis Ratté-Boulianne l...@collabora.com

When enabled, this will make all but the keyboard-focused window dim.
Also the background gets dimmed, if there are any windows open. The
panel is not dimmed.

When the keyboard focus changes, the change in dimming is animated.

The dimming is implemented with transparent solid-color surfaces, two at
most. The net effect of two overlapping dim surfaces is kept constant
during animations (stable fade animation).

There is a new weston.ini option focus-animation, that defaults to
none, and can be set to dim-layer to enable the focus change
animation.

[pq: Sliced, squashed, and rebased the patch series. Fixed surface alpha
interaction with the switcher. Wrote the commit message.]
---
 src/animation.c  |  52 ++--
 src/compositor.h |   8 ++
 src/shell.c  | 251 +--
 3 files changed, 282 insertions(+), 29 deletions(-)

diff --git a/src/animation.c b/src/animation.c
index e947d72..6f20179 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -108,9 +108,10 @@ struct weston_surface_animation {
weston_surface_animation_frame_func_t frame;
weston_surface_animation_done_func_t done;
void *data;
+   void *private;
 };
 
-static void
+WL_EXPORT void
 weston_surface_animation_destroy(struct weston_surface_animation *animation)
 {
wl_list_remove(animation-animation.link);
@@ -162,7 +163,8 @@ weston_surface_animation_run(struct weston_surface *surface,
 float start, float stop,
 weston_surface_animation_frame_func_t frame,
 weston_surface_animation_done_func_t done,
-void *data)
+void *data,
+void *private)
 {
struct weston_surface_animation *animation;
 
@@ -176,6 +178,7 @@ weston_surface_animation_run(struct weston_surface *surface,
animation-data = data;
animation-start = start;
animation-stop = stop;
+   animation-private = private;
weston_matrix_init(animation-transform.matrix);
wl_list_insert(surface-geometry.transformation_list,
   animation-transform.link);
@@ -222,7 +225,7 @@ weston_zoom_run(struct weston_surface *surface, float 
start, float stop,
weston_surface_animation_done_func_t done, void *data)
 {
return weston_surface_animation_run(surface, start, stop,
-   zoom_frame, done, data);
+   zoom_frame, done, data, NULL);
 }
 
 static void
@@ -244,7 +247,7 @@ weston_fade_run(struct weston_surface *surface,
struct weston_surface_animation *fade;
 
fade = weston_surface_animation_run(surface, 0, 0,
-   fade_frame, done, data);
+   fade_frame, done, data, NULL);
 
weston_spring_init(fade-spring, k, start, end);
surface-alpha = start;
@@ -260,6 +263,45 @@ weston_fade_update(struct weston_surface_animation *fade,
 }
 
 static void
+stable_fade_frame(struct weston_surface_animation *animation)
+{
+   struct weston_surface *back_surface;
+
+   if (animation-spring.current  0.999)
+   animation-surface-alpha = 1;
+   else if (animation-spring.current  0.001 )
+   animation-surface-alpha = 0;
+   else
+   animation-surface-alpha = animation-spring.current;
+
+   back_surface = (struct weston_surface *) animation-private;
+   back_surface-alpha =
+   (animation-spring.target - animation-surface-alpha) /
+   (1.0 - animation-surface-alpha);
+   weston_surface_geometry_dirty(back_surface);
+}
+
+WL_EXPORT struct weston_surface_animation *
+weston_stable_fade_run(struct weston_surface *front_surface, float start,
+   struct weston_surface *back_surface, float end,
+   weston_surface_animation_done_func_t done, void *data)
+{
+   struct weston_surface_animation *fade;
+
+   fade = weston_surface_animation_run(front_surface, 0, 0,
+   stable_fade_frame, done, data, 
back_surface);
+
+
+   weston_spring_init(fade-spring, 400, start, end);
+   fade-spring.friction = 1150;
+
+   front_surface-alpha = start;
+   back_surface-alpha = end;
+
+   return fade;
+}
+
+static void
 slide_frame(struct weston_surface_animation *animation)
 {
float scale;
@@ -278,7 +320,7 @@ weston_slide_run(struct weston_surface *surface, float 
start, float stop,
struct weston_surface_animation *animation;
 
animation = weston_surface_animation_run(surface, start, stop,
-slide_frame, done, data);
+slide_frame, done, data, NULL);
if (!animation)
  

[PATCH weston 11/18] animation: Make zoom animation renders better and smoother

2013-05-22 Thread ppaalanen
From: Louis-Francis Ratté-Boulianne l...@collabora.com

Don't scale to a size smaller than 1/8 the surface size
Adjust spring parameters so we don't go over the target value
---
 src/animation.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/animation.c b/src/animation.c
index 6f20179..835ed13 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -206,6 +206,9 @@ zoom_frame(struct weston_surface_animation *animation)
scale = animation-start +
(animation-stop - animation-start) *
animation-spring.current;
+   if (scale  0.125)
+   scale = 0.125;
+
weston_matrix_init(animation-transform.matrix);
weston_matrix_translate(animation-transform.matrix,
-0.5f * es-geometry.width,
@@ -224,8 +227,15 @@ WL_EXPORT struct weston_surface_animation *
 weston_zoom_run(struct weston_surface *surface, float start, float stop,
weston_surface_animation_done_func_t done, void *data)
 {
-   return weston_surface_animation_run(surface, start, stop,
+   struct weston_surface_animation *zoom;
+
+   zoom = weston_surface_animation_run(surface, start, stop,
zoom_frame, done, data, NULL);
+
+   zoom-spring.k = 400;
+   zoom-spring.friction = 1150;
+
+   return zoom;
 }
 
 static void
-- 
1.8.1.5

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


[PATCH weston 12/18] compositor, shell: Add animation to measure desktop fps

2013-05-22 Thread ppaalanen
From: Louis-Francis Ratté-Boulianne l...@collabora.com

On the first output, count the number of frames rendered for each
second, and report the fps in the Weston log.

To ensure a busy rendering loop, the debug key binding starting the
measurement also creates a bouncing box animation on screen. The box is
simply a solid color surface that moves around randomly.

This crude benchmark mode is useful for seeing whether the compositor
can consistently hit the screen refresh rate.

[pq: wrote the commit message, ported over the great input rework]
---
 src/compositor.c |  33 +++
 src/compositor.h |  10 +
 src/shell.c  | 121 +++
 3 files changed, 164 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 65da583..238c809 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1293,6 +1293,22 @@ weston_output_finish_frame(struct weston_output *output, 
uint32_t msecs)
wl_display_get_event_loop(compositor-wl_display);
int fd;
 
+   if (output-benchmark.enabled) {
+   if (output-benchmark.update_time == 0) {
+   output-benchmark.update_time = msecs;
+   } else {
+   uint32_t d = msecs - output-benchmark.update_time;
+   float fps;
+   output-benchmark.frame_counter++;
+   if (d = 1000) {
+   fps = output-benchmark.frame_counter * 1000.0f 
/ d;
+   weston_log(FPS = %f\n, fps);
+   output-benchmark.update_time = msecs;
+   output-benchmark.frame_counter = 0;
+   }
+   }
+   }
+
output-frame_time = msecs;
if (output-repaint_needed) {
weston_output_repaint(output, msecs);
@@ -2634,6 +2650,9 @@ weston_output_init(struct weston_output *output, struct 
weston_compositor *c,
output-mm_width = width;
output-mm_height = height;
output-dirty = 1;
+   output-benchmark.enabled = 0;
+   output-benchmark.update_time = 0;
+   output-benchmark.frame_counter = 0;
 
weston_output_transform_init(output, transform);
weston_output_init_zoom(output);
@@ -2655,6 +2674,20 @@ weston_output_init(struct weston_output *output, struct 
weston_compositor *c,
wl_signal_emit(c-output_created_signal, output);
 }
 
+WL_EXPORT void
+weston_output_enable_benchmark(struct weston_output *output)
+{
+   output-benchmark.enabled = 1;
+   output-benchmark.update_time = 0;
+   output-benchmark.frame_counter = 0;
+}
+
+WL_EXPORT void
+weston_output_disable_benchmark(struct weston_output *output)
+{
+   output-benchmark.enabled = 0;
+}
+
 static void
 compositor_bind(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
diff --git a/src/compositor.h b/src/compositor.h
index 61aeb9f..96cabeb 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -188,6 +188,12 @@ struct weston_output {
struct weston_mode *origin;
struct wl_list mode_list;
 
+   struct {
+   int enabled;
+   uint32_t update_time;
+   int frame_counter;
+   } benchmark;
+
void (*start_repaint_loop)(struct weston_output *output);
void (*repaint)(struct weston_output *output,
pixman_region32_t *damage);
@@ -864,6 +870,10 @@ weston_output_schedule_repaint(struct weston_output 
*output);
 void
 weston_output_damage(struct weston_output *output);
 void
+weston_output_enable_benchmark(struct weston_output *output);
+void
+weston_output_disable_benchmark(struct weston_output *output);
+void
 weston_compositor_schedule_repaint(struct weston_compositor *compositor);
 void
 weston_compositor_fade(struct weston_compositor *compositor, float tint);
diff --git a/src/shell.c b/src/shell.c
index b7c372e..812296a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -158,6 +158,18 @@ struct desktop_shell {
} screensaver;
 
struct {
+   struct weston_layer layer;
+   struct weston_surface *surface;
+   struct weston_animation animation;
+   struct weston_transform transform;
+   uint32_t anim_timestamp;
+   double anim_current;
+   double anim_duration;
+   int32_t anim_dx;
+   int32_t anim_dy;
+   } benchmark;
+
+   struct {
struct wl_resource *binding;
struct wl_list surfaces;
} input_panel;
@@ -4265,6 +4277,111 @@ backlight_binding(struct weston_seat *seat, uint32_t 
time, uint32_t key,
output-set_backlight(output, output-backlight_current);
 }
 
+static void
+benchmark_animation_frame(struct weston_animation *animation,
+ struct weston_output *output, uint32_t msecs)
+{
+   struct 

[PATCH weston 13/18] Add modifier-only binding

2013-05-22 Thread ppaalanen
From: Daniel Stone dan...@fooishbar.org

Add the ability to bind to modifiers; the binding is armed when a key
which sets the requested modifier is pressed, and triggered if the key
is released with no other keys having been pressed in the meantime, as
well as mouse buttons or scroll axes.

This only works for direct modifiers (e.g. Shift and Alt), not modifiers
which latch or lock.

Signed-off-by: Daniel Stone dan...@fooishbar.org
---
 src/bindings.c   | 58 
 src/compositor.c |  1 +
 src/compositor.h | 16 
 src/input.c  | 38 +
 4 files changed, 113 insertions(+)

diff --git a/src/bindings.c b/src/bindings.c
index e548ff1..e560b61 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -74,6 +74,24 @@ weston_compositor_add_key_binding(struct weston_compositor 
*compositor,
 }
 
 WL_EXPORT struct weston_binding *
+weston_compositor_add_modifier_binding(struct weston_compositor *compositor,
+  uint32_t modifier,
+  weston_modifier_binding_handler_t 
handler,
+  void *data)
+{
+   struct weston_binding *binding;
+
+   binding = weston_compositor_add_binding(compositor, 0, 0, 0,
+   modifier, handler, data);
+   if (binding == NULL)
+   return NULL;
+
+   wl_list_insert(compositor-modifier_binding_list.prev, binding-link);
+
+   return binding;
+}
+
+WL_EXPORT struct weston_binding *
 weston_compositor_add_button_binding(struct weston_compositor *compositor,
 uint32_t button, uint32_t modifier,
 weston_button_binding_handler_t handler,
@@ -215,6 +233,10 @@ weston_compositor_run_key_binding(struct weston_compositor 
*compositor,
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
return;
 
+   /* Invalidate all active modifier bindings. */
+   wl_list_for_each(b, compositor-modifier_binding_list, link)
+   b-key = key;
+
wl_list_for_each(b, compositor-key_binding_list, link) {
if (b-key == key  b-modifier == seat-modifier_state) {
weston_key_binding_handler_t handler = b-handler;
@@ -231,6 +253,34 @@ weston_compositor_run_key_binding(struct weston_compositor 
*compositor,
 }
 
 WL_EXPORT void
+weston_compositor_run_modifier_binding(struct weston_compositor *compositor,
+  struct weston_seat *seat,
+  enum weston_keyboard_modifier modifier,
+  enum wl_keyboard_key_state state)
+{
+   struct weston_binding *b;
+
+   wl_list_for_each(b, compositor-modifier_binding_list, link) {
+   weston_modifier_binding_handler_t handler = b-handler;
+
+   if (b-modifier != modifier)
+   continue;
+
+   /* Prime the modifier binding. */
+   if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+   b-key = 0;
+   continue;
+   }
+   /* Ignore the binding if a key was pressed in between. */
+   else if (b-key != 0) {
+   return;
+   }
+
+   handler(seat, modifier, b-data);
+   }
+}
+
+WL_EXPORT void
 weston_compositor_run_button_binding(struct weston_compositor *compositor,
 struct weston_seat *seat,
 uint32_t time, uint32_t button,
@@ -241,6 +291,10 @@ weston_compositor_run_button_binding(struct 
weston_compositor *compositor,
if (state == WL_POINTER_BUTTON_STATE_RELEASED)
return;
 
+   /* Invalidate all active modifier bindings. */
+   wl_list_for_each(b, compositor-modifier_binding_list, link)
+   b-key = button;
+
wl_list_for_each(b, compositor-button_binding_list, link) {
if (b-button == button  b-modifier == seat-modifier_state) 
{
weston_button_binding_handler_t handler = b-handler;
@@ -257,6 +311,10 @@ weston_compositor_run_axis_binding(struct 
weston_compositor *compositor,
 {
struct weston_binding *b;
 
+   /* Invalidate all active modifier bindings. */
+   wl_list_for_each(b, compositor-modifier_binding_list, link)
+   b-key = axis;
+
wl_list_for_each(b, compositor-axis_binding_list, link) {
if (b-axis == axis  b-modifier == seat-modifier_state) {
weston_axis_binding_handler_t handler = b-handler;
diff --git a/src/compositor.c b/src/compositor.c
index 238c809..aa5baaf 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2786,6 +2786,7 @@ weston_compositor_init(struct weston_compositor *ec,
wl_list_init(ec-seat_list);

[PATCH weston 14/18] Add move/scale animation

2013-05-22 Thread ppaalanen
From: Daniel Stone dan...@fooishbar.org

Add an animation which moves a surface to a new location, at the same
time as also rescaling it to a different size from the origin, rather
than the existing scale animation which resizes from the centre.

Signed-off-by: Daniel Stone dan...@fooishbar.org
---
 src/animation.c  | 62 
 src/compositor.h |  5 +
 2 files changed, 67 insertions(+)

diff --git a/src/animation.c b/src/animation.c
index 835ed13..7dd3683 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -339,3 +339,65 @@ weston_slide_run(struct weston_surface *surface, float 
start, float stop,
 
return animation;
 }
+
+struct weston_move_animation {
+   int dx;
+   int dy;
+   int reverse;
+   weston_surface_animation_done_func_t done;
+};
+
+static void
+move_frame(struct weston_surface_animation *animation)
+{
+   struct weston_move_animation *move = animation-private;
+   float scale;
+   float progress = animation-spring.current;
+
+   if (move-reverse)
+   progress = 1.0 - progress;
+
+   scale = animation-start +
+(animation-stop - animation-start) *
+progress;
+   weston_matrix_init(animation-transform.matrix);
+   weston_matrix_scale(animation-transform.matrix, scale, scale, 1.0f);
+   weston_matrix_translate(animation-transform.matrix,
+move-dx * progress, move-dy * progress,
+   0);
+}
+
+static void
+move_done(struct weston_surface_animation *animation, void *data)
+{
+   struct weston_move_animation *move = animation-private;
+
+   if (move-done)
+   move-done(animation, data);
+
+   free(move);
+}
+
+WL_EXPORT struct weston_surface_animation *
+weston_move_scale_run(struct weston_surface *surface, int dx, int dy,
+  float start, float end, int reverse,
+ weston_surface_animation_done_func_t done, void *data)
+{
+   struct weston_move_animation *move;
+   struct weston_surface_animation *animation;
+
+   move = malloc(sizeof(*move));
+   if (!move)
+   return NULL;
+   move-dx = dx;
+   move-dy = dy;
+   move-reverse = reverse;
+   move-done = done;
+
+   animation = weston_surface_animation_run(surface, start, end, 
move_frame,
+move_done, data, move);
+   animation-spring.k = 400;
+   animation-spring.friction = 1150;
+
+   return animation;
+}
diff --git a/src/compositor.h b/src/compositor.h
index 4d70ba2..2de6eb4 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -1142,6 +1142,11 @@ struct weston_surface_animation *
 weston_fade_run(struct weston_surface *surface,
float start, float end, float k,
weston_surface_animation_done_func_t done, void *data);
+
+struct weston_surface_animation *
+weston_move_scale_run(struct weston_surface *surface, int dx, int dy,
+  float start, float end, int reverse,
+ weston_surface_animation_done_func_t done, void *data);
 void
 weston_fade_update(struct weston_surface_animation *fade,
   float start, float end, float k);
-- 
1.8.1.5

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


[PATCH weston 15/18] Shell: Add Exposay

2013-05-22 Thread ppaalanen
From: Daniel Stone dan...@fooishbar.org

Exposay provides window overview functions which, when a key which
produces the binding modifier is pressed on its own, scales all
currently-open windows down to be shown overlaid on the desktop,
providing keyboard and mouse navigation to be able to switch window
focus.

Signed-off-by: Daniel Stone dan...@fooishbar.org
---
 src/shell.c | 574 
 1 file changed, 574 insertions(+)

diff --git a/src/shell.c b/src/shell.c
index 812296a..e0d579a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1,6 +1,7 @@
 /*
  * Copyright © 2010-2012 Intel Corporation
  * Copyright © 2011-2012 Collabora, Ltd.
+ * Copyright © 2013 Raspberry Pi Foundation
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
@@ -55,6 +56,19 @@ enum fade_type {
FADE_OUT
 };
 
+enum exposay_target_state {
+   EXPOSAY_TARGET_OVERVIEW, /* show all windows */
+   EXPOSAY_TARGET_CANCEL, /* return to normal, same focus */
+   EXPOSAY_TARGET_SWITCH, /* return to normal, switch focus */
+};
+
+enum exposay_layout_state {
+   EXPOSAY_LAYOUT_INACTIVE = 0, /* normal desktop */
+   EXPOSAY_LAYOUT_ANIMATE_TO_INACTIVE, /* in transition to normal */
+   EXPOSAY_LAYOUT_OVERVIEW, /* show all windows */
+   EXPOSAY_LAYOUT_ANIMATE_TO_OVERVIEW, /* in transition to all windows */
+};
+
 struct focus_state {
struct weston_seat *seat;
struct workspace *ws;
@@ -181,6 +195,34 @@ struct desktop_shell {
struct wl_event_source *startup_timer;
} fade;
 
+   struct exposay {
+   /* XXX: Make these exposay_surfaces. */
+   struct weston_surface *focus_prev;
+   struct weston_surface *focus_current;
+   struct weston_surface *clicked;
+   struct workspace *workspace;
+   struct weston_seat *seat;
+   struct wl_list surface_list;
+
+   struct weston_keyboard_grab grab_kbd;
+   struct weston_pointer_grab grab_ptr;
+
+enum exposay_target_state state_target;
+enum exposay_layout_state state_cur;
+   int in_flight; /* number of animations still running */
+
+   int num_surfaces;
+   int grid_size;
+   int surface_size;
+
+   int hpadding_outer;
+   int vpadding_outer;
+   int padding_inner;
+
+   int row_current;
+   int column_current;
+   } exposay;
+
uint32_t binding_modifier;
enum animation_type win_animation_type;
enum animation_type focus_animation_type;
@@ -4244,6 +4286,533 @@ switcher_binding(struct weston_seat *seat, uint32_t 
time, uint32_t key,
switcher_next(switcher);
 }
 
+struct exposay_surface {
+   struct desktop_shell *shell;
+   struct weston_surface *surface;
+   struct wl_list link;
+
+   int x;
+   int y;
+   int width;
+   int height;
+   double scale;
+
+   int row;
+   int column;
+
+   /* The animations only apply a transformation for their own lifetime,
+* and don't have an option to indefinitely maintain the
+* transformation in a steady state - so, we apply our own once the
+* animation has finished. */
+   struct weston_transform transform;
+};
+
+static void exposay_set_state(struct desktop_shell *shell,
+  enum exposay_target_state state,
+ struct weston_seat *seat);
+static void exposay_check_state(struct desktop_shell *shell);
+
+static void
+exposay_in_flight_inc(struct desktop_shell *shell)
+{
+   shell-exposay.in_flight++;
+}
+
+static void
+exposay_in_flight_dec(struct desktop_shell *shell)
+{
+   if (--shell-exposay.in_flight  0)
+   return;
+
+   exposay_check_state(shell);
+}
+
+static void
+exposay_animate_in_done(struct weston_surface_animation *animation, void *data)
+{
+   struct exposay_surface *esurface = data;
+
+   wl_list_insert(esurface-surface-geometry.transformation_list,
+  esurface-transform.link);
+   weston_matrix_init(esurface-transform.matrix);
+   weston_matrix_scale(esurface-transform.matrix,
+   esurface-scale, esurface-scale, 1.0f);
+   weston_matrix_translate(esurface-transform.matrix,
+   esurface-x - esurface-surface-geometry.x,
+   esurface-y - esurface-surface-geometry.y,
+   0);
+
+   weston_surface_geometry_dirty(esurface-surface);
+   weston_compositor_schedule_repaint(esurface-surface-compositor);
+
+   exposay_in_flight_dec(esurface-shell);
+}
+
+static void
+exposay_animate_in(struct exposay_surface *esurface)
+{
+   

[PATCH weston 16/18] configure.ac: Enable AC_USE_SYSTEM_EXTENSIONS

2013-05-22 Thread ppaalanen
From: Daniel Stone dan...@fooishbar.org

AC_USE_SYSTEM_EXTENSIONS enables _XOPEN_SOURCE, _GNU_SOURCE and similar
macros to expose the largest extent of functionality supported by the
underlying system.  This is required since these macros are often
limiting rather than merely additive, e.g. _XOPEN_SOURCE will actually
on some systems hide declarations which are not part of the X/Open spec.

Since this goes into config.h rather than the command line, ensure all
source is consistently including config.h before anything else,
including system libraries.  This doesn't need to be guarded by a
HAVE_CONFIG_H ifdef, which was only ever a hangover from the X.Org
modular transition.

Signed-off-by: Daniel Stone dan...@fooishbar.org

[pq: rebased and converted more files]
---
 clients/window.c  | 4 +---
 configure.ac  | 2 ++
 shared/cairo-util.c   | 2 +-
 shared/config-parser.c| 3 ++-
 shared/image-loader.c | 2 +-
 shared/matrix.c   | 2 ++
 shared/option-parser.c| 2 ++
 shared/os-compatibility.c | 2 +-
 src/animation.c   | 2 ++
 src/bindings.c| 2 ++
 src/clipboard.c   | 2 +-
 src/cms-helper.c  | 4 +---
 src/cms-static.c  | 5 +
 src/compositor-drm.c  | 6 +-
 src/compositor-fbdev.c| 2 +-
 src/compositor-headless.c | 4 +---
 src/compositor-rdp.c  | 4 +---
 src/compositor-rpi.c  | 4 +---
 src/compositor-wayland.c  | 5 +
 src/compositor-x11.c  | 4 +---
 src/compositor.c  | 2 --
 src/evdev-touchpad.c  | 2 ++
 src/evdev.c   | 2 ++
 src/filter.c  | 2 ++
 src/gl-renderer.c | 2 +-
 src/gl-renderer.h | 7 +++
 src/launcher-util.c   | 2 ++
 src/libbacklight.c| 2 +-
 src/log.c | 2 ++
 src/noop-renderer.c   | 2 +-
 src/pixman-renderer.c | 2 +-
 src/rpi-renderer.c| 4 ++--
 src/screenshooter.c   | 2 ++
 src/shell.c   | 2 ++
 src/tablet-shell.c| 2 ++
 src/text-backend.c| 2 ++
 src/tty.c | 2 ++
 src/udev-seat.c   | 2 ++
 src/weston-launch.c   | 2 --
 src/xwayland/launcher.c   | 2 +-
 src/xwayland/selection.c  | 2 +-
 src/xwayland/window-manager.c | 2 +-
 src/zoom.c| 2 ++
 43 files changed, 62 insertions(+), 54 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 3f54111..28df2ca 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -21,9 +21,7 @@
  * OF THIS SOFTWARE.
  */
 
-#define _GNU_SOURCE
-
-#include ../config.h
+#include config.h
 
 #include stdint.h
 #include stdio.h
diff --git a/configure.ac b/configure.ac
index 323bd87..68a54e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,8 @@ AC_SUBST([WESTON_VERSION], [weston_version])
 
 AC_CONFIG_HEADERS([config.h])
 
+AC_USE_SYSTEM_EXTENSIONS
+
 AM_INIT_AUTOMAKE([1.11 parallel-tests foreign no-dist-gzip dist-xz 
color-tests])
 
 AM_SILENT_RULES([yes])
diff --git a/shared/cairo-util.c b/shared/cairo-util.c
index 8b41f41..c3a966a 100644
--- a/shared/cairo-util.c
+++ b/shared/cairo-util.c
@@ -21,7 +21,7 @@
  * OF THIS SOFTWARE.
  */
 
-#include ../config.h
+#include config.h
 
 #include stdint.h
 #include stdlib.h
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 652da1f..a49e29e 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -20,7 +20,8 @@
  * OF THIS SOFTWARE.
  */
 
-#define _GNU_SOURCE   /* for stchrnul() */
+#include config.h
+
 #include string.h
 #include stdio.h
 #include stdlib.h
diff --git a/shared/image-loader.c b/shared/image-loader.c
index 9f65dea..35dadd3 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -21,7 +21,7 @@
  * OF THIS SOFTWARE.
  */
 
-#include ../config.h
+#include config.h
 
 #include stdlib.h
 #include stdio.h
diff --git a/shared/matrix.c b/shared/matrix.c
index 3ff4089..4f0b6b7 100644
--- a/shared/matrix.c
+++ b/shared/matrix.c
@@ -21,6 +21,8 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include config.h
+
 #include float.h
 #include string.h
 #include stdlib.h
diff --git a/shared/option-parser.c b/shared/option-parser.c
index a7e497f..c00349a 100644
--- a/shared/option-parser.c
+++ b/shared/option-parser.c
@@ -20,6 +20,8 @@
  * OF THIS SOFTWARE.
  */
 
+#include config.h
+
 #include stdlib.h
 #include stdint.h
 #include stdio.h
diff --git a/shared/os-compatibility.c b/shared/os-compatibility.c
index 21d4d02..4f96dd4 100644
--- a/shared/os-compatibility.c
+++ b/shared/os-compatibility.c
@@ -20,7 +20,7 @@
  * OF THIS SOFTWARE.
  */
 
-#define _GNU_SOURCE
+#include config.h
 
 #include sys/types.h
 #include sys/socket.h
diff --git a/src/animation.c b/src/animation.c
index 7dd3683..80b200e 100644
--- a/src/animation.c
+++ b/src/animation.c
@@ -20,6 +20,8 @@
  * CONNECTION WITH THE USE OR 

[PATCH weston 17/18] xwayland: Fix the race condition when mapping a surface

2013-05-22 Thread ppaalanen
From: Louis-Francis Ratté-Boulianne l...@collabora.com

Make sure XCB_MAP_NOTIFY has been received and the window id has been
set before mapping the shell surface. It fixes race condition making the
surface appears at wrong coordinates or with wrong size.
---
 src/xwayland/window-manager.c | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index 366f2e0..c2e680b 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -113,6 +113,7 @@ struct weston_wm_window {
int decorate;
int override_redirect;
int fullscreen;
+   int mapped;
 };
 
 static struct weston_wm_window *
@@ -121,6 +122,9 @@ get_wm_window(struct weston_surface *surface);
 static void
 weston_wm_window_schedule_repaint(struct weston_wm_window *window);
 
+static void
+xserver_map_shell_surface(struct weston_wm *wm, struct weston_wm_window 
*window);
+
 const char *
 get_atom_name(xcb_connection_t *c, xcb_atom_t atom)
 {
@@ -723,6 +727,14 @@ static void
 weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
 {
xcb_map_notify_event_t *map_notify = (xcb_map_notify_event_t *) event;
+   struct weston_wm_window *window;
+
+   window = hash_table_lookup(wm-window_hash, map_notify-window);
+
+   if (window-surface != NULL)
+   xserver_map_shell_surface(wm, window);
+   else
+   window-mapped = 1;
 
if (our_resource(wm, map_notify-window)) {
weston_log(XCB_MAP_NOTIFY (window %d, ours)\n,
@@ -915,6 +927,8 @@ weston_wm_window_create(struct weston_wm *wm,
window-override_redirect = override;
window-width = width;
window-height = height;
+   window-surface = NULL;
+   window-mapped = 0;
 
hash_table_insert(wm-window_hash, id, window);
 }
@@ -1874,7 +1888,9 @@ xserver_set_window_id(struct wl_client *client, struct 
wl_resource *resource,
  window-surface_destroy_listener);
 
weston_wm_window_schedule_repaint(window);
-   xserver_map_shell_surface(wm, window);
+
+   if (window-mapped)
+   xserver_map_shell_surface(wm, window);
 }
 
 const struct xserver_interface xserver_implementation = {
-- 
1.8.1.5

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


[PATCH weston 18/18] shell: Fix calculation of center point in surface rotation

2013-05-22 Thread ppaalanen
From: Louis-Francis Ratté-Boulianne l...@collabora.com

---
 src/shell.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index e46c30f..757d98d 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -3092,8 +3092,8 @@ surface_rotate(struct shell_surface *surface, struct 
weston_seat *seat)
return;
 
weston_surface_to_global_float(surface-surface,
-  surface-surface-geometry.width / 2,
-  surface-surface-geometry.height / 2,
+  surface-surface-geometry.width * 0.5f,
+  surface-surface-geometry.height * 0.5f,
   rotate-center.x, rotate-center.y);
 
dx = wl_fixed_to_double(seat-pointer-x) - rotate-center.x;
-- 
1.8.1.5

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


[PATCH wayland-web] raspberrypi: update for the new rpi-backend

2013-05-22 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

This depends on the rpi-renderer patch series for Weston.

Update the build instructions for the current state of Weston, remove
options that do not exist anymore, add some more troubleshooting issues.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 raspberrypi.html | 42 ++
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/raspberrypi.html b/raspberrypi.html
index 67b7829..d77a9e1 100644
--- a/raspberrypi.html
+++ b/raspberrypi.html
@@ -47,14 +47,6 @@ old firmware may cause rpi-backend to malfunction on 
Raspberry Pi./p
happen off-line into the buffer./dd
 /dl
 
-pBy default, the rpi-backend is configured for the 
ttdispmanx_offline=1/tt
-case. Without this setting, it would be better to run Weston with
-tt--max-planes=10/tt command line option./p
-
-pIf you want to use Weston with purely GLESv2 compositing, you can pass
-tt--max-planes=0/tt to Weston. In that case it would be preferrable
-to not set ttdispmanx_offline=1/tt to conserve VideoCore memory./p
-
 h2Setting up the environment/h2
 
 pHere we will install to the home directory of the pi user./p
@@ -67,9 +59,11 @@ export 
PKG_CONFIG_PATH=$WLD/lib/pkgconfig/:$WLD/share/pkgconfig/
 export ACLOCAL=aclocal -I $WLD/share/aclocal
 export XDG_RUNTIME_DIR=/run/shm/wayland
 export XDG_CONFIG_HOME=$WLD/etc
+export XORGCONFIG=$WLD/etc/xorg.conf
 
 mkdir -p $WLD/share/aclocal
 mkdir -p $XDG_RUNTIME_DIR
+chmod 0700 $XDG_RUNTIME_DIR
 /pre
 /blockquote
 
@@ -97,11 +91,11 @@ contains similar files for Android, and will not work./p
 
 pre$ git clone git://anongit.freedesktop.org/wayland/wayland
 $ cd wayland
-$ ./autogen.sh --prefix=$WLD
+$ ./autogen.sh --prefix=$WLD --disable-documentation
 $ make
 $ make install
 /pre
-
+pThe tt--disable-documentation/tt makes it not require Doxygen./p
 
 h2libxkbcommon/h2
 
@@ -124,9 +118,10 @@ contains similar files for Android, and will not work./p
 $ ./autogen.sh --prefix=$WLD \
 --disable-setuid-install --with-cairo-glesv2 \
 --disable-x11-compositor --disable-drm-compositor \
---disable-android-compositor --disable-wayland-compositor \
+--disable-fbdev-compositor --disable-wayland-compositor \
 --disable-weston-launch --disable-simple-egl-clients \
---disable-fbdev-compositor \
+--disable-egl --disable-libunwind --disable-colord \
+--disable-resize-optimization --disable-xwayland-test \
 WESTON_NATIVE_BACKEND=rpi-backend.so
 
 $ make
@@ -168,10 +163,25 @@ configure: WARNING: clients will use cairo image, 
cairo-egl not used/pre
 
 h3Some or all surfaces (graphics) are corrupted/h3
 
-pToo old firmware might cause corrupted graphics. If you don't want to
-update the firmware, a workaround is to add tt--max-planes=0/tt to the
-Weston command line. This forces everything to be composited with
-GLESv2./p
+pToo old firmware might cause corrupted graphics.
+Try upgrading the firmware, and try the tt/boot/config.txt/tt
+options mentioned above./p
+
+h3Monitor or TV goes blank, loses signal, etc./h3
+
+pYou probably do not have ttdispmanx_offline=1/tt for the firmware.
+When there are too many things on screen for the on-line compositor to
+handle, the output dies or becomes corrupt without the off-line fallback./p
+
+h3Some windows or the whole image flickers/h3
+
+pThere may be so many things on screen, that even the off-line compositor
+in the firmware cannot keep up. Try to close some windows./p
+
+h3Programs are dying on SIGBUS/h3
+
+pMost likely you are running out of space in tt$XDG_RUNTIME_DIR/tt.
+This is where Wayland programs allocate their pixel buffers./p
 
 /body
 /html
-- 
1.8.1.5

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


[PATCH weston 1/6] protocol: improve sub-surface spec wording

2013-05-17 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

Mention, that sub-surfaces are not clipped to the parent.
Be more accurate on surface commit vs. apply state.
Mention the initial stacking order.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 protocol/subsurface.xml | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/protocol/subsurface.xml b/protocol/subsurface.xml
index 60b4002..71dc1e9 100644
--- a/protocol/subsurface.xml
+++ b/protocol/subsurface.xml
@@ -87,7 +87,10 @@
   interface name=wl_subsurface version=1
 description summary=sub-surface interface to a wl_surface
   An additional interface to a wl_surface object, which has been
-  made a sub-surface. A sub-surface has one parent surface.
+  made a sub-surface. A sub-surface has one parent surface. A
+  sub-surface's size and position are not limited to that of the parent.
+  Particularly, a sub-surface is not automatically clipped to its
+  parent's area.
 
   A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
   and the parent surface is mapped. The order of which one happens
@@ -99,8 +102,8 @@
   depends on the sub-surface's mode. The possible modes are
   synchronized and desynchronized, see methods
   wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized
-  mode caches wl_surface state to be applied on the next parent
-  surface's commit, and desynchronized mode applies the pending
+  mode caches the wl_surface state to be applied when the parent's
+  state gets applied, and desynchronized mode applies the pending
   wl_surface state directly. A sub-surface is initially in the
   synchronized mode.
 
@@ -113,15 +116,15 @@
   wl_surface state is applied, regardless of the sub-surface's mode.
   As the exception, set_sync and set_desync are effective immediately.
 
-  The main surface can thought to be always in desynchronized mode,
+  The main surface can be thought to be always in desynchronized mode,
   since it does not have a parent in the sub-surfaces sense.
 
   Even if a sub-surface is in desynchronized mode, it will behave as
   in synchronized mode, if its parent surface behaves as in
   synchronized mode. This rule is applied recursively throughout the
   tree of surfaces. This means, that one can set a sub-surface into
-  synchronized mode, and then assume that all its child sub-surfaces
-  are synchronized, too, without explicitly setting them.
+  synchronized mode, and then assume that all its child and grand-child
+  sub-surfaces are synchronized, too, without explicitly setting them.
 
   If the wl_surface associated with the wl_subsurface is destroyed, the
   wl_subsurface object becomes inert. Note, that destroying either object
@@ -153,7 +156,9 @@
   description summary=reposition the sub-surface
This schedules a sub-surface position change.
The sub-surface will be moved so, that its origin (top-left
-   corner pixel) will be at the location x, y of the parent surface.
+   corner pixel) will be at the location x, y of the parent surface
+   coordinate system. The coordinates are not restricted to the parent
+   surface area. Negative values are allowed.
 
The next wl_surface.commit on the parent surface will reset
the sub-surface's position to the scheduled coordinates.
@@ -176,6 +181,9 @@
The z-order is double-buffered state, and will be applied on the
next commit of the parent surface.
See wl_surface.commit and wl_subcompositor.get_subsurface.
+
+   A new sub-surface is initially added as the top-most in the stack
+   of its siblings and parent.
   /description
 
   arg name=sibling type=object interface=wl_surface
@@ -200,9 +208,8 @@
In synchronized mode, wl_surface.commit on a sub-surface will
accumulate the committed state in a cache, but the state will
not be applied and hence will not change the compositor output.
-   The cached state is applied to the sub-surface when
-   wl_surface.commit is called on the parent surface, after the
-   parent surface's own state is applied. This ensures atomic
+   The cached state is applied to the sub-surface immediately after
+   the parent surface's state is applied. This ensures atomic
updates of the parent and all its synchronized sub-surfaces.
Applying the cached state will invalidate the cache, so further
parent surface commits do not (re-)apply old state.
-- 
1.8.1.5

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


[PATCH weston 2/6] tests: add sub-surface tree destruction permutations

2013-05-17 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

Add a test for varying the object destruction order in a complex
sub-surface tree.

This test attemps to fuzz the destruction of a sub-surface tree to make
sure the server does not crash on any wl_surface or wl_subsurface
destruction sequence.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 tests/subsurface-test.c | 202 
 1 file changed, 202 insertions(+)

diff --git a/tests/subsurface-test.c b/tests/subsurface-test.c
index 8f1fd14..0a210fb 100644
--- a/tests/subsurface-test.c
+++ b/tests/subsurface-test.c
@@ -24,6 +24,7 @@
 
 #include weston-test-client-helper.h
 #include subsurface-client-protocol.h
+#include stdio.h
 
 #define NUM_SUBSURFACES 3
 
@@ -323,3 +324,204 @@ TEST(test_subsurface_destroy_protocol)
 
client_roundtrip(client);
 }
+
+static void
+create_subsurface_tree(struct client *client, struct wl_surface **surfs,
+  struct wl_subsurface **subs, int n)
+{
+   struct wl_subcompositor *subco;
+   int i;
+
+   subco = get_subcompositor(client);
+
+   for (i = 0; i  n; i++)
+   surfs[i] = wl_compositor_create_surface(client-wl_compositor);
+
+   /*
+* The tree of sub-surfaces:
+*0
+*   / \
+*  1   2 - 10
+* / \  |\
+*3   5 9 6
+*   /   / \
+*  4   7   8
+* Surface 0 has no wl_subsurface, others do.
+*/
+
+   switch (n) {
+   default:
+   assert(0);
+   break;
+
+#define SUB_LINK(s,p) \
+   subs[s] = wl_subcompositor_get_subsurface(subco, surfs[s], surfs[p])
+
+   case 11:
+   SUB_LINK(10, 2);
+   case 10:
+   SUB_LINK(9, 2);
+   case 9:
+   SUB_LINK(8, 6);
+   case 8:
+   SUB_LINK(7, 6);
+   case 7:
+   SUB_LINK(6, 2);
+   case 6:
+   SUB_LINK(5, 1);
+   case 5:
+   SUB_LINK(4, 3);
+   case 4:
+   SUB_LINK(3, 1);
+   case 3:
+   SUB_LINK(2, 0);
+   case 2:
+   SUB_LINK(1, 0);
+
+#undef SUB_LINK
+   };
+}
+
+static void
+destroy_subsurface_tree(struct wl_surface **surfs,
+   struct wl_subsurface **subs, int n)
+{
+   int i;
+
+   for (i = n; i--  0; ) {
+   if (surfs[i])
+   wl_surface_destroy(surfs[i]);
+
+   if (subs[i])
+   wl_subsurface_destroy(subs[i]);
+   }
+}
+
+static int
+has_dupe(int *cnt, int n)
+{
+   int i;
+
+   for (i = 0; i  n; i++)
+   if (cnt[i] == cnt[n])
+   return 1;
+
+   return 0;
+}
+
+/* Note: number of permutations to test is: set_size! / (set_size - NSTEPS)!
+ */
+#define NSTEPS 3
+
+struct permu_state {
+   int set_size;
+   int cnt[NSTEPS];
+};
+
+static void
+permu_init(struct permu_state *s, int set_size)
+{
+   int i;
+
+   s-set_size = set_size;
+   for (i = 0; i  NSTEPS; i++)
+   s-cnt[i] = 0;
+}
+
+static int
+permu_next(struct permu_state *s)
+{
+   int k;
+
+   s-cnt[NSTEPS - 1]++;
+
+   while (1) {
+   if (s-cnt[0] = s-set_size) {
+   return -1;
+   }
+
+   for (k = 1; k  NSTEPS; k++) {
+   if (s-cnt[k] = s-set_size) {
+   s-cnt[k - 1]++;
+   s-cnt[k] = 0;
+   break;
+   }
+
+   if (has_dupe(s-cnt, k)) {
+   s-cnt[k]++;
+   break;
+   }
+   }
+
+   if (k == NSTEPS)
+   return 0;
+   }
+}
+
+static void
+destroy_permu_object(struct wl_surface **surfs,
+struct wl_subsurface **subs, int i)
+{
+   int h = (i + 1) / 2;
+
+   if (i  1) {
+   fprintf(stderr,  [sub  %2d], h);
+   wl_subsurface_destroy(subs[h]);
+   subs[h] = NULL;
+   } else {
+   fprintf(stderr,  [surf %2d], h);
+   wl_surface_destroy(surfs[h]);
+   surfs[h] = NULL;
+   }
+}
+
+TEST(test_subsurface_destroy_permutations)
+{
+   /*
+* Test wl_surface and wl_subsurface destruction orders in a
+* complex tree of sub-surfaces.
+*
+* In the tree of sub-surfaces, go through every possible
+* permutation of destroying all wl_surface and wl_subsurface
+* objects. Execpt, to limit running time to a reasonable level,
+* execute only the first NSTEPS destructions from each
+* permutation, and ignore identical cases.
+*/
+
+ 

[PATCH weston 3/6] protocol: set_desync should flush

2013-05-17 Thread ppaalanen
From: Pekka Paalanen ppaala...@gmail.com

wl_subsurface.set_desync should apply the cached wl_surface state.
Otherwise, the sub-surface may be stuck: a commit on the parent surface,
if desynchronized, will not commit the sub-surface because it is
desynchronized, too. A commit on the sub-surface may not happen, if it
is waiting for the frame callback from the previous commit.

Signed-off-by: Pekka Paalanen ppaala...@gmail.com
---
 protocol/subsurface.xml |  3 +++
 src/compositor.c| 33 +
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/protocol/subsurface.xml b/protocol/subsurface.xml
index 71dc1e9..9c04a30 100644
--- a/protocol/subsurface.xml
+++ b/protocol/subsurface.xml
@@ -236,6 +236,9 @@
Note: even if a sub-surface is set to desynchronized, a parent
sub-surface may override it to behave as synchronized. For details,
see wl_subsurface.
+
+   If a surface's parent surface behaves as desynchronized, then
+   the cached state is applied on set_desync.
   /description
 /request
 
diff --git a/src/compositor.c b/src/compositor.c
index 89b9cef..ed250ba 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1851,21 +1851,11 @@ weston_subsurface_commit(struct weston_subsurface *sub)
 }
 
 static void
-weston_subsurface_parent_commit(struct weston_subsurface *sub,
-   int parent_is_synchronized)
+weston_subsurface_synchronized_commit(struct weston_subsurface *sub)
 {
struct weston_surface *surface = sub-surface;
struct weston_subsurface *tmp;
 
-   if (sub-position.set) {
-   weston_surface_set_position(sub-surface,
-   sub-position.x, sub-position.y);
-   sub-position.set = 0;
-   }
-
-   if (!parent_is_synchronized  !sub-synchronized)
-   return;
-
/* From now on, commit_from_cache the whole sub-tree, regardless of
 * the synchronized mode of each child. This sub-surface or some
 * of its ancestors were synchronized, so we are synchronized
@@ -1882,6 +1872,20 @@ weston_subsurface_parent_commit(struct weston_subsurface 
*sub,
 }
 
 static void
+weston_subsurface_parent_commit(struct weston_subsurface *sub,
+   int parent_is_synchronized)
+{
+   if (sub-position.set) {
+   weston_surface_set_position(sub-surface,
+   sub-position.x, sub-position.y);
+   sub-position.set = 0;
+   }
+
+   if (parent_is_synchronized || sub-synchronized)
+   weston_subsurface_synchronized_commit(sub);
+}
+
+static void
 subsurface_configure(struct weston_surface *surface, int32_t dx, int32_t dy,
 int32_t width, int32_t height)
 {
@@ -2050,8 +2054,13 @@ subsurface_set_desync(struct wl_client *client, struct 
wl_resource *resource)
 {
struct weston_subsurface *sub = resource-data;
 
-   if (sub)
+   if (sub  sub-synchronized) {
sub-synchronized = 0;
+
+   /* If sub became effectively desynchronized, flush. */
+   if (!weston_subsurface_is_synchronized(sub))
+   weston_subsurface_synchronized_commit(sub);
+   }
 }
 
 static void
-- 
1.8.1.5

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


[PATCH weston 4/6] tests: add a sub-surface nesting loop test

2013-05-17 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

It should not be possible to create a loop by nesting sub-surfaces.
Currently Weston fails this test.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 tests/subsurface-test.c | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/tests/subsurface-test.c b/tests/subsurface-test.c
index 0a210fb..98e00fe 100644
--- a/tests/subsurface-test.c
+++ b/tests/subsurface-test.c
@@ -220,6 +220,28 @@ TEST(test_subsurface_nesting_parent)
client_roundtrip(client);
 }
 
+FAIL_TEST(test_subsurface_loop_paradox)
+{
+   struct client *client;
+   struct wl_surface *surface[3];
+   struct wl_subcompositor *subco;
+
+   client = client_create(100, 50, 123, 77);
+   assert(client);
+
+   subco = get_subcompositor(client);
+   surface[0] = wl_compositor_create_surface(client-wl_compositor);
+   surface[1] = wl_compositor_create_surface(client-wl_compositor);
+   surface[2] = wl_compositor_create_surface(client-wl_compositor);
+
+   /* create a nesting loop */
+   wl_subcompositor_get_subsurface(subco, surface[1], surface[0]);
+   wl_subcompositor_get_subsurface(subco, surface[2], surface[1]);
+   wl_subcompositor_get_subsurface(subco, surface[0], surface[2]);
+
+   client_roundtrip(client);
+}
+
 FAIL_TEST(test_subsurface_place_above_stranger)
 {
struct client *client;
-- 
1.8.1.5

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


[PATCH weston 5/6] compositor: forbid sub-surface nesting loops

2013-05-17 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

The only way to create a sub-surface loop by recursive nesting is to
make the main surface (which does not have a role) a sub-surface of any
of its sub-surfaces. All other cases should already be cought.

This change checks for that exact case, and sends a protocol error.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 src/compositor.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index ed250ba..f67028e 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2295,6 +2295,14 @@ subcompositor_get_subsurface(struct wl_client *client,
return;
}
 
+   if (weston_surface_get_main_surface(parent) == surface) {
+   wl_resource_post_error(resource,
+   WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE,
+   %s%d: wl_surface@%d is an ancestor of parent,
+   where, id, surface_resource-object.id);
+   return;
+   }
+
/* make sure the parent is in its own list */
if (wl_list_empty(parent-subsurface_list)) {
if (!weston_subsurface_create_for_parent(parent)) {
-- 
1.8.1.5

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


[PATCH weston 6/6] protocol: remove an unused sub-surface error code

2013-05-17 Thread ppaalanen
From: Pekka Paalanen pekka.paala...@collabora.co.uk

This was left over from allowing nesting.

Signed-off-by: Pekka Paalanen pekka.paala...@collabora.co.uk
---
 protocol/subsurface.xml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/protocol/subsurface.xml b/protocol/subsurface.xml
index 9c04a30..9e4a658 100644
--- a/protocol/subsurface.xml
+++ b/protocol/subsurface.xml
@@ -60,8 +60,6 @@
 enum name=error
   entry name=bad_surface value=0
  summary=the to-be sub-surface is invalid/
-  entry name=bad_parent value=1
- summary=the given parent is a sub-surface/
 /enum
 
 request name=get_subsurface
-- 
1.8.1.5

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