xserver/render Makefile.am, 1.3, 1.4 mipict.c, 1.19, 1.20 mitrap.c, 1.10, 1.11 mitri.c, 1.7, 1.8 picture.c, 1.35, 1.36 render.c, 1.30, 1.31 renderedge.c, NONE, 1.1
Keith Packard <xserver-commit-u7BhqnqprCWvj1b/[email protected]>
| Newsgroups | gmane.comp.freedesktop.xserver.cvs |
|---|---|
| Message-ID | <[email protected]> |
Committed by: keithp Update of /cvs/xserver/xserver/render In directory pdx:/tmp/cvs-serv18390/render Modified Files: Makefile.am mipict.c mitrap.c mitri.c picture.c render.c Added Files: renderedge.c Log Message: 2004-07-29 Keith Packard <[email protected]> * fb/Makefile.am: * fb/fbedge.c: (fbRasterizeEdges): * fb/fbedgeimp.h: * fb/fbpict.c: (fbPictureInit): * fb/fbpict.h: * fb/fbtrap.c: (fbAddTraps), (fbRasterizeTrapezoid), (_GreaterY), (_Clockwise), (fbAddTriangles): * include/mipict.h: * include/picture.h: * include/picturestr.h: * include/renderedge.h: * render/Makefile.am: * render/mipict.c: (miIsSolidAlpha), (miPictureInit): * render/mitrap.c: (miTrapezoids): * render/mitri.c: (miTriangles), (miTriStrip), (miTriFan): * render/picture.c: (AddTraps): * render/render.c: (RenderNumberRequests), (ProcRenderAddTraps), (SProcRenderAddTraps), (PanoramiXRenderAddTraps), (PanoramiXRenderInit): * render/renderedge.c: (RenderSampleCeilY), (RenderSampleFloorY), (RenderEdgeStep), (_RenderEdgeMultiInit), (RenderEdgeInit), (RenderLineFixedEdgeInit): Change polygon fill semantics to regular point sampling Add RenderAddTraps request Index: Makefile.am =================================================================== RCS file: /cvs/xserver/xserver/render/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.am 2 Nov 2003 19:56:11 -0000 1.3 +++ Makefile.am 29 Jul 2004 08:10:15 -0000 1.4 @@ -16,5 +16,5 @@ mitrap.c \ mitri.c \ picture.c \ - render.c - + render.c \ + renderedge.c Index: mipict.c =================================================================== RCS file: /cvs/xserver/xserver/render/mipict.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- mipict.c 2 Dec 2003 01:59:38 -0000 1.19 +++ mipict.c 29 Jul 2004 08:10:15 -0000 1.20 @@ -520,6 +520,35 @@ return (CARD16) pixel; } +Bool +miIsSolidAlpha (PicturePtr pSrc) +{ + ScreenPtr pScreen = pSrc->pDrawable->pScreen; + char line[1]; + + /* Alpha-only */ + if (PICT_FORMAT_TYPE (pSrc->format) != PICT_TYPE_A) + return FALSE; + /* repeat */ + if (!pSrc->repeat) + return FALSE; + /* 1x1 */ + if (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1) + return FALSE; + line[0] = 1; + (*pScreen->GetImage) (pSrc->pDrawable, 0, 0, 1, 1, ZPixmap, ~0L, line); + switch (pSrc->pDrawable->bitsPerPixel) { + case 1: + return (CARD8) line[0] == 1 || (CARD8) line[0] == 0x80; + case 4: + return (CARD8) line[0] == 0xf || (CARD8) line[0] == 0xf0; + case 8: + return (CARD8) line[0] == 0xff; + default: + return FALSE; + } +} + void miRenderPixelToColor (PictFormatPtr format, CARD32 pixel, @@ -580,5 +609,9 @@ ps->TriStrip = miTriStrip; ps->TriFan = miTriFan; + ps->RasterizeTrapezoid = 0; /* requires DDX support */ + ps->AddTraps = 0; /* requires DDX support */ + ps->AddTriangles = 0; /* requires DDX support */ + return TRUE; } Index: mitrap.c =================================================================== RCS file: /cvs/xserver/xserver/render/mitrap.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- mitrap.c 11 Sep 2003 05:12:51 -0000 1.10 +++ mitrap.c 29 Jul 2004 08:10:15 -0000 1.11 @@ -139,16 +139,25 @@ { ScreenPtr pScreen = pDst->pDrawable->pScreen; PictureScreenPtr ps = GetPictureScreen(pScreen); - PicturePtr pPicture = 0; - BoxRec bounds; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = traps[0].left.p1.x >> 16; - yDst = traps[0].left.p1.y >> 16; - - if (maskFormat) + + /* + * Check for solid alpha add + */ + if (op == PictOpAdd && miIsSolidAlpha (pSrc)) { + for (; ntrap; ntrap--, traps++) + (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0); + } + else if (maskFormat) + { + PicturePtr pPicture; + BoxRec bounds; + INT16 xDst, yDst; + INT16 xRel, yRel; + + xDst = traps[0].left.p1.x >> 16; + yDst = traps[0].left.p1.y >> 16; + miTrapezoidBounds (ntrap, traps, &bounds); if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) return; @@ -157,37 +166,9 @@ bounds.y2 - bounds.y1); if (!pPicture) return; - } - for (; ntrap; ntrap--, traps++) - { - if (!xTrapezoidValid(traps)) - continue; - if (!maskFormat) - { - miTrapezoidBounds (1, traps, &bounds); - if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - continue; - } - (*ps->RasterizeTrapezoid) (pPicture, traps, - -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - } - if (maskFormat) - { + for (; ntrap; ntrap--, traps++) + (*ps->RasterizeTrapezoid) (pPicture, traps, + -bounds.x1, -bounds.y1); xRel = bounds.x1 + xSrc - xDst; yRel = bounds.y1 + ySrc - yDst; CompositePicture (op, pSrc, pPicture, pDst, @@ -196,4 +177,13 @@ bounds.y2 - bounds.y1); FreePicture (pPicture, 0); } + else + { + if (pDst->polyEdge == PolyEdgeSharp) + maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1); + else + maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8); + for (; ntrap; ntrap--, traps++) + miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps); + } } Index: mitri.c =================================================================== RCS file: /cvs/xserver/xserver/render/mitri.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mitri.c 11 Sep 2003 05:12:51 -0000 1.7 +++ mitri.c 29 Jul 2004 08:10:15 -0000 1.8 @@ -68,82 +68,6 @@ } void -miRasterizeTriangle (PicturePtr pPicture, - xTriangle *tri, - int x_off, - int y_off) -{ - ScreenPtr pScreen = pPicture->pDrawable->pScreen; - PictureScreenPtr ps = GetPictureScreen(pScreen); - xPointFixed *top, *left, *right, *t; - xTrapezoid trap[2]; - - top = &tri->p1; - left = &tri->p2; - right = &tri->p3; - if (left->y < top->y) { - t = left; left = top; top = t; - } - if (right->y < top->y) { - t = right; right = top; top = t; - } - if (right->x < left->x) { - t = right; right = left; left = t; - } - - /* - * Two cases: - * - * + + - * / \ / \ - * / \ / \ - * / + + \ - * / -- -- \ - * / -- -- \ - * / --- --- \ - * +-- --+ - */ - - trap[0].top = top->y; - - trap[0].left.p1.x = top->x; - trap[0].left.p1.y = trap[0].top; - trap[0].left.p2.x = left->x; - trap[0].left.p2.y = left->y; - - trap[0].right.p1 = trap[0].left.p1; - trap[0].right.p2.x = right->x; - trap[0].right.p2.y = right->y; - - if (right->y < left->y) - { - trap[0].bottom = trap[0].right.p2.y; - - trap[1].top = trap[0].bottom; - trap[1].bottom = trap[0].left.p2.y; - - trap[1].left = trap[0].left; - trap[1].right.p1 = trap[0].right.p2; - trap[1].right.p2 = trap[0].left.p2; - } - else - { - trap[0].bottom = trap[0].left.p2.y; - - trap[1].top = trap[0].bottom; - trap[1].bottom = trap[0].right.p2.y; - - trap[1].right = trap[0].right; - trap[1].left.p1 = trap[0].left.p2; - trap[1].left.p2 = trap[0].right.p2; - } - if (trap[0].top != trap[0].bottom) - (*ps->RasterizeTrapezoid) (pPicture, &trap[0], x_off, y_off); - if (trap[1].top != trap[1].bottom) - (*ps->RasterizeTrapezoid) (pPicture, &trap[1], x_off, y_off); -} - -void miTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst, @@ -154,16 +78,25 @@ xTriangle *tris) { ScreenPtr pScreen = pDst->pDrawable->pScreen; - BoxRec bounds; - PicturePtr pPicture = 0; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = tris[0].p1.x >> 16; - yDst = tris[0].p1.y >> 16; + PictureScreenPtr ps = GetPictureScreen(pScreen); - if (maskFormat) + /* + * Check for solid alpha add + */ + if (op == PictOpAdd && miIsSolidAlpha (pSrc)) { + (*ps->AddTriangles) (pDst, 0, 0, ntri, tris); + } + else if (maskFormat) + { + BoxRec bounds; + PicturePtr pPicture; + INT16 xDst, yDst; + INT16 xRel, yRel; + + xDst = tris[0].p1.x >> 16; + yDst = tris[0].p1.y >> 16; + miTriangleBounds (ntri, tris, &bounds); if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) return; @@ -172,34 +105,8 @@ bounds.y2 - bounds.y1); if (!pPicture) return; - } - for (; ntri; ntri--, tris++) - { - if (!maskFormat) - { - miTriangleBounds (1, tris, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - break; - } - miRasterizeTriangle (pPicture, tris, -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - /* XXX adjust xSrc and ySrc */ - } - if (maskFormat) - { + (*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris); + xRel = bounds.x1 + xSrc - xDst; yRel = bounds.y1 + ySrc - yDst; CompositePicture (op, pSrc, pPicture, pDst, @@ -207,6 +114,16 @@ bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); FreePicture (pPicture, 0); } + else + { + if (pDst->polyEdge == PolyEdgeSharp) + maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1); + else + maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8); + + for (; ntri; ntri--, tris++) + miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris); + } } void @@ -220,64 +137,24 @@ xPointFixed *points) { ScreenPtr pScreen = pDst->pDrawable->pScreen; - xTriangle tri; - BoxRec bounds; - PicturePtr pPicture = 0; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = points[0].x >> 16; - yDst = points[0].y >> 16; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xTriangle *tris, *tri; + int ntri; if (npoint < 3) return; - if (maskFormat) - { - miPointFixedBounds (npoint, points, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - return; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - return; - } - for (; npoint >= 3; npoint--, points++) - { - tri.p1 = points[0]; - tri.p2 = points[1]; - tri.p3 = points[2]; - if (!maskFormat) - { - miTriangleBounds (1, &tri, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - continue; - } - miRasterizeTriangle (pPicture, &tri, -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - } - if (maskFormat) + ntri = npoint - 2; + tris = ALLOCATE_LOCAL (ntri & sizeof (xTriangle)); + if (!tris) + return; + for (tri = tris; npoint >= 3; npoint--, points++, tri++) { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); + tri->p1 = points[0]; + tri->p2 = points[1]; + tri->p3 = points[2]; } + (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); + DEALLOCATE_LOCAL (tris); } void @@ -291,65 +168,24 @@ xPointFixed *points) { ScreenPtr pScreen = pDst->pDrawable->pScreen; - xTriangle tri; - BoxRec bounds; - PicturePtr pPicture = 0; + PictureScreenPtr ps = GetPictureScreen(pScreen); + xTriangle *tris, *tri; xPointFixed *first; - INT16 xDst, yDst; - INT16 xRel, yRel; - - xDst = points[0].x >> 16; - yDst = points[0].y >> 16; + int ntri; if (npoint < 3) return; - if (maskFormat) - { - miPointFixedBounds (npoint, points, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - return; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - return; - } + ntri = npoint - 2; + tris = ALLOCATE_LOCAL (ntri & sizeof (xTriangle)); + if (!tris) + return; first = points++; - npoint--; - for (; npoint >= 2; npoint--, points++) - { - tri.p1 = *first; - tri.p2 = points[0]; - tri.p3 = points[1]; - if (!maskFormat) - { - miTriangleBounds (1, &tri, &bounds); - if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1) - continue; - pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat, - bounds.x2 - bounds.x1, - bounds.y2 - bounds.y1); - if (!pPicture) - continue; - } - miRasterizeTriangle (pPicture, &tri, -bounds.x1, -bounds.y1); - if (!maskFormat) - { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); - } - } - if (maskFormat) + for (tri = tris; npoint >= 3; npoint--, points++, tri++) { - xRel = bounds.x1 + xSrc - xDst; - yRel = bounds.y1 + ySrc - yDst; - CompositePicture (op, pSrc, pPicture, pDst, - xRel, yRel, 0, 0, bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1); - FreePicture (pPicture, 0); + tri->p1 = *first; + tri->p2 = points[0]; + tri->p3 = points[1]; } + (*ps->Triangles) (op, pSrc, pDst, maskFormat, xSrc, ySrc, ntri, tris); + DEALLOCATE_LOCAL (tris); } Index: picture.c =================================================================== RCS file: /cvs/xserver/xserver/render/picture.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- picture.c 18 Nov 2003 07:10:14 -0000 1.35 +++ picture.c 29 Jul 2004 08:10:15 -0000 1.36 @@ -1328,7 +1328,18 @@ (*ps->TriFan) (op, pSrc, pDst, maskFormat, xSrc, ySrc, npoints, points); } -typedef xFixed_32_32 xFixed_48_16; +void +AddTraps (PicturePtr pPicture, + INT16 xOff, + INT16 yOff, + int ntrap, + xTrap *traps) +{ + PictureScreenPtr ps = GetPictureScreen(pPicture->pDrawable->pScreen); + + ValidatePicture (pPicture); + (*ps->AddTraps) (pPicture, xOff, yOff, ntrap, traps); +} #define MAX_FIXED_48_16 ((xFixed_48_16) 0x7fffffff) #define MIN_FIXED_48_16 (-((xFixed_48_16) 1 << 31)) Index: render.c =================================================================== RCS file: /cvs/xserver/xserver/render/render.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- render.c 19 Mar 2004 16:00:02 -0000 1.30 +++ render.c 29 Jul 2004 08:10:15 -0000 1.31 @@ -80,6 +80,7 @@ static int ProcRenderQueryFilters (ClientPtr pClient); static int ProcRenderSetPictureFilter (ClientPtr pClient); static int ProcRenderCreateAnimCursor (ClientPtr pClient); +static int ProcRenderAddTraps (ClientPtr pClient); static int ProcRenderDispatch (ClientPtr pClient); @@ -113,6 +114,7 @@ static int SProcRenderQueryFilters (ClientPtr pClient); static int SProcRenderSetPictureFilter (ClientPtr pClient); static int SProcRenderCreateAnimCursor (ClientPtr pClient); +static int SProcRenderAddTraps (ClientPtr pClient); static int SProcRenderDispatch (ClientPtr pClient); @@ -149,6 +151,7 @@ ProcRenderQueryFilters, ProcRenderSetPictureFilter, ProcRenderCreateAnimCursor, + ProcRenderAddTraps, }; int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { @@ -184,6 +187,7 @@ SProcRenderQueryFilters, SProcRenderSetPictureFilter, SProcRenderCreateAnimCursor, + SProcRenderAddTraps, }; static void @@ -1810,6 +1814,27 @@ } static int +ProcRenderAddTraps (ClientPtr client) +{ + int ntraps; + PicturePtr pPicture; + REQUEST(xRenderAddTrapsReq); + + REQUEST_AT_LEAST_SIZE(xRenderAddTrapsReq); + VERIFY_PICTURE (pPicture, stuff->picture, client, SecurityWriteAccess, + RenderErrBase + BadPicture); + ntraps = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); + if (ntraps % sizeof (xTrap)) + return BadLength; + ntraps /= sizeof (xTrap); + if (ntraps) + AddTraps (pPicture, + stuff->xOff, stuff->yOff, + ntraps, (xTrap *) &stuff[1]); + return client->noClientException; +} + +static int ProcRenderDispatch (ClientPtr client) { REQUEST(xReq); @@ -2275,6 +2300,21 @@ } static int +SProcRenderAddTraps (ClientPtr client) +{ + register int n; + REQUEST (xRenderAddTrapsReq); + REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); + + swaps(&stuff->length, n); + swapl(&stuff->picture, n); + swaps(&stuff->xOff, n); + swaps(&stuff->yOff, n); + SwapRestL(stuff); + return (*ProcRenderVector[stuff->renderReqType]) (client); +} + +static int SProcRenderDispatch (ClientPtr client) { REQUEST(xReq); @@ -2557,6 +2597,44 @@ return result; } +static int +PanoramiXRenderAddTraps (ClientPtr client) +{ + PanoramiXRes *picture; + int result = Success, j; + REQUEST(xRenderAddTrapsReq); + char *extra; + int extra_len; + INT16 x_off, y_off; + + REQUEST_AT_LEAST_SIZE (xRenderAddTrapsReq); + VERIFY_XIN_PICTURE (picture, stuff->picture, client, SecurityWriteAccess, + RenderErrBase + BadPicture); + extra_len = (client->req_len << 2) - sizeof (xRenderAddTrapsReq); + if (extra_len && + (extra = (char *) ALLOCATE_LOCAL (extra_len))) + { + memcpy (extra, stuff + 1, extra_len); + x_off = stuff->x_off; + y_off = stuff->y_off; + FOR_NSCREENS_FORWARD(j) { + if (j) memcpy (stuff + 1, extra, extra_len); + stuff->picture = picture->info[j].id; + + if (dst->u.pict.root) + { + stuff->x_off = x_off + panoramiXdataPtr[j].x; + stuff->y_off = y_off + panoramiXdataPtr[j].y; + } + result = (*PanoramiXSaveRenderVector[X_RenderAddTraps]) (client); + if(result != Success) break; + } + DEALLOCATE_LOCAL(extra); + } + + return result; +} + void PanoramiXRenderInit (void) { @@ -2577,6 +2655,7 @@ ProcRenderVector[X_RenderCompositeGlyphs16] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderCompositeGlyphs32] = PanoramiXRenderCompositeGlyphs; ProcRenderVector[X_RenderFillRectangles] = PanoramiXRenderFillRectangles; + ProcRenderVector[X_RenderAddTraps] = PanoramiXRenderAddTraps; } void --- NEW FILE: renderedge.c --- (This appears to be a binary file; contents omitted.)