From 90222e6445eacb3487a96e8a93b4aaa9fc311422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 19 Aug 2013 15:20:15 -0300 Subject: [PATCH] More code clean up, some minor optimizations in cImage::CopyImage --- src/eepp/graphics/cimage.cpp | 16 +++++++++++++--- src/eepp/graphics/cttffont.cpp | 4 ---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/eepp/graphics/cimage.cpp b/src/eepp/graphics/cimage.cpp index f18b0c037..a13e352fc 100644 --- a/src/eepp/graphics/cimage.cpp +++ b/src/eepp/graphics/cimage.cpp @@ -389,9 +389,19 @@ void cImage::CopyImage( cImage * image, const Uint32& x, const Uint32& y ) { eeUint dWidth = image->Width(); eeUint dHeight = image->Height(); - for ( eeUint ty = 0; ty < dHeight; ty++ ) { - for ( eeUint tx = 0; tx < dWidth; tx++ ) { - SetPixel( x + tx, y + ty, image->GetPixel( tx, ty ) ); + if ( mChannels != image->Channels() ) { + for ( eeUint ty = 0; ty < dHeight; ty++ ) { + for ( eeUint tx = 0; tx < dWidth; tx++ ) { + SetPixel( x + tx, y + ty, image->GetPixel( tx, ty ) ); + } + } + } else { + // Copy per row + for ( eeUint ty = 0; ty < dHeight; ty++ ) { + Uint8 * pDst = &mPixels[ ( x + ( ( ty + y ) * mWidth ) ) * mChannels ]; + const Uint8 * pSrc = &( ( image->GetPixelsPtr() )[ ( ty * dWidth ) * mChannels ] ); + + memcpy( pDst, pSrc, mChannels * dWidth ); } } } diff --git a/src/eepp/graphics/cttffont.cpp b/src/eepp/graphics/cttffont.cpp index d7399f585..b72ac3eec 100755 --- a/src/eepp/graphics/cttffont.cpp +++ b/src/eepp/graphics/cttffont.cpp @@ -339,10 +339,6 @@ void cTTFFont::RebuildFromGlyphs() { for (eeUint i = 0; i < mNumChars; i++) { tGlyph = mGlyphs[i]; - if ( 99 == i ) { - Top++; - } - tR.Left = (eeFloat)tGlyph.CurX / Tex->Width(); tR.Top = (eeFloat)tGlyph.CurY / Tex->Height();