xf86-video-intel: 2 commits - src/sna/gen2_render.c src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/sna_gradient.c src/sna/sna_render.c src/sna/sna_render.h

Chris Wilson ickle at kemper.freedesktop.org
Fri Jun 28 03:27:05 PDT 2013


 src/sna/gen2_render.c  |   14 ++++++++------
 src/sna/gen3_render.c  |   27 ++++++++++++++++++++++++---
 src/sna/gen4_render.c  |   14 ++++++++------
 src/sna/gen5_render.c  |   14 ++++++++------
 src/sna/gen6_render.c  |   14 ++++++++------
 src/sna/gen7_render.c  |   14 ++++++++------
 src/sna/sna_gradient.c |   13 +++++++++++++
 src/sna/sna_render.c   |    9 +++++++--
 src/sna/sna_render.h   |    3 +++
 9 files changed, 87 insertions(+), 35 deletions(-)

New commits:
commit e979d32bb71fef7341ceb9c2b2e80c6dfa50a7b3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 28 10:59:23 2013 +0100

    sna/gen2+: Consider precision in render operation placement
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66297
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c
index f09a20b..faf2227 100644
--- a/src/sna/gen2_render.c
+++ b/src/sna/gen2_render.c
@@ -1632,7 +1632,7 @@ gen2_composite_set_target(struct sna *sna,
 }
 
 static bool
-is_unhandled_gradient(PicturePtr picture)
+is_unhandled_gradient(PicturePtr picture, bool precise)
 {
 	if (picture->pDrawable)
 		return false;
@@ -1642,7 +1642,7 @@ is_unhandled_gradient(PicturePtr picture)
 	case SourcePictTypeLinear:
 		return false;
 	default:
-		return true;
+		return precise;
 	}
 }
 
@@ -1678,12 +1678,12 @@ source_is_busy(PixmapPtr pixmap)
 }
 
 static bool
