From 313bd84a48319965b7c4d1324172ae08d56af98b Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 26 Apr 2012 15:14:50 +0300 Subject: [PATCH 1/6] simple-shm: render meaningful diagnostics Previously, simple-shm was rendering an image that looked like stride gone wrong somewhere, and was quite confusing if you did not know it was supposed to look like that. Replace the drawing code. Two circles, inner and outer, now delimit three co-centric areas. The outmost area from surface borders to outer circle contains horizontal gradients that move (animate) to the left. The area between outer and inner circles contains vertical gradients that move upwards. The center disc has circular gradients moving towards the center. The circles are not ellipses. Diagnostics: The X-channel is manipulated so, that if a compositor takes the XRGB image, and uses the X channel as alpha instead of ignoring it, the whole image will be crossed out by two lines that either quickly saturate to white or show through with additive blending. Does not work on black background. Signed-off-by: Pekka Paalanen --- clients/simple-shm.c | 51 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/clients/simple-shm.c b/clients/simple-shm.c index d1fe0c68..65c0eae4 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -130,21 +130,56 @@ destroy_window(struct window *window) free(window); } +static void +paint_pixels(void *image, int width, int height, uint32_t time) +{ + const int halfh = height / 2; + const int halfw = width / 2; + int ir, or; + uint32_t *pixel = image; + int y; + + /* squared radii thresholds */ + or = (halfw < halfh ? halfw : halfh) - 8; + ir = or - 32; + or *= or; + ir *= ir; + + for (y = 0; y < height; y++) { + int x; + int y2 = (y - halfh) * (y - halfh); + + for (x = 0; x < width; x++) { + uint32_t v; + + /* squared distance from center */ + int r2 = (x - halfw) * (x - halfw) + y2; + + if (r2 < ir) + v = (r2 / 32 + time / 64) * 0x0080401; + else if (r2 < or) + v = (y + time / 32) * 0x0080401; + else + v = (x + time / 16) * 0x0080401; + v &= 0x00ffffff; + + /* cross if compositor uses X from XRGB as alpha */ + if (abs(x - y) > 6 && abs(x + y - height) > 6) + v |= 0xff000000; + + *pixel++ = v; + } + } +} + static const struct wl_callback_listener frame_listener; static void redraw(void *data, struct wl_callback *callback, uint32_t time) { struct window *window = data; - uint32_t *p; - int i, end, offset; - - p = window->shm_data; - end = window->width * window->height; - offset = time >> 4; - for (i = 0; i < end; i++) - p[i] = (i + offset) * 0x0080401; + paint_pixels(window->shm_data, window->width, window->height, time); wl_surface_attach(window->surface, window->buffer, 0, 0); wl_surface_damage(window->surface, 0, 0, window->width, window->height); From f31ad10b77a86f7c7d3481eb083c5699594983f5 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 26 Apr 2012 10:31:36 +0300 Subject: [PATCH 2/6] compositor: report .so path when load_module() fails I want to know which module is failing to load with unresolved symbols. Signed-off-by: Pekka Paalanen --- src/compositor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 768477de..6ce10a4b 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2608,14 +2608,15 @@ load_module(const char *name, const char *entrypoint, void **handle) module = dlopen(path, RTLD_LAZY); if (!module) { fprintf(stderr, - "failed to load module: %s\n", dlerror()); + "failed to load module '%s': %s\n", path, dlerror()); return NULL; } init = dlsym(module, entrypoint); if (!init) { fprintf(stderr, - "failed to lookup init function: %s\n", dlerror()); + "failed to lookup init function in '%s': %s\n", + path, dlerror()); return NULL; } From 3baf946b9ae3d93e47c754e49e2ecead3d397db3 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 18 Apr 2012 13:23:09 +0300 Subject: [PATCH 3/6] simple-shm: handle shm buffer failure Do not segfault, if creating the shm buffer fails. Signed-off-by: Pekka Paalanen --- clients/simple-shm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/clients/simple-shm.c b/clients/simple-shm.c index 65c0eae4..850567d1 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -101,6 +101,17 @@ create_window(struct display *display, int width, int height) struct window *window; window = malloc(sizeof *window); + + window->buffer = create_shm_buffer(display, + width, height, + WL_SHM_FORMAT_XRGB8888, + &window->shm_data); + + if (!window->buffer) { + free(window); + return NULL; + } + window->callback = NULL; window->display = display; window->width = width; @@ -108,10 +119,6 @@ create_window(struct display *display, int width, int height) window->surface = wl_compositor_create_surface(display->compositor); window->shell_surface = wl_shell_get_shell_surface(display->shell, window->surface); - window->buffer = create_shm_buffer(display, - width, height, - WL_SHM_FORMAT_XRGB8888, - &window->shm_data); wl_shell_surface_set_toplevel(window->shell_surface); @@ -293,6 +300,8 @@ main(int argc, char **argv) display = create_display(); window = create_window(display, 250, 250); + if (!window) + return 1; sigint.sa_handler = signal_int; sigemptyset(&sigint.sa_mask); From c3710f2379730ea7e216a0f9769e35b5918c2f1f Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 17 Apr 2012 16:34:47 +0300 Subject: [PATCH 4/6] simple-shm: no need for wayland-egl.h Signed-off-by: Pekka Paalanen --- clients/simple-shm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/clients/simple-shm.c b/clients/simple-shm.c index 850567d1..16f718c1 100644 --- a/clients/simple-shm.c +++ b/clients/simple-shm.c @@ -31,7 +31,6 @@ #include #include -#include struct display { struct wl_display *display; From ec2507695f92168590704ba234af23436a8720a7 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 17 Apr 2012 16:49:12 +0300 Subject: [PATCH 5/6] fix build for --disable-clients --enable-simple-clients Simple clients were relying on AM_CFLAGS and AM_CPPFLAGS set for toytoolkit clients. With toytoolkit clients disabled, the build fails with missing wayland-client.h. Move AM_CFLAGS and AM_CPPFLAGS outside of conditional sections, since they are meant to be global settings. Let simple clients override AM_CPPFLAGS with their own SIMPLE_CLIENT_CFLAGS, which the configure script already sets up for us, but was unused until now. Signed-off-by: Pekka Paalanen --- clients/Makefile.am | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/clients/Makefile.am b/clients/Makefile.am index dd11382b..23771898 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -11,6 +11,12 @@ libexec_PROGRAMS = \ $(tablet_shell) \ $(screenshooter) +AM_CFLAGS = $(GCC_CFLAGS) +AM_CPPFLAGS = \ + -DDATADIR='"$(datadir)"' \ + -DBINDIR='"$(bindir)"' \ + $(CLIENT_CFLAGS) $(CAIRO_EGL_CFLAGS) + if BUILD_SIMPLE_CLIENTS simple_clients_programs = \ simple-egl \ @@ -18,12 +24,15 @@ simple_clients_programs = \ simple-touch simple_egl_SOURCES = simple-egl.c +simple_egl_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS) simple_egl_LDADD = $(SIMPLE_CLIENT_LIBS) -lm simple_shm_SOURCES = simple-shm.c +simple_shm_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS) simple_shm_LDADD = $(SIMPLE_CLIENT_LIBS) simple_touch_SOURCES = simple-touch.c +simple_touch_CPPFLAGS = $(SIMPLE_CLIENT_CFLAGS) simple_touch_LDADD = $(SIMPLE_CLIENT_LIBS) endif @@ -46,12 +55,6 @@ screenshooter = weston-screenshooter noinst_LIBRARIES = libtoytoolkit.a -AM_CFLAGS = $(GCC_CFLAGS) -AM_CPPFLAGS = \ - -DDATADIR='"$(datadir)"' \ - -DBINDIR='"$(bindir)"' \ - $(CLIENT_CFLAGS) $(CAIRO_EGL_CFLAGS) - libtoytoolkit_a_SOURCES = \ window.c \ window.h \ From e17f61008c693a0ab360787cd28d1735e7d118eb Mon Sep 17 00:00:00 2001 From: Scott Moreau Date: Wed, 25 Apr 2012 10:03:06 -0600 Subject: [PATCH 6/6] compositor: Initialize xserver variable This variable is used unitialized if --xserver is not passed to weston. Signed-off-by: Pekka Paalanen --- src/compositor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compositor.c b/src/compositor.c index 6ce10a4b..4e4c66d3 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2640,7 +2640,7 @@ int main(int argc, char *argv[]) char *backend = NULL; char *shell = NULL; int32_t idle_time = 300; - int32_t xserver; + int32_t xserver = 0; char *socket_name = NULL; char *config_file;