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

📄 surf.cpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 CPP
字号:
#include "precomp.h"

extern	GPE *pGPE;

SCODE 
MQGC::AllocSurface(
    GPESurf **ppSurf, 
    int width, 
    int height, 
    EGPEFormat format, 
    int surfaceFlags
    )
{
	DEBUGMSG (GPE_ZONE_INIT, (L"AllocSurface without pixelFormat\n"));

	return	AllocSurface ((DDGPESurf**)ppSurf,
						  width,
						  height,
						  format,
						  EGPEFormatToEDDGPEPixelFormat[format],
						  surfaceFlags);
}


SCODE 
MQGC::AllocSurface(
    DDGPESurf **ppSurf, 
    int width, 
    int height, 
    EGPEFormat format, 
    EDDGPEPixelFormat pixelFormat,
    int surfaceFlags
    )
{
    DWORD bpp  = EGPEFormatToBpp[format];
    LONG align = 8; // quadword aligned
    DWORD alignedWidth = ((width + align - 1) & (- align));
    DWORD nSurfaceBytes = (bpp * (alignedWidth * height)) / 8;
    DWORD stride = ((alignedWidth * bpp) / 8);
	
	DEBUGMSG (GPE_ZONE_INIT, (L"AllocSurface with pixelFormat\n"));

	DEBUGMSG (GPE_ZONE_INIT, (L"width=%d\nheight=%d\nformat=%d\npixelFormat=%d\nsurfaceFlags=%x",
				   width,
				   height,
				   format,
				   pixelFormat,
				   surfaceFlags));

    if (((surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY) || 
         (surfaceFlags & GPE_PREFER_VIDEO_MEMORY)) &&
        (format == m_pMode->format))
    {

		DEBUGMSG (GPE_ZONE_INIT, 
				(TEXT("AllocSurface==>Width=%d,Height=%d Bpp=%d\r\n"),
				width,height,EGPEFormatToBpp[format]));
		//Attempt to allocate from video memory
		Node2D *pNode = m_p2DVideoMemory->Alloc( width, height );
		if(pNode)
		{
			ULONG	offset = m_ulScreenStride * pNode->Top() +
						( pNode->Left() * EGPEFormatToBpp[format] ) / 8 ;
			*ppSurf = new MQGCSurf(
				width,
				height,
				offset,
				m_pLAW + offset,
				m_ulScreenStride,
				format,
				pixelFormat,
				pNode);
			if( !(*ppSurf) )
			{
				pNode->Free();
				DEBUGMSG (GPE_ZONE_INIT, (L"Bad Exit from AllocSurface\n"));
				return E_OUTOFMEMORY;
			}
			return S_OK;
		}
		if( surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY )
		{
			*ppSurf = (DDGPESurf *)NULL;
			DEBUGMSG (GPE_ZONE_INIT, (L"Bad Exit from AllocSurface\n"));
			return E_OUTOFMEMORY;
		}
	}
	//Allocate from system memory
	DEBUGMSG (GPE_ZONE_INIT, 
			(TEXT("Creating a DDGPESurf in system memory. EGPEFormat = %d\r\n"),
			(int)format ));
	*ppSurf = new DDGPESurf(width, height, stride, format, pixelFormat);
	if( *ppSurf )
	{
		//check we allocated bits succesfully
		if( !((*ppSurf)->Buffer()) )
			delete *ppSurf;	//and then return E_OUTOFMEMORY
		else
			return S_OK;
	}
	DEBUGMSG (GPE_ZONE_INIT, (L"Bad Exit from AllocSurface\n"));
	return E_OUTOFMEMORY;
}

void
MQGC::CheckVisibleSurface()
{
	DEBUGMSG( GPE_ZONE_FLIP, ( TEXT("CheckVisibleSurface()") ) );
}

int
MQGC::SurfaceBusyFlipping( MQGCSurf *pSurf )
{
	return (1);
}

int
MQGC::FlipInProgress()
{
	return (1);
}

void
MQGC::SetVisibleSurface( GPESurf *pTempSurf )
{
    MQGCSurf *pSurf = (MQGCSurf *) pTempSurf;
}

void
MQGC::VBlankReceived()
{
	return;
}

//
//void MQGC::PanScreen( )
//{
//	int row;
//	int displayStart = 0;
//	for( row=0; row<2790; row++ )
//	{
//		reg_CR[0x69] = (displayStart>>16)&0x0F;
//		reg_STA_H = (displayStart>>8) & 0xFF;
//		reg_STA_L = displayStart & 0xFF;
//		WaitForVBlank();
//		displayStart += (640>>2);
//	}
//}
//
  
MQGCSurf::MQGCSurf(
	int width,
	int height,
	unsigned long offset,
	void *pBits,            //virtual address of allocated bits
	int stride,
	EGPEFormat format,
	Node2D *pNode
    )
	: DDGPESurf( width, height, pBits, stride, format )
{
	m_ulTop = (ULONG)pNode->Top();
	m_ulLeft= (ULONG)pNode->Left();

#ifdef	CHECK_24BPP
	if ( format == gpe24Bpp )
		m_ulLeft = (m_ulLeft << 1) + m_ulLeft;
#endif	//CHECK_24BPP
	m_ulTopLeft = (m_ulTop << 16) | m_ulLeft;

	m_pNode2D = pNode;
	m_fInVideoMemory = TRUE;
	m_nOffsetInVideoMemory = offset;
} 

MQGCSurf::MQGCSurf(
	int width,
	int height,
	unsigned long offset,
	void *pBits,            //virtual address of allocated bits
	int stride,
	EGPEFormat format,
	EDDGPEPixelFormat pixelFormat,
	Node2D *pNode
	)
	: DDGPESurf( width, height, pBits, stride, format, pixelFormat)
{
	m_ulTop = (ULONG)pNode->Top();
	m_ulLeft= (ULONG)pNode->Left();

#ifdef	CHECK_24BPP
	if ( format == gpe24Bpp )
		m_ulLeft = (m_ulLeft << 1) + m_ulLeft;
#endif	//CHECK_24BPP
	m_ulTopLeft = (m_ulTop << 16) | m_ulLeft;

	m_pNode2D = pNode;
	m_fInVideoMemory = TRUE;
	m_nOffsetInVideoMemory = offset;
} 

MQGCSurf::~MQGCSurf()
{
	if ( m_pNode2D )
		m_pNode2D->Free();
}


⌨️ 快捷键说明

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