-source_fallback(PicturePtr p, PixmapPtr pixmap)
+source_fallback(PicturePtr p, PixmapPtr pixmap, bool precise)
 {
 	if (sna_picture_is_solid(p, NULL))
 		return false;
 
-	if (is_unhandled_gradient(p) || !gen2_check_repeat(p))
+	if (is_unhandled_gradient(p, precise) || !gen2_check_repeat(p))
 		return true;
 
 	if (pixmap && source_is_busy(pixmap))
@@ -1712,11 +1712,13 @@ gen2_composite_fallback(struct sna *sna,
 	dst_pixmap = get_drawable_pixmap(dst->pDrawable);
 
 	src_pixmap = src->pDrawable ? get_drawable_pixmap(src->pDrawable) : NULL;
-	src_fallback = source_fallback(src, src_pixmap);
+	src_fallback = source_fallback(src, src_pixmap,
+				       dst->polyMode == PolyModePrecise);
 
 	if (mask) {
 		mask_pixmap = mask->pDrawable ? get_drawable_pixmap(mask->pDrawable) : NULL;
-		mask_fallback = source_fallback(mask, mask_pixmap);
+		mask_fallback = source_fallback(mask, mask_pixmap,
+						dst->polyMode == PolyModePrecise);
 	} else {
 		mask_pixmap = NULL;
 		mask_fallback = NULL;
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index 13a46d3..8d65e6e 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -3307,11 +3307,30 @@ source_is_busy(PixmapPtr pixmap)
 }
 
 static bool
-source_fallback(PicturePtr p, PixmapPtr pixmap)
+is_unhandled_gradient(PicturePtr picture, bool precise)
+{
+	if (picture->pDrawable)
+		return false;
+
+	switch (picture->pSourcePict->type) {
+	case SourcePictTypeSolidFill:
+	case SourcePictTypeLinear:
+	case SourcePictTypeRadial:
+		return false;
+	default:
+		return precise;
+	}
+}
+
+static bool
+source_fallback(PicturePtr p, PixmapPtr pixmap, bool precise)
 {
 	if (sna_picture_is_solid(p, NULL))
 		return false;
 
+	if (is_unhandled_gradient(p, precise))
+		return true;
+
 	if (!gen3_check_xformat(p) || !gen3_check_repeat(p))
 		return true;
 
@@ -3342,11 +3361,13 @@ gen3_composite_fallback(struct sna *sna,
 	dst_pixmap = get_drawable_pixmap(dst->pDrawable);
 
 	src_pixmap = src->pDrawable ? get_drawable_pixmap(src->pDrawable) : NULL;
-	src_fallback = source_fallback(src, src_pixmap);
+	src_fallback = source_fallback(src, src_pixmap,
+				       dst->polyMode == PolyModePrecise);
 
 	if (mask) {
 		mask_pixmap = mask->pDrawable ? get_drawable_pixmap(mask->pDrawable) : NULL;
-		mask_fallback = source_fallback(mask, mask_pixmap);
+		mask_fallback = source_fallback(mask, mask_pixmap,
+						dst->polyMode == PolyModePrecise);
 	} else {
 		mask_pixmap = NULL;
 		mask_fallback = false;
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index b27e531..fa140cf 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -1635,14 +1635,14 @@ try_blt(struct sna *sna,
 }
 
 static bool
-check_gradient(PicturePtr picture)
+check_gradient(PicturePtr picture, bool precise)
 {
 	switch (picture->pSourcePict->type) {
 	case SourcePictTypeSolidFill:
 	case SourcePictTypeLinear:
 		return false;
 	default:
-		return true;
+		return precise;
 	}
 }
 
@@ -1679,13 +1679,13 @@ source_is_busy(PixmapPtr pixmap)
 }
 
 static bool
-source_fallback(struct sna *sna, PicturePtr p, PixmapPtr pixmap)
+source_fallback(struct sna *sna, PicturePtr p, PixmapPtr pixmap, bool precise)
 {
 	if (sna_picture_is_solid(p, NULL))
 		return false;
 
 	if (p->pSourcePict)
-		return check_gradient(p);
+		return check_gradient(p, precise);
 
 	if (!gen4_check_repeat(p) || !gen4_check_format(p->format))
 		return true;
@@ -1717,11 +1717,13 @@ gen4_composite_fallback(struct sna *sna,
 	dst_pixmap = get_drawable_pixmap(dst->pDrawable);
 
 	src_pixmap = src->pDrawable ? get_drawable_pixmap(src->pDrawable) : NULL;
-	src_fallback = source_fallback(sna, src, src_pixmap);
+	src_fallback = source_fallback(sna, src, src_pixmap,
+				       dst->polyMode == PolyModePrecise);
 
 	if (mask) {
 		mask_pixmap = mask->pDrawable ? get_drawable_pixmap(mask->pDrawable) : NULL;
-		mask_fallback = source_fallback(sna, mask, mask_pixmap);
+		mask_fallback = source_fallback(sna, mask, mask_pixmap,
+						dst->polyMode == PolyModePrecise);
 	} else {
 		mask_pixmap = NULL;
 		mask_fallback = false;
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 689332c..b31ac1e 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1611,7 +1611,7 @@ try_blt(struct sna *sna,
 }
 
 static bool
-is_gradient(PicturePtr picture)
+is_gradient(PicturePtr picture, bool precise)
 {
 	if (picture->pDrawable)
 		return false;
@@ -1621,7 +1621,7 @@ is_gradient(PicturePtr picture)
 	case SourcePictTypeLinear:
 		return false;
 	default:
-		return true;
+		return precise;
 	}
 }
 
@@ -1658,12 +1658,12 @@ source_is_busy(PixmapPtr pixmap)
 }
 
 static bool
-source_fallback(struct sna *sna, PicturePtr p, PixmapPtr pixmap)
+source_fallback(struct sna *sna, PicturePtr p, PixmapPtr pixmap, bool precise)
 {
 	if (sna_picture_is_solid(p, NULL))
 		return false;
 
-	if (is_gradient(p) ||
+	if (is_gradient(p, precise) ||
 	    !gen5_check_repeat(p) ||
 	    !gen5_check_format(p->format))
 		return true;
@@ -1694,11 +1694,13 @@ gen5_composite_fallback(struct sna *sna,
 	dst_pixmap = get_drawable_pixmap(dst->pDrawable);
 
 	src_pixmap = src->pDrawable ? get_drawable_pixmap(src->pDrawable) : NULL;
-	src_fallback = source_fallback(sna, src, src_pixmap);
+	src_fallback = source_fallback(sna, src, src_pixmap,
+				       dst->polyMode == PolyModePrecise);
 
 	if (mask) {
 		mask_pixmap = mask->pDrawable ? get_drawable_pixmap(mask->pDrawable) : NULL;
-		mask_fallback = source_fallback(sna, mask, mask_pixmap);
+		mask_fallback = source_fallback(sna, mask, mask_pixmap,
+						dst->polyMode == PolyModePrecise);
 	} else {
 		mask_pixmap = NULL;
 		mask_fallback = false;
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index e9136d7..d87ac12 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1931,7 +1931,7 @@ try_blt(struct sna *sna,
 }
 
 static bool
-check_gradient(PicturePtr picture)
+check_gradient(PicturePtr picture, bool precise)
 {
 	if (picture->pDrawable)
 		return false;
@@ -1941,7 +1941,7 @@ check_gradient(PicturePtr picture)
 	case SourcePictTypeLinear:
 		return false;
 	default:
-		return true;
+		return precise;
 	}
 }
 
@@ -1974,13 +1974,13 @@ source_is_busy(PixmapPtr pixmap)
 }
 
 static bool
-source_fallback(PicturePtr p, PixmapPtr pixmap)
+source_fallback(PicturePtr p, PixmapPtr pixmap, bool precise)
 {
 	if (sna_picture_is_solid(p, NULL))
 		return false;
 
 	if (p->pSourcePict)
-		return check_gradient(p);
+		return check_gradient(p, precise);
 
 	if (!gen6_check_repeat(p) || !gen6_check_format(p->format))
 		return true;
@@ -2011,11 +2011,13 @@ gen6_composite_fallback(struct sna *sna,
 	dst_pixmap = get_drawable_pixmap(dst->pDrawable);
 
 	src_pixmap = src->pDrawable ? get_drawable_pixmap(src->pDrawable) : NULL;
-	src_fallback = source_fallback(src, src_pixmap);
+	src_fallback = source_fallback(src, src_pixmap,
+				       dst->polyMode == PolyModePrecise);
 
 	if (mask) {
 		mask_pixmap = mask->pDrawable ? get_drawable_pixmap(mask->pDrawable) : NULL;
-		mask_fallback = source_fallback(mask, mask_pixmap);
+		mask_fallback = source_fallback(mask, mask_pixmap,
+						dst->polyMode == PolyModePrecise);
 	} else {
 		mask_pixmap = NULL;
 		mask_fallback = false;
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 665d515..a36ecf7 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -2138,7 +2138,7 @@ try_blt(struct sna *sna,
 }
 
 static bool
-check_gradient(PicturePtr picture)
+check_gradient(PicturePtr picture, bool precise)
 {
 	if (picture->pDrawable)
 		return false;
@@ -2148,7 +2148,7 @@ check_gradient(PicturePtr picture)
 	case SourcePictTypeLinear:
 		return false;
 	default:
-		return true;
+		return precise;
 	}
 }
 
@@ -2181,13 +2181,13 @@ source_is_busy(PixmapPtr pixmap)
 }
 
 static bool
-source_fallback(PicturePtr p, PixmapPtr pixmap)
+source_fallback(PicturePtr p, PixmapPtr pixmap, bool precise)
 {
 	if (sna_picture_is_solid(p, NULL))
 		return false;
 
 	if (p->pSourcePict)
-		return check_gradient(p);
+		return check_gradient(p, precise);
 
 	if (!gen7_check_repeat(p) || !gen7_check_format(p->format))
 		return true;
@@ -2218,11 +2218,13 @@ gen7_composite_fallback(struct sna *sna,
 	dst_pixmap = get_drawable_pixmap(dst->pDrawable);
 
 	src_pixmap = src->pDrawable ? get_drawable_pixmap(src->pDrawable) : NULL;
-	src_fallback = source_fallback(src, src_pixmap);
+	src_fallback = source_fallback(src, src_pixmap,
+				       dst->polyMode == PolyModePrecise);
 
 	if (mask) {
 		mask_pixmap = mask->pDrawable ? get_drawable_pixmap(mask->pDrawable) : NULL;
-		mask_fallback = source_fallback(mask, mask_pixmap);
+		mask_fallback = source_fallback(mask, mask_pixmap,
+						dst->polyMode == PolyModePrecise);
 	} else {
 		mask_pixmap = NULL;
 		mask_fallback = false;
commit 541f816815e392db9e798d2f940029d82a6b2e0b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 28 10:14:16 2013 +0100

    sna: Markup when a gradient is opaque
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_gradient.c b/src/sna/sna_gradient.c
index 3f0d7a5..26e4167 100644
--- a/src/sna/sna_gradient.c
+++ b/src/sna/sna_gradient.c
@@ -34,6 +34,19 @@
 
 #define xFixedToDouble(f) pixman_fixed_to_double(f)
 
+bool
+sna_gradient_is_opaque(const PictGradient *gradient)
+{
+	int n;
+
+	for (n = 0; n < gradient->nstops; n++) {
+		 if (gradient->stops[n].color.alpha < 0xff00)
+			 return false;
+	}
+
+	return true;
+}
+
 static int
 sna_gradient_sample_width(PictGradient *gradient)
 {
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index dd757dd..032dba7 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -1480,8 +1480,13 @@ sna_render_picture_approximate_gradient(struct sna *sna,
 		return -1;
 	}
 
+	channel->is_opaque = sna_gradient_is_opaque(picture->pSourcePict);
+	channel->pict_format =
+		channel->is_opaque ? PIXMAN_x8r8g8b8 : PIXMAN_a8r8g8b8;
+	DBG(("%s: gradient is opaque? %d, selecting format %08x\n",
+	     __FUNCTION__, channel->is_opaque, channel->pict_format));
 	assert(channel->card_format == -1);
-	channel->pict_format = PIXMAN_a8r8g8b8;
+
 	channel->bo = kgem_create_buffer_2d(&sna->kgem,
 					    w2, h2, 32,
 					    KGEM_BUFFER_WRITE_INPLACE,
@@ -1492,7 +1497,7 @@ sna_render_picture_approximate_gradient(struct sna *sna,
 		return 0;
 	}
 
-	dst = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+	dst = pixman_image_create_bits(channel->pict_format,
 				       w2, h2, ptr, channel->bo->pitch);
 	if (!dst) {
 		kgem_bo_destroy(&sna->kgem, channel->bo);
diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h
index d4406c3..ab69fe0 100644
--- a/src/sna/sna_render.h
+++ b/src/sna/sna_render.h
@@ -531,6 +531,9 @@ struct kgem_bo *
 sna_render_get_gradient(struct sna *sna,
 			PictGradient *pattern);
 
+bool
+sna_gradient_is_opaque(const PictGradient *gradient);
+
 uint32_t sna_rgba_for_color(uint32_t color, int depth);
 uint32_t sna_rgba_to_color(uint32_t rgba, uint32_t format);
 bool sna_get_rgba_from_pixel(uint32_t pixel,


More information about the xorg-commit mailing list