~ubuntu-branches/debian/experimental/xserver-xorg-video-intel/experimental

« back to all changes in this revision

Viewing changes to src/sna/sna_trapezoids.c

  • Committer: Package Import Robot
  • Author(s): Cyril Brulebois
  • Date: 2012-01-16 00:52:23 UTC
  • mto: (0.4.17)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20120116005223-nyclxd7g2tw09g0v
Tags: upstream-2.17.0+git20120115
ImportĀ upstreamĀ versionĀ 2.17.0+git20120115

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#define DBG(x) ErrorF x
45
45
#endif
46
46
 
 
47
#if 0
 
48
#define __DBG(x) ErrorF x
 
49
#else
 
50
#define __DBG(x)
 
51
#endif
 
52
 
47
53
#define NO_ACCEL 0
48
54
#define NO_ALIGNED_BOXES 0
49
55
#define NO_UNALIGNED_BOXES 0
571
577
        FAST_SAMPLES_X_TO_INT_FRAC(x1, ix1, fx1);
572
578
        FAST_SAMPLES_X_TO_INT_FRAC(x2, ix2, fx2);
573
579
 
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));
576
582
 
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;
679
685
 
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",
681
 
             __FUNCTION__,
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),
688
 
             dir));
 
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",
 
687
               __FUNCTION__,
 
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),
 
694
               dir));
689
695
        assert (dy > 0);
690
696
 
691
697
        e->dy = dy;
732
738
        if (dy == 0)
733
739
                return;
734
740
 
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));
737
743
 
738
744
        e->dir = 1;
739
745
        if (dy < 0) {
1066
1072
static int
1067
1073
tor_init(struct tor *converter, const BoxRec *box, int num_edges)
1068
1074
{
1069
 
        DBG(("%s: (%d, %d),(%d, %d) x (%d, %d), num_edges=%d\n",
1070
 
             __FUNCTION__,
1071
 
             box->x1, box->y1, box->x2, box->y2,
1072
 
             FAST_SAMPLES_X, FAST_SAMPLES_Y,
1073
 
             num_edges));
 
1075
        __DBG(("%s: (%d, %d),(%d, %d) x (%d, %d), num_edges=%d\n",
 
1076
               __FUNCTION__,
 
1077
               box->x1, box->y1, box->x2, box->y2,
 
1078
               FAST_SAMPLES_X, FAST_SAMPLES_Y,
 
1079
               num_edges));
1074
1080
 
1075
1081
        converter->xmin = box->x1;
1076
1082
        converter->ymin = box->y1;
1120
1126
             const BoxRec *box,
1121
1127
             int coverage)
1122
1128
{
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));
1124
1130
 
1125
1131
        op->box(sna, op, box, AREA_TO_ALPHA(coverage));
1126
1132
        apply_damage_box(&op->base, box);
1137
1143
        float opacity;
1138
1144
 
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));
1141
1147
 
1142
1148
        pixman_region_init_rects(&region, box, 1);
1143
1149
        RegionIntersect(&region, &region, clip);
1219
1225
 
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",
1223
 
                     __FUNCTION__,
1224
 
                     cell->x, cell->covered_height, cell->uncovered_area));
 
1228
                __DBG(("%s: skipping cell (%d, %d, %d)\n",
 
1229
                       __FUNCTION__,
 
1230
                       cell->x, cell->covered_height, cell->uncovered_area));
1225
1231
 
1226
1232
                cover += cell->covered_height;
1227
1233
                cell = cell->next;
1239
1245
                if (x >= xmax)
1240
1246
                        break;
1241
1247
 
1242
 
                DBG(("%s: cell=(%d, %d, %d), cover=%d, max=%d\n", __FUNCTION__,
1243
 
                     cell->x, cell->covered_height, cell->uncovered_area,
1244
 
                     cover, xmax));
 
1248
                __DBG(("%s: cell=(%d, %d, %d), cover=%d, max=%d\n", __FUNCTION__,
 
1249
                       cell->x, cell->covered_height, cell->uncovered_area,
 
1250
                       cover, xmax));
1245
1251
 
1246
1252
                box.x2 = x;
1247
1253
                if (box.x2 > box.x1 && (unbounded || cover)) {
1248
 
                        DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1249
 
                             box.x1, box.y1,
1250
 
                             box.x2 - box.x1,
1251
 
                             box.y2 - box.y1,
1252
 
                             cover));
 
1254
                        __DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
 
1255
                               box.x1, box.y1,
 
1256
                               box.x2 - box.x1,
 
1257
                               box.y2 - box.y1,
 
1258
                               cover));
1253
1259
                        span(sna, op, clip, &box, cover);
1254
1260
                }
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__,
1264
 
                                     box.x1, box.y1,
1265
 
                                     box.x2 - box.x1,
1266
 
                                     box.y2 - box.y1,
1267
 
                                     area));
 
1269
                                __DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
 
1270
                                       box.x1, box.y1,
 
1271
                                       box.x2 - box.x1,
 
1272
                                       box.y2 - box.y1,
 
1273
                                       area));
1268
1274
                                span(sna, op, clip, &box, area);
1269
1275
                        }
1270
1276
                        box.x1 = box.x2;
1273
1279
 
1274
1280
        box.x2 = xmax;
1275
1281
        if (box.x2 > box.x1 && (unbounded || cover)) {
1276
 
                DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
1277
 
                     box.x1, box.y1,
1278
 
                     box.x2 - box.x1,
1279
 
                     box.y2 - box.y1,
1280
 
                     cover));
 
1282
                __DBG(("%s: span (%d, %d)x(%d, %d) @ %d\n", __FUNCTION__,
 
1283
                       box.x1, box.y1,
 
1284
                       box.x2 - box.x1,
 
1285
                       box.y2 - box.y1,
 
1286
                       cover));
1281
1287
                span(sna, op, clip, &box, cover);
1282
1288
        }
1283
1289
}
1325
1331
        struct active_list *active = converter->active;
1326
1332
        struct edge *buckets[FAST_SAMPLES_Y] = { 0 };
1327
1333
 
1328
 
        DBG(("%s: unbounded=%d\n", __FUNCTION__, unbounded));
 
1334
        __DBG(("%s: unbounded=%d\n", __FUNCTION__, unbounded));
1329
1335
 
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++)
1343
1349
                                        ;
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));
1346
1352
 
1347
1353
                                if (unbounded)
1348
1354
                                        tor_blt_empty(sna, op, clip, span, i+ymin, j-i, xmin, xmax);
1352
1358
                        do_full_step = can_full_step(active);
1353
1359
                }
1354
1360
 
1355
 
                DBG(("%s: y=%d [%d], do_full_step=%d, new edges=%d, min_height=%d, vertical=%d\n",
1356
 
                     __FUNCTION__,
1357
 
                     i, i+ymin, do_full_step,
1358
 
                     polygon->y_buckets[i] != NULL,
1359
 
                     active->min_height,
1360
 
                     active->is_vertical));
 
1361
                __DBG(("%s: y=%d [%d], do_full_step=%d, new edges=%d, min_height=%d, vertical=%d\n",
 
1362
                       __FUNCTION__,
 
1363
                       i, i+ymin, do_full_step,
 
1364
                       polygon->y_buckets[i] != NULL,
 
1365
                       active->min_height,
 
1366
                       active->is_vertical));
1361
1367
                if (do_full_step) {
1362
1368
                        nonzero_row(active, coverages);
1363
1369
 
1372
1378
                                if (j != i + 1)
1373
1379
                                        step_edges(active, j - (i + 1));
1374
1380
 
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));
1377
1383
                        }
