Move sw driver render support methods out of cimage class.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3767 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
0c7e433063
commit
d245db3a98
|
@ -1233,6 +1233,57 @@ static s32 StretchBlit(eBlitter operation,
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
|
|
@ -451,55 +451,5 @@ inline SColor CImage::getPixelBox( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) cons
|
|||
}
|
||||
|
||||
|
||||
// Methods for Software drivers, non-virtual and not necessary to copy into other image classes
|
||||
//! draws a rectangle
|
||||
void CImage::drawRectangle(const core::rect<s32>& rect, const SColor &color)
|
||||
{
|
||||
Blit(color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA,
|
||||
this, 0, &rect.UpperLeftCorner, 0, &rect, color.color);
|
||||
}
|
||||
|
||||
|
||||
//! draws a line from to with color
|
||||
void CImage::drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color)
|
||||
{
|
||||
AbsRectangle clip;
|
||||
GetClip( clip, this );
|
||||
|
||||
core::position2d<s32> p[2];
|
||||
|
||||
if ( ClipLine( clip, p[0], p[1], from, to ) )
|
||||
{
|
||||
u32 alpha = extractAlpha( color.color );
|
||||
|
||||
switch ( Format )
|
||||
{
|
||||
case ECF_A1R5G5B5:
|
||||
if ( alpha == 256 )
|
||||
{
|
||||
RenderLine16_Decal( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5( color.color ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderLine16_Blend( this, p[0], p[1], video::A8R8G8B8toA1R5G5B5( color.color ), alpha >> 3 );
|
||||
}
|
||||
break;
|
||||
case ECF_A8R8G8B8:
|
||||
if ( alpha == 256 )
|
||||
{
|
||||
RenderLine32_Decal( this, p[0], p[1], color.color );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderLine32_Blend( this, p[0], p[1], color.color, alpha );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
|
|
@ -103,12 +103,6 @@ public:
|
|||
//! fills the surface with given color
|
||||
virtual void fill(const SColor &color);
|
||||
|
||||
//! draws a rectangle
|
||||
void drawRectangle(const core::rect<s32>& rect, const SColor &color);
|
||||
|
||||
//! draws a line from to
|
||||
void drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color);
|
||||
|
||||
private:
|
||||
|
||||
//! assumes format and size has been set and creates the rest
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
|
||||
|
||||
#include "CSoftwareTexture.h"
|
||||
#include "CBlit.h"
|
||||
#include "os.h"
|
||||
#include "S3DVertex.h"
|
||||
|
||||
|
@ -820,7 +821,7 @@ void CSoftwareDriver::draw2DLine(const core::position2d<s32>& start,
|
|||
const core::position2d<s32>& end,
|
||||
SColor color)
|
||||
{
|
||||
RenderTargetSurface->drawLine(start, end, color );
|
||||
drawLine(RenderTargetSurface, start, end, color );
|
||||
}
|
||||
|
||||
|
||||
|
@ -844,14 +845,14 @@ void CSoftwareDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos,
|
|||
if(!p.isValid())
|
||||
return;
|
||||
|
||||
RenderTargetSurface->drawRectangle(p, color);
|
||||
drawRectangle(RenderTargetSurface, p, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!pos.isValid())
|
||||
return;
|
||||
|
||||
RenderTargetSurface->drawRectangle(pos, color);
|
||||
drawRectangle(RenderTargetSurface, pos, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2277,7 +2277,7 @@ void CBurningVideoDriver::draw2DLine(const core::position2d<s32>& start,
|
|||
const core::position2d<s32>& end,
|
||||
SColor color)
|
||||
{
|
||||
BackBuffer->drawLine(start, end, color );
|
||||
drawLine(BackBuffer, start, end, color );
|
||||
}
|
||||
|
||||
|
||||
|
@ -2301,14 +2301,14 @@ void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& p
|
|||
if(!p.isValid())
|
||||
return;
|
||||
|
||||
BackBuffer->drawRectangle(p, color);
|
||||
drawRectangle(BackBuffer, p, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!pos.isValid())
|
||||
return;
|
||||
|
||||
BackBuffer->drawRectangle(pos, color);
|
||||
drawRectangle(BackBuffer, pos, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2267,6 +2267,10 @@
|
|||
<Filter
|
||||
Name="Null"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\CBlit.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="CColorConverter.cpp"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue