summaryrefslogtreecommitdiff
path: root/src/sna
diff options
context:
space:
mode:
Diffstat (limited to 'src/sna')
-rw-r--r--src/sna/sna_trapezoids.c9
-rw-r--r--src/sna/sna_trapezoids.h37
-rw-r--r--src/sna/sna_trapezoids_imprecise.c14
-rw-r--r--src/sna/sna_trapezoids_mono.c4
-rw-r--r--src/sna/sna_trapezoids_precise.c82
5 files changed, 125 insertions, 21 deletions
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index d9390db4..8131cb2a 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -822,11 +822,13 @@ void
sna_add_traps(PicturePtr picture, INT16 x, INT16 y, int n, xTrap *t)
{
struct sna *sna;
+ PixmapPtr pixmap;
DBG(("%s (%d, %d) x %d\n", __FUNCTION__, x, y, n));
- sna = to_sna_from_drawable(picture->pDrawable);
- if (is_gpu(sna, picture->pDrawable, PREFER_GPU_SPANS)) {
+ pixmap = get_drawable_pixmap(picture->pDrawable);
+ sna = to_sna_from_pixmap(pixmap);
+ if (is_gpu_dst(sna_pixmap(pixmap))) {
if (trap_span_converter(sna, picture, x, y, n, t))
return;
}
@@ -840,8 +842,7 @@ sna_add_traps(PicturePtr picture, INT16 x, INT16 y, int n, xTrap *t)
}
DBG(("%s -- fallback\n", __FUNCTION__));
- if (sna_drawable_move_to_cpu(picture->pDrawable,
- MOVE_READ | MOVE_WRITE)) {
+ if (sna_pixmap_move_to_cpu(pixmap, MOVE_READ | MOVE_WRITE)) {
pixman_image_t *image;
int dx, dy;
diff --git a/src/sna/sna_trapezoids.h b/src/sna/sna_trapezoids.h
index c057cabe..64c77478 100644
--- a/src/sna/sna_trapezoids.h
+++ b/src/sna/sna_trapezoids.h
@@ -54,12 +54,6 @@ mono_trapezoid_span_inplace(struct sna *sna,
int ntrap, xTrapezoid *traps);
bool
-mono_trap_span_converter(struct sna *sna,
- PicturePtr dst,
- INT16 x, INT16 y,
- int ntrap, xTrap *traps);
-
-bool
mono_triangles_span_converter(struct sna *sna,
CARD8 op, PicturePtr src, PicturePtr dst,
INT16 src_x, INT16 src_y,
@@ -210,10 +204,39 @@ trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
}
bool
+mono_trap_span_converter(struct sna *sna,
+ PicturePtr dst,
+ INT16 x, INT16 y,
+ int ntrap, xTrap *traps);
+
+bool
+precise_trap_span_converter(struct sna *sna,
+ PicturePtr dst,
+ INT16 src_x, INT16 src_y,
+ int ntrap, xTrap *trap);
+
+bool
+imprecise_trap_span_converter(struct sna *sna,
+ PicturePtr dst,
+ INT16 src_x, INT16 src_y,
+ int ntrap, xTrap *trap);
+
+static inline bool
trap_span_converter(struct sna *sna,
PicturePtr dst,
INT16 src_x, INT16 src_y,
- int ntrap, xTrap *trap);
+ int ntrap, xTrap *trap)
+{
+ if (NO_SCAN_CONVERTER)
+ return false;
+
+ if (dst->polyEdge == PolyEdgeSharp || dst->pDrawable->depth < 8)
+ return mono_trap_span_converter(sna, dst, src_x, src_y, ntrap, trap);
+ else if (dst->polyMode == PolyModePrecise)
+ return precise_trap_span_converter(sna, dst, src_x, src_y, ntrap, trap);
+ else
+ return imprecise_trap_span_converter(sna, dst, src_x, src_y, ntrap, trap);
+}
bool
trap_mask_converter(struct sna *sna,
diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c
index 0887d4fd..f88a8ae5 100644
--- a/src/sna/sna_trapezoids_imprecise.c
+++ b/src/sna/sna_trapezoids_imprecise.c
@@ -3233,10 +3233,10 @@ imprecise_trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
}
bool
-trap_span_converter(struct sna *sna,
- PicturePtr dst,
- INT16 src_x, INT16 src_y,
- int ntrap, xTrap *trap)
+imprecise_trap_span_converter(struct sna *sna,
+ PicturePtr dst,
+ INT16 src_x, INT16 src_y,
+ int ntrap, xTrap *trap)
{
struct sna_composite_spans_op tmp;
struct tor tor;
@@ -3244,15 +3244,9 @@ trap_span_converter(struct sna *sna,
pixman_region16_t *clip;
int dx, dy, n;
- if (NO_SCAN_CONVERTER)
- return false;
-
if (dst->pDrawable->depth < 8)
return false;
- if (dst->polyEdge == PolyEdgeSharp)
- return mono_trap_span_converter(sna, dst, src_x, src_y, ntrap, trap);
-
if (!sna->render.check_composite_spans(sna, PictOpAdd, sna->render.white_picture, dst,
dst->pCompositeClip->extents.x2 - dst->pCompositeClip->extents.x1,
dst->pCompositeClip->extents.y2 - dst->pCompositeClip->extents.y1,
diff --git a/src/sna/sna_trapezoids_mono.c b/src/sna/sna_trapezoids_mono.c
index be958754..4ad4573f 100644
--- a/src/sna/sna_trapezoids_mono.c
+++ b/src/sna/sna_trapezoids_mono.c
@@ -1286,6 +1286,10 @@ mono_trap_span_converter(struct sna *sna,
mono.clip.extents.x2 - mono.clip.extents.x1,
mono.clip.extents.y2 - mono.clip.extents.y1,
COMPOSITE_PARTIAL, memset(&mono.op, 0, sizeof(mono.op)))) {
+ if (mono.clip.data == NULL && mono.op.damage == NULL)
+ mono.span = mono_span__fast;
+ else
+ mono.span = mono_span;
mono_render(&mono);
mono.op.done(mono.sna, &mono.op);
}
diff --git a/src/sna/sna_trapezoids_precise.c b/src/sna/sna_trapezoids_precise.c
index 2c5dad55..9925654d 100644
--- a/src/sna/sna_trapezoids_precise.c
+++ b/src/sna/sna_trapezoids_precise.c
@@ -3538,3 +3538,85 @@ skip:
REGION_UNINIT(NULL, &clip);
return true;
}
+
+bool
+precise_trap_span_converter(struct sna *sna,
+ PicturePtr dst,
+ INT16 src_x, INT16 src_y,
+ int ntrap, xTrap *trap)
+{
+ struct sna_composite_spans_op tmp;
+ struct tor tor;
+ BoxRec extents;
+ pixman_region16_t *clip;
+ int dx, dy, n;
+
+ if (dst->pDrawable->depth < 8)
+ return false;
+
+ if (!sna->render.check_composite_spans(sna, PictOpAdd, sna->render.white_picture, dst,
+ dst->pCompositeClip->extents.x2 - dst->pCompositeClip->extents.x1,
+ dst->pCompositeClip->extents.y2 - dst->pCompositeClip->extents.y1,
+ 0)) {
+ DBG(("%s: fallback -- composite spans not supported\n",
+ __FUNCTION__));
+ return false;
+ }
+
+ clip = dst->pCompositeClip;
+ extents = *RegionExtents(clip);
+ dx = dst->pDrawable->x;
+ dy = dst->pDrawable->y;
+
+ DBG(("%s: after clip -- extents (%d, %d), (%d, %d), delta=(%d, %d)\n",
+ __FUNCTION__,
+ extents.x1, extents.y1,
+ extents.x2, extents.y2,
+ dx, dy));
+
+ memset(&tmp, 0, sizeof(tmp));
+ if (!sna->render.composite_spans(sna, PictOpAdd, sna->render.white_picture, dst,
+ 0, 0,
+ extents.x1, extents.y1,
+ extents.x2 - extents.x1,
+ extents.y2 - extents.y1,
+ 0,
+ &tmp)) {
+ DBG(("%s: fallback -- composite spans render op not supported\n",
+ __FUNCTION__));
+ return false;
+ }
+
+ dx *= SAMPLES_X;
+ dy *= SAMPLES_Y;
+ if (!tor_init(&tor, &extents, 2*ntrap))
+ goto skip;
+
+ for (n = 0; n < ntrap; n++) {
+ xPointFixed p1, p2;
+
+ if (pixman_fixed_to_int(trap[n].top.y) + dst->pDrawable->y >= extents.y2 ||
+ pixman_fixed_to_int(trap[n].bot.y) + dst->pDrawable->y < extents.y1)
+ continue;
+
+ p1.y = trap[n].top.y;
+ p2.y = trap[n].bot.y;
+ p1.x = trap[n].top.l;
+ p2.x = trap[n].bot.l;
+ polygon_add_line(tor.polygon, &p1, &p2, dx, dy);
+
+ p1.y = trap[n].bot.y;
+ p2.y = trap[n].top.y;
+ p1.x = trap[n].top.r;
+ p2.x = trap[n].bot.r;
+ polygon_add_line(tor.polygon, &p1, &p2, dx, dy);
+ }
+
+ tor_render(sna, &tor, &tmp, clip,
+ choose_span(&tmp, dst, NULL, clip), false);
+
+ tor_fini(&tor);
+skip:
+ tmp.done(sna, &tmp);
+ return true;
+}