1378
1384
                } else {
1379
1385
                        grid_scaled_y_t suby;
1488
1494
        pixman_fixed_t dy;
1489
1495
        int y, ytop, ybot;
1490
1496
 
1491
 
        DBG(("%s: top=%d, bottom=%d, line=(%d, %d), (%d, %d) delta=%dx%d, dir=%d\n",
1492
 
             __FUNCTION__,
1493
 
             (int)top, (int)bottom,
1494
 
             (int)p1->x, (int)p1->y, (int)p2->x, (int)p2->y,
1495
 
             dst_x, dst_y,
1496
 
             dir));
 
1497
        __DBG(("%s: top=%d, bottom=%d, line=(%d, %d), (%d, %d) delta=%dx%d, dir=%d\n",
 
1498
               __FUNCTION__,
 
1499
               (int)top, (int)bottom,
 
1500
               (int)p1->x, (int)p1->y, (int)p2->x, (int)p2->y,
 
1501
               dst_x, dst_y,
 
1502
               dir));
1497
1503
 
1498
1504
        if (top > bottom) {
1499
1505
                xPointFixed *t;
1516
1522
        ybot = MIN(y, mono->clip.extents.y2);
1517
1523
 
1518
1524
        if (ybot <= ytop) {
1519
 
                DBG(("discard clipped line\n"));
 
1525
                __DBG(("discard clipped line\n"));
1520
1526
                return;
1521
1527
        }
1522
1528
 
1697
1703
        if (x2 <= x1)
1698
1704
                return;
1699
1705
 
1700
 
        DBG(("%s [%d, %d]\n", __FUNCTION__, x1, x2));
 
1706
        __DBG(("%s [%d, %d]\n", __FUNCTION__, x1, x2));
1701
1707
 
1702
1708
        box->x1 = x1;
1703
1709
        box->x2 = x2;
1872
1878
        }
1873
1879
}
1874
1880
 
 
1881
inline static xFixed
 
1882
line_x_for_y(const xLineFixed *l, xFixed y, bool ceil)
 
1883
{
 
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;
 
1886
 
 
1887
        if (ceil)
 
1888
                ex += (d - 1);
 
1889
 
 
1890
        return l->p1.x + (xFixed) (ex / d);
 
1891
}
 
1892
 
 
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))
 
1895
 
 
1896
static void
 
1897
trapezoids_bounds(int n, const xTrapezoid *t, BoxPtr box)
 
1898
{
 
1899
        xFixed x1, y1, x2, y2;
 
1900
 
 
1901
        /* XXX need 33 bits... */
 
1902
        x1 = y1 = INT_MAX / 2;
 
1903
        x2 = y2 = INT_MIN / 2;
 
1904
 
 
1905
        do {
 
1906
                xFixed fx1, fx2, v;
 
1907
 
 
1908
                if (!xTrapezoidValid(t))
 
1909
                        continue;
 
1910
 
 
1911
                if (t->top < y1)
 
1912
                        y1 = t->top;
 
1913
                if (t->bottom > y2)
 
1914
                        y2 = t->bottom;
 
1915
 
 
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);
 
1919
                        } else {
 
1920
                                if (t->left.p1.y == t->top)
 
1921
                                        fx1 = t->left.p1.x;
 
1922
                                else
 
1923
                                        fx1 = line_x_for_y(&t->left, t->top, false);
 
1924
 
 
1925
                                if (t->left.p2.y == t->bottom)
 
1926
                                        fx2 = t->left.p2.x;
 
1927
                                else
 
1928
                                        fx2 = line_x_for_y(&t->left, t->bottom, false);
 
1929
 
 
1930
                                v = min(fx1, fx2);
 
1931
                                if (v < x1)
 
1932
                                        x1 = pixman_fixed_floor(v);
 
1933
                        }
 
1934
                }
 
1935
 
 
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);
 
