diff options
author | Søren Sandmann <ssp@redhat.com> | 2010-07-09 10:27:24 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2011-01-26 08:08:42 -0500 |
commit | c91939f318c472a2bfbc9fdbf526647dada87159 (patch) | |
tree | 3931a46af5e234715284dab7c15c1b06d567a70f /src/uxa | |
parent | 38cf1ae55006125cf502199b9fb3a4f75f4b009f (diff) |
Initial preparations for surfaces.
- Surface command enums
- Memory contexts for allocating video memory
- Internal API for creating, drawing to, and destroying surfaces
Diffstat (limited to 'src/uxa')
-rw-r--r-- | src/uxa/uxa-accel.c | 43 | ||||
-rw-r--r-- | src/uxa/uxa-damage.c | 18 | ||||
-rw-r--r-- | src/uxa/uxa-unaccel.c | 58 | ||||
-rw-r--r-- | src/uxa/uxa.c | 21 |
4 files changed, 113 insertions, 27 deletions
diff --git a/src/uxa/uxa-accel.c b/src/uxa/uxa-accel.c index 73d1059..49870ed 100644 --- a/src/uxa/uxa-accel.c +++ b/src/uxa/uxa-accel.c @@ -509,7 +509,9 @@ uxa_copy_n_to_n(DrawablePtr pSrcDrawable, int src_off_x, src_off_y; int dst_off_x, dst_off_y; PixmapPtr pSrcPixmap, pDstPixmap; - + RegionRec src_region; + RegionRec dst_region; + pSrcPixmap = uxa_get_drawable_pixmap(pSrcDrawable); pDstPixmap = uxa_get_drawable_pixmap(pDstDrawable); if (!pSrcPixmap || !pDstPixmap) @@ -597,18 +599,34 @@ uxa_copy_n_to_n(DrawablePtr pSrcDrawable, return; fallback: +#if 0 + ErrorF ("falling back: %d boxes\n", nbox); +#endif + + pixman_region_init_rects (&dst_region, pbox, nbox); + REGION_INIT (NULL, &src_region, (BoxPtr)NULL, 0); + REGION_COPY (NULL, &src_region, &dst_region); + REGION_TRANSLATE (NULL, &src_region, dx, dy); + UXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable, uxa_drawable_location(pSrcDrawable), uxa_drawable_location(pDstDrawable))); - if (uxa_prepare_access(pDstDrawable, NULL, UXA_ACCESS_RW)) { - if (uxa_prepare_access(pSrcDrawable, NULL, UXA_ACCESS_RO)) { - fbCopyNtoN(pSrcDrawable, pDstDrawable, pGC, pbox, nbox, - dx, dy, reverse, upsidedown, bitplane, - closure); - uxa_finish_access(pSrcDrawable); - } - uxa_finish_access(pDstDrawable); + if (uxa_prepare_access(pDstDrawable, &dst_region, UXA_ACCESS_RW)) + { + if (uxa_prepare_access(pSrcDrawable, &src_region, UXA_ACCESS_RO)) + { + fbCopyNtoN(pSrcDrawable, pDstDrawable, pGC, pbox, nbox, + dx, dy, reverse, upsidedown, bitplane, + closure); + + uxa_finish_access(pSrcDrawable); + } + + uxa_finish_access(pDstDrawable); } + + REGION_UNINIT (NULL, &src_region); + REGION_UNINIT (NULL, &dst_region); } RegionPtr @@ -1212,6 +1230,7 @@ uxa_get_image(DrawablePtr pDrawable, int x, int y, int w, int h, PixmapPtr pPix = uxa_get_drawable_pixmap(pDrawable); int xoff, yoff; Bool ok; + RegionRec region; uxa_get_drawable_deltas(pDrawable, pPix, &xoff, &yoff); @@ -1248,10 +1267,14 @@ fallback: UXA_FALLBACK(("from %p (%c)\n", pDrawable, uxa_drawable_location(pDrawable))); - if (uxa_prepare_access(pDrawable, NULL, UXA_ACCESS_RO)) { + REGION_INIT(screen, ®ion, &Box, 1); + + if (uxa_prepare_access(pDrawable, ®ion, UXA_ACCESS_RO)) { fbGetImage(pDrawable, x, y, w, h, format, planeMask, d); uxa_finish_access(pDrawable); } + REGION_UNINIT(screen, ®ion); + return; } diff --git a/src/uxa/uxa-damage.c b/src/uxa/uxa-damage.c index 63ad0ea..7d52fb1 100644 --- a/src/uxa/uxa-damage.c +++ b/src/uxa/uxa-damage.c @@ -92,7 +92,6 @@ trim_region (RegionPtr pRegion, int subWindowMode) { RegionRec pixClip; - int draw_x, draw_y; #ifdef COMPOSITE int screen_x = 0, screen_y = 0; #endif @@ -135,6 +134,9 @@ trim_region (RegionPtr pRegion, /* If subWindowMode is set to an invalid value, don't perform * any drawable-based clipping. */ } + + int draw_x = 0; + int draw_y = 0; /* Clip against border or pixmap bounds */ if (pDrawable->type == DRAWABLE_WINDOW) @@ -145,6 +147,20 @@ trim_region (RegionPtr pRegion, else { BoxRec box; + + draw_x = pDrawable->x; + draw_y = pDrawable->y; +#ifdef COMPOSITE + /* + * Need to move everyone to screen coordinates + * XXX what about off-screen pixmaps with non-zero x/y? + */ + if (!WindowDrawable(pDrawable->type)) + { + draw_x += ((PixmapPtr) pDrawable)->screen_x; + draw_y += ((PixmapPtr) pDrawable)->screen_y; + } +#endif box.x1 = draw_x; box.y1 = draw_y; diff --git a/src/uxa/uxa-unaccel.c b/src/uxa/uxa-unaccel.c index 84e9d8b..2c068a0 100644 --- a/src/uxa/uxa-unaccel.c +++ b/src/uxa/uxa-unaccel.c @@ -78,10 +78,15 @@ uxa_check_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int nspans, DDXPointPtr ppt, int *pwidth, int fSorted) { ScreenPtr screen = pDrawable->pScreen; + RegionRec region; + + REGION_INIT (screen, ®ion, (BoxPtr)NULL, 0); + uxa_damage_fill_spans (®ion, pDrawable, pGC, nspans, + ppt, pwidth, fSorted); UXA_FALLBACK(("to %p (%c)\n", pDrawable, uxa_drawable_location(pDrawable))); - if (uxa_prepare_access(pDrawable, NULL, UXA_ACCESS_RW)) { + if (uxa_prepare_access(pDrawable, ®ion, UXA_ACCESS_RW)) { if (uxa_prepare_access_gc(pGC)) { fbFillSpans(pDrawable, pGC, nspans, ppt, pwidth, fSorted); @@ -89,6 +94,8 @@ uxa_check_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int nspans, } uxa_finish_access(pDrawable); } + + REGION_UNINIT (screen, ®ion); } void @@ -127,7 +134,13 @@ uxa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, { ScreenPtr screen = pSrc->pScreen; RegionPtr ret = NULL; - RegionRec region; + RegionRec src_region; + RegionRec dst_region; + BoxRec src_box = { srcx, srcy, srcx + w, srcy + h }; + BoxRec dst_box = { dstx, dsty, dstx + w, dsty + h }; + + REGION_INIT (screen, &src_region, &src_box, 1); + REGION_INIT (screen, &dst_region, &dst_box, 1); /* FIXME: Hmm, it's not totally clear what to do in this case. In fact, * all cases where more than one drawable can get prepare_access() called @@ -137,8 +150,8 @@ uxa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, UXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst, uxa_drawable_location(pSrc), uxa_drawable_location(pDst))); - if (uxa_prepare_access(pDst, ®ion, UXA_ACCESS_RW)) { - if (uxa_prepare_access(pSrc, ®ion, UXA_ACCESS_RO)) { + if (uxa_prepare_access(pDst, &dst_region, UXA_ACCESS_RW)) { + if (uxa_prepare_access(pSrc, &src_region, UXA_ACCESS_RO)) { ret = fbCopyArea(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); @@ -146,6 +159,10 @@ uxa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, } uxa_finish_access(pDst); } + + REGION_UNINIT (screen, &src_region); + REGION_UNINIT (screen, &dst_region); + return ret; } @@ -215,12 +232,16 @@ uxa_check_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nsegInit, xSegment * pSegInit) { ScreenPtr screen = pDrawable->pScreen; + RegionRec region; + + REGION_INIT (screen, ®ion, (BoxPtr)NULL, 0); + uxa_damage_poly_segment (®ion, pDrawable, pGC, nsegInit, pSegInit); UXA_FALLBACK(("to %p (%c) width %d, count %d\n", pDrawable, uxa_drawable_location(pDrawable), pGC->lineWidth, nsegInit)); if (pGC->lineWidth == 0) { - if (uxa_prepare_access(pDrawable, NULL, UXA_ACCESS_RW)) { + if (uxa_prepare_access(pDrawable, ®ion, UXA_ACCESS_RW)) { if (uxa_prepare_access_gc(pGC)) { fbPolySegment(pDrawable, pGC, nsegInit, pSegInit); @@ -228,10 +249,14 @@ uxa_check_poly_segment(DrawablePtr pDrawable, GCPtr pGC, } uxa_finish_access(pDrawable); } - return; + goto out; } + /* fb calls mi functions in the lineWidth != 0 case. */ fbPolySegment(pDrawable, pGC, nsegInit, pSegInit); + +out: + REGION_UNINIT (screen, ®ion); } void @@ -341,11 +366,15 @@ uxa_check_push_pixels(GCPtr pGC, PixmapPtr pBitmap, DrawablePtr pDrawable, int w, int h, int x, int y) { ScreenPtr screen = pDrawable->pScreen; + RegionRec region; + + REGION_INIT (screen, ®ion, (BoxPtr)NULL, 0); + uxa_damage_push_pixels (®ion, pGC, pBitmap, pDrawable, w, h, x, y); UXA_FALLBACK(("from %p to %p (%c,%c)\n", pBitmap, pDrawable, uxa_drawable_location(&pBitmap->drawable), uxa_drawable_location(pDrawable))); - if (uxa_prepare_access(pDrawable, NULL, UXA_ACCESS_RW)) { + if (uxa_prepare_access(pDrawable, ®ion, UXA_ACCESS_RW)) { if (uxa_prepare_access(&pBitmap->drawable, NULL, UXA_ACCESS_RO)) { if (uxa_prepare_access_gc(pGC)) { fbPushPixels(pGC, pBitmap, pDrawable, w, h, x, @@ -356,6 +385,8 @@ uxa_check_push_pixels(GCPtr pGC, PixmapPtr pBitmap, } uxa_finish_access(pDrawable); } + + REGION_UNINIT (screen, ®ion); } void @@ -384,10 +415,21 @@ uxa_check_composite(CARD8 op, CARD16 width, CARD16 height) { ScreenPtr screen = pDst->pDrawable->pScreen; + RegionRec region; UXA_FALLBACK(("from picts %p/%p to pict %p\n", pSrc, pMask, pDst)); - if (uxa_prepare_access(pDst->pDrawable, NULL, UXA_ACCESS_RW)) { + REGION_INIT (screen, ®ion, (BoxPtr)NULL, 0); + uxa_damage_composite (®ion, op, pSrc, pMask, pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, + width, height); + +#if 0 + ErrorF ("destination: %p\n", pDst->pDrawable); + ErrorF ("source: %p\n", pSrc->pDrawable); + ErrorF ("mask: %p\n", pMask? pMask->pDrawable : NULL); +#endif + if (uxa_prepare_access(pDst->pDrawable, ®ion, UXA_ACCESS_RW)) { if (pSrc->pDrawable == NULL || uxa_prepare_access(pSrc->pDrawable, NULL, UXA_ACCESS_RO)) { if (!pMask || pMask->pDrawable == NULL || diff --git a/src/uxa/uxa.c b/src/uxa/uxa.c index 71fe482..bfc700d 100644 --- a/src/uxa/uxa.c +++ b/src/uxa/uxa.c @@ -149,17 +149,22 @@ Bool uxa_prepare_access(DrawablePtr pDrawable, RegionPtr region, uxa_access_t ac if (!offscreen) return TRUE; + box.x1 = 0; + box.y1 = 0; + box.x2 = pPixmap->drawable.width; + box.y2 = pPixmap->drawable.height; + + REGION_INIT (pScreen, ®ion_rec, &box, 1); if (!region) - { region = ®ion_rec; - box.x1 = 0; - box.y1 = 0; - box.x2 = pPixmap->drawable.width; - box.y2 = pPixmap->drawable.height; - - REGION_INIT (pScreen, ®ion_rec, &box, 1); - } +#if 0 + /* Confine to the size of the drawable pixmap. The original + * drawable may be bigger than the underlying one. For example, + * the root window might be bigger than the screen pixmap. + */ + REGION_INTERSECT (pScreen, region, region, ®ion_rec); +#endif result = TRUE; |