Commit d245db3a authored by hybrid's avatar hybrid

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-e03cc46cb475
parent 0c7e4330
...@@ -1233,6 +1233,57 @@ static s32 StretchBlit(eBlitter operation, ...@@ -1233,6 +1233,57 @@ static s32 StretchBlit(eBlitter operation,
return 1; 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 #endif
......
...@@ -451,55 +451,5 @@ inline SColor CImage::getPixelBox( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) cons ...@@ -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 video
} // end namespace irr } // end namespace irr
...@@ -103,12 +103,6 @@ public: ...@@ -103,12 +103,6 @@ public:
//! fills the surface with given color //! fills the surface with given color
virtual void fill(const SColor &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: private:
//! assumes format and size has been set and creates the rest //! assumes format and size has been set and creates the rest
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#ifdef _IRR_COMPILE_WITH_SOFTWARE_ #ifdef _IRR_COMPILE_WITH_SOFTWARE_
#include "CSoftwareTexture.h" #include "CSoftwareTexture.h"
#include "CBlit.h"
#include "os.h" #include "os.h"
#include "S3DVertex.h" #include "S3DVertex.h"
...@@ -820,7 +821,7 @@ void CSoftwareDriver::draw2DLine(const core::position2d<s32>& start, ...@@ -820,7 +821,7 @@ void CSoftwareDriver::draw2DLine(const core::position2d<s32>& start,
const core::position2d<s32>& end, const core::position2d<s32>& end,
SColor color) 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, ...@@ -844,14 +845,14 @@ void CSoftwareDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos,
if(!p.isValid()) if(!p.isValid())
return; return;
RenderTargetSurface->drawRectangle(p, color); drawRectangle(RenderTargetSurface, p, color);
} }
else else
{ {
if(!pos.isValid()) if(!pos.isValid())
return; return;
RenderTargetSurface->drawRectangle(pos, color); drawRectangle(RenderTargetSurface, pos, color);
} }
} }
......
...@@ -2277,7 +2277,7 @@ void CBurningVideoDriver::draw2DLine(const core::position2d<s32>& start, ...@@ -2277,7 +2277,7 @@ void CBurningVideoDriver::draw2DLine(const core::position2d<s32>& start,
const core::position2d<s32>& end, const core::position2d<s32>& end,
SColor color) 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 ...@@ -2301,14 +2301,14 @@ void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& p
if(!p.isValid()) if(!p.isValid())
return; return;
BackBuffer->drawRectangle(p, color); drawRectangle(BackBuffer, p, color);
} }
else else
{ {
if(!pos.isValid()) if(!pos.isValid())
return; return;
BackBuffer->drawRectangle(pos, color); drawRectangle(BackBuffer, pos, color);
} }
} }
......
...@@ -2267,6 +2267,10 @@ ...@@ -2267,6 +2267,10 @@
<Filter <Filter
Name="Null" Name="Null"
> >
<File
RelativePath=".\CBlit.h"
>
</File>
<File <File
RelativePath="CColorConverter.cpp" RelativePath="CColorConverter.cpp"
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment