mirror of
https://github.com/minetest/irrlicht.git
synced 2025-07-01 15:50:27 +02:00
Remove unused functions
renderLine16_Blend(), renderLine16_Decal(), renderLine32_Blend(), renderLine32_Decal() clipLine() frand() drawRectangle() and drawLine() remove unused private fields
This commit is contained in:
@ -85,96 +85,6 @@ inline u32 GetClipCode( const AbsRectangle &r, const core::position2d<s32> &p )
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Cohen Sutherland clipping
|
||||
@return: 1 if valid
|
||||
*/
|
||||
|
||||
static int ClipLine(const AbsRectangle &clipping,
|
||||
core::position2d<s32> &p0,
|
||||
core::position2d<s32> &p1,
|
||||
const core::position2d<s32>& p0_in,
|
||||
const core::position2d<s32>& p1_in)
|
||||
{
|
||||
u32 code0;
|
||||
u32 code1;
|
||||
u32 code;
|
||||
|
||||
p0 = p0_in;
|
||||
p1 = p1_in;
|
||||
|
||||
code0 = GetClipCode( clipping, p0 );
|
||||
code1 = GetClipCode( clipping, p1 );
|
||||
|
||||
// trivial accepted
|
||||
while ( code0 | code1 )
|
||||
{
|
||||
s32 x=0;
|
||||
s32 y=0;
|
||||
|
||||
// trivial reject
|
||||
if ( code0 & code1 )
|
||||
return 0;
|
||||
|
||||
if ( code0 )
|
||||
{
|
||||
// clip first point
|
||||
code = code0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// clip last point
|
||||
code = code1;
|
||||
}
|
||||
|
||||
if ( (code & CLIPCODE_BOTTOM) == CLIPCODE_BOTTOM )
|
||||
{
|
||||
// clip bottom viewport
|
||||
y = clipping.y1;
|
||||
x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y );
|
||||
}
|
||||
else
|
||||
if ( (code & CLIPCODE_TOP) == CLIPCODE_TOP )
|
||||
{
|
||||
// clip to viewport
|
||||
y = clipping.y0;
|
||||
x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y );
|
||||
}
|
||||
else
|
||||
if ( (code & CLIPCODE_RIGHT) == CLIPCODE_RIGHT )
|
||||
{
|
||||
// clip right viewport
|
||||
x = clipping.x1;
|
||||
y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X );
|
||||
}
|
||||
else
|
||||
if ( (code & CLIPCODE_LEFT) == CLIPCODE_LEFT )
|
||||
{
|
||||
// clip left viewport
|
||||
x = clipping.x0;
|
||||
y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X );
|
||||
}
|
||||
|
||||
if ( code == code0 )
|
||||
{
|
||||
// modify first point
|
||||
p0.X = x;
|
||||
p0.Y = y;
|
||||
code0 = GetClipCode( clipping, p0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// modify second point
|
||||
p1.X = x;
|
||||
p1.Y = y;
|
||||
code1 = GetClipCode( clipping, p1 );
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
inline void GetClip(AbsRectangle &clipping, video::IImage * t)
|
||||
@ -226,263 +136,6 @@ inline u32 PixelLerp32(const u32 source, const u32 value)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine32_Decal(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u32 argb )
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 4;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u32 *dst;
|
||||
dst = (u32*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 4 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
do
|
||||
{
|
||||
*dst = argb;
|
||||
|
||||
dst = (u32*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u32*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine32_Blend(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u32 argb, u32 alpha)
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 4;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u32 *dst;
|
||||
dst = (u32*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 4 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
const u32 packA = packAlpha ( alpha );
|
||||
do
|
||||
{
|
||||
*dst = packA | PixelBlend32( *dst, argb, alpha );
|
||||
|
||||
dst = (u32*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u32*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine16_Decal(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u32 argb )
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 2;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u16 *dst;
|
||||
dst = (u16*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 2 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
do
|
||||
{
|
||||
*dst = (u16)argb;
|
||||
|
||||
dst = (u16*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u16*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
static void RenderLine16_Blend(video::IImage *t,
|
||||
const core::position2d<s32> &p0,
|
||||
const core::position2d<s32> &p1,
|
||||
u16 argb,
|
||||
u16 alpha)
|
||||
{
|
||||
s32 dx = p1.X - p0.X;
|
||||
s32 dy = p1.Y - p0.Y;
|
||||
|
||||
s32 c;
|
||||
s32 m;
|
||||
s32 d = 0;
|
||||
s32 run;
|
||||
|
||||
s32 xInc = 2;
|
||||
s32 yInc = (s32) t->getPitch();
|
||||
|
||||
if ( dx < 0 )
|
||||
{
|
||||
xInc = -xInc;
|
||||
dx = -dx;
|
||||
}
|
||||
|
||||
if ( dy < 0 )
|
||||
{
|
||||
yInc = -yInc;
|
||||
dy = -dy;
|
||||
}
|
||||
|
||||
u16 *dst;
|
||||
dst = (u16*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 2 ) );
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
s32 tmp;
|
||||
tmp = dx;
|
||||
dx = dy;
|
||||
dy = tmp;
|
||||
tmp = xInc;
|
||||
xInc = yInc;
|
||||
yInc = tmp;
|
||||
}
|
||||
|
||||
c = dx << 1;
|
||||
m = dy << 1;
|
||||
|
||||
run = dx;
|
||||
const u16 packA = alpha ? 0x8000 : 0;
|
||||
do
|
||||
{
|
||||
*dst = packA | PixelBlend16( *dst, argb, alpha );
|
||||
|
||||
dst = (u16*) ( (u8*) dst + xInc ); // x += xInc
|
||||
d += m;
|
||||
if ( d > dx )
|
||||
{
|
||||
dst = (u16*) ( (u8*) dst + yInc ); // y += yInc
|
||||
d -= c;
|
||||
}
|
||||
run -= 1;
|
||||
} while (run>=0);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
*/
|
||||
static void executeBlit_TextureCopy_x_to_x( const SBlitJob * job )
|
||||
@ -1471,56 +1124,6 @@ static s32 StretchBlit(eBlitter operation,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Methods for Software drivers
|
||||
//! draws a rectangle
|
||||
static void drawRectangle(video::IImage* img, const core::rect<s32>& rect, const video::SColor &color)
|
||||
{
|
||||
Blit(color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA,
|
||||
img, 0, &rect.UpperLeftCorner, 0, &rect, color.color);
|
||||
}
|
||||
|
||||
|
||||
//! draws a line from to with color
|
||||
static void drawLine(video::IImage* img, const core::position2d<s32>& from,
|
||||
const core::position2d<s32>& to, const video::SColor &color)
|
||||
{
|
||||
AbsRectangle clip;
|
||||
GetClip(clip, img);
|
||||
|
||||
core::position2d<s32> p[2];
|
||||
if (ClipLine( clip, p[0], p[1], from, to))
|
||||
{
|
||||
u32 alpha = extractAlpha(color.color);
|
||||
|
||||
switch(img->getColorFormat())
|
||||
{
|
||||
case video::ECF_A1R5G5B5:
|
||||
if (alpha == 256)
|
||||
{
|
||||
RenderLine16_Decal(img, p[0], p[1], video::A8R8G8B8toA1R5G5B5(color.color));
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderLine16_Blend(img, p[0], p[1], video::A8R8G8B8toA1R5G5B5(color.color), alpha >> 3);
|
||||
}
|
||||
break;
|
||||
case video::ECF_A8R8G8B8:
|
||||
if (alpha == 256)
|
||||
{
|
||||
RenderLine32_Decal(img, p[0], p[1], color.color);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderLine32_Blend(img, p[0], p[1], color.color, alpha);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user