1939
                        } else  {
 
1940
                                if (t->right.p1.y == t->top)
 
1941
                                        fx1 = t->right.p1.x;
 
1942
                                else
 
1943
                                        fx1 = line_x_for_y(&t->right, t->top, true);
 
1944
 
 
1945
                                if (t->right.p2.y == t->bottom)
 
1946
                                        fx2 = t->right.p2.x;
 
1947
                                else
 
1948
                                        fx2 = line_x_for_y(&t->right, t->bottom, true);
 
1949
 
 
1950
                                v = max(fx1, fx2);
 
1951
                                if (v > x2)
 
1952
                                        x2 = pixman_fixed_ceil(v);
 
1953
                        }
 
1954
                }
 
1955
        } while (t++, --n);
 
1956
 
 
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);
 
1961
}
 
1962
 
1875
1963
static void
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);
1894
1982
 
1895
 
                miTrapezoidBounds(ntrap, traps, &bounds);
 
1983
                trapezoids_bounds(ntrap, traps, &bounds);
1896
1984
                if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
1897
1985
                        return;
1898
1986
 
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));
1901
1989
 
1902
1990
                if (!sna_compute_composite_extents(&bounds,
1903
1991
                                                   src, NULL, dst,
1908
1996
                                                   bounds.y2 - bounds.y1))
1909
1997
                        return;
1910
1998
 
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));
1913
2001
 
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,
 
2013
                                                   KGEM_BUFFER_WRITE);
1925
2014
                if (!scratch)
1926
2015
                        return;
1927
2016
 
2356
2445
                scratch = sna_pixmap_create_upload(screen,
2357
2446
                                                   extents.x2 - extents.x1,
2358
2447
                                                   extents.y2 - extents.y1,
2359
 
                                                   8);
 
2448
                                                   8, KGEM_BUFFER_WRITE);
2360
2449
                if (!scratch)
2361
2450
                        continue;
2362
2451
 
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);
2587
2676
 
2588
 
        miTrapezoidBounds(ntrap, traps, &extents);
 
2677
        trapezoids_bounds(ntrap, traps, &extents);
2589
2678
        if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
2590
2679
                return true;
2591
2680
 
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);
2744
2833
 
2745
 
        miTrapezoidBounds(ntrap, traps, &extents);
 
2834
        trapezoids_bounds(ntrap, traps, &extents);
2746
2835
        if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
2747
2836
                return true;
2748
2837
 
2905
2994
                return true;
2906
2995
        }
2907
2996
 
2908
 
        miTrapezoidBounds(ntrap, traps, &extents);
 
2997
        trapezoids_bounds(ntrap, traps, &extents);
2909
2998
        if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
2910
2999
                return true;
2911
3000
 
2936
3025
 
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);
2940
3031
        if (!scratch)
2941
3032
                return true;
2942
3033
 
3213
3304
static bool
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,
 
3308
                       bool fallback)
3217
3309
{
3218
3310
        struct tor tor;
3219
3311
        struct inplace inplace;
3246
3338
        }
3247
3339
 
3248
3340
        switch (op) {
 
3341
        case PictOpIn:
 
3342
        case PictOpAdd:
3249
3343
        case PictOpSrc:
3250
 
        case PictOpIn:
3251
 
        case PictOpAdd:
 
3344
                if (!fallback && is_gpu(dst->pDrawable))
 
3345
                        return false;
3252
3346
                break;
3253
3347
        default:
3254
3348
                DBG(("%s: fallback -- can not perform op [%d] in place\n",
3265
3359
                do {
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++,
 
3363
                                                    fallback))
3269
3364
                                return false;
3270
3365
                } while (--ntrap);
3271
3366
                return true;
3272
3367
        }
3273
3368
 
3274
 
        miTrapezoidBounds(ntrap, traps, &region.extents);
 
3369
        trapezoids_bounds(ntrap, traps, &region.extents);
3275
3370
        if (region.extents.y1 >= region.extents.y2 ||
3276
3371
            region.extents.x1 >= region.extents.x2)
