From d245db3a985c1ce80c8ce9bc0806d7d911f7965b Mon Sep 17 00:00:00 2001 From: hybrid Date: Sun, 29 May 2011 00:04:41 +0000 Subject: [PATCH] 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 --- source/Irrlicht/CBlit.h | 51 ++++++++++++++++++++++++++++ source/Irrlicht/CImage.cpp | 50 --------------------------- source/Irrlicht/CImage.h | 6 ---- source/Irrlicht/CSoftwareDriver.cpp | 7 ++-- source/Irrlicht/CSoftwareDriver2.cpp | 6 ++-- source/Irrlicht/Irrlicht9.0.vcproj | 4 +++ 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/source/Irrlicht/CBlit.h b/source/Irrlicht/CBlit.h index 022a9829..34b8b001 100644 --- a/source/Irrlicht/CBlit.h +++ b/source/Irrlicht/CBlit.h @@ -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& 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& from, + const core::position2d& to, const video::SColor &color) +{ + AbsRectangle clip; + GetClip(clip, img); + + core::position2d 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 diff --git a/source/Irrlicht/CImage.cpp b/source/Irrlicht/CImage.cpp index 4e8b4e4e..24067656 100644 --- a/source/Irrlicht/CImage.cpp +++ b/source/Irrlicht/CImage.cpp @@ -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& 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& from, const core::position2d& to, const SColor &color) -{ - AbsRectangle clip; - GetClip( clip, this ); - - core::position2d 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 diff --git a/source/Irrlicht/CImage.h b/source/Irrlicht/CImage.h index 6645a29e..3bae6760 100644 --- a/source/Irrlicht/CImage.h +++ b/source/Irrlicht/CImage.h @@ -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& rect, const SColor &color); - - //! draws a line from to - void drawLine(const core::position2d& from, const core::position2d& to, const SColor &color); - private: //! assumes format and size has been set and creates the rest diff --git a/source/Irrlicht/CSoftwareDriver.cpp b/source/Irrlicht/CSoftwareDriver.cpp index 126e8ca8..393415ee 100644 --- a/source/Irrlicht/CSoftwareDriver.cpp +++ b/source/Irrlicht/CSoftwareDriver.cpp @@ -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& start, const core::position2d& 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& 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); } } diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 9352a6b4..22ee3f34 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -2277,7 +2277,7 @@ void CBurningVideoDriver::draw2DLine(const core::position2d& start, const core::position2d& 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& 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); } } diff --git a/source/Irrlicht/Irrlicht9.0.vcproj b/source/Irrlicht/Irrlicht9.0.vcproj index f1cfcad0..f3dd56a9 100644 --- a/source/Irrlicht/Irrlicht9.0.vcproj +++ b/source/Irrlicht/Irrlicht9.0.vcproj @@ -2267,6 +2267,10 @@ + +