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

📄 gpe93surf.cpp

📁 EP9315开发板的Wince6.0的BSP包文件
💻 CPP
字号:
//**********************************************************************
//                                                                      
// Filename: gpe93surf.cpp
//                                                                      
// Description: Contains the class for the gpesurf for memory in the 
//              video buffer. 
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Use of this source code is subject to the terms of the Cirrus end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to 
// use this source code. For a copy of the EULA, please see the 
// EULA.RTF on your install media.
//
// Copyright(c) Cirrus Logic Corporation 2005, All Rights Reserved
//                                                                      
//**********************************************************************
#include    "precomp.h"


GPE93xxSurf::GPE93xxSurf
(                      
    int         width,         
    int         height,
	int			offset,
    void        *pBits,
    int         stride,
    EGPEFormat  format,
	Node2D * node
)
#ifdef BSP_EP93XX_DISPLAY_ROTATION 
:GPESurfRotate(width, height, pBits, stride, format)
#endif
{

    pNode = node;

    Init( width, height, pBits, stride, format
#ifdef	DD_ENABLE
                , EGPEFormatToEDDGPEPixelFormat[format]
#endif
                );

  m_fInVideoMemory        = TRUE;

  m_nOffsetInVideoMemory  = offset;

#ifdef	DD_ENABLE
    m_fOwnsBuffer = FALSE;

    m_dwColorKeyLowValue = 0L;
    m_dwColorKeyHighValue = 0L;
    m_dwColorKeyMask = 0xFFFFFFFFL;

    lpDDSurface = NULL;
    m_pDriverData = NULL;
#endif

}


GPE93xxSurf::~GPE93xxSurf()
{
    if(pNode)
    {
		while(*GRAPHICS_BLOCKCTRL & BLOCKCTRL_ENABLE);
        pNode->Free();
    }
}



SCODE
GPEAccel::AllocSurface(GPESurf **ppSurf, int width, int height, EGPEFormat format, int surfaceFlags)
{
	if ((surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY) || (format == m_pMode->format) && (surfaceFlags & GPE_PREFER_VIDEO_MEMORY))
	{
		if (!(format == m_pMode->format))
		{
			RETAILMSG (1, (L"AllocSurface - Invalid format value\n"));
			return E_INVALIDARG;
		}

		Node2D *pNode = m_p2DVideoMemory->Alloc( width, height );

		if( pNode ){

			ULONG offset = (m_cbScanLineLength * pNode->Top()) + ((pNode->Left()* EGPEFormatToBpp[format]) / 8);

			*ppSurf= new GPE93xxSurf(width, height, offset, (PVOID)(m_VirtualFrameBuffer + offset), m_cbScanLineLength, format, pNode);

			if (!(*ppSurf))
			{
				RETAILMSG (1, (L"AllocSurface - Out of Memory 1\n"));
				return E_OUTOFMEMORY;
			}
			//RETAILMSG (1, (L"AllocSurface - OK\r\n"));
			return S_OK;
		}

		if (surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY)
		{
			*ppSurf = (GPESurf *)NULL;
			RETAILMSG (1, (L"AllocSurface - Out of Memory 2\n"));
			return E_OUTOFMEMORY;
		}
	}

	if (surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY)
	{
	    *ppSurf = (GPESurf *)NULL;
	    RETAILMSG (1, (L"AllocSurface - Out of Memory 3\n"));
	    return	E_OUTOFMEMORY;
	}

	// Allocate from system memory
	RETAILMSG(0, (TEXT("Creating a GPESurf in system memory. EGPEFormat = %d\r\n"), (int) format));
	*ppSurf = new GPESurf(width, height, format);
	if (*ppSurf != NULL)
	{
		// check we allocated bits succesfully
		if (((*ppSurf)->Buffer()) == NULL)
		{
			delete *ppSurf;
		}
		else
		{
			return	S_OK;
		}
	}

	RETAILMSG (1, (L"AllocSurface - Out of Memory 4\n"));
	return E_OUTOFMEMORY;
}



#ifdef BSP_EP93XX_DISPLAY_ROTATION

ULONG  GPEAccel::DrvEscape(
                        SURFOBJ *pso,
                        ULONG    iEsc,
                        ULONG    cjIn,
                        PVOID    pvIn,
                        ULONG    cjOut,
                        PVOID    pvOut)
{
	if (iEsc == DRVESC_GETSCREENROTATION)
	{
		*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)m_iRotate);
		return DISP_CHANGE_SUCCESSFUL; 
	}
	else if (iEsc == DRVESC_SETSCREENROTATION)
	{
		if ((cjIn == DMDO_0) ||
			(cjIn == DMDO_90) ||
			(cjIn == DMDO_180) ||
			(cjIn == DMDO_270) )
			{
			    return DynRotate(cjIn);
			}
		return DISP_CHANGE_BADMODE;
	}
    return 0;
}



int GPEAccel::GetRotateModeFromReg(  )
{
	HKEY hKey;
	int angle=DMDO_90;

	if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, DRIVER_REGISTRY_STRING,0,0, &hKey))
	{
		DWORD dwSize, dwAngle=0, dwType = REG_DWORD;
		dwSize = sizeof(DWORD);
		if (ERROR_SUCCESS == RegQueryValueEx(hKey, 
											   TEXT("RotationDegree"), 
											   NULL, 
											   &dwType,
											   (LPBYTE)&dwAngle,
											   &dwSize))
		{
			RETAILMSG (1, (L"GetRotateModeFromReg - reg %d\n", dwAngle));
			switch (dwAngle)
			{
			case 0:
				angle= DMDO_0;
				break;
			case 90: 
				angle= DMDO_90;
				break;
			case 180:
				angle= DMDO_180;
				break;
			case 270:
				angle= DMDO_270;
				break;
			default:
				angle= DMDO_0;
				break;
			}
		}
		RegCloseKey(hKey);

	}else
		RETAILMSG (1, (L"GetRotateModeFromReg open failed\n"));
	
	RETAILMSG (1, (L"GetRotateModeFromReg - get %d\n", angle));
    return angle;
}



void GPEAccel::SetRotateParams()
{
	int iswap;
    switch(m_iRotate)
    {
    case DMDO_0:
		m_nScreenHeightSave = m_nScreenHeight;
		m_nScreenWidthSave = m_nScreenWidth;
		break;
    case DMDO_180:
		m_nScreenHeightSave = m_nScreenHeight;
		m_nScreenWidthSave = m_nScreenWidth;
		break;
	case DMDO_90:
	case DMDO_270:
		iswap = m_nScreenHeight;
		m_nScreenHeight = m_nScreenWidth;
		m_nScreenWidth = iswap;
	    m_nScreenHeightSave = m_nScreenWidth;
	    m_nScreenWidthSave = m_nScreenHeight;
		break;
	default:
	  	m_nScreenHeightSave = m_nScreenHeight;
		m_nScreenWidthSave = m_nScreenWidth;
		break;
    }
	return;
}


LONG GPEAccel::DynRotate(int angle)
{
	GPESurfRotate *pSurf = (GPESurfRotate *)m_pPrimarySurface;
	if (angle == m_iRotate)
		return DISP_CHANGE_SUCCESSFUL;

	m_iRotate = angle;

	switch(m_iRotate)
    {
    case DMDO_0:
    case DMDO_180:
		m_nScreenHeight = m_nScreenHeightSave;
		m_nScreenWidth = m_nScreenWidthSave;
		break;
	case DMDO_90:
	case DMDO_270:
		m_nScreenHeight = m_nScreenWidthSave;
		m_nScreenWidth = m_nScreenHeightSave;
		break;
    }

	m_pMode->width = m_nScreenWidth;
	m_pMode->height = m_nScreenHeight;
	pSurf->SetRotation(m_nScreenWidth, m_nScreenHeight, angle);

	return DISP_CHANGE_SUCCESSFUL;
}


#endif

⌨️ 快捷键说明

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