summaryrefslogtreecommitdiff
path: root/src/sna
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-03-12 21:09:19 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-03-13 14:28:31 +0000
commit8b9abe2be1f54bd8e8593ed155cc4725ac97627a (patch)
treea35413349056e2969e4e1df6e52c61cae1573812 /src/sna
parent1e2d6ee31a21267ba27e4bebb883aaab08a12f30 (diff)
sna: Prefer to render very thin trapezoids inplace
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna')
-rw-r--r--src/sna/sna_render.h1
-rw-r--r--src/sna/sna_render_inline.h8
-rw-r--r--src/sna/sna_trapezoids.c54
3 files changed, 57 insertions, 6 deletions
diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h
index e6015af0..8d3d9e4f 100644
--- a/src/sna/sna_render.h
+++ b/src/sna/sna_render.h
@@ -204,6 +204,7 @@ struct sna_render {
unsigned flags,
struct sna_composite_spans_op *tmp);
#define COMPOSITE_SPANS_RECTILINEAR 0x1
+#define COMPOSITE_SPANS_INPLACE_HINT 0x2
Bool (*video)(struct sna *sna,
struct sna_video *video,
diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h
index a523fed5..88d0130a 100644
--- a/src/sna/sna_render_inline.h
+++ b/src/sna/sna_render_inline.h
@@ -85,7 +85,13 @@ static inline Bool
is_cpu(DrawablePtr drawable)
{
struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable);
- return !priv || priv->cpu_damage != NULL;
+ if (priv == NULL || priv->clear || DAMAGE_IS_ALL(priv->cpu_damage))
+ return true;
+
+ if (priv->gpu_damage || (priv->cpu_bo && kgem_bo_is_busy(priv->cpu_bo)))
+ return false;
+
+ return true;
}
static inline Bool
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index 23a65ef8..d2f16f23 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -3180,7 +3180,8 @@ mono_trapezoids_span_converter(CARD8 op, PicturePtr src, PicturePtr dst,
static bool
trapezoid_span_converter(CARD8 op, PicturePtr src, PicturePtr dst,
- PictFormatPtr maskFormat, INT16 src_x, INT16 src_y,
+ PictFormatPtr maskFormat, unsigned int flags,
+ INT16 src_x, INT16 src_y,
int ntrap, xTrapezoid *traps)
{
struct sna *sna;
@@ -3263,8 +3264,7 @@ trapezoid_span_converter(CARD8 op, PicturePtr src, PicturePtr dst,
extents.x1, extents.y1,
extents.x2 - extents.x1,
extents.y2 - extents.y1,
- 0,
- &tmp)) {
+ flags, &tmp)) {
DBG(("%s: fallback -- composite spans render op not supported\n",
__FUNCTION__));
return false;
@@ -3776,6 +3776,40 @@ mono_inplace_composite_boxes(struct sna *sna,
}
static bool
+trapezoid_spans_maybe_inplace(CARD8 op, PicturePtr src, PicturePtr dst,
+ PictFormatPtr maskFormat)
+{
+ if (NO_SCAN_CONVERTER)
+ return false;
+
+ if (dst->polyMode == PolyModePrecise && !is_mono(dst, maskFormat))
+ return false;
+ if (dst->alphaMap)
+ return false;
+
+ if (is_mono(dst, maskFormat))
+ goto out;
+
+ if (!sna_picture_is_solid(src, NULL))
+ return false;
+
+ if (dst->format != PICT_a8)
+ return false;
+
+ switch (op) {
+ case PictOpIn:
+ case PictOpAdd:
+ case PictOpSrc:
+ break;
+ default:
+ return false;
+ }
+
+out:
+ return is_cpu(dst->pDrawable) ? true : dst->pDrawable->width <= TOR_INPLACE_SIZE;
+}
+
+static bool
trapezoid_span_mono_inplace(CARD8 op,
PicturePtr src,
PicturePtr dst,
@@ -4304,6 +4338,7 @@ sna_composite_trapezoids(CARD8 op,
{
struct sna *sna = to_sna_from_drawable(dst->pDrawable);
bool rectilinear, pixel_aligned;
+ unsigned flags;
int n;
DBG(("%s(op=%d, src=(%d, %d), mask=%08x, ntrap=%d)\n", __FUNCTION__,
@@ -4370,8 +4405,9 @@ sna_composite_trapezoids(CARD8 op,
}
}
- DBG(("%s: rectlinear? %d, pixel-aligned? %d\n",
+ DBG(("%s: rectilinear? %d, pixel-aligned? %d\n",
__FUNCTION__, rectilinear, pixel_aligned));
+ flags = 0;
if (rectilinear) {
if (pixel_aligned) {
if (composite_aligned_boxes(sna, op, src, dst,
@@ -4386,9 +4422,17 @@ sna_composite_trapezoids(CARD8 op,
ntrap, traps))
return;
}
+ flags |= COMPOSITE_SPANS_RECTILINEAR;
+ }
+ if (trapezoid_spans_maybe_inplace(op, src, dst, maskFormat)) {
+ flags |= COMPOSITE_SPANS_INPLACE_HINT;
+ if (trapezoid_span_inplace(op, src, dst, maskFormat,
+ xSrc, ySrc, ntrap, traps,
+ false))
+ return;
}
- if (trapezoid_span_converter(op, src, dst, maskFormat,
+ if (trapezoid_span_converter(op, src, dst, maskFormat, flags,
xSrc, ySrc, ntrap, traps))
return;