Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authoralexwild <alexwild@users.sourceforge.net>2008-03-04 11:47:16 +0300
committeralexwild <alexwild@users.sourceforge.net>2008-03-04 11:47:16 +0300
commitce2e03fe33219be4b878c9249adfe87b8ddf13be (patch)
tree077c8c948a3ba5b288905c65bbf1c6ae2168f9f5 /src/ui
parentec27e41cb99abffc5365a33ddbddd4aac444c439 (diff)
update lcd api to v2.02.101
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@428 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/LCDUI/LCDGfx.h7
-rw-r--r--src/ui/LCDUI/LCDOutput.cpp110
-rw-r--r--src/ui/LCDUI/LCDOutput.h6
-rw-r--r--src/ui/LCDUI/LCDText.cpp6
4 files changed, 109 insertions, 20 deletions
diff --git a/src/ui/LCDUI/LCDGfx.h b/src/ui/LCDUI/LCDGfx.h
index 09bde311b..880e825d6 100644
--- a/src/ui/LCDUI/LCDGfx.h
+++ b/src/ui/LCDUI/LCDGfx.h
@@ -17,6 +17,13 @@
#include <tchar.h>
#include <lglcd/lglcd.h>
+#if _MSC_VER >= 1400
+#define LCDUI_tcsncpy(x, y, z) _tcsncpy_s(x, _countof(x), y, z)
+#define LCDUI_tcscpy(x, y) _tcscpy_s(x, _countof(x), y)
+#else
+#define LCDUI_tcsncpy(x, y, z) _tcsncpy(x, y, z)
+#define LCDUI_tcscpy(x, y) _tcscpy(x, y)
+#endif
#ifndef LCDUITRACE
// .NET compiler uses __noop intrinsic
diff --git a/src/ui/LCDUI/LCDOutput.cpp b/src/ui/LCDUI/LCDOutput.cpp
index e63cf1264..ec1a1396a 100644
--- a/src/ui/LCDUI/LCDOutput.cpp
+++ b/src/ui/LCDUI/LCDOutput.cpp
@@ -40,6 +40,11 @@ CLCDOutput::CLCDOutput()
LGLCD_DEVICE_FAMILY_JACKBOX |
LGLCD_DEVICE_FAMILY_SPEAKERS_Z10;
m_dwDeviceFamiliesSupportedReserved1 = 0;
+
+ m_pLastBitmap = new lgLcdBitmap160x43x1;
+ ClearBitmap(m_pLastBitmap);
+ // Allow the first update to go through
+ m_bPriorityHasChanged = TRUE;
}
//************************************************************************
@@ -50,7 +55,8 @@ CLCDOutput::CLCDOutput()
CLCDOutput::~CLCDOutput()
{
-
+ delete m_pLastBitmap;
+ m_pLastBitmap = NULL;
}
@@ -208,30 +214,34 @@ void CLCDOutput::Shutdown(void)
HRESULT CLCDOutput::Draw()
{
- DWORD dwPriorityToUse;
+ DWORD dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
- if (m_pActiveScreen)
- {
- m_pActiveScreen->Draw();
- dwPriorityToUse = LGLCD_ASYNC_UPDATE(m_nPriority);
- }
- else
+ if ( (NULL == m_pActiveScreen) ||
+ (LGLCD_INVALID_DEVICE == m_hDevice) ||
+ (LGLCD_PRIORITY_IDLE_NO_SHOW == dwPriorityToUse) )
{
- dwPriorityToUse = LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW);
+ // don't submit the bitmap
+ return S_OK;
}
+
+ // Render the active screen
+ m_pActiveScreen->Draw();
- lgLcdBitmap160x43x1* pScreen = GetLCDScreen();
- if (pScreen && (LGLCD_INVALID_DEVICE != m_hDevice) && (LGLCD_PRIORITY_IDLE_NO_SHOW != dwPriorityToUse))
+ // Get the active bitmap
+ lgLcdBitmap160x43x1* pScreen = m_pActiveScreen->GetLCDScreen();
+
+ // Only submit if the bitmap needs to be updated
+ // (If the priority or bitmap have changed)
+ DWORD res = ERROR_SUCCESS;
+ if (DoesBitmapNeedUpdate(pScreen))
{
- DWORD res = ERROR_SUCCESS;
res = lgLcdUpdateBitmap(m_hDevice, &pScreen->hdr, dwPriorityToUse);
-
HandleErrorFromAPI(res);
-
- // read the soft buttons
- ReadButtons();
}
+ // read the soft buttons
+ ReadButtons();
+
return S_OK;
}
@@ -259,6 +269,9 @@ void CLCDOutput::Update(DWORD dwTimestamp)
OnScreenExpired(m_pActiveScreen);
+ // Clear the bitmap
+ ClearBitmap(m_pLastBitmap);
+
// find the next active screen
LCD_MGR_LIST::iterator it = m_LCDMgrList.begin();
while(it != m_LCDMgrList.end())
@@ -696,14 +709,25 @@ void CLCDOutput::HandleErrorFromAPI(DWORD dwRes)
//************************************************************************
void CLCDOutput::SetScreenPriority(DWORD priority)
{
+ if (priority == m_nPriority)
+ {
+ // Nothing to do
+ return;
+ }
+
+ // Clear the bitmap
+ ClearBitmap(m_pLastBitmap);
+
m_nPriority = priority;
+ m_bPriorityHasChanged = TRUE;
+
if (LGLCD_PRIORITY_IDLE_NO_SHOW == m_nPriority)
{
// send an empty bitmap at idle priority
if (LGLCD_INVALID_DEVICE != m_hDevice)
{
- lgLcdUpdateBitmap(m_hDevice, &CLCDManager::GetLCDScreen()->hdr,
- LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW));
+ lgLcdUpdateBitmap(m_hDevice, &m_pLastBitmap->hdr,
+ LGLCD_ASYNC_UPDATE(LGLCD_PRIORITY_IDLE_NO_SHOW));
}
}
}
@@ -769,6 +793,7 @@ void CLCDOutput::OnClosingDevice(int hDevice)
lgLcdClose(m_hDevice);
m_hDevice = LGLCD_INVALID_DEVICE;
}
+ ClearBitmap(m_pLastBitmap);
}
//************************************************************************
@@ -788,6 +813,7 @@ void CLCDOutput::OnDisconnecting(int hConnection)
{
lgLcdDisconnect(m_hConnection);
m_hConnection = LGLCD_INVALID_CONNECTION;
+ ZeroMemory(m_pLastBitmap, sizeof(lgLcdBitmap160x43x1));
}
}
@@ -819,4 +845,52 @@ void CLCDOutput::SetAsForeground(BOOL bSetAsForeground)
}
}
+
+//************************************************************************
+//
+// CLCDOutput::DoesBitmapNeedUpdate
+//
+//************************************************************************
+
+BOOL CLCDOutput::DoesBitmapNeedUpdate(lgLcdBitmap160x43x1* pCurrentBitmap)
+{
+ // The bitmap is different from the last one sent
+ // send the bitmap
+ BOOL bBitmapChanged = 0 != memcmp(pCurrentBitmap, m_pLastBitmap, sizeof(lgLcdBitmap160x43x1));
+ BOOL bPriorityChanged = m_bPriorityHasChanged;
+
+ if (bBitmapChanged)
+ {
+ LCDUITRACE(_T("Resubmitting bitmap (bitmap changed)\n"));
+ }
+ else if (bPriorityChanged)
+ {
+ LCDUITRACE(_T("Resubmitting bitmap (priority changed)\n"));
+ }
+
+ // Save the current bitmap
+ memcpy(m_pLastBitmap, pCurrentBitmap, sizeof(lgLcdBitmap160x43x1));
+ // Reset the priority change
+ m_bPriorityHasChanged = FALSE;
+
+ return (bBitmapChanged || bPriorityChanged);
+}
+
+
+//************************************************************************
+//
+// CLCDOutput::ClearBitmap
+//
+//************************************************************************
+
+void CLCDOutput::ClearBitmap(lgLcdBitmap160x43x1* pCurrentBitmap)
+{
+ LCDUIASSERT(NULL != pCurrentBitmap);
+ if (pCurrentBitmap)
+ {
+ pCurrentBitmap->hdr.Format = LGLCD_BMP_FORMAT_160x43x1;
+ ZeroMemory(pCurrentBitmap->pixels, sizeof(pCurrentBitmap->pixels));
+ }
+}
+
//** end of LCDOutput.cpp ************************************************
diff --git a/src/ui/LCDUI/LCDOutput.h b/src/ui/LCDUI/LCDOutput.h
index 0b447157b..f2f214b2e 100644
--- a/src/ui/LCDUI/LCDOutput.h
+++ b/src/ui/LCDUI/LCDOutput.h
@@ -77,6 +77,12 @@ protected:
virtual void OnDisconnecting(int hConnection);
protected:
+ BOOL DoesBitmapNeedUpdate(lgLcdBitmap160x43x1* pCurrentBitmap);
+ void ClearBitmap(lgLcdBitmap160x43x1* pCurrentBitmap);
+ lgLcdBitmap160x43x1* m_pLastBitmap;
+ BOOL m_bPriorityHasChanged;
+
+protected:
CLCDManager* m_pActiveScreen;
// list
diff --git a/src/ui/LCDUI/LCDText.cpp b/src/ui/LCDUI/LCDText.cpp
index e9441d77a..e77282db2 100644
--- a/src/ui/LCDUI/LCDText.cpp
+++ b/src/ui/LCDUI/LCDText.cpp
@@ -22,7 +22,7 @@ CLCDText::CLCDText()
{
m_nTextLength = 0;
m_hFont = NULL;
- m_sText.clear();
+ m_sText.erase(m_sText.begin(), m_sText.end());
m_crColor = RGB(255, 255, 255); // white
m_bRecalcExtent = TRUE;
ZeroMemory(&m_dtp, sizeof(DRAWTEXTPARAMS));
@@ -117,7 +117,9 @@ void CLCDText::SetFontFaceName(LPCTSTR szFontName)
ZeroMemory(&lf, sizeof(lf));
GetObject(m_hFont, sizeof(LOGFONT), &lf);
- _tcsncpy(lf.lfFaceName, szFontName, LF_FACESIZE);
+ //_tcsncpy(lf.lfFaceName, szFontName, LF_FACESIZE);
+ //_tcsncpy_s(lf.lfFaceName, LF_FACESIZE, szFontName, LF_FACESIZE);
+ LCDUI_tcsncpy(lf.lfFaceName, szFontName, LF_FACESIZE);
SetFont(lf);
}