Commit 3ca38ba7 authored by hybrid's avatar hybrid

Changed order of functions.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2509 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 0aad7654
...@@ -12,7 +12,7 @@ namespace irr ...@@ -12,7 +12,7 @@ namespace irr
namespace video namespace video
{ {
//! constructor //! Constructor of empty image
CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size)
:Data(0), Size(size), Format(format), DeleteMemory(true) :Data(0), Size(size), Format(format), DeleteMemory(true)
{ {
...@@ -23,7 +23,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) ...@@ -23,7 +23,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size)
} }
//! constructor //! Constructor from raw data
CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* data, CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* data,
bool ownForeignMemory, bool deleteForeignMemory) bool ownForeignMemory, bool deleteForeignMemory)
: Data(0), Size(size), Format(format), DeleteMemory(deleteForeignMemory) : Data(0), Size(size), Format(format), DeleteMemory(deleteForeignMemory)
...@@ -43,8 +43,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* d ...@@ -43,8 +43,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size, void* d
} }
//! Constructor from other image, with color conversion
//! constructor
CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy) CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy)
: Data(0), Format(format), DeleteMemory(true) : Data(0), Format(format), DeleteMemory(true)
{ {
...@@ -55,13 +54,11 @@ CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy) ...@@ -55,13 +54,11 @@ CImage::CImage(ECOLOR_FORMAT format, IImage* imageToCopy)
initData(); initData();
// now copy data from other image // now copy data from other image
Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, 0,0 ); Blit ( BLITTER_TEXTURE, this, 0, 0, imageToCopy, 0,0 );
} }
//! Constructor from other image, partially
//! constructor
CImage::CImage(IImage* imageToCopy, const core::position2d<s32>& pos, CImage::CImage(IImage* imageToCopy, const core::position2d<s32>& pos,
const core::dimension2d<u32>& size) const core::dimension2d<u32>& size)
: Data(0), Size(0,0), DeleteMemory(true) : Data(0), Size(0,0), DeleteMemory(true)
...@@ -79,7 +76,6 @@ CImage::CImage(IImage* imageToCopy, const core::position2d<s32>& pos, ...@@ -79,7 +76,6 @@ CImage::CImage(IImage* imageToCopy, const core::position2d<s32>& pos,
} }
//! assumes format and size has been set and creates the rest //! assumes format and size has been set and creates the rest
void CImage::initData() void CImage::initData()
{ {
...@@ -108,7 +104,6 @@ const core::dimension2d<u32>& CImage::getDimension() const ...@@ -108,7 +104,6 @@ const core::dimension2d<u32>& CImage::getDimension() const
} }
//! Returns bits per pixel. //! Returns bits per pixel.
u32 CImage::getBitsPerPixel() const u32 CImage::getBitsPerPixel() const
{ {
...@@ -123,7 +118,6 @@ u32 CImage::getBytesPerPixel() const ...@@ -123,7 +118,6 @@ u32 CImage::getBytesPerPixel() const
} }
//! Returns image data size in bytes //! Returns image data size in bytes
u32 CImage::getImageDataSizeInBytes() const u32 CImage::getImageDataSizeInBytes() const
{ {
...@@ -131,7 +125,6 @@ u32 CImage::getImageDataSizeInBytes() const ...@@ -131,7 +125,6 @@ u32 CImage::getImageDataSizeInBytes() const
} }
//! Returns image data size in pixels //! Returns image data size in pixels
u32 CImage::getImageDataSizeInPixels() const u32 CImage::getImageDataSizeInPixels() const
{ {
...@@ -216,9 +209,9 @@ u32 CImage::getAlphaMask() const ...@@ -216,9 +209,9 @@ u32 CImage::getAlphaMask() const
//! sets a pixel //! sets a pixel
void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend ) void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend)
{ {
if (x >= (u32)Size.Width || y >= (u32)Size.Height) if (x >= Size.Width || y >= Size.Height)
return; return;
switch(Format) switch(Format)
...@@ -255,7 +248,7 @@ void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend ) ...@@ -255,7 +248,7 @@ void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend )
//! returns a pixel //! returns a pixel
SColor CImage::getPixel(u32 x, u32 y) const SColor CImage::getPixel(u32 x, u32 y) const
{ {
if (x >= (u32)Size.Width || y >= (u32)Size.Height) if (x >= Size.Width || y >= Size.Height)
return SColor(0); return SColor(0);
switch(Format) switch(Format)
...@@ -284,30 +277,21 @@ ECOLOR_FORMAT CImage::getColorFormat() const ...@@ -284,30 +277,21 @@ ECOLOR_FORMAT CImage::getColorFormat() const
} }
//! draws a rectangle //! copies this surface into another at given position
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);
}
//! copies this surface into another
void CImage::copyTo(IImage* target, const core::position2d<s32>& pos) void CImage::copyTo(IImage* target, const core::position2d<s32>& pos)
{ {
Blit(BLITTER_TEXTURE, target, 0, &pos, this, 0, 0); Blit(BLITTER_TEXTURE, target, 0, &pos, this, 0, 0);
} }
//! copies this surface into another //! copies this surface partially into another at given position
void CImage::copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect) void CImage::copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect)
{ {
Blit(BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0); Blit(BLITTER_TEXTURE, target, clipRect, &pos, this, &sourceRect, 0);
} }
//! copies this surface into another, using the alpha mask, a cliprect and a color to add with
//! copies this surface into another, using the alpha mask, an cliprect and a color to add with
void CImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const SColor &color, const core::rect<s32>* clipRect) void CImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const SColor &color, const core::rect<s32>* clipRect)
{ {
// color blend only necessary on not full spectrum aka. color.color != 0xFFFFFFFF // color blend only necessary on not full spectrum aka. color.color != 0xFFFFFFFF
...@@ -316,52 +300,8 @@ void CImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, c ...@@ -316,52 +300,8 @@ void CImage::copyToWithAlpha(IImage* target, const core::position2d<s32>& pos, c
} }
//! 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;
}
}
}
//! copies this surface into another, scaling it to the target image size //! copies this surface into another, scaling it to the target image size
// note: this is very very slow. (i didn't want to write a fast version. // note: this is very very slow.
// but hopefully, nobody wants to scale surfaces every frame.
void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch) void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch)
{ {
if (!target || !width || !height) if (!target || !width || !height)
...@@ -415,9 +355,9 @@ void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT fo ...@@ -415,9 +355,9 @@ void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT fo
} }
} }
//! copies this surface into another, scaling it to the target image size //! copies this surface into another, scaling it to the target image size
// note: this is very very slow. (i didn't want to write a fast version. // note: this is very very slow.
// but hopefully, nobody wants to scale surfaces every frame.
void CImage::copyToScaling(IImage* target) void CImage::copyToScaling(IImage* target)
{ {
if (!target) if (!target)
...@@ -435,6 +375,7 @@ void CImage::copyToScaling(IImage* target) ...@@ -435,6 +375,7 @@ void CImage::copyToScaling(IImage* target)
target->unlock(); target->unlock();
} }
//! copies this surface into another, scaling it to fit it. //! copies this surface into another, scaling it to fit it.
void CImage::copyToScalingBoxFilter(IImage* target, s32 bias, bool blend) void CImage::copyToScalingBoxFilter(IImage* target, s32 bias, bool blend)
{ {
...@@ -540,5 +481,55 @@ inline SColor CImage::getPixelBox( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) cons ...@@ -540,5 +481,55 @@ 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
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