From 84e0d5d63c393fc36e91433cd7897e776e82528c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Fri, 27 May 2016 16:58:19 +0900 Subject: [PATCH 1/4] xfree86/modes: Assign xf86_config->cursor in xf86_load_cursor_image v2 Fixes a crash on startup in the radeon driver's drmmode_show_cursor() due to xf86_config->cursor == NULL, because no CRTC was enabled yet, so xf86_crtc_load_cursor_image was never called. (Also use scrn->pScreen instead of xf86ScrnToScreen(scrn)) v2: Set xf86_config->cursor at the beginning of xf86_load_cursor_image instead of at the end. Reviewed-by: Keith Packard --- hw/xfree86/modes/xf86Cursors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index b7372682e..351777b0d 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -456,7 +456,6 @@ xf86_crtc_load_cursor_image(xf86CrtcPtr crtc, CARD8 *src) CARD8 *cursor_image; const Rotation rotation = xf86_crtc_cursor_rotation(crtc); - xf86_config->cursor = xf86CurrentCursor(xf86ScrnToScreen(scrn)); crtc->cursor_argb = FALSE; if (rotation == RR_Rotate_0) @@ -493,6 +492,7 @@ xf86_load_cursor_image(ScrnInfoPtr scrn, unsigned char *src) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); int c; + xf86_config->cursor = xf86CurrentCursor(scrn->pScreen); for (c = 0; c < xf86_config->num_crtc; c++) { xf86CrtcPtr crtc = xf86_config->crtc[c]; From 5ff75da317539e87cca429185d710d0eeb9d9222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 26 May 2016 19:01:59 +0900 Subject: [PATCH 2/4] glamor: Cannot use copies when accessing outside of composite source Commit b64108fa ("glamor: Check for composite operations which are equivalent to copies") failed to copy conditions from exaComposite which ensure that the composite operation doesn't access outside of the source picture. This fixes rendercheck regressions from the commit above. Reviewed-by: Keith Packard --- glamor/glamor_render.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index 165bcede6..64141ac0f 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -1424,18 +1424,21 @@ glamor_composite_clipped_region(CARD8 op, if (!mask && !source->alphaMap && !dest->alphaMap && source->pDrawable && !source->transform && ((op == PictOpSrc - && ((source->format == dest->format - || (PICT_FORMAT_COLOR(dest->format) - && PICT_FORMAT_COLOR(source->format) - && dest->format == PICT_FORMAT(PICT_FORMAT_BPP(source->format), - PICT_FORMAT_TYPE(source->format), - 0, - PICT_FORMAT_R(source->format), - PICT_FORMAT_G(source->format), - PICT_FORMAT_B(source->format)))) - || (op == PictOpOver - && source->format == dest->format - && !PICT_FORMAT_A(source->format)))))) { + && (source->format == dest->format + || (PICT_FORMAT_COLOR(dest->format) + && PICT_FORMAT_COLOR(source->format) + && dest->format == PICT_FORMAT(PICT_FORMAT_BPP(source->format), + PICT_FORMAT_TYPE(source->format), + 0, + PICT_FORMAT_R(source->format), + PICT_FORMAT_G(source->format), + PICT_FORMAT_B(source->format))))) + || (op == PictOpOver + && source->format == dest->format + && !PICT_FORMAT_A(source->format))) + && x_source >= 0 && y_source >= 0 + && (x_source + width) <= source->pDrawable->width + && (y_source + height) <= source->pDrawable->height) { x_source += source->pDrawable->x; y_source += source->pDrawable->y; x_dest += dest->pDrawable->x; From e156c0ccb530897d3a428255bd5585f7ea7b9b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 30 Mar 2016 18:23:04 +0900 Subject: [PATCH 3/4] os: Use strtok instead of xstrtokenize in ComputeLocalClient Fixes leaking the memory pointed to by the members of the array returned by xstrtokenize. Reviewed-by: Adam Jackson --- os/access.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/os/access.c b/os/access.c index 58f95a971..8828e0834 100644 --- a/os/access.c +++ b/os/access.c @@ -1131,19 +1131,20 @@ ComputeLocalClient(ClientPtr client) * is forwarded from another host via SSH */ if (cmdname) { - char **cmd; + char *cmd = strdup(cmdname); Bool ret; /* Cut off any colon and whatever comes after it, see * https://lists.freedesktop.org/archives/xorg-devel/2015-December/048164.html */ - cmd = xstrtokenize(cmdname, ":"); + cmd = strtok(cmd, ":"); #if !defined(WIN32) || defined(__CYGWIN__) - cmd[0] = basename(cmd[0]); + ret = strcmp(basename(cmd), "ssh") != 0; +#else + ret = strcmp(cmd, "ssh") != 0; #endif - ret = strcmp(cmd[0], "ssh") != 0; free(cmd); return ret; From 43dbc556f3a4d743b9121d6cfc21961be4a9da56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 24 Dec 2015 16:43:44 +0900 Subject: [PATCH 4/4] xfree86/modes: Remove xf86_reload_cursors v2 No longer needed now that xf86CursorResetCursor is getting called for each CRTC configuration change. v2: Keep xf86_reload_cursors as a deprecated empty inline function until all drivers stop calling it. (Adam Jackson) Reviewed-by: Adam Jackson --- .../drivers/modesetting/drmmode_display.c | 5 -- hw/xfree86/modes/xf86Crtc.h | 10 +--- hw/xfree86/modes/xf86Cursors.c | 57 ------------------- 3 files changed, 3 insertions(+), 69 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 8ca0c26a1..bf21320ce 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -508,11 +508,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, } } -#if 0 - if (pScrn->pScreen && - !xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) - xf86_reload_cursors(pScrn->pScreen); -#endif done: if (!ret) { crtc->x = saved_x; diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index 8b0160845..bdcfa131a 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -968,14 +968,10 @@ extern _X_EXPORT Bool xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags); /** - * Called when anything on the screen is reconfigured. - * - * Reloads cursor images as needed, then adjusts cursor positions. - * - * Driver should call this from crtc commit function. + * Superseeded by xf86CursorResetCursor, which is getting called + * automatically when necessary. */ -extern _X_EXPORT void - xf86_reload_cursors(ScreenPtr screen); +static _X_INLINE _X_DEPRECATED void xf86_reload_cursors(ScreenPtr screen) {} /** * Called from EnterVT to turn the cursors back on diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 351777b0d..6293b7332 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -640,63 +640,6 @@ xf86_cursors_init(ScreenPtr screen, int max_width, int max_height, int flags) return xf86InitCursor(screen, cursor_info); } -/** - * Called when anything on the screen is reconfigured. - * - * Reloads cursor images as needed, then adjusts cursor positions - * @note We assume that all hardware cursors to be loaded have already been - * found to be usable by the hardware. - */ - -void -xf86_reload_cursors(ScreenPtr screen) -{ - ScrnInfoPtr scrn; - xf86CrtcConfigPtr xf86_config; - xf86CursorInfoPtr cursor_info; - CursorPtr cursor; - int x, y; - xf86CursorScreenPtr cursor_screen_priv; - - /* initial mode setting will not have set a screen yet. - May be called before the devices are initialised. - */ - if (!screen || !inputInfo.pointer) - return; - cursor_screen_priv = dixLookupPrivate(&screen->devPrivates, - xf86CursorScreenKey); - /* return if HW cursor is inactive, to avoid displaying two cursors */ - if (!cursor_screen_priv || !cursor_screen_priv->isUp) - return; - - scrn = xf86ScreenToScrn(screen); - xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - - /* make sure the cursor code has been initialized */ - cursor_info = xf86_config->cursor_info; - if (!cursor_info) - return; - - cursor = xf86CurrentCursor(screen); - GetSpritePosition(inputInfo.pointer, &x, &y); - if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) - (*cursor_info->HideCursor) (scrn); - - if (cursor) { - void *src = - dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, - screen); - if (cursor->bits->argb && xf86DriverHasLoadCursorARGB(cursor_info)) - xf86DriverLoadCursorARGB(cursor_info, cursor); - else if (src) - xf86DriverLoadCursorImage(cursor_info, src); - - x += scrn->frameX0 + cursor_screen_priv->HotX; - y += scrn->frameY0 + cursor_screen_priv->HotY; - (*cursor_info->SetCursorPosition) (scrn, x, y); - } -} - /** * Clean up CRTC-based cursor code */