📄 mbxconvrt.cpp
字号:
/***************************************************************************
* Name : mbxconvrt.cpp
* Title : MBX WinCE driver GPE class
* Author(s) : Imagination Technologies
* Created : 11th February 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 mode related components of GPE class.
*
* Platform : WinCE
*
* Modifications:-
* $Log: mbxconvrt.cpp $
*
* --- Revision Logs Removed ---
*
****************************************************************************/
#include "precomp.h"
#if defined (INCLUDE_DXHAL)
extern "C"
{
#include "pvrdd.h"
}
#endif
extern EGPEFormat GetDisplayModeGPEFormat (USHORT usBpp);
/* cannot do replication as some of the CE test kit tests fail */
//#define JUST_SHIFT 1
#if 0 /* only used by SetMBXPalette and then only if uncommented */
extern PALETTEENTRY _rgbIdentity[256]; \
// !BUGBUG!
// Note: These are all RGB tables! If you switch the driver to run BGR, these
// tables must be modified!
static const ULONG l_MBX1BppPalette[] = {
0x00000000, // 0 = Black
0x00FFFFFF // 1 = White
};
static const ULONG l_MBX2BppPalette[] = {
0x00000000, // 0 = Black
0x00808080, // 1 = Dark gray
0x00C0C0C0, // 2 = Light gray
0x00FFFFFF // 3 = White
};
static const PALETTEENTRY _rgb4BppPalette[] = {
{ 0x00, 0x00, 0x00, 0 }, /* 0 Sys Black gray 0 */
{ 0x80, 0x00, 0x00, 0 }, /* 1 Sys Dk Red */
{ 0xFF, 0x00, 0x00, 0 }, /* 2 Sys Red */
{ 0x00, 0x80, 0x00, 0 }, /* 3 Sys Dk Green */
{ 0x80, 0x80, 0x00, 0 }, /* 4 Sys Dk Yellow */
{ 0x00, 0xFF, 0x00, 0 }, /* 5 Sys Green */
{ 0xFF, 0xFF, 0x00, 0 }, /* 6 Sys Yellow */
{ 0x00, 0x00, 0x80, 0 }, /* 7 Sys Dk Blue */
{ 0x80, 0x00, 0x80, 0 }, /* 8 Sys Dk Violet */
{ 0x00, 0x80, 0x80, 0 }, /* 9 Sys Dk Cyan */
{ 0x80, 0x80, 0x80, 0 }, /* 10 Sys Dark gray */
{ 0xc0, 0xc0, 0xc0, 0 }, /* 11 Sys Lt Grey gray 192 */
{ 0x00, 0x00, 0xFF, 0 }, /* 12 Sys Blue */
{ 0xFF, 0x00, 0xFF, 0 }, /* 13 Sys Purple */
{ 0x00, 0xFF, 0xFF, 0 }, /* 14 Sys Cyan */
{ 0xFF, 0xFF, 0xFF, 0 } /* 15 Sys White */
};
static const ULONG l_MBXLookupMasks[][4] = {
// Red Green Blue Alpha
{ 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, // NULL format
{ 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, // 565
{ 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 } // 888
};
static const ULONG *pulMBXPaletteLookup[] = {
{ (ULONG *)&l_MBX1BppPalette }, /* gpe1Bpp */
{ (ULONG *)&l_MBX2BppPalette }, /* gpe2Bpp */
{ (ULONG *)&_rgb4BppPalette }, /* gpe4Bpp */
{ (ULONG *)&_rgbIdentity }, /* gpe8Bpp */
{ (ULONG *)&l_MBXLookupMasks[1] }, /* gpe16Bpp */
{ (ULONG *)&l_MBXLookupMasks[2] }, /* gpe24Bpp */
{ (ULONG *)&l_MBXLookupMasks[2] }, /* gpe32Bpp */
{ NULL }, /* gpe16YrCb */
{ NULL }, /* DeviceCompat */
{ NULL } /* gpeUndefined */
};
static const ULONG l_NumMBXPaletteLookup = sizeof(pulMBXPaletteLookup) / sizeof(ULONG *);
ULONG *pulEGPEFormatToPalette (EGPEFormat eFormat)
{
if (eFormat <= l_NumMBXPaletteLookup)
{
return ((ULONG *)pulMBXPaletteLookup[eFormat]);
}
else
{
return (NULL);
}
}
#endif
/******************************************************************************
* Function Name: Replicate
*
* Inputs : ULONG ulData, ulMask, ulShift, ulCount
* Outputs : -
* Returns : ULONG ulData
* Globals Used : -
*
* Description : Given a mask will relicate data shifted by n bit m times
* Pre-condition:
*****************************************************************************/
ULONG MBXReplicate(ULONG ulData, ULONG ulMask, ULONG ulShift, int nCount)
{
#ifndef JUST_SHIFT
ULONG ulBits;
int nCnt;
ulBits = ulData & ulMask;
ulData = 0;
for (nCnt=0; nCnt <= nCount; nCnt++)
{
ulData = ulData | (ulBits >> (ulShift * nCnt));
}
#else
ulData &= ulMask;
#endif
return ulData;
}
/******************************************************************************
* Function Name: DestToABGR
*
* Inputs : - EGPEFormat eFormat, ULONG ulPixel
* Outputs : - ULONG ABGR
* Returns : -
* Globals Used : -
*
* Description : Convert pixel/palette to ABGR 888
* Pre-condition:
*****************************************************************************/
ULONG DestToABGR(EGPEFormat eFormat, ULONG ulPixel)
{
ULONG ulR = 0, ulG = 0, ulB = 0, ulA = 0;
switch (eFormat)
{
case gpe8Bpp:
ulB = MBXReplicate( ulPixel, 0xE0, 3, 2);
ulG = MBXReplicate((ulPixel << 3), 0xE0, 3, 2);
ulR = MBXReplicate((ulPixel << 6), 0xC0, 2, 3);
break;
case gpe16Bpp:
ulB = MBXReplicate((ulPixel >> 8), 0xF8, 5, 1);
ulG = MBXReplicate((ulPixel >> 3), 0xFC, 6, 1);
ulR = MBXReplicate((ulPixel << 3), 0xF8, 5, 1);
break;
case gpe32Bpp:
ulA = ((ulPixel >> 24) & 0xFF);
case gpe24Bpp:
ulB = ((ulPixel >> 16) & 0xFF);
ulG = ((ulPixel >> 8) & 0xFF);
ulR = ((ulPixel >> 0) & 0xFF);
break;
}
return (ulA<<24 | ulB<<16 | ulG<<8 | ulR);
}
#if defined (INCLUDE_DXHAL)
EXTERN_C void CreateMBXSurfClass(PSURFDATA psSurfData)
{
ASSERT(sizeof(MBXSurf) == SIZEOF_MBXSURF_CLASS);
ASSERT(sizeof(MemNode) == SIZEOF_MEMNODE_CLASS);
USHORT usBpp = (USHORT)psSurfData->sPixelFormat.dwRGBBitCount;
/*
Create MBXSurf object
*/
MBXSurf * pclSurf = new MBXSurf( psSurfData->dwWidth,
psSurfData->dwHeight,
psSurfData->pvLinAddress,
psSurfData->lStride * ((usBpp + 1) >> 3),
GetDisplayModeGPEFormat(usBpp) );
/*
Set up embedded MemNode structure
*/
MemNode * psMem = (MemNode *) psSurfData->abyMemNodeClass;
psMem->m_psDevMemHandle = psSurfData->psMemInfo;
psMem->m_pclNext = NULL;
psMem->m_pclPrev = NULL;
psMem->m_pclSurf = (MBXSurf *) psSurfData->abyMBXSurfClass;
/*
Add node to Surf object and copy to embedded MBXSurface and set the
HAL surface strucure's pvGPESurf to reference it.
*/
pclSurf->SetMemNode(psMem);
memcpy((void*)psSurfData->abyMBXSurfClass, pclSurf, SIZEOF_MBXSURF_CLASS);
psSurfData->pvGPESurf = (MBXSurf *) psSurfData->abyMBXSurfClass;
/*
The surf object is superflous now so we can delete it. Set the mem
node to NULL first so the destructor doesn't try and release it.
*/
pclSurf->SetMemNode(NULL);
delete pclSurf;
}
#endif // INCLUDE_DXHAL
/********************************** end of file ******************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -