forked from Mirrors/openclonk
Remove some dead blitting code
parent
fe5a29b198
commit
bc45d417a9
|
@ -746,7 +746,7 @@ bool C4Draw::Blit8(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt,
|
|||
C4Surface * sfcTarget, int tx, int ty, int twdt, int thgt,
|
||||
bool fSrcColKey, const C4BltTransform *pTransform)
|
||||
{
|
||||
if (!pTransform) return BlitRotate(sfcSource, fx, fy, fwdt, fhgt, sfcTarget, tx, ty, twdt, thgt, 0, fSrcColKey!=false);
|
||||
if (!pTransform) return BlitSimple(sfcSource, fx, fy, fwdt, fhgt, sfcTarget, tx, ty, twdt, thgt, fSrcColKey!=false);
|
||||
// safety
|
||||
if (!fwdt || !fhgt) return true;
|
||||
// Lock the surfaces
|
||||
|
@ -787,21 +787,17 @@ bool C4Draw::Blit8(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4Draw::BlitRotate(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt,
|
||||
bool C4Draw::BlitSimple(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt,
|
||||
C4Surface * sfcTarget, int tx, int ty, int twdt, int thgt,
|
||||
int iAngle, bool fTransparency)
|
||||
bool fTransparency)
|
||||
{
|
||||
// rendertarget?
|
||||
if (sfcTarget->IsRenderTarget())
|
||||
{
|
||||
C4BltTransform rot;
|
||||
rot.SetRotate(iAngle, (float) (tx+tx+twdt)/2, (float) (ty+ty+thgt)/2);
|
||||
return Blit(sfcSource, float(fx), float(fy), float(fwdt), float(fhgt), sfcTarget, float(tx), float(ty), float(twdt), float(thgt), true, &rot);
|
||||
return Blit(sfcSource, float(fx), float(fy), float(fwdt), float(fhgt), sfcTarget, float(tx), float(ty), float(twdt), float(thgt), true);
|
||||
}
|
||||
// Object is first stretched to dest rect, then rotated at place.
|
||||
int xcnt,ycnt,fcx,fcy,tcx,tcy,cpcx,cpcy;
|
||||
int npcx,npcy;
|
||||
double mtx[4],dang;
|
||||
// Object is first stretched to dest rect
|
||||
int xcnt,ycnt,tcx,tcy,cpcx,cpcy;
|
||||
if (!fwdt || !fhgt || !twdt || !thgt) return false;
|
||||
// Lock the surfaces
|
||||
if (!sfcSource->Lock())
|
||||
|
@ -809,71 +805,12 @@ bool C4Draw::BlitRotate(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhg
|
|||
if (!sfcTarget->Lock())
|
||||
{ sfcSource->Unlock(); return false; }
|
||||
// Rectangle centers
|
||||
fcx=fwdt/2; fcy=fhgt/2;
|
||||
tcx=twdt/2; tcy=thgt/2;
|
||||
// Adjust angle range
|
||||
while (iAngle<0) iAngle+=36000; while (iAngle>35999) iAngle-=36000;
|
||||
// Exact/free rotation
|
||||
switch (iAngle)
|
||||
{
|
||||
case 0:
|
||||
for (ycnt=0; ycnt<thgt; ycnt++)
|
||||
if (Inside(cpcy=ty+tcy-thgt/2+ycnt,0,sfcTarget->Hgt-1))
|
||||
for (xcnt=0; xcnt<twdt; xcnt++)
|
||||
if (Inside(cpcx=tx+tcx-twdt/2+xcnt,0,sfcTarget->Wdt-1))
|
||||
sfcTarget->BltPix(cpcx, cpcy, sfcSource, xcnt*fwdt/twdt+fx, ycnt*fhgt/thgt+fy, fTransparency);
|
||||
break;
|
||||
|
||||
case 9000:
|
||||
for (ycnt=0; ycnt<thgt; ycnt++)
|
||||
if (Inside(cpcx=ty+tcy+thgt/2-ycnt,0,sfcTarget->Wdt-1))
|
||||
for (xcnt=0; xcnt<twdt; xcnt++)
|
||||
if (Inside(cpcy=tx+tcx-twdt/2+xcnt,0,sfcTarget->Hgt-1))
|
||||
sfcTarget->BltPix(cpcx, cpcy, sfcSource, xcnt*fwdt/twdt+fx, ycnt*fhgt/thgt+fy, fTransparency);
|
||||
break;
|
||||
|
||||
case 18000:
|
||||
for (ycnt=0; ycnt<thgt; ycnt++)
|
||||
if (Inside(cpcy=ty+tcy+thgt/2-ycnt,0,sfcTarget->Hgt-1))
|
||||
for (xcnt=0; xcnt<twdt; xcnt++)
|
||||
if (Inside(cpcx=tx+tcx+twdt/2-xcnt,0,sfcTarget->Wdt-1))
|
||||
sfcTarget->BltPix(cpcx, cpcy, sfcSource, xcnt*fwdt/twdt+fx, ycnt*fhgt/thgt+fy, fTransparency);
|
||||
break;
|
||||
|
||||
case 27000:
|
||||
for (ycnt=0; ycnt<thgt; ycnt++)
|
||||
if (Inside(cpcx=ty+tcy-thgt/2+ycnt,0,sfcTarget->Wdt-1))
|
||||
for (xcnt=0; xcnt<twdt; xcnt++)
|
||||
if (Inside(cpcy=tx+tcx+twdt/2-xcnt,0,sfcTarget->Hgt-1))
|
||||
sfcTarget->BltPix(cpcx, cpcy, sfcSource, xcnt*fwdt/twdt+fx, ycnt*fhgt/thgt+fy, fTransparency);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Calculate rotation matrix
|
||||
dang=M_PI*iAngle/18000.0;
|
||||
mtx[0]=cos(dang); mtx[1]=-sin(dang);
|
||||
mtx[2]=sin(dang); mtx[3]= cos(dang);
|
||||
// Blit source rect
|
||||
for (ycnt=0; ycnt<fhgt; ycnt++)
|
||||
{
|
||||
// Source line start
|
||||
for (xcnt=0; xcnt<fwdt; xcnt++)
|
||||
{
|
||||
// Current pixel coordinate as from source
|
||||
cpcx=xcnt-fcx; cpcy=ycnt-fcy;
|
||||
// Convert to coordinate as in dest
|
||||
cpcx=cpcx*twdt/fwdt; cpcy=cpcy*thgt/fhgt;
|
||||
// Rotate current pixel coordinate
|
||||
npcx= (int) ( mtx[0]*cpcx + mtx[1]*cpcy );
|
||||
npcy= (int) ( mtx[2]*cpcx + mtx[3]*cpcy );
|
||||
// Place in dest
|
||||
sfcTarget->BltPix(tx+tcx+npcx, ty+tcy+npcy, sfcSource, xcnt+fx, ycnt+fy, fTransparency);
|
||||
sfcTarget->BltPix(tx+tcx+npcx+1, ty+tcy+npcy, sfcSource, xcnt+fx, ycnt+fy, fTransparency);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (ycnt=0; ycnt<thgt; ycnt++)
|
||||
if (Inside(cpcy=ty+tcy-thgt/2+ycnt,0,sfcTarget->Hgt-1))
|
||||
for (xcnt=0; xcnt<twdt; xcnt++)
|
||||
if (Inside(cpcx=tx+tcx-twdt/2+xcnt,0,sfcTarget->Wdt-1))
|
||||
sfcTarget->BltPix(cpcx, cpcy, sfcSource, xcnt*fwdt/twdt+fx, ycnt*fhgt/thgt+fy, fTransparency);
|
||||
// Unlock the surfaces
|
||||
sfcSource->Unlock();
|
||||
sfcTarget->Unlock();
|
||||
|
|
|
@ -250,9 +250,9 @@ public:
|
|||
bool Blit8(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt, // force 8bit-blit (inline)
|
||||
C4Surface * sfcTarget, int tx, int ty, int twdt, int thgt,
|
||||
bool fSrcColKey=false, const C4BltTransform *pTransform=NULL);
|
||||
bool BlitRotate(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt,
|
||||
bool BlitSimple(C4Surface * sfcSource, int fx, int fy, int fwdt, int fhgt,
|
||||
C4Surface * sfcTarget, int tx, int ty, int twdt, int thgt,
|
||||
int iAngle, bool fTransparency=true);
|
||||
bool fTransparency=true);
|
||||
bool BlitSurface(C4Surface * sfcSurface, C4Surface * sfcTarget, int tx, int ty, bool fBlitBase);
|
||||
bool BlitSurfaceTile(C4Surface * sfcSurface, C4Surface * sfcTarget, int iToX, int iToY, int iToWdt, int iToHgt, int iOffsetX=0, int iOffsetY=0, bool fSrcColKey=false);
|
||||
bool BlitSurfaceTile2(C4Surface * sfcSurface, C4Surface * sfcTarget, int iToX, int iToY, int iToWdt, int iToHgt, int iOffsetX=0, int iOffsetY=0, bool fSrcColKey=false);
|
||||
|
|
Loading…
Reference in New Issue