From 4811e428a9206ef59487fb0d3fab160a19845d46 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 8 Feb 2010 21:46:49 +0100 Subject: [PATCH] glamor: Pull in UXA code for dumping some composites down to copy_n_to_n. Window dragging with metacity+gnome-terminal+xcompmgr is almost credible. --- glamor/glamor_render.c | 57 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index f9e7341c1..a7777fbad 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -399,6 +399,32 @@ glamor_set_composite_solid(PicturePtr picture, GLint uniform_location) glUniform4fvARB(uniform_location, 1, color); } +static int +compatible_formats (CARD8 op, PicturePtr dst, PicturePtr src) +{ + if (op == PictOpSrc) { + if (src->format == dst->format) + return 1; + + if (src->format == PICT_a8r8g8b8 && dst->format == PICT_x8r8g8b8) + return 1; + + if (src->format == PICT_a8b8g8r8 && dst->format == PICT_x8b8g8r8) + return 1; + } else if (op == PictOpOver) { + if (src->alphaMap || dst->alphaMap) + return 0; + + if (src->format != dst->format) + return 0; + + if (src->format == PICT_x8r8g8b8 || src->format == PICT_x8b8g8r8) + return 1; + } + + return 0; +} + void glamor_composite(CARD8 op, PicturePtr source, @@ -424,8 +450,6 @@ glamor_composite(CARD8 op, RegionRec region; int i; - goto fail; - /* Do two-pass PictOpOver componentAlpha, until we enable * dual source color blending. */ @@ -445,6 +469,35 @@ glamor_composite(CARD8 op, return; } + if (!mask) { + if (compatible_formats (op, dest, source)) { + if (!source->repeat && !source->transform) { + x_dest += dest->pDrawable->x; + y_dest += dest->pDrawable->y; + x_source += source->pDrawable->x; + y_source += source->pDrawable->y; + + if (!miComputeCompositeRegion + (®ion, + source, NULL, dest, + x_source, y_source, 0, 0, x_dest, y_dest, width, height)) + return; + + glamor_copy_n_to_n(source->pDrawable, + dest->pDrawable, NULL, + REGION_RECTS(®ion), + REGION_NUM_RECTS(®ion), + x_source - x_dest, y_source - y_dest, + FALSE, FALSE, 0, NULL); + REGION_UNINIT(dest->pDrawable->pScreen, + ®ion); + return; + } + } + } + + goto fail; + memset(&key, 0, sizeof(key)); key.has_mask = (mask != NULL); if (!source->pDrawable) {