From 0ca0de7698b523effaaf6cc9c608e936fa5aaf86 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 2 Dec 2014 21:55:57 +0000 Subject: useless calls of mir_*strlen in DrawText replaced with -1 git-svn-id: http://svn.miranda-ng.org/main/trunk@11223 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirandaG15/src/CContactList.cpp | 13 +- plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp | 411 ++++++++++++------------ plugins/MirandaG15/src/LCDFramework/CLCDGfx.h | 43 ++- 3 files changed, 229 insertions(+), 238 deletions(-) (limited to 'plugins/MirandaG15') diff --git a/plugins/MirandaG15/src/CContactList.cpp b/plugins/MirandaG15/src/CContactList.cpp index cf16976481..69e6165d38 100644 --- a/plugins/MirandaG15/src/CContactList.cpp +++ b/plugins/MirandaG15/src/CContactList.cpp @@ -401,29 +401,24 @@ void CContactList::DeleteGroup(CContactListGroup *pGroup) //************************************************************************ void CContactList::DrawEntry(CLCDGfx *pGfx,CContactListEntry *pEntry,bool bSelected) { - if(pEntry == NULL) { + if(pEntry == NULL) return; - } int iOffset = 0; tstring strText = _T(""); - if(pEntry->iMessages > 0) - { + if(pEntry->iMessages > 0) { strText = _T("["); strText += pEntry->strMessages; strText += _T("]"); } strText += pEntry->strName; - if(CConfig::GetBoolSetting(CLIST_SHOWPROTO) && !CConfig::GetBoolSetting(CLIST_COLUMNS)) - { + if(CConfig::GetBoolSetting(CLIST_SHOWPROTO) && !CConfig::GetBoolSetting(CLIST_COLUMNS)) { int w = pGfx->GetClipWidth(); pGfx->DrawText(w-w*0.3,0,w*0.3,pEntry->strProto); pGfx->DrawText(8,0,w*0.7-8,strText); } - else - pGfx->DrawText(8,0,pGfx->GetClipWidth()-8,strText); - + else pGfx->DrawText(8,0,pGfx->GetClipWidth()-8,strText); pGfx->DrawBitmap(1,ceil((pGfx->GetClipHeight()-5)/2.0f),5,5,CAppletManager::GetInstance()->GetStatusBitmap(pEntry->iStatus)); diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp index 814410f9b8..9314bb52aa 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp +++ b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.cpp @@ -22,12 +22,12 @@ CLCDGfx::CLCDGfx(void) { m_nWidth = 0; - m_nHeight = 0; - m_pBitmapInfo = NULL; - m_hDC = NULL; - m_hBitmap = NULL; - m_hPrevBitmap = NULL; - m_pBitmapBits = NULL; + m_nHeight = 0; + m_pBitmapInfo = NULL; + m_hDC = NULL; + m_hBitmap = NULL; + m_hPrevBitmap = NULL; + m_pBitmapBits = NULL; m_pLcdBitmapBits = NULL; m_pSavedBitmapBits = NULL; m_bInitialized = false; @@ -43,7 +43,7 @@ CLCDGfx::CLCDGfx(void) //************************************************************************ CLCDGfx::~CLCDGfx(void) { - Shutdown(); + Shutdown(); } //************************************************************************ @@ -53,40 +53,40 @@ bool CLCDGfx::Initialize(int nWidth, int nHeight, int nBPP, PBYTE pLcdBitmapBits { m_pLcdBitmapBits = pLcdBitmapBits; - m_nWidth = nWidth; - m_nHeight = nHeight; + m_nWidth = nWidth; + m_nHeight = nHeight; m_nBPP = nBPP; - m_hDC = CreateCompatibleDC(NULL); - if(NULL == m_hDC) - { - TRACE(_T("CLCDGfx::Initialize(): failed to create compatible DC.\n")); - Shutdown(); - return false; - } - - int nBMISize = sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD); - m_pBitmapInfo = (BITMAPINFO *) new BYTE [nBMISize]; - if(NULL == m_pBitmapInfo) - { - TRACE(_T("CLCDGfx::Initialize(): failed to allocate bitmap info.\n")); - Shutdown(); - return false; - } - - memset(m_pBitmapInfo, 0, nBMISize); - m_pBitmapInfo->bmiHeader.biSize = sizeof(m_pBitmapInfo->bmiHeader); - m_pBitmapInfo->bmiHeader.biWidth = m_nWidth; - m_pBitmapInfo->bmiHeader.biHeight = -m_nHeight; - m_pBitmapInfo->bmiHeader.biPlanes = 1; - m_pBitmapInfo->bmiHeader.biBitCount = 8*m_nBPP; - m_pBitmapInfo->bmiHeader.biCompression = BI_RGB; - m_pBitmapInfo->bmiHeader.biSizeImage = m_pBitmapInfo->bmiHeader.biWidth * m_pBitmapInfo->bmiHeader.biHeight * m_nBPP; - m_pBitmapInfo->bmiHeader.biXPelsPerMeter = 3200; - m_pBitmapInfo->bmiHeader.biYPelsPerMeter = 3200; - m_pBitmapInfo->bmiHeader.biClrUsed = 256; - m_pBitmapInfo->bmiHeader.biClrImportant = 256; - + m_hDC = CreateCompatibleDC(NULL); + if(NULL == m_hDC) + { + TRACE(_T("CLCDGfx::Initialize(): failed to create compatible DC.\n")); + Shutdown(); + return false; + } + + int nBMISize = sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD); + m_pBitmapInfo = (BITMAPINFO *) new BYTE [nBMISize]; + if(NULL == m_pBitmapInfo) + { + TRACE(_T("CLCDGfx::Initialize(): failed to allocate bitmap info.\n")); + Shutdown(); + return false; + } + + memset(m_pBitmapInfo, 0, nBMISize); + m_pBitmapInfo->bmiHeader.biSize = sizeof(m_pBitmapInfo->bmiHeader); + m_pBitmapInfo->bmiHeader.biWidth = m_nWidth; + m_pBitmapInfo->bmiHeader.biHeight = -m_nHeight; + m_pBitmapInfo->bmiHeader.biPlanes = 1; + m_pBitmapInfo->bmiHeader.biBitCount = 8*m_nBPP; + m_pBitmapInfo->bmiHeader.biCompression = BI_RGB; + m_pBitmapInfo->bmiHeader.biSizeImage = m_pBitmapInfo->bmiHeader.biWidth * m_pBitmapInfo->bmiHeader.biHeight * m_nBPP; + m_pBitmapInfo->bmiHeader.biXPelsPerMeter = 3200; + m_pBitmapInfo->bmiHeader.biYPelsPerMeter = 3200; + m_pBitmapInfo->bmiHeader.biClrUsed = 256; + m_pBitmapInfo->bmiHeader.biClrImportant = 256; + if(m_nBPP == 1) { for(int nColor = 0; nColor < 256; ++nColor) { @@ -97,17 +97,17 @@ bool CLCDGfx::Initialize(int nWidth, int nHeight, int nBPP, PBYTE pLcdBitmapBits } } - m_hBitmap = CreateDIBSection(m_hDC, m_pBitmapInfo, DIB_RGB_COLORS, (PVOID *) &m_pBitmapBits, NULL, 0); - if(NULL == m_hBitmap) - { - TRACE(_T("CLCDGfx::Initialize(): failed to create bitmap.\n")); - Shutdown(); - return false; - } - - m_bInitialized = true; - - return true; + m_hBitmap = CreateDIBSection(m_hDC, m_pBitmapInfo, DIB_RGB_COLORS, (PVOID *) &m_pBitmapBits, NULL, 0); + if(NULL == m_hBitmap) + { + TRACE(_T("CLCDGfx::Initialize(): failed to create bitmap.\n")); + Shutdown(); + return false; + } + + m_bInitialized = true; + + return true; } //************************************************************************ @@ -125,31 +125,31 @@ bool CLCDGfx::Shutdown(void) { EndTransition(); - if(NULL != m_hBitmap) - { - DeleteObject(m_hBitmap); - m_hBitmap = NULL; - m_pBitmapBits = NULL; - } - - ASSERT(NULL == m_hPrevBitmap); - m_hPrevBitmap = NULL; - - if(NULL != m_pBitmapInfo) - { - delete [] m_pBitmapInfo; - m_pBitmapInfo = NULL; - } - - if(NULL != m_hDC) - { - DeleteDC(m_hDC); - m_hDC = NULL; - } - - m_nWidth = 0; - m_nHeight = 0; - + if(NULL != m_hBitmap) + { + DeleteObject(m_hBitmap); + m_hBitmap = NULL; + m_pBitmapBits = NULL; + } + + ASSERT(NULL == m_hPrevBitmap); + m_hPrevBitmap = NULL; + + if(NULL != m_pBitmapInfo) + { + delete [] m_pBitmapInfo; + m_pBitmapInfo = NULL; + } + + if(NULL != m_hDC) + { + DeleteDC(m_hDC); + m_hDC = NULL; + } + + m_nWidth = 0; + m_nHeight = 0; + m_bInitialized = false; return true; @@ -160,7 +160,7 @@ bool CLCDGfx::Shutdown(void) void CLCDGfx::SetClipRegion(int iX,int iY,int iWidth,int iHeight) { ASSERT(NULL != m_hPrevBitmap); - + m_rClipRegion.left = iX; m_rClipRegion.right = iX+iWidth; m_rClipRegion.top = iY; @@ -184,16 +184,16 @@ RECT CLCDGfx::GetClipRegion() //************************************************************************ void CLCDGfx::BeginDraw(void) { - ASSERT(NULL != m_hBitmap); + ASSERT(NULL != m_hBitmap); if(m_hPrevBitmap != NULL) Sleep(1); - ASSERT(NULL == m_hPrevBitmap); - if(NULL == m_hPrevBitmap) - { - m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hBitmap); - SetTextColor(m_hDC, RGB(255, 255, 255)); - SetBkColor(m_hDC, RGB(0, 0, 0)); - } + ASSERT(NULL == m_hPrevBitmap); + if(NULL == m_hPrevBitmap) + { + m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hBitmap); + SetTextColor(m_hDC, RGB(255, 255, 255)); + SetBkColor(m_hDC, RGB(0, 0, 0)); + } } //************************************************************************ @@ -201,10 +201,10 @@ void CLCDGfx::BeginDraw(void) //************************************************************************ void CLCDGfx::ClearScreen(void) { - // this means, we're inside BeginDraw()/EndDraw() - ASSERT(NULL != m_hPrevBitmap); - RECT rc = { 0, 0, m_nWidth, m_nHeight }; - FillRect(m_hDC, &rc, (HBRUSH) GetStockObject(BLACK_BRUSH)); + // this means, we're inside BeginDraw()/EndDraw() + ASSERT(NULL != m_hPrevBitmap); + RECT rc = { 0, 0, m_nWidth, m_nHeight }; + FillRect(m_hDC, &rc, (HBRUSH) GetStockObject(BLACK_BRUSH)); } //************************************************************************ @@ -218,9 +218,9 @@ COLORREF CLCDGfx::GetPixel(int nX, int nY) { // CLCDGfx::SetPixel //************************************************************************ void CLCDGfx::SetPixel(int nX, int nY, COLORREF color) { - // this means, we're inside BeginDraw()/EndDraw() - ASSERT(NULL != m_hPrevBitmap); - ::SetPixel(m_hDC, nX, nY, color); + // this means, we're inside BeginDraw()/EndDraw() + ASSERT(NULL != m_hPrevBitmap); + ::SetPixel(m_hDC, nX, nY, color); } void CLCDGfx::SetPixel(int nX, int nY, BYTE r, BYTE g, BYTE b) @@ -231,7 +231,7 @@ void CLCDGfx::SetPixel(int nX, int nY, BYTE r, BYTE g, BYTE b) } else { ref = RGB(r,g,b); } - SetPixel(nX,nY,ref); + SetPixel(nX,nY,ref); } @@ -240,13 +240,13 @@ void CLCDGfx::SetPixel(int nX, int nY, BYTE r, BYTE g, BYTE b) //************************************************************************ void CLCDGfx::DrawLine(int nX1, int nY1, int nX2, int nY2) { - // this means, we're inside BeginDraw()/EndDraw() - ASSERT(NULL != m_hPrevBitmap); + // this means, we're inside BeginDraw()/EndDraw() + ASSERT(NULL != m_hPrevBitmap); - HPEN hPrevPen = (HPEN) SelectObject(m_hDC, GetStockObject(WHITE_PEN)); - ::MoveToEx(m_hDC, nX1, nY1, NULL); - ::LineTo(m_hDC, nX2, nY2); - SelectObject(m_hDC, hPrevPen); + HPEN hPrevPen = (HPEN) SelectObject(m_hDC, GetStockObject(WHITE_PEN)); + ::MoveToEx(m_hDC, nX1, nY1, NULL); + ::LineTo(m_hDC, nX2, nY2); + SelectObject(m_hDC, hPrevPen); } @@ -257,13 +257,13 @@ void CLCDGfx::DrawLine(int nX1, int nY1, int nX2, int nY2) //************************************************************************ void CLCDGfx::DrawFilledRect(int nX, int nY, int nWidth, int nHeight) { - // this means, we're inside BeginDraw()/EndDraw() - ASSERT(NULL != m_hPrevBitmap); + // this means, we're inside BeginDraw()/EndDraw() + ASSERT(NULL != m_hPrevBitmap); - HBRUSH hPrevBrush = (HBRUSH) SelectObject(m_hDC, GetStockObject(WHITE_BRUSH)); - RECT r = { nX, nY, nX + nWidth, nY + nHeight }; - ::FillRect(m_hDC, &r, hPrevBrush); - SelectObject(m_hDC, hPrevBrush); + HBRUSH hPrevBrush = (HBRUSH) SelectObject(m_hDC, GetStockObject(WHITE_BRUSH)); + RECT r = { nX, nY, nX + nWidth, nY + nHeight }; + ::FillRect(m_hDC, &r, hPrevBrush); + SelectObject(m_hDC, hPrevBrush); } //************************************************************************ @@ -272,10 +272,10 @@ void CLCDGfx::DrawFilledRect(int nX, int nY, int nWidth, int nHeight) void CLCDGfx::DrawRect(int iX, int iY, int iWidth, int iHeight) { // this means, we're inside BeginDraw()/EndDraw() - ASSERT(NULL != m_hPrevBitmap); + ASSERT(NULL != m_hPrevBitmap); + + HBRUSH hPrevBrush = (HBRUSH) SelectObject(m_hDC, GetStockObject(WHITE_BRUSH)); - HBRUSH hPrevBrush = (HBRUSH) SelectObject(m_hDC, GetStockObject(WHITE_BRUSH)); - // top line DrawLine(iX+1,iY,iX+iWidth-1,iY); // bottom line @@ -285,7 +285,7 @@ void CLCDGfx::DrawRect(int iX, int iY, int iWidth, int iHeight) // right line DrawLine(iX+iWidth-1,iY,iX+iWidth-1,iY+iHeight); - SelectObject(m_hDC, hPrevBrush); + SelectObject(m_hDC, hPrevBrush); } //************************************************************************ @@ -293,20 +293,20 @@ void CLCDGfx::DrawRect(int iX, int iY, int iWidth, int iHeight) //************************************************************************ void CLCDGfx::DrawText(int nX, int nY, LPCTSTR sText) { - // map mode text, with transparency - int nOldMapMode = SetMapMode(m_hDC, MM_TEXT); - int nOldBkMode = SetBkMode(m_hDC, TRANSPARENT); - + // map mode text, with transparency + int nOldMapMode = SetMapMode(m_hDC, MM_TEXT); + int nOldBkMode = SetBkMode(m_hDC, TRANSPARENT); + DRAWTEXTPARAMS dtp; memset(&dtp, 0, sizeof(DRAWTEXTPARAMS)); - dtp.cbSize = sizeof(DRAWTEXTPARAMS); + dtp.cbSize = sizeof(DRAWTEXTPARAMS); RECT rBounds = {nX,nY,GetClipWidth(),GetClipHeight()}; DrawTextEx(m_hDC,(LPTSTR)sText,mir_tstrlen(sText),&rBounds,(DT_LEFT | DT_NOPREFIX),&dtp); - // restores - SetMapMode(m_hDC, nOldMapMode); - SetBkMode(m_hDC, nOldBkMode); + // restores + SetMapMode(m_hDC, nOldMapMode); + SetBkMode(m_hDC, nOldBkMode); } //************************************************************************ @@ -319,23 +319,20 @@ void CLCDGfx::DrawText(int nX,int nY,int nWidth,tstring strText) SIZE sizeCutOff = {0, 0}; GetTextExtentPoint(GetHDC(),_T("..."),3,&sizeCutOff); - + int *piWidths = new int[strText.length()]; int iMaxChars = 0; GetTextExtentExPoint(GetHDC(),strText.c_str(),strText.length(),nWidth,&iMaxChars,piWidths,&sizeLine); - - if(iMaxChars < strText.length()) - { + + if(iMaxChars < strText.length()) { for(iMaxChars--;iMaxChars>0;iMaxChars--) - { if(piWidths[iMaxChars] + sizeCutOff.cx <= nWidth) break; - } + DrawText(nX,nY,(strText.substr(0,iMaxChars) + _T("...")).c_str()); } - else - DrawText(nX,nY,strText.c_str()); + else DrawText(nX,nY,strText.c_str()); free(piWidths); } @@ -345,13 +342,13 @@ void CLCDGfx::DrawText(int nX,int nY,int nWidth,tstring strText) void CLCDGfx::DrawBitmap(int nX, int nY,int nWidth, int nHeight, HBITMAP hBitmap) { HDC hCompatibleDC = CreateCompatibleDC(GetHDC()); - HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, hBitmap); - - BitBlt(GetHDC(), nX, nY, nWidth, nHeight, hCompatibleDC, 0, 0, SRCCOPY); - - // restores - SelectObject(hCompatibleDC, hOldBitmap); - DeleteDC(hCompatibleDC); + HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, hBitmap); + + BitBlt(GetHDC(), nX, nY, nWidth, nHeight, hCompatibleDC, 0, 0, SRCCOPY); + + // restores + SelectObject(hCompatibleDC, hOldBitmap); + DeleteDC(hCompatibleDC); } //************************************************************************ @@ -359,15 +356,15 @@ void CLCDGfx::DrawBitmap(int nX, int nY,int nWidth, int nHeight, HBITMAP hBitmap //************************************************************************ void CLCDGfx::EndDraw(void) { - ASSERT(NULL != m_hPrevBitmap); - if(NULL != m_hPrevBitmap) - { - GdiFlush(); - m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hPrevBitmap); + ASSERT(NULL != m_hPrevBitmap); + if(NULL != m_hPrevBitmap) + { + GdiFlush(); + m_hPrevBitmap = (HBITMAP) SelectObject(m_hDC, m_hPrevBitmap); ASSERT(m_hPrevBitmap == m_hBitmap); - m_hPrevBitmap = NULL; - } - + m_hPrevBitmap = NULL; + } + if(m_nBPP != 1 || !m_bTransition) memcpy(m_pLcdBitmapBits, m_pBitmapBits, m_nWidth * m_nHeight * m_nBPP); else @@ -380,56 +377,56 @@ void CLCDGfx::EndDraw(void) PBYTE pScreen2 = m_pBitmapBits; DWORD dwTimeElapsed = GetTickCount() - m_dwTransitionStart; - - /* if(m_eTransition == TRANSITION_BT || m_eTransition == TRANSITION_TB) + + /* if(m_eTransition == TRANSITION_BT || m_eTransition == TRANSITION_TB) { - int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight; - - if(m_eTransition == TRANSITION_TB) - { - iCols = m_nHeight - iCols; + int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight; - pScreen1 = m_pBitmapBits; - pScreen2 = m_pSavedBitmapBits; - } + if(m_eTransition == TRANSITION_TB) + { + iCols = m_nHeight - iCols; - if(iCols > m_nHeight) - iCols = m_nHeight; - if(iCols < 0) - iCols = 0; + pScreen1 = m_pBitmapBits; + pScreen2 = m_pSavedBitmapBits; + } + + if(iCols > m_nHeight) + iCols = m_nHeight; + if(iCols < 0) + iCols = 0; - memcpy(m_pLcdBitmapBits,pScreen1+(iCols*m_nWidth),((m_nHeight-iCols)*m_nWidth)); - memcpy(m_pLcdBitmapBits+((m_nHeight-iCols)*m_nWidth),pScreen2,iCols *m_nWidth); + memcpy(m_pLcdBitmapBits,pScreen1+(iCols*m_nWidth),((m_nHeight-iCols)*m_nWidth)); + memcpy(m_pLcdBitmapBits+((m_nHeight-iCols)*m_nWidth),pScreen2,iCols *m_nWidth); } else if(m_eTransition == TRANSITION_LR || m_eTransition == TRANSITION_RL) { - int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth; + int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth; - if(m_eTransition == TRANSITION_LR) - { - iCols = m_nWidth - iCols; + if(m_eTransition == TRANSITION_LR) + { + iCols = m_nWidth - iCols; - pScreen1 = m_pBitmapBits; - pScreen2 = m_pSavedBitmapBits; - } + pScreen1 = m_pBitmapBits; + pScreen2 = m_pSavedBitmapBits; + } - if(iCols > m_nWidth) - iCols = m_nWidth; - if(iCols < 0) - iCols = 0; + if(iCols > m_nWidth) + iCols = m_nWidth; + if(iCols < 0) + iCols = 0; - for(int i=0;i m_nHeight) iCols = m_nHeight; if(iCols < 2) @@ -444,7 +441,7 @@ void CLCDGfx::EndDraw(void) int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth; if(iCols%2 == 1) iCols--; - + if(iCols > m_nWidth) iCols = m_nWidth; if(iCols < 2) @@ -462,16 +459,16 @@ void CLCDGfx::EndDraw(void) int iCols = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nHeight; if(iCols%2 == 1) iCols--; - + if(iCols > m_nHeight) iCols = m_nHeight; if(iCols < 2) iCols = 2; - + int iCols2 = ((float)dwTimeElapsed/(float)TRANSITION_DURATION)*m_nWidth; if(iCols2%2 == 1) iCols2--; - + if(iCols2 > m_nWidth) iCols2 = m_nWidth; if(iCols2 < 2) @@ -502,7 +499,7 @@ void CLCDGfx::EndDraw(void) pPixel = *iter; if(pPixel->Position.x != pPixel->Destination.x ||pPixel->Position.y != pPixel->Destination.y) { iMoved++; - + dPixelPercent = dPercent * pPixel->dSpeed; if(dPixelPercent > 1.0f) dPixelPercent = 1.0f; @@ -511,17 +508,17 @@ void CLCDGfx::EndDraw(void) pPixel->Position.x = pPixel->Start.x + dPixelPercent*(pPixel->Destination.x-pPixel->Start.x); else if(pPixel->Start.x > pPixel->Destination.x) pPixel->Position.x = pPixel->Start.x - dPixelPercent*(pPixel->Start.x-pPixel->Destination.x); - + if(pPixel->Start.y < pPixel->Destination.y) pPixel->Position.y = pPixel->Start.y + dPixelPercent*(pPixel->Destination.y-pPixel->Start.y); else if(pPixel->Start.y > pPixel->Destination.y) pPixel->Position.y = pPixel->Start.y - dPixelPercent*(pPixel->Start.y-pPixel->Destination.y); } - iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x; - if(iIndex >= 0 && iIndex < m_nHeight * m_nWidth) - m_pLcdBitmapBits[iIndex] = pPixel->cValue; - + iIndex = pPixel->Position.y*m_nWidth + pPixel->Position.x; + if(iIndex >= 0 && iIndex < m_nHeight * m_nWidth) + m_pLcdBitmapBits[iIndex] = pPixel->cValue; + iter++; } @@ -549,8 +546,8 @@ void CLCDGfx::EndDraw(void) //************************************************************************ HDC CLCDGfx::GetHDC(void) { - ASSERT(NULL != m_hDC); - return m_hDC; + ASSERT(NULL != m_hDC); + return m_hDC; } //************************************************************************ @@ -558,8 +555,8 @@ HDC CLCDGfx::GetHDC(void) //************************************************************************ BITMAPINFO *CLCDGfx::GetBitmapInfo(void) { - ASSERT(NULL != m_pBitmapInfo); - return m_pBitmapInfo; + ASSERT(NULL != m_pBitmapInfo); + return m_pBitmapInfo; } //************************************************************************ @@ -568,8 +565,8 @@ BITMAPINFO *CLCDGfx::GetBitmapInfo(void) HBITMAP CLCDGfx::GetHBITMAP(void) { - ASSERT(NULL != m_hBitmap); - return m_hBitmap; + ASSERT(NULL != m_hBitmap); + return m_hBitmap; } int CLCDGfx::findNearestMatch(PBYTE targetArray,int iSourceIndex) { @@ -591,17 +588,17 @@ int CLCDGfx::findNearestMatch(PBYTE targetArray,int iSourceIndex) { if(targetArray[iIndex] != 0) return iIndex; } - for(iX = startX-iPass;iX<=startX+iPass;iX+=iPass*2) - for(iY=startY-iPass;iY= m_nHeight || iX <0 || iX >= m_nWidth) - continue; + for(iX = startX-iPass;iX<=startX+iPass;iX+=iPass*2) + for(iY=startY-iPass;iY= m_nHeight || iX <0 || iX >= m_nWidth) + continue; - iIndex = iY*m_nWidth + iX; - if(targetArray[iIndex] != 0) - return iIndex; - } + iIndex = iY*m_nWidth + iX; + if(targetArray[iIndex] != 0) + return iIndex; + } } return -1; } @@ -618,13 +615,13 @@ void CLCDGfx::Cache() { SLCDPixel *pPixel = NULL; SLCDPixel *pSource = NULL; - + int iIndex = 0; bool bBreak = false; bool bSearch = true; - + int iTransitionPixels = 0; - + POINT pt; for(int j=0;j<2;j++) { @@ -659,7 +656,7 @@ void CLCDGfx::Cache() bBreak = true; } } - + if(j==0 || bBreak) { pPixel->Destination.y = iIndex/m_nWidth; @@ -684,7 +681,7 @@ void CLCDGfx::Cache() } bSearch = false; } - + if(j == 0) m_LStaticPixels.push_back(pPixel); else { @@ -705,7 +702,7 @@ void CLCDGfx::Cache() pPixel = new SLCDPixel(); pPixel->dSpeed = GetRandomDouble()*0.5 + 1; pPixel->cValue = m_pBitmapBits[iIndex]; - + if(!bRandom) { pSource = m_LMovingPixels[GetRandomInt(0,m_LMovingPixels.size()-1)]; @@ -725,7 +722,7 @@ void CLCDGfx::Cache() } } - + m_dwTransitionStart = GetTickCount(); TRACE(_T("Textmorphing: time consumed: %0.2f\n"),(double)(m_dwTransitionStart-dwStart)/(double)1000); @@ -752,7 +749,7 @@ void CLCDGfx::StartTransition(ETransitionType eType,LPRECT rect) m_eTransition = static_cast(GetRandomInt(0,2)); else m_eTransition = eType; - + if(m_bTransition) { EndTransition(); memcpy(m_pBitmapBits,m_pLcdBitmapBits,sizeof(BYTE)*m_nWidth*m_nHeight*m_nBPP); @@ -760,7 +757,7 @@ void CLCDGfx::StartTransition(ETransitionType eType,LPRECT rect) if(m_pSavedBitmapBits == NULL) m_pSavedBitmapBits = (BYTE*)malloc(sizeof(BYTE)*m_nWidth*m_nHeight*m_nBPP); - + memcpy(m_pSavedBitmapBits, m_pBitmapBits,sizeof(BYTE)* m_nWidth * m_nHeight * m_nBPP); m_dwTransitionStart = 0; diff --git a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h index bdca950718..9ac2288262 100644 --- a/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h +++ b/plugins/MirandaG15/src/LCDFramework/CLCDGfx.h @@ -15,26 +15,25 @@ struct SLCDPixel class CLCDGfx { public: - CLCDGfx(void); - virtual ~CLCDGfx(void); + CLCDGfx(void); + virtual ~CLCDGfx(void); - bool Initialize(int nWidth, int nHeight, int nBPP, PBYTE pBitmapBits); + bool Initialize(int nWidth, int nHeight, int nBPP, PBYTE pBitmapBits); bool IsInitialized(); - bool Shutdown(void); + bool Shutdown(void); - void BeginDraw(void); - void ClearScreen(void); + void BeginDraw(void); + void ClearScreen(void); COLORREF GetPixel(int nX, int nY); void SetPixel(int nX, int nY, COLORREF color); void SetPixel(int nX, int nY, BYTE r, BYTE g, BYTE b); - void DrawLine(int nX1, int nY1, int nX2, int nY2); - void DrawFilledRect(int nX, int nY, int nWidth, int nHeight); + void DrawLine(int nX1, int nY1, int nX2, int nY2); + void DrawFilledRect(int nX, int nY, int nWidth, int nHeight); void DrawRect(int iX, int iY, int iWidth, int iHeight); void DrawText(int nX, int nY, LPCTSTR sText); void DrawText(int nX,int nY,int iWidth,tstring strText); void DrawBitmap(int nX,int nY,int nWidth, int nHeight,HBITMAP hBitmap); - void EndDraw(void); - + void EndDraw(void); void SetClipRegion(int iX,int iY,int iWidth,int iHeight); RECT GetClipRegion(); @@ -42,12 +41,12 @@ public: inline int GetClipWidth() { return m_rClipRegion.right-m_rClipRegion.left; }; inline int GetClipHeight() { return m_rClipRegion.bottom-m_rClipRegion.top; }; - HDC GetHDC(void); + HDC GetHDC(void); BITMAPINFO *GetBitmapInfo(void); - HBITMAP GetHBITMAP(void); - + HBITMAP GetHBITMAP(void); + void StartTransition(ETransitionType eType = TRANSITION_RANDOM,LPRECT rect = NULL); - + protected: void Cache(); int findNearestMatch(PBYTE targetArray,int iSourceIndex); @@ -57,20 +56,20 @@ protected: RECT m_rClipRegion; RECT m_rTransitionRegion; - int m_nWidth; - int m_nHeight; + int m_nWidth; + int m_nHeight; int m_nBPP; - BITMAPINFO *m_pBitmapInfo; - HDC m_hDC; - HBITMAP m_hBitmap; - HBITMAP m_hPrevBitmap; - PBYTE m_pBitmapBits,m_pLcdBitmapBits,m_pSavedBitmapBits; + BITMAPINFO *m_pBitmapInfo; + HDC m_hDC; + HBITMAP m_hBitmap; + HBITMAP m_hPrevBitmap; + PBYTE m_pBitmapBits,m_pLcdBitmapBits,m_pSavedBitmapBits; bool m_bInitialized; DWORD m_dwTransitionStart; bool m_bTransition; - + ETransitionType m_eTransition; vector m_LMovingPixels; vector m_LStaticPixels; -- cgit v1.2.3