void fbSegment(DrawablePtr drawable, GCPtr gc, int x1, int y1, int x2, int y2, bool drawLast, int *dashOffset) { struct fbSegment data; BoxRec box; DBG(("%s (%d, %d), (%d, %d), drawLast?=%d\n", __FUNCTION__, x1, y1, x2, y2, drawLast)); /* simple overestimate of line extents for clipping */ box.x1 = x1 - 1; box.y1 = y1 - 1; box.x2 = x2 + 1; box.y2 = y2 + 1; data.x1 = x1; data.y1 = y1; data.x2 = x2; data.y2 = y2; data.dashOffset = dashOffset; data.drawLast = drawLast; data.bres = fbSelectBres(drawable, gc); fbDrawableRunUnclipped(drawable, gc, &box, _fbSegment, &data); }
void fbSegment1(DrawablePtr drawable, GCPtr gc, const BoxRec *b, int x1, int y1, int x2, int y2, bool drawLast, int *dashOffset) { struct fbSegment data; DBG(("%s (%d, %d), (%d, %d), drawLast?=%d\n", __FUNCTION__, x1, y1, x2, y2, drawLast)); data.x1 = x1; data.y1 = y1; data.x2 = x2; data.y2 = y2; data.dashOffset = dashOffset; data.drawLast = drawLast; data.bres = fbSelectBres(drawable, gc); _fbSegment(drawable, gc, b, &data); }
void fbSegment(DrawablePtr pDrawable, GCPtr pGC, int x1, int y1, int x2, int y2, Bool drawLast, int *dashOffset) { FbBres *bres; RegionPtr pClip = fbGetCompositeClip(pGC); BoxPtr pBox; int nBox; int adx; /* abs values of dx and dy */ int ady; int signdx; /* sign of dx and dy */ int signdy; int e, e1, e2, e3; /* bresenham error and increments */ int len; /* length of segment */ int axis; /* major axis */ int octant; int dashoff; int doff; unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); unsigned int oc1; /* outcode of point 1 */ unsigned int oc2; /* outcode of point 2 */ nBox = RegionNumRects(pClip); pBox = RegionRects(pClip); bres = fbSelectBres(pDrawable, pGC); CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy, 1, 1, octant); if (adx > ady) { axis = X_AXIS; e1 = ady << 1; e2 = e1 - (adx << 1); e = e1 - adx; len = adx; } else { axis = Y_AXIS; e1 = adx << 1; e2 = e1 - (ady << 1); e = e1 - ady; SetYMajorOctant(octant); len = ady; } FIXUP_ERROR(e, octant, bias); /* * Adjust error terms to compare against zero */ e3 = e2 - e1; e = e - e1; /* we have bresenham parameters and two points. all we have to do now is clip and draw. */ if (drawLast) len++; dashoff = *dashOffset; *dashOffset = dashoff + len; while (nBox--) { oc1 = 0; oc2 = 0; OUTCODES(oc1, x1, y1, pBox); OUTCODES(oc2, x2, y2, pBox); if ((oc1 | oc2) == 0) { (*bres) (pDrawable, pGC, dashoff, signdx, signdy, axis, x1, y1, e, e1, e3, len); break; } else if (oc1 & oc2) { pBox++; } else { int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2; int clip1 = 0, clip2 = 0; int clipdx, clipdy; int err; if (miZeroClipLine(pBox->x1, pBox->y1, pBox->x2 - 1, pBox->y2 - 1, &new_x1, &new_y1, &new_x2, &new_y2, adx, ady, &clip1, &clip2, octant, bias, oc1, oc2) == -1) { pBox++; continue; } if (axis == X_AXIS) len = abs(new_x2 - new_x1); else len = abs(new_y2 - new_y1); if (clip2 != 0 || drawLast) len++; if (len) { /* unwind bresenham error term to first point */ doff = dashoff; err = e; if (clip1) { clipdx = abs(new_x1 - x1); clipdy = abs(new_y1 - y1); if (axis == X_AXIS) { doff += clipdx; err += e3 * clipdy + e1 * clipdx; } else { doff += clipdy; err += e3 * clipdx + e1 * clipdy; } } (*bres) (pDrawable, pGC, doff, signdx, signdy, axis, new_x1, new_y1, err, e1, e3, len); } pBox++; } } /* while (nBox--) */ }