diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-04 18:37:01 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-05 18:52:56 +0100 |
commit | c98b770a87a5ec5ed9dc0aa375ad173b0e98322e (patch) | |
tree | be457f634828fc06077e3476c048c9e9e80f5821 /src/sna/sna_trapezoids_imprecise.c | |
parent | 27ad2fc1dcb2a6177eda7f1319b4f4eccdbea140 (diff) |
sna/trapezoids: Add a precise scan converter
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_trapezoids_imprecise.c')
-rw-r--r-- | src/sna/sna_trapezoids_imprecise.c | 188 |
1 files changed, 72 insertions, 116 deletions
diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c index a0126b3d..bbb7f2f3 100644 --- a/src/sna/sna_trapezoids_imprecise.c +++ b/src/sna/sna_trapezoids_imprecise.c @@ -642,7 +642,6 @@ polygon_add_line(struct polygon *polygon, unsigned ix = EDGE_Y_BUCKET_INDEX(e->ytop, polygon->ymin); polygon->y_buckets[ix] = prev->next; - polygon->num_edges--; return; } } @@ -778,10 +777,10 @@ static struct edge *filter(struct edge *edges) } static struct edge * -merge_unsorted_edges (struct edge *head, struct edge *unsorted) +merge_unsorted_edges(struct edge *head, struct edge *unsorted) { - sort_edges (unsorted, UINT_MAX, &unsorted); - return merge_sorted_edges (head, filter(unsorted)); + sort_edges(unsorted, UINT_MAX, &unsorted); + return merge_sorted_edges(head, filter(unsorted)); } /* Test if the edges on the active list can be safely advanced by a @@ -816,7 +815,8 @@ can_full_step(struct active_list *active) inline static void merge_edges(struct active_list *active, struct edge *edges) { - active->head.next = merge_unsorted_edges (active->head.next, edges); + active->head.next = merge_unsorted_edges(active->head.next, edges); + active->min_height = -1; } inline static void @@ -891,7 +891,6 @@ nonzero_subrow(struct active_list *active, struct cell_list *coverages) } else { edge->prev->next = next; next->prev = edge->prev; - active->min_height = -1; } edge = next; @@ -1251,7 +1250,7 @@ tor_render(struct sna *sna, nonzero_row(active, coverages); while (polygon->y_buckets[j] == NULL && - active->min_height >= 2*FAST_SAMPLES_Y) { + active->min_height >= FAST_SAMPLES_Y) { active->min_height -= FAST_SAMPLES_Y; j++; } @@ -1473,7 +1472,6 @@ inplace_subrow(struct active_list *active, int8_t *row, } else { edge->prev->next = next; next->prev = edge->prev; - active->min_height = -1; } edge = next; @@ -1615,7 +1613,7 @@ tor_inplace(struct tor *converter, PixmapPtr scratch, int mono, uint8_t *buf) memcpy(row, ptr, width); while (polygon->y_buckets[j] == NULL && - active->min_height >= 2*FAST_SAMPLES_Y) + active->min_height >= FAST_SAMPLES_Y) { active->min_height -= FAST_SAMPLES_Y; row += stride; @@ -1678,18 +1676,18 @@ project_trapezoid_onto_grid(const xTrapezoid *in, in->right.p1.x, in->right.p1.y, in->right.p2.x, in->right.p2.y, in->top, in->bottom)); - out->left.p1.x = dx + pixman_fixed_to_grid(in->left.p1.x); - out->left.p1.y = dy + pixman_fixed_to_grid(in->left.p1.y); - out->left.p2.x = dx + pixman_fixed_to_grid(in->left.p2.x); - out->left.p2.y = dy + pixman_fixed_to_grid(in->left.p2.y); + out->left.p1.x = dx + pixman_fixed_to_fast(in->left.p1.x); + out->left.p1.y = dy + pixman_fixed_to_fast(in->left.p1.y); + out->left.p2.x = dx + pixman_fixed_to_fast(in->left.p2.x); + out->left.p2.y = dy + pixman_fixed_to_fast(in->left.p2.y); - out->right.p1.x = dx + pixman_fixed_to_grid(in->right.p1.x); - out->right.p1.y = dy + pixman_fixed_to_grid(in->right.p1.y); - out->right.p2.x = dx + pixman_fixed_to_grid(in->right.p2.x); - out->right.p2.y = dy + pixman_fixed_to_grid(in->right.p2.y); + out->right.p1.x = dx + pixman_fixed_to_fast(in->right.p1.x); + out->right.p1.y = dy + pixman_fixed_to_fast(in->right.p1.y); + out->right.p2.x = dx + pixman_fixed_to_fast(in->right.p2.x); + out->right.p2.y = dy + pixman_fixed_to_fast(in->right.p2.y); - out->top = dy + pixman_fixed_to_grid(in->top); - out->bottom = dy + pixman_fixed_to_grid(in->bottom); + out->top = dy + pixman_fixed_to_fast(in->top); + out->bottom = dy + pixman_fixed_to_fast(in->bottom); __DBG(("%s: out: L:(%d, %d), (%d, %d); R:(%d, %d), (%d, %d), [%d, %d]\n", __FUNCTION__, @@ -1882,11 +1880,11 @@ span_thread(void *arg) } bool -trapezoid_span_converter(struct sna *sna, - CARD8 op, PicturePtr src, PicturePtr dst, - PictFormatPtr maskFormat, unsigned int flags, - INT16 src_x, INT16 src_y, - int ntrap, xTrapezoid *traps) +imprecise_trapezoid_span_converter(struct sna *sna, + CARD8 op, PicturePtr src, PicturePtr dst, + PictFormatPtr maskFormat, unsigned int flags, + INT16 src_x, INT16 src_y, + int ntrap, xTrapezoid *traps) { struct sna_composite_spans_op tmp; pixman_region16_t clip; @@ -1895,20 +1893,8 @@ trapezoid_span_converter(struct sna *sna, int dx, dy, n; int num_threads; - if (NO_SCAN_CONVERTER) - return false; - - if (is_mono(dst, maskFormat)) - return mono_trapezoids_span_converter(sna, op, src, dst, - src_x, src_y, - ntrap, traps); - - /* XXX strict adherence to the Render specification */ - if (dst->polyMode == PolyModePrecise) { - DBG(("%s: fallback -- precise rasterisation requested\n", - __FUNCTION__)); + if (NO_IMPRECISE) return false; - } if (!sna->render.check_composite_spans(sna, op, src, dst, 0, 0, flags)) { DBG(("%s: fallback -- composite spans not supported\n", @@ -2116,9 +2102,9 @@ tor_blt_mask_mono(struct sna *sna, } bool -trapezoid_mask_converter(CARD8 op, PicturePtr src, PicturePtr dst, - PictFormatPtr maskFormat, INT16 src_x, INT16 src_y, - int ntrap, xTrapezoid *traps) +imprecise_trapezoid_mask_converter(CARD8 op, PicturePtr src, PicturePtr dst, + PictFormatPtr maskFormat, INT16 src_x, INT16 src_y, + int ntrap, xTrapezoid *traps) { struct tor tor; ScreenPtr screen = dst->pDrawable->pScreen; @@ -2129,22 +2115,16 @@ trapezoid_mask_converter(CARD8 op, PicturePtr src, PicturePtr dst, int dx, dy; int error, n; - if (NO_SCAN_CONVERTER) - return false; - - if (dst->polyMode == PolyModePrecise && !is_mono(dst, maskFormat)) { - DBG(("%s: fallback -- precise rasterisation requested\n", - __FUNCTION__)); + if (NO_IMPRECISE) return false; - } if (maskFormat == NULL && ntrap > 1) { DBG(("%s: individual rasterisation requested\n", __FUNCTION__)); do { /* XXX unwind errors? */ - if (!trapezoid_mask_converter(op, src, dst, NULL, - src_x, src_y, 1, traps++)) + if (!imprecise_trapezoid_mask_converter(op, src, dst, NULL, + src_x, src_y, 1, traps++)) return false; } while (--ntrap); return true; @@ -2258,37 +2238,41 @@ static force_inline uint8_t coverage_opacity(int coverage, uint8_t opacity) return opacity == 255 ? coverage : mul_8_8(coverage, opacity); } -static void -tor_blt_src(struct sna *sna, - struct sna_composite_spans_op *op, - pixman_region16_t *clip, - const BoxRec *box, - int coverage) +static void _tor_blt_src(struct inplace *in, const BoxRec *box, uint8_t v) { - struct inplace *in = (struct inplace *)op; uint8_t *ptr = in->ptr; int h, w; - coverage = coverage_opacity(coverage, in->opacity); - ptr += box->y1 * in->stride + box->x1; h = box->y2 - box->y1; w = box->x2 - box->x1; if ((w | h) == 1) { - *ptr = coverage; + *ptr = v; } else if (w == 1) { do { - *ptr = coverage; + *ptr = v; ptr += in->stride; } while (--h); } else do { - memset(ptr, coverage, w); + memset(ptr, v, w); ptr += in->stride; } while (--h); } static void +tor_blt_src(struct sna *sna, + struct sna_composite_spans_op *op, + pixman_region16_t *clip, + const BoxRec *box, + int coverage) +{ + struct inplace *in = (struct inplace *)op; + + _tor_blt_src(in, box, coverage_opacity(coverage, in->opacity)); +} + +static void tor_blt_src_clipped(struct sna *sna, struct sna_composite_spans_op *op, pixman_region16_t *clip, @@ -2319,7 +2303,7 @@ tor_blt_in(struct sna *sna, int h, w, i; if (coverage == 0) { - tor_blt_src(sna, op, clip, box, 0); + _tor_blt_src(in, box, 0); return; } @@ -2373,7 +2357,7 @@ tor_blt_add(struct sna *sna, coverage = coverage_opacity(coverage, in->opacity); if (coverage == 0xff) { - tor_blt_src(sna, op, clip, box, 0xff); + _tor_blt_src(in, box, 0xff); return; } @@ -2971,11 +2955,11 @@ static void inplace_thread(void *arg) } bool -trapezoid_span_inplace(struct sna *sna, - CARD8 op, PicturePtr src, PicturePtr dst, - PictFormatPtr maskFormat, INT16 src_x, INT16 src_y, - int ntrap, xTrapezoid *traps, - bool fallback) +imprecise_trapezoid_span_inplace(struct sna *sna, + CARD8 op, PicturePtr src, PicturePtr dst, + PictFormatPtr maskFormat, INT16 src_x, INT16 src_y, + int ntrap, xTrapezoid *traps, + bool fallback) { struct inplace inplace; span_func_t span; @@ -2988,30 +2972,8 @@ trapezoid_span_inplace(struct sna *sna, int dx, dy; int num_threads, n; - if (NO_SCAN_CONVERTER) - return false; - - if (dst->polyMode == PolyModePrecise && !is_mono(dst, maskFormat)) { - DBG(("%s: fallback -- precise rasterisation requested\n", - __FUNCTION__)); - return false; - } - if (dst->alphaMap) { - DBG(("%s: fallback -- dst alphamap\n", - __FUNCTION__)); - return false; - } - - if (!fallback && is_gpu(sna, dst->pDrawable, PREFER_GPU_SPANS)) { - DBG(("%s: fallback -- can not perform operation in place, destination busy\n", - __FUNCTION__)); - + if (NO_IMPRECISE) return false; - } - - if (is_mono(dst, maskFormat)) - return mono_trapezoid_span_inplace(sna, op, src, dst, - src_x, src_y, ntrap, traps); if (dst->format == PICT_a8r8g8b8 || dst->format == PICT_x8r8g8b8) return trapezoid_span_inplace__x8r8g8b8(op, dst, @@ -3085,9 +3047,9 @@ trapezoid_span_inplace(struct sna *sna, __FUNCTION__)); do { /* XXX unwind errors? */ - if (!trapezoid_span_inplace(sna, op, src, dst, NULL, - src_x, src_y, 1, traps++, - fallback)) + if (!imprecise_trapezoid_span_inplace(sna, op, src, dst, NULL, + src_x, src_y, 1, traps++, + fallback)) return false; } while (--ntrap); return true; @@ -3220,9 +3182,9 @@ trapezoid_span_inplace(struct sna *sna, } bool -trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst, - PictFormatPtr maskFormat, INT16 src_x, INT16 src_y, - int ntrap, xTrapezoid *traps) +imprecise_trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst, + PictFormatPtr maskFormat, INT16 src_x, INT16 src_y, + int ntrap, xTrapezoid *traps) { struct tor tor; ScreenPtr screen = dst->pDrawable->pScreen; @@ -3233,22 +3195,16 @@ trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst, int dx, dy; int error, n; - if (NO_SCAN_CONVERTER) - return false; - - if (dst->polyMode == PolyModePrecise && !is_mono(dst, maskFormat)) { - DBG(("%s: fallback -- precise rasterisation requested\n", - __FUNCTION__)); + if (NO_IMPRECISE) return false; - } if (maskFormat == NULL && ntrap > 1) { DBG(("%s: individual rasterisation requested\n", __FUNCTION__)); do { /* XXX unwind errors? */ - if (!trapezoid_span_fallback(op, src, dst, NULL, - src_x, src_y, 1, traps++)) + if (!imprecise_trapezoid_span_fallback(op, src, dst, NULL, + src_x, src_y, 1, traps++)) return false; } while (--ntrap); return true; @@ -3356,13 +3312,13 @@ project_trap_onto_grid(const xTrap *in, int dx, int dy, xTrap *out) { - out->top.l = dx + pixman_fixed_to_grid(in->top.l); - out->top.r = dx + pixman_fixed_to_grid(in->top.r); - out->top.y = dy + pixman_fixed_to_grid(in->top.y); + out->top.l = dx + pixman_fixed_to_fast(in->top.l); + out->top.r = dx + pixman_fixed_to_fast(in->top.r); + out->top.y = dy + pixman_fixed_to_fast(in->top.y); - out->bot.l = dx + pixman_fixed_to_grid(in->bot.l); - out->bot.r = dx + pixman_fixed_to_grid(in->bot.r); - out->bot.y = dy + pixman_fixed_to_grid(in->bot.y); + out->bot.l = dx + pixman_fixed_to_fast(in->bot.l); + out->bot.r = dx + pixman_fixed_to_fast(in->bot.r); + out->bot.y = dy + pixman_fixed_to_fast(in->bot.y); return out->bot.y > out->top.y; } @@ -3601,8 +3557,8 @@ project_point_onto_grid(const xPointFixed *in, int dx, int dy, xPointFixed *out) { - out->x = dx + pixman_fixed_to_grid(in->x); - out->y = dy + pixman_fixed_to_grid(in->y); + out->x = dx + pixman_fixed_to_fast(in->x); + out->y = dy + pixman_fixed_to_fast(in->y); } #if HAS_PIXMAN_TRIANGLES @@ -3771,7 +3727,7 @@ triangles_mask_converter(CARD8 op, PicturePtr src, PicturePtr dst, if (NO_SCAN_CONVERTER) return false; - if (dst->polyMode == PolyModePrecise && !is_mono(dst, maskFormat)) { + if (is_precise(dst, maskFormat)) { DBG(("%s: fallback -- precise rasterisation requested\n", __FUNCTION__)); return false; @@ -3887,7 +3843,7 @@ tristrip_span_converter(struct sna *sna, return false; /* XXX strict adherence to the Render specification */ - if (dst->polyMode == PolyModePrecise && !is_mono(dst, maskFormat)) { + if (is_precise(dst, maskFormat)) { DBG(("%s: fallback -- precise rasterisation requested\n", __FUNCTION__)); return false; |