Commit 93f1824a authored by Eric Anholt's avatar Eric Anholt

glamor: Rely on nested mappings to handle src==dst and !prepare bugs.

Now that the core deals with that for us, we can avoid all this extra
carefulness.
Signed-off-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarMarkus Wick <markus@selfnet.de>
parent 4c9a2007
......@@ -40,8 +40,8 @@ _glamor_add_traps(PicturePtr pPicture,
if (glamor_prepare_access_picture(pPicture, GLAMOR_ACCESS_RW)) {
fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
glamor_finish_access_picture(pPicture, GLAMOR_ACCESS_RW);
}
glamor_finish_access_picture(pPicture);
return TRUE;
}
......
......@@ -570,15 +570,13 @@ _glamor_copy_n_to_n(DrawablePtr src,
glamor_get_drawable_location(src),
glamor_get_drawable_location(dst));
if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) {
if (dst == src || glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
fbCopyNtoN(src, dst, gc, box, nbox,
dx, dy, reverse, upsidedown, bitplane, closure);
if (dst != src)
glamor_finish_access(src, GLAMOR_ACCESS_RO);
}
glamor_finish_access(dst, GLAMOR_ACCESS_RW);
if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW) &&
glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
fbCopyNtoN(src, dst, gc, box, nbox,
dx, dy, reverse, upsidedown, bitplane, closure);
}
glamor_finish_access(src);
glamor_finish_access(dst);
ok = TRUE;
done:
......
......@@ -38,12 +38,13 @@ _glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
&& glamor_ddx_fallback_check_pixmap(pDst))
goto fail;
glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, bitPlane);
glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
if (glamor_prepare_access(pDst, GLAMOR_ACCESS_RW) &&
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO)) {
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, bitPlane);
}
glamor_finish_access(pSrc);
glamor_finish_access(pDst);
return TRUE;
fail:
......
......@@ -304,7 +304,7 @@ glamor_fini_finish_access_shaders(ScreenPtr screen)
}
void
glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
glamor_finish_access(DrawablePtr drawable)
{
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
......@@ -370,7 +370,7 @@ glamor_prepare_access_gc(GCPtr gc)
if (!glamor_prepare_access(&gc->tile.pixmap->drawable,
GLAMOR_ACCESS_RO)) {
if (gc->stipple)
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&gc->stipple->drawable);
return FALSE;
}
}
......@@ -384,9 +384,9 @@ void
glamor_finish_access_gc(GCPtr gc)
{
if (gc->fillStyle == FillTiled)
glamor_finish_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&gc->tile.pixmap->drawable);
if (gc->stipple)
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&gc->stipple->drawable);
}
Bool
......@@ -460,7 +460,7 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
(&old_tile->drawable, GLAMOR_ACCESS_RO)) {
new_tile =
fb24_32ReformatTile(old_tile, drawable->bitsPerPixel);
glamor_finish_access(&old_tile->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&old_tile->drawable);
}
}
if (new_tile) {
......@@ -483,8 +483,7 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
if (glamor_prepare_access
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW)) {
fbPadPixmap(gc->tile.pixmap);
glamor_finish_access
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW);
glamor_finish_access(&gc->tile.pixmap->drawable);
}
}
}
......@@ -500,7 +499,7 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
*/
if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
fbValidateGC(gc, changes, drawable);
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
glamor_finish_access(&gc->stipple->drawable);
}
}
else {
......@@ -544,7 +543,7 @@ glamor_bitmap_to_region(PixmapPtr pixmap)
if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
return NULL;
ret = fbPixmapToRegion(pixmap);
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&pixmap->drawable);
return ret;
}
......
......@@ -112,13 +112,12 @@ glamor_fill(DrawablePtr drawable,
x = 0;
y = 0;
}
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbFill(drawable, gc, x, y, width, height);
glamor_finish_access_gc(gc);
}
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
glamor_prepare_access_gc(gc)) {
fbFill(drawable, gc, x, y, width, height);
}
glamor_finish_access_gc(gc);
glamor_finish_access(drawable);
if (sub_pixmap != NULL) {
if (gc->fillStyle != FillSolid) {
......
......@@ -79,13 +79,12 @@ _glamor_fill_spans(DrawablePtr drawable,
}
glamor_fallback("to %p (%c)\n", drawable,
glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbFillSpans(drawable, gc, n, points, widths, sorted);
glamor_finish_access_gc(gc);
}
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
glamor_prepare_access_gc(gc)) {
fbFillSpans(drawable, gc, n, points, widths, sorted);
}
glamor_finish_access_gc(gc);
glamor_finish_access(drawable);
ret = TRUE;
done:
......
......@@ -69,8 +69,8 @@ _glamor_get_spans(DrawablePtr drawable,
ret = TRUE;
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
fbGetSpans(drawable, wmax, points, widths, count, dst);
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
}
glamor_finish_access(drawable);
done:
return ret;
}
......
......@@ -55,12 +55,12 @@ glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
}
void
glamor_finish_access_picture(PicturePtr picture, glamor_access_t access)
glamor_finish_access_picture(PicturePtr picture)
{
if (!picture || !picture->pDrawable)
return;
glamor_finish_access(picture->pDrawable, access);
glamor_finish_access(picture->pDrawable);
}
/*
......
......@@ -96,13 +96,12 @@ _glamor_poly_fill_rect(DrawablePtr drawable,
glamor_fallback(" to %p (%c)\n",
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbPolyFillRect(drawable, gc, nrect, prect);
glamor_finish_access_gc(gc);
}
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
glamor_prepare_access_gc(gc)) {
fbPolyFillRect(drawable, gc, nrect, prect);
}
glamor_finish_access_gc(gc);
glamor_finish_access(drawable);
ret = TRUE;
done:
......
......@@ -105,13 +105,12 @@ _glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
return FALSE;
if (gc->lineWidth == 0) {
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_gc(gc)) {
fbPolyLine(drawable, gc, mode, n, points);
glamor_finish_access_gc(gc);
}
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW) &&
glamor_prepare_access_gc(gc)) {
fbPolyLine(drawable, gc, mode, n, points);
}
glamor_finish_access_gc(gc);
glamor_finish_access(drawable);
}
else {
wide_line:
......
......@@ -578,7 +578,7 @@ void glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
/* glamor_core.c */
Bool glamor_prepare_access(DrawablePtr drawable, glamor_access_t access);
void glamor_finish_access(DrawablePtr drawable, glamor_access_t access);
void glamor_finish_access(DrawablePtr drawable);
Bool glamor_prepare_access_window(WindowPtr window);
void glamor_finish_access_window(WindowPtr window);
Bool glamor_prepare_access_gc(GCPtr gc);
......@@ -904,7 +904,7 @@ void glamor_set_window_pixmap(WindowPtr pWindow, PixmapPtr pPixmap);
Bool glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
void glamor_finish_access_picture(PicturePtr picture, glamor_access_t access);
void glamor_finish_access_picture(PicturePtr picture);
void glamor_destroy_picture(PicturePtr picture);
......
......@@ -229,8 +229,8 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
fail:
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap, bits);
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
}
glamor_finish_access(drawable);
}
#endif
......
......@@ -1784,22 +1784,17 @@ _glamor_composite(CARD8 op,
if (mask && mask->pDrawable && !mask->transform)
GET_SUB_PICTURE(mask, GLAMOR_ACCESS_RO);
if (glamor_prepare_access_picture(dest, GLAMOR_ACCESS_RW)) {
if (source_pixmap == dest_pixmap || glamor_prepare_access_picture
(source, GLAMOR_ACCESS_RO)) {
if (!mask || glamor_prepare_access_picture(mask, GLAMOR_ACCESS_RO)) {
fbComposite(op,
source, mask, dest,
x_source, y_source,
x_mask, y_mask, x_dest, y_dest, width, height);
if (mask)
glamor_finish_access_picture(mask, GLAMOR_ACCESS_RO);
}
if (source_pixmap != dest_pixmap)
glamor_finish_access_picture(source, GLAMOR_ACCESS_RO);
}
glamor_finish_access_picture(dest, GLAMOR_ACCESS_RW);
}
if (glamor_prepare_access_picture(dest, GLAMOR_ACCESS_RW) &&
glamor_prepare_access_picture(source, GLAMOR_ACCESS_RO) &&
glamor_prepare_access_picture(mask, GLAMOR_ACCESS_RO)) {
fbComposite(op,
source, mask, dest,
x_source, y_source,
x_mask, y_mask, x_dest, y_dest, width, height);
}
glamor_finish_access_picture(mask);
glamor_finish_access_picture(source);
glamor_finish_access_picture(dest);
#define PUT_SUB_PICTURE(p, access) do { \
if (sub_ ##p ##_pixmap != NULL) { \
......
......@@ -88,8 +88,8 @@ _glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
drawable, glamor_get_drawable_location(drawable));
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
}
glamor_finish_access(drawable);
ret = TRUE;
done:
......
......@@ -41,16 +41,13 @@ _glamor_triangles(CARD8 op,
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
return FALSE;
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
if (glamor_prepare_access_picture(pSrc, GLAMOR_ACCESS_RO)) {
fbTriangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
glamor_finish_access_picture(pSrc, GLAMOR_ACCESS_RO);
}
glamor_finish_access_picture(pDst, GLAMOR_ACCESS_RW);
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW) &&
glamor_prepare_access_picture(pSrc, GLAMOR_ACCESS_RO)) {
fbTriangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
}
glamor_finish_access_picture(pSrc);
glamor_finish_access_picture(pDst);
return TRUE;
}
......
......@@ -1177,7 +1177,7 @@ glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h)
default:
ErrorF("dump depth %d, not implemented.\n", pixmap->drawable.depth);
}
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&pixmap->drawable);
}
static inline void
......@@ -1318,13 +1318,12 @@ glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
{
assert(pixmap1->drawable.depth == pixmap2->drawable.depth);
glamor_prepare_access(&pixmap1->drawable, GLAMOR_ACCESS_RO);
glamor_prepare_access(&pixmap2->drawable, GLAMOR_ACCESS_RO);
_glamor_compare_pixmaps(pixmap1, pixmap2, x, y, w, h, -1, all, diffs);
glamor_finish_access(&pixmap1->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&pixmap2->drawable, GLAMOR_ACCESS_RO);
if (glamor_prepare_access(&pixmap1->drawable, GLAMOR_ACCESS_RO) &&
glamor_prepare_access(&pixmap2->drawable, GLAMOR_ACCESS_RO)) {
_glamor_compare_pixmaps(pixmap1, pixmap2, x, y, w, h, -1, all, diffs);
}
glamor_finish_access(&pixmap1->drawable);
glamor_finish_access(&pixmap2->drawable);
}
/* This function is used to compare two pictures.
......@@ -1432,9 +1431,6 @@ glamor_compare_pictures(ScreenPtr screen,
return;
}
glamor_prepare_access(&fst_pixmap->drawable, GLAMOR_ACCESS_RO);
glamor_prepare_access(&snd_pixmap->drawable, GLAMOR_ACCESS_RO);
if ((fst_type == SourcePictTypeLinear) ||
(fst_type == SourcePictTypeRadial) ||
(fst_type == SourcePictTypeConical) ||
......@@ -1444,12 +1440,15 @@ glamor_compare_pictures(ScreenPtr screen,
x_source = y_source = 0;
}
_glamor_compare_pixmaps(fst_pixmap, snd_pixmap,
x_source, y_source,
width, height, fst_picture->format, all, diffs);
glamor_finish_access(&fst_pixmap->drawable, GLAMOR_ACCESS_RO);
glamor_finish_access(&snd_pixmap->drawable, GLAMOR_ACCESS_RO);
if (glamor_prepare_access(&fst_pixmap->drawable, GLAMOR_ACCESS_RO) &&
glamor_prepare_access(&snd_pixmap->drawable, GLAMOR_ACCESS_RO)) {
_glamor_compare_pixmaps(fst_pixmap, snd_pixmap,
x_source, y_source,
width, height, fst_picture->format,
all, diffs);
}
glamor_finish_access(&fst_pixmap->drawable);
glamor_finish_access(&snd_pixmap->drawable);
if (fst_generated)
glamor_destroy_picture(fst_picture);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment