-int Ax=start.x(),
-Ay=start.y(), Bx=dst.x(),
-By=dst.y(); int dX, dY, fbXincr,
-fbYincr, fbXYincr, dPr, dPru, P; __u8
-*AfbAddr = &((__u8*)surface->data)[Ay*surface->stride+Ax*surface->bypp]; __u8
-*BfbAddr = &((__u8*)surface->data)[By*surface->stride+Bx*surface->bypp]; fbXincr=
-surface->bypp; if ( (dX=Bx-Ax) >= 0) goto AFTERNEGX; dX=-dX;
-fbXincr=-1; AFTERNEGX: fbYincr=surface->stride; if ( (dY=By
--Ay) >= 0) goto AFTERNEGY; fbYincr=-surface->stride; dY=-dY;AFTERNEGY:
-fbXYincr = fbXincr+fbYincr; if (dY > dX) goto YisIndependent; dPr = dY+
-dY; P = -dX; dPru = P+P; dY = dX>>1; XLOOP: *AfbAddr=color; *BfbAddr=color; if ((P+=dPr) > 0)
-goto RightAndUp; AfbAddr+=fbXincr; BfbAddr-=fbXincr; if ((dY=dY-1) > 0) goto XLOOP; *AfbAddr=color; if ((dX & 1)
-== 0) return; *BfbAddr=color; return; RightAndUp: AfbAddr+=fbXYincr; BfbAddr-=fbXYincr; P+=dPru; if ((dY=dY-1) >
-0) goto XLOOP; *AfbAddr=color; if ((dX & 1) == 0) return; *BfbAddr=color; return; YisIndependent: dPr = dX+dX; P
-= -dY; dPru = P+P; dX = dY>>1; YLOOP: *AfbAddr=color; *BfbAddr=color; if ((P+=dPr) > 0) goto RightAndUp2; AfbAddr
-+=fbYincr; BfbAddr-=fbYincr; if ((dX=dX-1) > 0) goto YLOOP; *AfbAddr=color; if ((dY & 1) == 0) return; *BfbAddr=
-color;return; RightAndUp2: AfbAddr+=fbXYincr; BfbAddr-=fbXYincr; P+=dPru; if ((dX=dX-1) > 0) goto YLOOP; *AfbAddr
-=color; if((dY & 1) == 0) return; *BfbAddr=color; return;
+ __u8 *srf8 = 0;
+ __u32 *srf32 = 0;
+ int stride = surface->stride;
+
+ if (clip.rects.empty())
+ return;
+
+ __u32 col;
+ if (surface->bpp == 8)
+ {
+ srf8 = (__u8*)surface->data;
+ } else if (surface->bpp == 32)
+ {
+ srf32 = (__u32*)surface->data;
+
+ if (surface->clut.data && color < surface->clut.colors)
+ col=(surface->clut.data[color].a<<24)|(surface->clut.data[color].r<<16)|(surface->clut.data[color].g<<8)|(surface->clut.data[color].b);
+ else
+ col=0x10101*color;
+ col^=0xFF000000;
+ }
+
+ int xa = start.x(), ya = start.y(), xb = dst.x(), yb = dst.y();
+ int dx, dy, x, y, s1, s2, e, temp, swap, i;
+ dy=abs(yb-ya);
+ dx=abs(xb-xa);
+ s1=sgn(xb-xa);
+ s2=sgn(yb-ya);
+ x=xa;
+ y=ya;
+ if (dy>dx)
+ {
+ temp=dx;
+ dx=dy;
+ dy=temp;
+ swap=1;
+ } else
+ swap=0;
+ e = 2*dy-dx;
+
+ int lasthit = 0;
+ for(i=1; i<=dx; i++)
+ {
+ /* i don't like this clipping loop, but the only */
+ /* other choice i see is to calculate the intersections */
+ /* before iterating through the pixels. */
+
+ /* one could optimize this because of the ordering */
+ /* of the bands. */
+
+ lasthit = 0;
+ int a = lasthit;
+
+ /* if last pixel was invisble, first check bounding box */
+ if (a == -1)
+ {
+ /* check if we just got into the bbox again */
+ if (clip.extends.contains(x, y))
+ lasthit = a = 0;
+ else
+ goto fail;
+ } else if (!clip.rects[a].contains(x, y))
+ {
+ do
+ {
+ ++a;
+ if (a == clip.rects.size())
+ a = 0;
+ if (a == lasthit)
+ {
+ goto fail;
+ lasthit = -1;
+ }
+ } while (!clip.rects[a].contains(x, y));
+ lasthit = a;
+ }
+
+ if (srf8)
+ srf8[y * stride + x] = color;
+ if (srf32)
+ srf32[y * stride/4 + x] = col;
+fail:
+ while (e>=0)
+ {
+ if (swap==1) x+=s1;
+ else y+=s2;
+ e-=2*dx;
+ }
+ if (swap==1)
+ y+=s2;
+ else
+ x+=s1;
+ e+=2*dy;
+ }