-int Ax=start.x(), // dieser code rult ganz ganz doll weil er ganz ganz fast ist und auch sehr gut dokumentiert is
-Ay=start.y(), Bx=dst.x(), // t. es handelt sich immerhin um den weltbekannten bresenham algorithmus der nicht nur
-By=dst.y(); int dX, dY, fbXincr, // sehr schnell ist sondern auch sehr gut dokumentiert und getestet wurde. nicht
-fbYincr, fbXYincr, dPr, dPru, P; __u8 // nur auf dem LCD der dbox, sondern auch ueberall anders. und auch auf der
-*AfbAddr = &((__u8*)data)[Ay*stride+Ax*bypp]; __u8 // dbox mit LCD soll das teil nun tun, und ich denke das tut es. ausse
-*BfbAddr = &((__u8*)data)[By*stride+Bx*bypp]; fbXincr= // rdem hat dieser algo den vorteil dass man fehler sehr leicht fi
-bypp; if ( (dX=Bx-Ax) >= 0) goto AFTERNEGX; dX=-dX; // ndet und beheben kann. das liegt nicht zuletzt an den komment
-fbXincr=-1; AFTERNEGX: fbYincr=stride; if ( (dY=By // aren. und ausserdem, je kuerzer der code, desto weniger k
--Ay) >= 0) goto AFTERNEGY; fbYincr=-stride; dY=-dY;AFTERNEGY: // ann daran falsch sein. erwaehnte ich schon, da
-fbXYincr = fbXincr+fbYincr; if (dY > dX) goto YisIndependent; dPr = dY+ // s dieser tolle code wahnsinnig schnell
-dY; P = -dX; dPru = P+P; dY = dX>>1; XLOOP: *AfbAddr=color; *BfbAddr=color; if ((P+=dPr) > 0) // ist? bye, tmbinc
-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; // nun ist der tolle code leider zu ende. tut mir leid.
+ __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;
+ }