?? xslgpe.cpp
字號:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft 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 LICENSE.RTF on your
// install media.
//
/*++
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.
Module Name:
Abstract:
Functions:
Notes:
Revision:
12/20/02, Roger Yu, Create the file
--*/
#include "precomp.h"
#include "XSLGPE.h"
#include "palette.h" // for 8Bpp we use the natural palette
#ifdef CLEARTYPE
#include <ctblt.h>
#endif //CLEARTYPE
//cerate PALETTEENTRY _rgbIdentity[PALETTE_SIZE]
INSTANTIATE_PALETTE
INSTANTIATE_GPE_ZONES(0x3,"XSLGPE Driver","unused1","unused2") // Start with errors and warnings
PALETTEENTRY _rgb16Identity[16] =
{
{ 0x00, 0x00, 0x00, 0 }, /* 0 Sys Black gray 0 */
{ 0x80, 0x00, 0x00, 0 }, /* 1 Sys Dk Red */
{ 0x00, 0x80, 0x00, 0 }, /* 2 Sys Dk Green */
{ 0x80, 0x80, 0x00, 0 }, /* 3 Sys Dk Yellow */
{ 0x00, 0x00, 0x80, 0 }, /* 4 Sys Dk Blue */
{ 0x80, 0x00, 0x80, 0 }, /* 5 Sys Dk Violet */
{ 0x00, 0x80, 0x80, 0 }, /* 6 Sys Dk Cyan */
{ 0xc0, 0xc0, 0xc0, 0 }, /* 7 Sys Lt Grey gray 192 */
{ 0x80, 0x80, 0x80, 0 }, /* 8 */
{ 0xff, 0x00, 0x00, 0 }, /* 9 */
{ 0x00, 0xff, 0x00, 0 }, /* 10 */
{ 0xff, 0xff, 0x00, 0 }, /* 11 */
{ 0x00, 0x00, 0xff, 0 }, /* 12 */
{ 0xff, 0x00, 0xff, 0 }, /* 13 */
{ 0x00, 0xff, 0xff, 0 }, /* 14 */
{ 0xff, 0xff, 0xff, 0 } /* 15 */
};
//@#$Roger Yu; 04-12-03
// shiftright is used to shrink pixels from right so the strip at right will always
// untouched (may set as black)
unsigned shiftright=0;
//
#ifdef DD_ENABLE
DDGPE *gGPE = (DDGPE *)NULL;
#else // DD_ENABLE
GPE *gGPE = (GPE *)NULL;
#endif // DD_ENABLE
UINT hVideoOutDevice = VOD_ATTR_DEFAULT;
UINT hVodDev = VOD_ATTR_DEFAULT; // assuming only support SDTN
//unsigned dispScreenX, dispScreenY;
BOOL bIsTftPanel=TRUE;
VIDEO_POWER_MANAGEMENT videoPMState = {
sizeof(VIDEO_POWER_MANAGEMENT),
1,
VideoPowerOff
};
// This prototype avoids problems exporting from .lib
BOOL APIENTRY GPEEnableDriver(ULONG engineVersion, ULONG cj, DRVENABLEDATA *data,
PENGCALLBACKS engineCallbacks);
BOOL APIENTRY DrvEnableDriver(ULONG engineVersion, ULONG cj, DRVENABLEDATA *data,
PENGCALLBACKS engineCallbacks)
{
return GPEEnableDriver(engineVersion, cj, data, engineCallbacks);
}
//
// Main entry point for a GPE-compliant driver
//
GPE *GetGPE(void)
{
if (!gGPE)
{
gGPE = new XSLGPE();
}
return gGPE;
}
ULONG gBitMasks[] = { 0xf800,0x07e0,0x001f};
SCODE XSLGPE::SetMode (INT modeId, HPALETTE *palette)
{
DEBUGMSG(GPE_ZONE_INIT,(TEXT("XSLGPE::SetMode\r\n")));
if (modeId != 0)
{
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("XSLGPE::SetMode Want mode %d, only have mode 0\r\n"),modeId));
return E_INVALIDARG;
}
if (palette)
{
switch (m_colorDepth)
{
case 8:
*palette = EngCreatePalette (PAL_INDEXED,
PALETTE_SIZE,
(ULONG*)_rgbIdentity,
0,
0,
0);
break;
case 16:
case 24:
case 32:
/*
*palette = EngCreatePalette (PAL_BITFIELDS,
0,
NULL,
((1 << m_RedMaskSize) - 1) << m_RedMaskPosition,
((1 << m_GreenMaskSize) - 1) << m_GreenMaskPosition,
((1 << m_BlueMaskSize) - 1) << m_BlueMaskPosition);
*/
*palette = EngCreatePalette (PAL_BITFIELDS,
0,
NULL,
gBitMasks[0],
gBitMasks[1],
gBitMasks[2]
);
break;
}
}
CHDBG((TEXT("XSLGPE::SetMode Finished, ######PLEASE NOTICE####\n") ))
return S_OK;
}
SCODE XSLGPE::GetModeInfo(GPEMode *mode, INT modeNumber)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("XSLGPE::GetModeInfo\r\n")));
CHDBG((TEXT("XSLGPE::GetModeInfo, ######PLEASE NOTICE####\n") ))
if (modeNumber != 0)
{
return E_INVALIDARG;
}
*mode = m_ModeInfo;
return S_OK;
}
int XSLGPE::NumModes()
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("XSLGPE::NumModes\r\n")));
return 1;
}
void XSLGPE::CursorOn (void)
{
UCHAR *ptrScreen = (UCHAR*)m_pPrimarySurface->Buffer();
UCHAR *ptrLine;
UCHAR *cbsLine;
UCHAR *xorLine;
UCHAR *andLine;
int x, y;
int rlimit;
if (!m_CursorForcedOff && !m_CursorDisabled && !m_CursorVisible)
{
rlimit = (m_nScreenWidth-shiftright);
for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
{
if (y < 0)
{
continue;
}
if (y >= m_nScreenHeight)
{
break;
}
ptrLine = &ptrScreen[y * m_pPrimarySurface->Stride()];
cbsLine = &m_CursorBackingStore[(y - m_CursorRect.top) * (m_CursorSize.x * (m_colorDepth >> 3))];
xorLine = &m_CursorXorShape[(y - m_CursorRect.top) * m_CursorSize.x];
andLine = &m_CursorAndShape[(y - m_CursorRect.top) * m_CursorSize.x];
for (x = m_CursorRect.left; x < m_CursorRect.right; x++)
{
if (x < 0)
{
continue;
}
if (x >= rlimit )
{
break;
}
cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3)] = ptrLine[x * (m_colorDepth >> 3)];
ptrLine[x * (m_colorDepth >> 3)] &= andLine[x - m_CursorRect.left];
ptrLine[x * (m_colorDepth >> 3)] ^= xorLine[x - m_CursorRect.left];
if (m_colorDepth > 8)
{
cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 1] = ptrLine[x * (m_colorDepth >> 3) + 1];
ptrLine[x * (m_colorDepth >> 3) + 1] &= andLine[x - m_CursorRect.left];
ptrLine[x * (m_colorDepth >> 3) + 1] ^= xorLine[x - m_CursorRect.left];
if (m_colorDepth > 16)
{
cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 2] = ptrLine[x * (m_colorDepth >> 3) + 2];
ptrLine[x * (m_colorDepth >> 3) + 2] &= andLine[x - m_CursorRect.left];
ptrLine[x * (m_colorDepth >> 3) + 2] ^= xorLine[x - m_CursorRect.left];
}
}
}
}
m_CursorVisible = TRUE;
}
}
void XSLGPE::CursorOff (void)
{
UCHAR *ptrScreen = (UCHAR*)m_pPrimarySurface->Buffer();
UCHAR *ptrLine;
UCHAR *cbsLine;
int x, y;
int rlimit;
if (!m_CursorForcedOff && !m_CursorDisabled && m_CursorVisible)
{
rlimit = (m_nScreenWidth-shiftright);
for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
{
// clip to displayable screen area (top/bottom)
if (y < 0)
{
continue;
}
if (y >= m_nScreenHeight)
{
break;
}
ptrLine = &ptrScreen[y * m_pPrimarySurface->Stride()];
cbsLine = &m_CursorBackingStore[(y - m_CursorRect.top) * (m_CursorSize.x * (m_colorDepth >> 3))];
for (x = m_CursorRect.left; x < m_CursorRect.right; x++)
{
// clip to displayable screen area (left/right)
if (x < 0)
{
continue;
}
if (x >= rlimit)
{
break;
}
ptrLine[x * (m_colorDepth >> 3)] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3)];
if (m_colorDepth > 8)
{
ptrLine[x * (m_colorDepth >> 3) + 1] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 1];
if (m_colorDepth > 16)
{
ptrLine[x * (m_colorDepth >> 3) + 2] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 2];
}
}
}
}
m_CursorVisible = FALSE;
}
}
SCODE XSLGPE::SetPointerShape(GPESurf *pMask, GPESurf *pColorSurf, INT xHot, INT yHot, INT cX, INT cY)
{
DEBUGMSG(GPE_ZONE_CURSOR,(TEXT("XSLGPE::SetPointerShape(0x%X, 0x%X, %d, %d, %d, %d)\r\n"),pMask, pColorSurf, xHot, yHot, cX, cY));
// turn current cursor off
CursorOff();
{
UCHAR *andPtr; // input pointer
UCHAR *xorPtr; // input pointer
UCHAR *andLine; // output pointer
UCHAR *xorLine; // output pointer
char bAnd;
char bXor;
int row;
int col;
int i;
int bitMask;
// release memory associated with old cursor
if (!pMask) // do we have a new cursor shape
{
m_CursorDisabled = TRUE; // no, so tag as disabled
}
else
{
m_CursorDisabled = FALSE; // yes, so tag as not disabled
// store size and hotspot for new cursor
m_CursorSize.x = cX;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -