571
577
FAST_SAMPLES_X_TO_INT_FRAC(x1, ix1, fx1);
572
578
FAST_SAMPLES_X_TO_INT_FRAC(x2, ix2, fx2);
574
DBG(("%s: x1=%d (%d+%d), x2=%d (%d+%d)\n", __FUNCTION__,
575
x1, ix1, fx1, x2, ix2, fx2));
580
__DBG(("%s: x1=%d (%d+%d), x2=%d (%d+%d)\n", __FUNCTION__,
581
x1, ix1, fx1, x2, ix2, fx2));
577
583
cell = cell_list_find(cells, ix1);
578
584
if (ix1 != ix2) {
677
683
grid_scaled_y_t ymin = polygon->ymin;
678
684
grid_scaled_y_t ymax = polygon->ymax;
680
DBG(("%s: edge=(%d [%d.%d], %d [%d.%d]), (%d [%d.%d], %d [%d.%d]), top=%d [%d.%d], bottom=%d [%d.%d], dir=%d\n",
682
x1, FAST_SAMPLES_INT(x1), FAST_SAMPLES_FRAC(x1),
683
y1, FAST_SAMPLES_INT(y1), FAST_SAMPLES_FRAC(y1),
684
x2, FAST_SAMPLES_INT(x2), FAST_SAMPLES_FRAC(x2),
685
y2, FAST_SAMPLES_INT(y2), FAST_SAMPLES_FRAC(y2),
686
top, FAST_SAMPLES_INT(top), FAST_SAMPLES_FRAC(top),
687
bottom, FAST_SAMPLES_INT(bottom), FAST_SAMPLES_FRAC(bottom),
686
__DBG(("%s: edge=(%d [%d.%d], %d [%d.%d]), (%d [%d.%d], %d [%d.%d]), top=%d [%d.%d], bottom=%d [%d.%d], dir=%d\n",
688
x1, FAST_SAMPLES_INT(x1), FAST_SAMPLES_FRAC(x1),
689
y1, FAST_SAMPLES_INT(y1), FAST_SAMPLES_FRAC(y1),
690
x2, FAST_SAMPLES_INT(x2), FAST_SAMPLES_FRAC(x2),
691
y2, FAST_SAMPLES_INT(y2), FAST_SAMPLES_FRAC(y2),
692
top, FAST_SAMPLES_INT(top), FAST_SAMPLES_FRAC(top),
693
bottom, FAST_SAMPLES_INT(bottom), FAST_SAMPLES_FRAC(bottom),
735
DBG(("%s: line=(%d, %d), (%d, %d)\n",
736
__FUNCTION__, (int)p1->x, (int)p1->y, (int)p2->x, (int)p2->y));
741
__DBG(("%s: line=(%d, %d), (%d, %d)\n",
742
__FUNCTION__, (int)p1->x, (int)p1->y, (int)p2->x, (int)p2->y));
1067
1073
tor_init(struct tor *converter, const BoxRec *box, int num_edges)
1069
DBG(("%s: (%d, %d),(%d, %d) x (%d, %d), num_edges=%d\n",
1071
box->x1, box->y1, box->x2, box->y2,
1072
FAST_SAMPLES_X, FAST_SAMPLES_Y,
1075
__DBG(("%s: (%d, %d),(%d, %d) x (%d, %d), num_edges=%d\n",
1077
box->x1, box->y1, box->x2, box->y2,
1078
FAST_SAMPLES_X, FAST_SAMPLES_Y,
1075
1081
converter->xmin = box->x1;
1076
1082
converter->ymin = box->y1;
1120
1126
const BoxRec *box,
1123
DBG(("%s: %d -> %d @ %d\n", __FUNCTION__, box->x1, box->x2, coverage));
1129
__DBG(("%s: %d -> %d @ %d\n", __FUNCTION__, box->x1, box->x2, coverage));
1125
1131
op->box(sna, op, box, AREA_TO_ALPHA(coverage));
1126
1132
apply_damage_box(&op->base, box);
1139
1145
opacity = AREA_TO_ALPHA(coverage);
1140
DBG(("%s: %d -> %d @ %f\n", __FUNCTION__, box->x1, box->x2, opacity));
1146
__DBG(("%s: %d -> %d @ %f\n", __FUNCTION__, box->x1, box->x2, opacity));
1142
1148
pixman_region_init_rects(®ion, box, 1);
1143
1149
RegionIntersect(®ion, ®ion, clip);
1220
1226
/* Skip cells to the left of the clip region. */
1221
1227
while (cell->x < xmin) {
1222
DBG(("%s: skipping cell (%d, %d, %d)\n",
1224
cell->x, cell->covered_height, cell->uncovered_area));
1228
__DBG(("%s: skipping cell (%d, %d, %d)\n",
1230
cell->x, cell->covered_height, cell->uncovered_area));
1226
1232
cover += cell->covered_height;
1227
1233
cell = cell->next;
1242
DBG(("%s: cell=(%d, %d, %d), cover=%d, max=%d\n", __FUNCTION__,
1243
cell->x, cell->covered_height, cell->uncovered_area,
1248
__DBG(("%s: cell=(%d, %d, %d), cover=%d, max=%d\n", __FUNCTION__,
1249
cell->x, cell->covered_height, cell->uncovered_area,
1247
1253
if (box.x2 > box.x1 && (unbounded || cover)) {
1248
DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1254
__DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1253
1259
span(sna, op, clip, &box, cover);
1255
1261
box.x1 = box.x2;
1260
1266
int area = cover - cell->uncovered_area;
1261
1267
box.x2 = x + 1;
1262
1268
if (unbounded || area) {
1263
DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1269
__DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1268
1274
span(sna, op, clip, &box, area);
1270
1276
box.x1 = box.x2;
1275
1281
if (box.x2 > box.x1 && (unbounded || cover)) {
1276
DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1282
__DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1281
1287
span(sna, op, clip, &box, cover);
1325
1331
struct active_list *active = converter->active;
1326
1332
struct edge *buckets[FAST_SAMPLES_Y] = { 0 };
1328
DBG(("%s: unbounded=%d\n", __FUNCTION__, unbounded));
1334
__DBG(("%s: unbounded=%d\n", __FUNCTION__, unbounded));
1330
1336
/* Render each pixel row. */
1331
1337
for (i = 0; i < h; i = j) {
1341
1347
active->is_vertical = 1;
1342
1348
for (; j < h && !polygon->y_buckets[j]; j++)
1344
DBG(("%s: no new edges and no exisiting edges, skipping, %d -> %d\n",
1345
__FUNCTION__, i, j));
1350
__DBG(("%s: no new edges and no exisiting edges, skipping, %d -> %d\n",
1351
__FUNCTION__, i, j));
1348
1354
tor_blt_empty(sna, op, clip, span, i+ymin, j-i, xmin, xmax);
1352
1358
do_full_step = can_full_step(active);
1355
DBG(("%s: y=%d [%d], do_full_step=%d, new edges=%d, min_height=%d, vertical=%d\n",
1357
i, i+ymin, do_full_step,
1358
polygon->y_buckets[i] != NULL,
1360
active->is_vertical));
1361
__DBG(("%s: y=%d [%d], do_full_step=%d, new edges=%d, min_height=%d, vertical=%d\n",
1363
i, i+ymin, do_full_step,
1364
polygon->y_buckets[i] != NULL,
1366
active->is_vertical));
1361
1367
if (do_full_step) {
1362
1368
nonzero_row(active, coverages);
1372
1378
if (j != i + 1)
1373
1379
step_edges(active, j - (i + 1));
1375
DBG(("%s: vertical edges, full step (%d, %d)\n",
1376
__FUNCTION__, i, j));
1381
__DBG(("%s: vertical edges, full step (%d, %d)\n",
1382
__FUNCTION__, i, j));
1379
1385
grid_scaled_y_t suby;
1488
1494
pixman_fixed_t dy;
1489
1495
int y, ytop, ybot;
1491
DBG(("%s: top=%d, bottom=%d, line=(%d, %d), (%d, %d) delta=%dx%d, dir=%d\n",
1493
(int)top, (int)bottom,
1494
(int)p1->x, (int)p1->y, (int)p2->x, (int)p2->y,
1497
__DBG(("%s: top=%d, bottom=%d, line=(%d, %d), (%d, %d) delta=%dx%d, dir=%d\n",
1499
(int)top, (int)bottom,
1500
(int)p1->x, (int)p1->y, (int)p2->x, (int)p2->y,
1498
1504
if (top > bottom) {
1499
1505
xPointFixed *t;
1700
DBG(("%s [%d, %d]\n", __FUNCTION__, x1, x2));
1706
__DBG(("%s [%d, %d]\n", __FUNCTION__, x1, x2));
1881
inline static xFixed
1882
line_x_for_y(const xLineFixed *l, xFixed y, bool ceil)
1884
xFixed_32_32 ex = (xFixed_32_32)(y - l->p1.y) * (l->p2.x - l->p1.x);
1885
xFixed d = l->p2.y - l->p1.y;
1890
return l->p1.x + (xFixed) (ex / d);
1893
#define pixman_fixed_integer_floor(V) pixman_fixed_to_int(V)
1894
#define pixman_fixed_integer_ceil(V) pixman_fixed_to_int(pixman_fixed_ceil(V))
1897
trapezoids_bounds(int n, const xTrapezoid *t, BoxPtr box)
1899
xFixed x1, y1, x2, y2;
1901
/* XXX need 33 bits... */
1902
x1 = y1 = INT_MAX / 2;
1903
x2 = y2 = INT_MIN / 2;
1908
if (!xTrapezoidValid(t))
1916
if (((t->left.p1.x - x1) | (t->left.p2.x - x1)) < 0) {
1917
if (pixman_fixed_floor(t->left.p1.x) == pixman_fixed_floor(t->left.p2.x)) {
1918
x1 = pixman_fixed_floor(t->left.p1.x);
1920
if (t->left.p1.y == t->top)
1923
fx1 = line_x_for_y(&t->left, t->top, false);
1925
if (t->left.p2.y == t->bottom)
1928
fx2 = line_x_for_y(&t->left, t->bottom, false);
1932
x1 = pixman_fixed_floor(v);
1936
if (((x2 - t->right.p1.x) | (x2 - t->right.p2.x)) < 0) {
1937
if (pixman_fixed_floor(t->right.p1.x) == pixman_fixed_floor(t->right.p2.x)) {
1938
x2 = pixman_fixed_ceil(t->right.p1.x);
1940
if (t->right.p1.y == t->top)
1941
fx1 = t->right.p1.x;
1943
fx1 = line_x_for_y(&t->right, t->top, true);
1945
if (t->right.p2.y == t->bottom)
1946
fx2 = t->right.p2.x;
1948
fx2 = line_x_for_y(&t->right, t->bottom, true);
1952
x2 = pixman_fixed_ceil(v);
1957
box->x1 = pixman_fixed_to_int(x1);
1958
box->x2 = pixman_fixed_to_int(x2);
1959
box->y1 = pixman_fixed_integer_floor(y1);
1960
box->y2 = pixman_fixed_integer_ceil(y2);
1876
1964
trapezoids_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
1877
1965
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
1892
1980
dst_x = pixman_fixed_to_int(traps[0].left.p1.x);
1893
1981
dst_y = pixman_fixed_to_int(traps[0].left.p1.y);
1895
miTrapezoidBounds(ntrap, traps, &bounds);
1983
trapezoids_bounds(ntrap, traps, &bounds);
1896
1984
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
1899
DBG(("%s: bounds (%d, %d), (%d, %d)\n",
1900
__FUNCTION__, bounds.x1, bounds.y1, bounds.x2, bounds.y2));
1987
DBG(("%s: bounds (%d, %d), (%d, %d)\n", __FUNCTION__,
1988
bounds.x1, bounds.y1, bounds.x2, bounds.y2));
1902
1990
if (!sna_compute_composite_extents(&bounds,
1903
1991
src, NULL, dst,
1908
1996
bounds.y2 - bounds.y1))
1911
DBG(("%s: extents (%d, %d), (%d, %d)\n",
1912
__FUNCTION__, bounds.x1, bounds.y1, bounds.x2, bounds.y2));
1999
DBG(("%s: extents (%d, %d), (%d, %d)\n", __FUNCTION__,
2000
bounds.x1, bounds.y1, bounds.x2, bounds.y2));
1914
2002
width = bounds.x2 - bounds.x1;
1915
2003
height = bounds.y2 - bounds.y1;
1921
2009
DBG(("%s: mask (%dx%d) depth=%d, format=%08x\n",
1922
2010
__FUNCTION__, width, height, depth, format));
1923
2011
scratch = sna_pixmap_create_upload(screen,
1924
width, height, depth);
2012
width, height, depth,
2585
2674
dst_x = pixman_fixed_to_int(traps[0].left.p1.x);
2586
2675
dst_y = pixman_fixed_to_int(traps[0].left.p1.y);
2588
miTrapezoidBounds(ntrap, traps, &extents);
2677
trapezoids_bounds(ntrap, traps, &extents);
2589
2678
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
2742
2831
dst_x = pixman_fixed_to_int(traps[0].left.p1.x);
2743
2832
dst_y = pixman_fixed_to_int(traps[0].left.p1.y);
2745
miTrapezoidBounds(ntrap, traps, &extents);
2834
trapezoids_bounds(ntrap, traps, &extents);
2746
2835
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
2908
miTrapezoidBounds(ntrap, traps, &extents);
2997
trapezoids_bounds(ntrap, traps, &extents);
2909
2998
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
2937
3026
DBG(("%s: mask (%dx%d), dx=(%d, %d)\n",
2938
3027
__FUNCTION__, extents.x2, extents.y2, dx, dy));
2939
scratch = sna_pixmap_create_upload(screen, extents.x2, extents.y2, 8);
3028
scratch = sna_pixmap_create_upload(screen,
3029
extents.x2, extents.y2, 8,
3030
KGEM_BUFFER_WRITE_INPLACE);
3214
3305
trapezoid_span_inplace(CARD8 op, PicturePtr src, PicturePtr dst,
3215
3306
PictFormatPtr maskFormat, INT16 src_x, INT16 src_y,
3216
int ntrap, xTrapezoid *traps)
3307
int ntrap, xTrapezoid *traps,
3218
3310
struct tor tor;
3219
3311
struct inplace inplace;
3266
3360
/* XXX unwind errors? */
3267
3361
if (!trapezoid_span_inplace(op, src, dst, NULL,
3268
src_x, src_y, 1, traps++))
3362
src_x, src_y, 1, traps++,
3270
3365
} while (--ntrap);
3274
miTrapezoidBounds(ntrap, traps, ®ion.extents);
3369
trapezoids_bounds(ntrap, traps, ®ion.extents);
3275
3370
if (region.extents.y1 >= region.extents.y2 ||
3276
3371
region.extents.x1 >= region.extents.x2)
3451
DBG(("%s: move-to-cpu\n", __FUNCTION__));
3356
3452
region.data = NULL;
3357
3453
if (!sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion,
3454
op == PictOpSrc ? MOVE_WRITE : MOVE_WRITE | MOVE_READ))
3361
3457
pixmap = get_drawable_pixmap(dst->pDrawable);
3413
miTrapezoidBounds(ntrap, traps, &extents);
3509
trapezoids_bounds(ntrap, traps, &extents);
3414
3510
if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
3492
3588
region.extents.y2 = dst_y + extents.y2;
3493
3589
region.data = NULL;
3591
DBG(("%s: move-to-cpu\n", __FUNCTION__));
3495
3592
if (!sna_drawable_move_region_to_cpu(dst->pDrawable, ®ion,
3496
3593
MOVE_READ | MOVE_WRITE))
3609
DBG(("%s: fbComposite()\n", __FUNCTION__));
3512
3610
fbComposite(op, src, mask, dst,
3513
3611
src_x + dst_x - pixman_fixed_to_int(traps[0].left.p1.x),
3514
3612
src_y + dst_y - pixman_fixed_to_int(traps[0].left.p1.y),
3622
3720
xSrc, ySrc, ntrap, traps))
3723
if (trapezoid_span_inplace(op, src, dst, maskFormat,
3724
xSrc, ySrc, ntrap, traps,
3625
3728
if (trapezoid_mask_converter(op, src, dst, maskFormat,
3626
3729
xSrc, ySrc, ntrap, traps))
3630
3733
if (trapezoid_span_inplace(op, src, dst, maskFormat,
3631
xSrc, ySrc, ntrap, traps))
3734
xSrc, ySrc, ntrap, traps,
3634
3738
if (trapezoid_span_fallback(op, src, dst, maskFormat,
3834
#define pixman_fixed_integer_floor(V) pixman_fixed_to_int(pixman_fixed_floor(V))
3835
#define pixman_fixed_integer_ceil(V) pixman_fixed_to_int(pixman_fixed_ceil(V))
3837
3938
static void mark_damaged(PixmapPtr pixmap, struct sna_pixmap *priv,
3838
3939
BoxPtr box, int16_t x, int16_t y)
4018
4119
DBG(("%s: tmp (%dx%d) depth=%d\n",
4019
4120
__FUNCTION__, width, height, depth));
4020
scratch = sna_pixmap_create_upload(screen, width, height, depth);
4121
scratch = sna_pixmap_create_upload(screen,
4122
width, height, depth,
4419
4522
DBG(("%s: mask (%dx%d)\n",
4420
4523
__FUNCTION__, extents.x2, extents.y2));
4421
scratch = sna_pixmap_create_upload(screen, extents.x2, extents.y2, 8);
4524
scratch = sna_pixmap_create_upload(screen,
4525
extents.x2, extents.y2, 8,
4526
KGEM_BUFFER_WRITE_INPLACE);
4523
4628
DBG(("%s: mask (%dx%d) depth=%d, format=%08x\n",
4524
4629
__FUNCTION__, width, height, depth, format));
4525
4630
scratch = sna_pixmap_create_upload(screen,
4526
width, height, depth);
4631
width, height, depth,
4765
4871
DBG(("%s: mask (%dx%d) depth=%d, format=%08x\n",
4766
4872
__FUNCTION__, width, height, depth, format));
4767
4873
scratch = sna_pixmap_create_upload(screen,
4768
width, height, depth);
4874
width, height, depth,
4899
5006
DBG(("%s: mask (%dx%d) depth=%d, format=%08x\n",
4900
5007
__FUNCTION__, width, height, depth, format));
4901
5008
scratch = sna_pixmap_create_upload(screen,
4902
width, height, depth);
5009
width, height, depth,