3277
3372
                return true;
3353
3448
                }
3354
3449
        }
3355
3450
 
 
3451
        DBG(("%s: move-to-cpu\n", __FUNCTION__));
3356
3452
        region.data = NULL;
3357
3453
        if (!sna_drawable_move_region_to_cpu(dst->pDrawable, &region,
3358
 
                                             MOVE_WRITE))
 
3454
                                             op == PictOpSrc ? MOVE_WRITE : MOVE_WRITE | MOVE_READ))
3359
3455
                return true;
3360
3456
 
3361
3457
        pixmap = get_drawable_pixmap(dst->pDrawable);
3410
3506
                return true;
3411
3507
        }
3412
3508
 
3413
 
        miTrapezoidBounds(ntrap, traps, &extents);
 
3509
        trapezoids_bounds(ntrap, traps, &extents);
3414
3510
        if (extents.y1 >= extents.y2 || extents.x1 >= extents.x2)
3415
3511
                return true;
3416
3512
 
3492
3588
                region.extents.y2 = dst_y + extents.y2;
3493
3589
                region.data = NULL;
3494
3590
 
 
3591
                DBG(("%s: move-to-cpu\n", __FUNCTION__));
3495
3592
                if (!sna_drawable_move_region_to_cpu(dst->pDrawable, &region,
3496
3593
                                                     MOVE_READ | MOVE_WRITE))
3497
3594
                        goto done;
3509
3606
                                goto done;
3510
3607
                }
3511
3608
 
 
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))
3623
3721
                return;
3624
3722
 
 
3723
        if (trapezoid_span_inplace(op, src, dst, maskFormat,
 
3724
                                   xSrc, ySrc, ntrap, traps,
 
3725
                                   false))
 
3726
                return;
 
3727
 
3625
3728
        if (trapezoid_mask_converter(op, src, dst, maskFormat,
3626
3729
                                     xSrc, ySrc, ntrap, traps))
3627
3730
                return;
3628
3731
 
3629
3732
fallback:
3630
3733
        if (trapezoid_span_inplace(op, src, dst, maskFormat,
3631
 
                                   xSrc, ySrc, ntrap, traps))
 
3734
                                   xSrc, ySrc, ntrap, traps,
 
3735
                                   true))
3632
3736
                return;
3633
3737
 
3634
3738
        if (trapezoid_span_fallback(op, src, dst, maskFormat,
3831
3935
        return true;
3832
3936
}
3833
3937
 
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))
3836
 
 
3837
3938
static void mark_damaged(PixmapPtr pixmap, struct sna_pixmap *priv,
3838
3939
                         BoxPtr box, int16_t x, int16_t y)
3839
3940
{
3906
4007
        scratch = sna_pixmap_create_upload(screen,
3907
4008
                                           extents.x2-extents.x1,
3908
4009
                                           extents.y2-extents.y1,
3909
 
                                           8);
 
4010
                                           8, KGEM_BUFFER_WRITE_INPLACE);
3910
4011
        if (!scratch)
3911
4012
                return true;
3912
4013
 
4017
4118
 
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,
 
4123
                                           KGEM_BUFFER_WRITE);
4021
4124
        if (!scratch)
4022
4125
                return true;
4023
4126
 
4418
4521
 
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);
4422
4527
        if (!scratch)
4423
4528
                return true;
4424
4529
 
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,
 
4632
                                                   KGEM_BUFFER_WRITE);
4527
4633
                if (!scratch)
4528
4634
                        return;
4529
4635
 
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,
 
4875
                                                   KGEM_BUFFER_WRITE);
4769
4876
                if (!scratch)
4770
4877
                        return;
4771
4878
 
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,
 
5010
                                                   KGEM_BUFFER_WRITE);
4903
5011
                if (!scratch)
4904
5012
                        return;
4905
5013