From fa9339916d92f69c068406927b1d83c6be6c1fa7 Mon Sep 17 00:00:00 2001 From: yodesoft Date: Tue, 2 Apr 2013 10:16:51 +0800 Subject: [PATCH] Improve font rendering performance --- cocos2dx/platform/linux/CCImage.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/cocos2dx/platform/linux/CCImage.cpp b/cocos2dx/platform/linux/CCImage.cpp index 998c74d955..6c59bf5a46 100644 --- a/cocos2dx/platform/linux/CCImage.cpp +++ b/cocos2dx/platform/linux/CCImage.cpp @@ -377,22 +377,25 @@ public: int xoffset = iCurXCursor + glyph.paintPosition; for (int y = 0; y < bitmap.rows; ++y) { + int iY = yoffset + y; + if (iY>=iMaxLineHeight) { + //exceed the height truncate + break; + } + iY *= iMaxLineWidth; + + int bitmap_y = y * bitmap.width; + for (int x = 0; x < bitmap.width; ++x) { - unsigned char cTemp = bitmap.buffer[y * bitmap.width + x]; + unsigned char cTemp = bitmap.buffer[bitmap_y + x]; if (cTemp == 0) { continue; } - int iY = yoffset + y; int iX = xoffset + x; - if (iY>=iMaxLineHeight) { - //exceed the height truncate - break; - } - int iTemp = cTemp << 24 | cTemp << 16 | cTemp << 8 | cTemp; - *(int*) &m_pData[(iY * iMaxLineWidth + iX) * 4 + 0] = iTemp; + *(int*) &m_pData[(iY + iX) * 4 + 0] = iTemp; } } }