⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cursor.cpp

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
 * Name        : cursor.cpp
 * Title       : MBX WinCE driver GPE class
 * Author(s)   : Imagination Technologies
 * Created	   : 13th January 2003
 *
 * Copyright   : 2003 by Imagination Technologies. All rights reserved.
 *             : No part of this software, either material or conceptual 
 *             : may be copied or distributed, transmitted, transcribed,
 *             : stored in a retrieval system or translated into any 
 *             : human or computer language in any form by any means,
 *             : electronic, mechanical, manual or other-wise, or 
 *             : disclosed to third parties without the express written
 *             : permission of Imagination Technologies Limited, Unit 8,
 *             : HomePark Industrial Estate, King's Langley, Hertfordshire,
 *             : WD4 8LZ, U.K.
 *
 * Description : MBX WinCE driver GPE class.
 *
 * Platform    : WinCE
 *
 * Modifications:-
 * $Log: cursor.cpp $
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 *  --- Revision Logs Removed --- 
 *
 ****************************************************************************/

#include	"precomp.h"

#ifdef USE_SW_CURSOR
void	MBX::CursorOn (void)
{
	PBYTE	pbyScreen = (PBYTE)m_pPrimarySurface->Buffer();
	PBYTE	pbyLine;
	PBYTE	pbyBack;
	INT		nX, nY;
#ifndef ROTATE_ENABLE
	PBYTE	pbyXorLine;
	PBYTE	pbyAndLine;
#endif

#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryEnable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
	if (!m_bCursorForcedOff && !m_bCursorDisabled && !m_bCursorVisible)
	{
#ifdef ROTATE_ENABLE
		RECTL sCursorRectSave = m_sCursorRect;
		INT   nRotate;
		RotateRectl(&m_sCursorRect);

		for (nY = m_sCursorRect.top; nY < m_sCursorRect.bottom; nY++)
		{
			if (nY < 0)
			{
				continue;
			}
			if (nY >= m_nScreenHeightSave)
			{
				break;
			}

			pbyLine = &pbyScreen[nY * m_pPrimarySurface->Stride()];
			pbyBack = &m_byCursorBackingStore[(nY - m_sCursorRect.top) * (m_sCursorSize.x * (m_ulColorDepth >> 3))];

			for (nX = m_sCursorRect.left; nX < m_sCursorRect.right; nX++)
			{
				if (nX < 0)
				{
					continue;
				}

				if (nX >= m_nScreenWidthSave)
				{
					break;
				}

				// nX' = nX - m_sCursorRect.left; nY' = nY - m_sCursorRect.top;
				// Width = m_sCursorSize.x;   Height = m_sCursorSize.y;
				switch (m_iRotate)
				{
					default:
					case DMDO_0:
						nRotate = (nY - m_sCursorRect.top)*m_sCursorSize.x + nX - m_sCursorRect.left;
						break;
					case DMDO_90:
						nRotate = (nX - m_sCursorRect.left)*m_sCursorSize.x + m_sCursorSize.y - 1 - (nY - m_sCursorRect.top);
						break;
					case DMDO_180:
						nRotate = (m_sCursorSize.y - 1 - (nY - m_sCursorRect.top))*m_sCursorSize.x + m_sCursorSize.x - 1 - (nX - m_sCursorRect.left);
						break;
					case DMDO_270:
						nRotate = (m_sCursorSize.x -1 - (nX - m_sCursorRect.left))*m_sCursorSize.x + nY - m_sCursorRect.top;
						break;
				}

				pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3)] = pbyLine[nX * (m_ulColorDepth >> 3)];
				pbyLine[nX * (m_ulColorDepth >> 3)] &= m_byCursorAndShape[nRotate];
				pbyLine[nX * (m_ulColorDepth >> 3)] ^= m_byCursorXorShape[nRotate];

				if (m_ulColorDepth > 8)
				{
					pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 1] = pbyLine[nX * (m_ulColorDepth >> 3) + 1];
					pbyLine[nX * (m_ulColorDepth >> 3) + 1] &= m_byCursorAndShape[nRotate];
					pbyLine[nX * (m_ulColorDepth >> 3) + 1] ^= m_byCursorXorShape[nRotate];
					if (m_ulColorDepth > 16)
					{
						pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 2] = pbyLine[nX * (m_ulColorDepth >> 3) + 2];
						pbyLine[nX * (m_ulColorDepth >> 3) + 2] &= m_byCursorAndShape[nRotate];
						pbyLine[nX * (m_ulColorDepth >> 3) + 2] ^= m_byCursorXorShape[nRotate];
					}
				}
			}
		}

		// restore cursor rect
		m_sCursorRect = sCursorRectSave;
