📄 sa2video.cpp
字号:
goto contd;
}
}
}
}
code = EmulatedBlt(pParms);
}
contd:
if (bDoRotation)
{
bounds.left = pParms->prclDst->left;
bounds.top = pParms->prclDst->top;
bounds.right = pParms->prclDst->right;
bounds.bottom = pParms->prclDst->bottom;
if(bounds.left > bounds.right)
{
SWAP(int,bounds.left,bounds.right)
}
if( bounds.top > bounds.bottom)
{
SWAP(int,bounds.top,bounds.bottom)
}
if (bounds.top == bounds.bottom-1)
{
if ( !( (pParms->bltFlags & (BLT_ALPHABLEND | BLT_TRANSPARENT | BLT_STRETCH)) || (pParms->pLookup) || (pParms->pConvert) ) )
{
if ( pParms->rop4 == 0xf0f0 )
{
if ( EGPEFormatToBpp[pParms->pDst->Format()] == 16 )
{
if (pParms->solidColor != -1)
{ // must be a solid colored brush
if (!gDrawCursorFlag)
{
DispDrvrDirtyRectDump2((LPRECT)&bounds,pParms->solidColor);
return S_OK;
}
}
}
}
}
}
if ( !( (pParms->bltFlags & (BLT_ALPHABLEND | BLT_TRANSPARENT | BLT_STRETCH)) || (pParms->pLookup) || (pParms->pConvert) ) )
{
if ( pParms->rop4 == 0xf0f0 )
{
if ( EGPEFormatToBpp[pParms->pDst->Format()] == 16 )
{
if (pParms->solidColor != -1)
{ // must be a solid colored brush
DispDrvrDirtyRectDump_rectfill((LPRECT)&bounds,pParms->solidColor);
return S_OK;
}
}
}
}
if(FAILED(code))
{
return code;
}
DispDrvrDirtyRectDump((LPRECT)&bounds);
}
return code;
}
SCODE
SA2Video::BltPrepare(
GPEBltParms * pParms
)
{
DEBUGMSG(GPE_ZONE_LINE,(TEXT("SA2Video::BltPrepare\r\n")));
RECTL rectl;
pParms->pBlt = &GPE::EmulatedBlt;
// Check to see if the software cursor should be disabled.
if (!bDoRotation)
{
if (pParms->pDst == m_pPrimarySurface) // only care if dest is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (pParms->prclDst != NULL) // make sure there is a valid prclDst
{
rectl = *pParms->prclDst; // if so, use it
// There is no guarantee of a well ordered rect in pParms
// due to flipping and mirroring.
if(rectl.top > rectl.bottom)
{
int iSwapTmp = rectl.top;
rectl.top = rectl.bottom;
rectl.bottom = iSwapTmp;
}
if(rectl.left > rectl.right)
{
int iSwapTmp = rectl.left;
rectl.left = rectl.right;
rectl.right = iSwapTmp;
}
}
else
{
rectl = m_CursorRect; // if not, use the Cursor rect - this forces the cursor to be turned off in this case.
}
if (m_CursorRect.top <= rectl.bottom && m_CursorRect.bottom >= rectl.top &&
m_CursorRect.left <= rectl.right && m_CursorRect.right >= rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
}
// check for source overlap with cursor and turn off cursor if overlaps
if (pParms->pSrc == m_pPrimarySurface) // only care if source is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (pParms->prclSrc != NULL) // make sure there is a valid prclSrc
{
rectl = *pParms->prclSrc; // if so, use it
}
else
{
rectl = m_CursorRect; // if not, use the Cursor rect - this forces the cursor to be turned off in this case.
}
if (m_CursorRect.top < rectl.bottom && m_CursorRect.bottom > rectl.top &&
m_CursorRect.left < rectl.right && m_CursorRect.right > rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
}
}
if ((pParms->pDst == m_pPrimarySurface && m_iRotate) || (pParms->pSrc == m_pPrimarySurface && m_iRotate))
{
pParms->pBlt = &GPE::EmulatedBltRotate;
}
if (bDoRotation && pParms->pDst == m_pPrimarySurface)
{
pParms->pBlt = (SCODE (GPE::*)(GPEBltParms *))&SA2Video::WrappedEmulatedBlt;
}
return S_OK;
}
// This function would be used to undo the setting of clip registers etc
SCODE
SA2Video::BltComplete(
GPEBltParms * pParms
)
{
if (!bDoRotation)
{
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
}
return S_OK;
}
int
SA2Video::InVBlank()
{
static BOOL value = FALSE;
DEBUGMSG (GPE_ZONE_INIT, (TEXT("SA2Video::InVBlank\r\n")));
value = !value;
return value;
}
SCODE
SA2Video::SetPalette(
const PALETTEENTRY * source,
unsigned short firstEntry,
unsigned short numEntries
)
{
if (bpp == 8)
{
if (firstEntry < 0 || firstEntry + numEntries > 256)
{
return E_INVALIDARG;
}
DispDrvrSetPalette(source,firstEntry,numEntries);
}
return S_OK;
}
ULONG *
APIENTRY
DrvGetMasks(
DHPDEV dhpdev
)
{
return BitMasks;
}
// This routine maps between power manager power states and video
// ioctl power states.
ULONG
SA2Video::PmToVideoPowerState(CEDEVICE_POWER_STATE Dx)
{
ULONG PowerState;
switch( Dx )
{
case D0:
case D1:
PowerState = VideoPowerOn;
break;
case D2:
PowerState = VideoPowerStandBy;
break;
case D3:
PowerState = VideoPowerSuspend;
break;
case D4:
PowerState = VideoPowerOff;
break;
default:
PowerState = VideoPowerOn;
break;
}
return(PowerState);
}
// This routine maps video power states to PM power states.
// Not currently used.
CEDEVICE_POWER_STATE
SA2Video::VideoToPmPowerState(ULONG PowerState)
{
CEDEVICE_POWER_STATE Dx;
switch( PowerState )
{
case VideoPowerOn:
Dx = D0;
break;
case VideoPowerStandBy:
Dx = D2;
break;
case VideoPowerSuspend:
Dx = D3;
break;
case VideoPowerOff:
Dx = D4;
break;
default:
Dx = D0;
break;
}
return Dx;
}
void SA2Video::SetPmPowerState(CEDEVICE_POWER_STATE PowerState)
{
DEBUGMSG(ZONE_PM, (TEXT("SA2Video::SetPmPowerState: (D%d)\r\n"), PowerState));
switch ( PowerState )
{
case D0:
case D1:
if (bSuspended)
{
DEBUGMSG(ZONE_PM, (TEXT("SA2Video::SetPmPowerState: TurnOn Display %d\r\n"), PowerState));
DispDrvrPowerHandler(FALSE);
bSuspended = FALSE;
}
break;
case D2:
case D3:
case D4:
if (!bSuspended)
{
DEBUGMSG(ZONE_PM, (TEXT("SA2Video::SetPmPowerState: TurnOff Display %d\r\n"), PowerState));
DispDrvrPowerHandler(TRUE);
bSuspended = TRUE;
}
break;
}
m_PmPowerState = PowerState;
}
CEDEVICE_POWER_STATE
SA2Video::GetPmPowerState(void)
{
return(m_PmPowerState);
}
ULONG
SA2Video::GetVideoPowerState(void)
{
return( PmToVideoPowerState(m_PmPowerState) );
}
// this routine converts a string into a GUID and returns TRUE if the
// conversion was successful.
BOOL
SA2Video::ConvertStringToGuid (LPCTSTR pszGuid, GUID *pGuid)
{
UINT Data4[8];
int Count;
BOOL fOk = FALSE;
TCHAR *pszGuidFormat = _T("{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}");
DEBUGCHK(pGuid != NULL && pszGuid != NULL);
__try
{
if (_stscanf(pszGuid, pszGuidFormat, &pGuid->Data1,
&pGuid->Data2, &pGuid->Data3, &Data4[0], &Data4[1], &Data4[2], &Data4[3],
&Data4[4], &Data4[5], &Data4[6], &Data4[7]) == 11)
{
for(Count = 0; Count < (sizeof(Data4) / sizeof(Data4[0])); Count++)
{
pGuid->Data4[Count] = (UCHAR) Data4[Count];
}
}
fOk = TRUE;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
return fOk;
}
// This routine notifies the OS that we support the Power Manager IOCTLs (through
// ExtEscape(), which calls DrvEscape()).
BOOL
SA2Video::AdvertisePowerInterface()
{
BOOL fOk = FALSE;
DWORD dwStatus;
GUID gClass;
TCHAR szModuleFileName[MAX_PATH];
// PM assumes device is in power state D0 when it registers.
m_PmPowerState = D0;
// assume we are advertising the default class
ConvertStringToGuid(PMCLASS_DISPLAY, &gClass);
DEBUGMSG(ZONE_PM,(TEXT("SA2Video::AdvertisePowerInterface: (%s)\r\n"), PMCLASS_DISPLAY));
DEBUGMSG(ZONE_PM,(TEXT("SA2Video::AdvertisePowerInterface: 0x%x-0x%x-0x%x 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\r\n"),
gClass.Data1, gClass.Data2, gClass.Data3,
gClass.Data4[0], gClass.Data4[1], gClass.Data4[2], gClass.Data4[3],
gClass.Data4[4], gClass.Data4[5], gClass.Data4[6], gClass.Data4[7]));
// Figure out what device name to advertise
// Note - g_hmodDisplayDll is initialized in the DLL_PROCESS_ATTACH of DllMain()
fOk = GetModuleFileName(g_hmodDisplayDll, szModuleFileName, sizeof(szModuleFileName) / sizeof(szModuleFileName[0]));
if (!fOk)
{
RETAILMSG(1,(TEXT("SA2Video::AdvertisePowerInterface: Failed to obtain DLL name. Driver is not power managed!\r\n")));
return FALSE;
}
// Build the display device name for DevicePowerNotify().
if( FAILED(StringCchCopy(m_DisplayDeviceName, sizeof(m_DisplayDeviceName)/sizeof(m_DisplayDeviceName[0]), PMCLASS_DISPLAY))||
FAILED(StringCchCat(m_DisplayDeviceName, sizeof(m_DisplayDeviceName)/sizeof(m_DisplayDeviceName[0]), _T("\\"))) ||
FAILED(StringCchCat(m_DisplayDeviceName, sizeof(m_DisplayDeviceName)/sizeof(m_DisplayDeviceName[0]), szModuleFileName)) )
{
RETAILMSG(1,(TEXT("SA2Video::AdvertisePowerInterface: Failed to construct unique name parameter. Driver is not power managed!\r\n")));
return FALSE;
}
DEBUGMSG(ZONE_PM,(TEXT("SA2Video::AdvertisePowerInterface: m_DisplayDeviceName=%s\r\n"),m_DisplayDeviceName));
// now advertise the interface
fOk = AdvertiseInterface(&gClass, szModuleFileName, TRUE);
if(fOk)
{
// Request initial power management state.
dwStatus = DevicePowerNotify(m_DisplayDeviceName, m_PmPowerState, POWER_NAME);
DEBUGMSG(ZONE_PM,(TEXT("SA2Video::AdvertisePowerInterface: dwStatus=0x%x\r\n"), dwStatus));
}
return fOk;
}
ULONG
SA2Video::DrvEscape(
SURFOBJ * pso,
ULONG iEsc,
ULONG cjIn,
PVOID pvIn,
ULONG cjOut,
PVOID pvOut
)
{
int RetVal = 0; // default return value: "not supported"
DWORD EscapeFunction;
GXDeviceInfo *pgxoi;
CEDEVICE_POWER_STATE NewDx;
VIDEO_POWER_MANAGEMENT *pvpm;
BOOL bErr = TRUE;
switch (iEsc)
{
case GETPOWERMANAGEMENT :
if (!pvOut || (cjOut < sizeof(VIDEO_POWER_MANAGEMENT)))
{
SetLastError(ERROR_INVALID_PARAMETER);
return -1;
}
pvpm = (VIDEO_POWER_MANAGEMENT*)pvOut;
pvpm->Length = sizeof(VIDEO_POWER_MANAGEMENT);
pvpm->DPMSVersion = 0;
pvpm->PowerState = GetVideoPowerState();
RetVal = 1;
DEBUGMSG(ZONE_PM, (TEXT("SA2Video::GETPOWERMANAGEMENT: VidPowerState=0x%x\r\n"),pvpm->PowerState));
break;
case SETPOWERMANAGEMENT :
{
pvpm = (VIDEO_POWER_MANAGEMENT *)pvIn;
if (!pvpm || (cjIn < sizeof(VIDEO_POWER_MANAGEMENT)))
{
SetLastError(ERROR_INVALID_PARAMETER);
return -1;
}
if (pvpm->Length < sizeof(VIDEO_POWER_MANAGEMENT))
{
SetLastError(ERROR_INVALID_PARAMETER);
return -1;
}
if (DevicePowerNotify(m_DisplayDeviceName, VideoToPmPowerState(pvpm->PowerState), POWER_NAME) )
{
DEBUGMSG(ZONE_PM, (TEXT("SA2Video::SetPowerManagement:DevicePowerNotify-success VPwrstate=%d (D%d)\r\n"),pvpm->PowerState, VideoToPmPowerState(pvpm->PowerState)));
}
else
{
RETAILMSG(1, (TEXT("SA2Video::SetPowerManagement:DevicePowerNotify failed\r\n")));
}
RetVal = 1;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -