From patchwork Thu Aug 30 21:47:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11117 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4143323F27 for ; Thu, 30 Aug 2012 21:47:45 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 95905A192F9 for ; Thu, 30 Aug 2012 21:47:08 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j25so3732075iaf.11 for ; Thu, 30 Aug 2012 14:47:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=C+1ZG/VlFG6+FKAr6dtVnLkzb3iAF+8tYEO+sMpa1QQ=; b=gAz4DXJAFGP3sY5t4KABycfeSZhVmQans8hoX91z2M9b1L99th50PtEOPawgLd0HIL 3hDq/4a9zJ6d1HU2yN2JYw0T0GqfWt6tSeLyEiWN5nJoWU+RS4buw8vkRts9wvunYbTJ as0nuQ2coZogMHn7F3Nmkna98pTmWB+krpu9lIyuDCMbwMcgyUZxtZ+e99LMpg54LH44 Ol9HXQr9eQkLpc2gBNPMXnSSAH6qJYJYk47Vur/RVomcJ/ODUOG9ArXjcslPrkmBzI3S r/GMmk3fdPdbH4mGA18PkyhSdQP30sQ/ISOjV16V5f/UUAldegRB0Vkt0NmVZMi1b39F lERQ== Received: by 10.50.45.162 with SMTP id o2mr2638610igm.0.1346363264702; Thu, 30 Aug 2012 14:47:44 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp33040igc; Thu, 30 Aug 2012 14:47:44 -0700 (PDT) Received: by 10.66.81.66 with SMTP id y2mr11666134pax.62.1346363264126; Thu, 30 Aug 2012 14:47:44 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id gk6si4806647pbc.185.2012.08.30.14.47.43 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Aug 2012 14:47:44 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.210.50 as permitted sender) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.210.50 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by dade7 with SMTP id e7so1658312dad.37 for ; Thu, 30 Aug 2012 14:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=C+1ZG/VlFG6+FKAr6dtVnLkzb3iAF+8tYEO+sMpa1QQ=; b=ZdywUnBcgvTRmQ6zvpID7JuggUYvD2BNu2HK6HrKVkoBf8cGsvuquHjM8F95RArRNk Y/6OhEt1MVmnDIDfnGrT/s1zMnkOg1RE+6eRzsnx8neWPoHkRz1cuZTB9cYh51yIfKUi UrVQ0ULP5y0GSQCyh5oAvuHMW+wlUq+RUmT2Y0eAmWv71OfIy57YjpVOfDrCcCbea8ae Vh9lHlFnSlTfTrBeV0T5f9NjmfNq8tzSxsbwZNcsI+O6BqOqZiz5dGLRIQGgiRoqbxtm Ja+AZ5avyC6HKjAxLKNKkJ5+3QPbVG2ELsKIVrwixjhihifLx5Ibf7M/yXz7Srf1UnU3 glxQ== Received: by 10.68.224.5 with SMTP id qy5mr13896393pbc.4.1346363263868; Thu, 30 Aug 2012 14:47:43 -0700 (PDT) Received: from localhost ([38.96.16.75]) by mx.google.com with ESMTPS id os1sm2219233pbc.31.2012.08.30.14.47.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Aug 2012 14:47:43 -0700 (PDT) Sender: Rob Clark From: Rob Clark To: wayland-devel@lists.freedesktop.org Cc: patches@linaro.org, Pekka Paalanen , Rob Clark Subject: [PATCH weston 5/5] compositor: triangle fan debug Date: Thu, 30 Aug 2012 16:47:21 -0500 Message-Id: <1346363241-29219-6-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1346363241-29219-1-git-send-email-rob.clark@linaro.org> References: <1346363241-29219-1-git-send-email-rob.clark@linaro.org> X-Gm-Message-State: ALoCoQkrCl3lGbFdi1s4NWWeHIjV/3ll8PBP0P/T13X/LYhqBAdemaBUD7BAvz+T51+PlL8dtIYG From: Pekka Paalanen Draw the borders of all the triangles. v1: original v2: add keybinding to enable/disable fan debug (super-alt-space), cycle colors to make it easier to see individual draws, and redraw undamaged region to clean up previous frames debug lines Signed-off-by: Rob Clark --- src/compositor-android.c | 6 ++++- src/compositor-drm.c | 11 ++++++--- src/compositor-wayland.c | 5 +++- src/compositor-x11.c | 5 +++- src/compositor.c | 60 +++++++++++++++++++++++++++++++++++++++++++++- src/compositor.h | 3 ++- src/shell.c | 13 ++++++++++ 7 files changed, 95 insertions(+), 8 deletions(-) diff --git a/src/compositor-android.c b/src/compositor-android.c index a9c45d2..a8dec31 100644 --- a/src/compositor-android.c +++ b/src/compositor-android.c @@ -146,7 +146,8 @@ android_finish_frame(void *data) } static void -android_output_repaint(struct weston_output *base, pixman_region32_t *damage) +android_output_repaint(struct weston_output *base, pixman_region32_t *damage, + int flip) { struct android_output *output = to_android_output(base); struct android_compositor *compositor = output->compositor; @@ -161,6 +162,9 @@ android_output_repaint(struct weston_output *base, pixman_region32_t *damage) wl_list_for_each_reverse(surface, &compositor->base.surface_list, link) weston_surface_draw(surface, &output->base, damage); + if (!flip) + return; + wl_signal_emit(&output->base.frame_signal, output); ret = eglSwapBuffers(compositor->base.egl_display, output->egl_surface); diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 00b7502..00656dd 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -326,7 +326,7 @@ drm_output_prepare_scanout_surface(struct weston_output *_output, } static void -drm_output_render(struct drm_output *output, pixman_region32_t *damage) +drm_output_render(struct drm_output *output, pixman_region32_t *damage, int flip) { struct drm_compositor *compositor = (struct drm_compositor *) output->base.compositor; @@ -344,6 +344,9 @@ drm_output_render(struct drm_output *output, pixman_region32_t *damage) if (surface->plane == &compositor->base.primary_plane) weston_surface_draw(surface, &output->base, damage); + if (!flip) + return; + wl_signal_emit(&output->base.frame_signal, output); eglSwapBuffers(compositor->base.egl_display, output->egl_surface); @@ -363,7 +366,7 @@ drm_output_render(struct drm_output *output, pixman_region32_t *damage) static void drm_output_repaint(struct weston_output *output_base, - pixman_region32_t *damage) + pixman_region32_t *damage, int flip) { struct drm_output *output = (struct drm_output *) output_base; struct drm_compositor *compositor = @@ -373,9 +376,11 @@ drm_output_repaint(struct weston_output *output_base, int ret = 0; if (!output->next) - drm_output_render(output, damage); + drm_output_render(output, damage, flip); if (!output->next) return; + if (!flip) + return; mode = container_of(output->base.current, struct drm_mode, base); if (!output->current) { diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index 131fa32..f62eb92 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -330,7 +330,7 @@ static const struct wl_callback_listener frame_listener = { static void wayland_output_repaint(struct weston_output *output_base, - pixman_region32_t *damage) + pixman_region32_t *damage, int flip) { struct wayland_output *output = (struct wayland_output *) output_base; struct wayland_compositor *compositor = @@ -348,6 +348,9 @@ wayland_output_repaint(struct weston_output *output_base, wl_list_for_each_reverse(surface, &compositor->base.surface_list, link) weston_surface_draw(surface, &output->base, damage); + if (!flip) + return; + draw_border(output); wl_signal_emit(&output->base.frame_signal, output); diff --git a/src/compositor-x11.c b/src/compositor-x11.c index c02911d..bf00d6f 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -320,7 +320,7 @@ x11_compositor_fini_egl(struct x11_compositor *compositor) static void x11_output_repaint(struct weston_output *output_base, - pixman_region32_t *damage) + pixman_region32_t *damage, int flip) { struct x11_output *output = (struct x11_output *)output_base; struct x11_compositor *compositor = @@ -337,6 +337,9 @@ x11_output_repaint(struct weston_output *output_base, wl_list_for_each_reverse(surface, &compositor->base.surface_list, link) weston_surface_draw(surface, &output->base, damage); + if (!flip) + return; + wl_signal_emit(&output->base.frame_signal, output); eglSwapBuffers(compositor->base.egl_display, output->egl_surface); diff --git a/src/compositor.c b/src/compositor.c index e9fa56e..05315ed 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -55,6 +55,9 @@ #include "../shared/os-compatibility.h" #include "git-version.h" +#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) + + static struct wl_list child_process_list; static struct weston_compositor *segv_compositor; @@ -1236,6 +1239,45 @@ texture_region(struct weston_surface *es, pixman_region32_t *region, } static void +triangle_fan_debug(struct weston_surface *surface, int first, int count) +{ + struct weston_compositor *compositor = surface->compositor; + int i; + GLushort *buffer; + GLushort *index; + int nelems; + static int color_idx = 0; + static const GLfloat color[][4] = { + { 1.0, 0.0, 0.0, 1.0 }, + { 0.0, 1.0, 0.0, 1.0 }, + { 0.0, 0.0, 1.0, 1.0 }, + { 1.0, 1.0, 1.0, 1.0 }, + }; + + nelems = (count - 1 + count - 2) * 2; + + buffer = malloc(sizeof(GLushort) * nelems); + index = buffer; + + for (i = 1; i < count; i++) { + *index++ = first; + *index++ = first + i; + } + + for (i = 2; i < count; i++) { + *index++ = first + i - 1; + *index++ = first + i; + } + + glUseProgram(compositor->solid_shader.program); + glUniform4fv(compositor->solid_shader.color_uniform, 1, + color[color_idx++ % ARRAY_SIZE(color)]); + glDrawElements(GL_LINES, nelems, GL_UNSIGNED_SHORT, buffer); + glUseProgram(surface->shader->program); + free(buffer); +} + +static void repaint_region(struct weston_surface *es, pixman_region32_t *region, pixman_region32_t *surf_region) { @@ -1267,6 +1309,8 @@ repaint_region(struct weston_surface *es, pixman_region32_t *region, for (i = 0, first = 0; i < nfans; i++) { glDrawArrays(GL_TRIANGLE_FAN, first, vtxcnt[i]); + if (ec->fan_debug) + triangle_fan_debug(es, first, vtxcnt[i]); first += vtxcnt[i]; } @@ -1560,7 +1604,21 @@ weston_output_repaint(struct weston_output *output, uint32_t msecs) if (output->dirty) weston_output_update_matrix(output); - output->repaint(output, &output_damage); + /* if debugging, redraw everything outside the damage to clean up + * debug lines from the previous draw on this buffer: + */ + if (ec->fan_debug) { + pixman_region32_t undamaged; + pixman_region32_init(&undamaged); + pixman_region32_subtract(&undamaged, &output->region, + &output_damage); + ec->fan_debug = 0; + output->repaint(output, &undamaged, 0); + ec->fan_debug = 1; + pixman_region32_fini(&undamaged); + } + + output->repaint(output, &output_damage, 1); pixman_region32_fini(&output_damage); diff --git a/src/compositor.h b/src/compositor.h index 74b154a..b826862 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -176,7 +176,7 @@ struct weston_output { struct wl_list mode_list; void (*repaint)(struct weston_output *output, - pixman_region32_t *damage); + pixman_region32_t *damage, int flip); void (*destroy)(struct weston_output *output); void (*assign_planes)(struct weston_output *output); int (*switch_mode)(struct weston_output *output, struct weston_mode *mode); @@ -321,6 +321,7 @@ struct weston_compositor { struct wl_array indices; /* only used in compositor-wayland */ struct wl_array vtxcnt; struct weston_plane primary_plane; + int fan_debug; uint32_t focus; diff --git a/src/shell.c b/src/shell.c index 4d6bc4f..e5a6ab3 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3267,6 +3267,17 @@ debug_repaint_binding(struct wl_seat *seat, uint32_t time, uint32_t key, } } + +static void +fan_debug_repaint_binding(struct wl_seat *seat, uint32_t time, uint32_t key, + void *data) +{ + struct desktop_shell *shell = data; + struct weston_compositor *compositor = shell->compositor; + compositor->fan_debug = !compositor->fan_debug; + weston_compositor_damage_all(compositor); +} + static void force_kill_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data) @@ -3401,6 +3412,8 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell) backlight_binding, ec); weston_compositor_add_key_binding(ec, KEY_SPACE, mod | MODIFIER_SHIFT, debug_repaint_binding, shell); + weston_compositor_add_key_binding(ec, KEY_SPACE, mod | MODIFIER_ALT, + fan_debug_repaint_binding, shell); weston_compositor_add_key_binding(ec, KEY_K, mod, force_kill_binding, shell); weston_compositor_add_key_binding(ec, KEY_UP, mod,