#else
		for (nY = m_sCursorRect.top; nY < m_sCursorRect.bottom; nY++)
		{
			if (nY < 0)
			{
				continue;
			}

			if (nY >= m_nScreenHeight)
			{
				break;
			}

			pbyLine = &pbyScreen[nY * m_pPrimarySurface->Stride()];
			pbyBack = &m_byCursorBackingStore[(nY - m_sCursorRect.top) * (m_sCursorSize.x * (m_ulColorDepth >> 3))];
			pbyXorLine = &m_byCursorXorShape[(nY - m_sCursorRect.top) * m_sCursorSize.x];
			pbyAndLine = &m_byCursorAndShape[(nY - m_sCursorRect.top) * m_sCursorSize.x];

			for (nX = m_sCursorRect.left; nX < m_sCursorRect.right; nX++)
			{
				if (nX < 0)
				{
					continue;
				}

				if (nX >= m_nScreenWidth)
				{
					break;
				}

				pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3)] = pbyLine[nX * (m_ulColorDepth >> 3)];
				pbyLine[nX * (m_ulColorDepth >> 3)] &= pbyAndLine[nX - m_sCursorRect.left];
				pbyLine[nX * (m_ulColorDepth >> 3)] ^= pbyXorLine[nX - m_sCursorRect.left];

				if (m_ulColorDepth > 8)
				{
					pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 1] = pbyLine[nX * (m_ulColorDepth >> 3) + 1];
					pbyLine[nX * (m_ulColorDepth >> 3) + 1] &= pbyAndLine[nX - m_sCursorRect.left];
					pbyLine[nX * (m_ulColorDepth >> 3) + 1] ^= pbyXorLine[nX - m_sCursorRect.left];
					if (m_ulColorDepth > 16)
					{
						pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 2] = pbyLine[nX * (m_ulColorDepth >> 3) + 2];
						pbyLine[nX * (m_ulColorDepth >> 3) + 2] &= pbyAndLine[nX - m_sCursorRect.left];
						pbyLine[nX * (m_ulColorDepth >> 3) + 2] ^= pbyXorLine[nX - m_sCursorRect.left];
					}
				}
			}
		}
#endif //ROTATE_ENABLE
		m_bCursorVisible = TRUE;
	}
#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
}

void	MBX::CursorOff (void)
{
	PBYTE	pbyScreen = (UCHAR*)m_pPrimarySurface->Buffer();
	PBYTE	pbyLine;
	PBYTE	pbyBack;
	INT		nX, nY;

#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryEnable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
	if (!m_bCursorForcedOff && !m_bCursorDisabled && m_bCursorVisible)
	{
#ifdef ROTATE_ENABLE
		RECTL sSave = m_sCursorRect;

		RotateRectl(&m_sCursorRect);
		for (nY = m_sCursorRect.top; nY < m_sCursorRect.bottom; nY++)
		{
			// clip to displayable screen area (top/bottom)
			if (nY < 0)
			{
				continue;
			}
			if (nY >= m_nScreenHeightSave)
			{
				break;
			}

			pbyLine = &pbyScreen[nY * m_pPrimarySurface->Stride()];
			pbyBack = &m_byCursorBackingStore[(nY - m_sCursorRect.top) * (m_sCursorSize.x * (m_ulColorDepth >> 3))];

			for (nX = m_sCursorRect.left; nX < m_sCursorRect.right; nX++)
			{
				// clip to displayable screen area (left/right)
				if (nX < 0)
				{
					continue;
				}
				if (nX >= m_nScreenWidthSave)
				{
					break;
				}

				pbyLine[nX * (m_ulColorDepth >> 3)] = pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3)];
				if (m_ulColorDepth > 8)
				{
					pbyLine[nX * (m_ulColorDepth >> 3) + 1] = pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 1];
					if (m_ulColorDepth > 16)
					{
						pbyLine[nX * (m_ulColorDepth >> 3) + 2] = pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 2];
					}
				}
			}
		}
		m_sCursorRect = sSave;
#else
		for (nY = m_sCursorRect.top; nY < m_sCursorRect.bottom; nY++)
		{
			// clip to displayable screen area (top/bottom)
			if (nY < 0)
			{
				continue;
			}
			if (nY >= m_nScreenHeight)
			{
				break;
			}

			pbyLine = &pbyScreen[nY * m_pPrimarySurface->Stride()];
			pbyBack = &m_byCursorBackingStore[(nY - m_sCursorRect.top) * (m_sCursorSize.x * (m_ulColorDepth >> 3))];

			for (nX = m_sCursorRect.left; nX < m_sCursorRect.right; nX++)
			{
				// clip to displayable screen area (left/right)
				if (nX < 0)
				{
					continue;
				}
				if (nX >= m_nScreenWidth)
				{
					break;
				}

				pbyLine[nX * (m_ulColorDepth >> 3)] = pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3)];
				if (m_ulColorDepth > 8)
				{
					pbyLine[nX * (m_ulColorDepth >> 3) + 1] = pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 1];
					if (m_ulColorDepth > 16)
					{
						pbyLine[nX * (m_ulColorDepth >> 3) + 2] = pbyBack[(nX - m_sCursorRect.left) * (m_ulColorDepth >> 3) + 2];
					}
				}
			}
		}
#endif //ROTATE_ENABLE
		m_bCursorVisible = FALSE;
	}
#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryDisable(m_sDevData.psDevInfoKM);
#endif // LOCAL_MEMORY_SELF_REFRESH
}
#endif // USE_SW_CURSOR


SCODE	MBX::SetPointerShape(GPESurf *pclMask, GPESurf *pclColorSurf, INT nHotX, INT nHotY, INT nX, INT nY)
{
#ifdef LOCAL_MEMORY_SELF_REFRESH
	SysLocalMemoryEnable(m_sDevData.psDevInfoKM);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -