📄 blt.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: blt.cpp
Abstract: accelerated bitblt/rectangle for S3C6400 FIMGSE-2D
Functions:
Notes:
--*/
#include "precomp.h"
#include "dispperf.h"
#define HW_PROBE 0
#if HW_PROBE // For check HW consume time, insert GPIO LED triggering code.
#include <DrvLib.h>
static volatile S3C6400_GPIO_REG *g_pGPIORegs = NULL;
#endif
SCODE AcceleratedBltSelect02( GPEBltParms *pBltParms );
SCODE AcceleratedBltSelect08( GPEBltParms *pBltParms );
SCODE AcceleratedBltSelect16( GPEBltParms *pBltParms );
SCODE
S3C6400Disp::BltPrepare(GPEBltParms *pBltParms)
{
RECTL rectl;
int iSwapTmp;
BOOL bRotate = FALSE;
static bool bIsG2DReady = false;
#if G2D_PROFILE
RopProfiler *ropProfiler;
ropProfiler = RopProfiler::Instance();
#endif
#if HW_PROBE // For check HW consume time, insert GPIO LED triggering code.
// GPIO Virtual alloc
if(g_pGPIORegs == NULL)
{
g_pGPIORegs = (volatile S3C6400_GPIO_REG *)DrvLib_MapIoSpace(S3C6400_BASE_REG_PA_GPIO, sizeof(S3C6400_GPIO_REG), FALSE);
}
if (g_pGPIORegs == NULL)
{
RETAILMSG(1,(TEXT("[GPIO] g_pGPIORegs: VirtualAlloc failed!\r\n")));
DrvLib_UnmapIoSpace((PVOID)g_pGPIORegs);
g_pGPIORegs = NULL;
}
g_pGPIORegs->GPNDAT |= (1<<14); // For checking SW Workload Start Point
#endif
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6400Disp::BltPrepare\r\n")));
#ifdef DO_DISPPERF
DispPerfStart(pBltParms->rop4);
DispPerfParam(pBltParms);
#endif
// default to base EmulatedBlt routine
pBltParms->pBlt = &GPE::EmulatedBlt; // catch all
// see if we need to deal with cursor
// check for destination overlap with cursor and turn off cursor if overlaps
if (pBltParms->pDst == m_pPrimarySurface) // only care if dest is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (pBltParms->prclDst != NULL) // make sure there is a valid prclDst
{
rectl = *pBltParms->prclDst; // if so, use it
// There is no guarantee of a well ordered rect in blitParamters
// due to flipping and mirroring.
if(rectl.top > rectl.bottom)
{
iSwapTmp = rectl.top;
rectl.top = rectl.bottom;
rectl.bottom = iSwapTmp;
}
if(rectl.left > rectl.right)
{
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;
}
}
if (m_iRotate )
{
bRotate = TRUE;
}
}
// check for source overlap with cursor and turn off cursor if overlaps
if (pBltParms->pSrc == m_pPrimarySurface) // only care if source is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (pBltParms->prclSrc != NULL) // make sure there is a valid prclSrc
{
rectl = *pBltParms->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 (m_iRotate) //if rotated
{
bRotate = TRUE;
}
}
if (bRotate)
{
#if 0
if((( S3C6400Surf *)(pBltParms->pDst))->InVideoMemory())
{
// RETAILMSG (1, (TEXT("S3C6400::AccelRotate()\r\n")));
pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *)) &S3C6400Disp::AcceleratedBltRotate;
}
else
{
#endif
#if G2D_PROFILE
ropProfiler->Log(false, pBltParms->rop4);
#endif
pBltParms->pBlt = &GPE::EmulatedBltRotate;
#if 0
}
#endif
}
EmulatedBltSelect02(pBltParms);
EmulatedBltSelect08(pBltParms);
#if G2D_ACCELERATE
if( (m_VideoPowerState != VideoPowerOff) && // to avoid hanging while bring up display H/W
((S3C6400Surf *)(pBltParms->pDst))->InVideoMemory() &&
(((S3C6400Surf *)(pBltParms->pDst))->Format() == gpe16Bpp) &&
pBltParms->pBlt == &GPE::EmulatedBlt)
{
AcceleratedBltSelect16(pBltParms);
}
else
{
#endif
#if G2D_PROFILE
ropProfiler->Log(false, pBltParms->rop4);
#endif
EmulatedBltSelect16(pBltParms);
#if G2D_ACCELERATE
}
#endif
#ifdef DO_DISPPERF
// Performance Logging Type
DispPerfType(DISPPERF_ACCEL_EMUL);
#endif
return S_OK;
}
// This function would be used to undo the setting of clip registers etc
SCODE
S3C6400Disp::BltComplete(GPEBltParms *pBltParms)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6400Disp::BltComplete\r\n")));
#if HW_PROBE // For check HW consume time, insert GPIO LED triggering code.
g_pGPIORegs->GPNDAT &= ~(1<<14); // For checking SW Workload End Point
#endif
// see if cursor was forced off because of overlap with source or destination and turn back on
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
#ifdef DO_DISPPERF
DispPerfEnd(0);
#endif
return S_OK;
}
// Currently not Accelerated
SCODE
S3C6400Disp::AcceleratedBltRotate(GPEBltParms *pBltParms)
{
SCODE (GPE::*pBlt)(GPEBltParms*) = pBltParms->pBlt;
SCODE sc;
BOOL bSaveBltFunc = FALSE;
if( pBltParms->pDst->InVideoMemory() ||
( pBltParms->pSrc && pBltParms->pSrc->InVideoMemory() ) ||
( pBltParms->pMask && pBltParms->pMask->InVideoMemory() ) ||
( pBltParms->pBrush && pBltParms->pBrush->InVideoMemory() ) )
{
// If we have a pending blt and now attempt a software operation using
// video memory, the pipeline must be flushed.
WaitForNotBusy();
}
if (pBltParms->pBlt != &GPE::EmulatedBltRotate)
{
bSaveBltFunc = TRUE;
}
pBltParms->pBlt = &GPE::EmulatedBltRotate_Internal;
// Check to see if this should be handled by the ClearType(tm) or
// AAFont libraries.
if (pBltParms->rop4 == 0xAAF0)
{
// ClearTypeBltSelect(pBltParms);
// AATextBltSelect(pBltParms);
}
// Check to see if this should be handled by the emul library.
if (pBltParms->pBlt == &GPE::EmulatedBltRotate_Internal)
{
EmulatedBltSelect02(pBltParms);
EmulatedBltSelect08(pBltParms);
EmulatedBltSelect16(pBltParms);
}
if (pBltParms->pBlt != &GPE::EmulatedBltRotate_Internal)
{
DispPerfType(DISPPERF_ACCEL_EMUL);
}
// Check to see if we need to use Bilinear stretching
if (pBltParms->iMode == BILINEAR)
{
LONG DstWidth = pBltParms->prclDst->right - pBltParms->prclDst->left;
LONG DstHeight = pBltParms->prclDst->bottom - pBltParms->prclDst->top;
if (pBltParms->bltFlags == BLT_STRETCH
&& pBltParms->xPositive
&& pBltParms->yPositive
&& pBltParms->pDst->Format() > gpe8Bpp
&& (pBltParms->rop4 == 0xCCCC
|| pBltParms->rop4 == 0xEEEE
|| pBltParms->rop4 == 0x8888)
&& DstWidth > 0
&& DstHeight > 0
&& DstWidth >= pBltParms->prclSrc->right - pBltParms->prclSrc->left
&& DstHeight >= pBltParms->prclSrc->bottom - pBltParms->prclSrc->top)
{
pBltParms->pBlt = &GPE::EmulatedBltRotate_Bilinear;
}
}
sc = (this->*(pBltParms->pBlt))(pBltParms);
if (bSaveBltFunc)
{
pBltParms->pBlt = pBlt;
}
return sc;
}
SCODE
S3C6400Disp::AcceleratedBltFill(GPEBltParms *pBltParms)
{
PRECTL prcDst = pBltParms->prclDst;
CSPACE ColorMode;
RETAILMSG (G2D_MSG, (TEXT("BltFill\r\n")));
if ( pBltParms->pDst->Format() == gpe16Bpp)
{
ColorMode = RGB16;
}
else if ( pBltParms->pDst->Format() == gpe24Bpp)
{
ColorMode = RGB24;
}
else
{
ColorMode = RGB16;
}
// Code refactoring is needed.
// m_oG2D->SetColorMode(ColorMode);
// m_oG2D->SetBaseAddr(m_VideoMemoryPhysicalBase + (( S3C6400Surf *)(pBltParms->pDst))->OffsetInVideoMemory());
// m_oG2D->SetClipRgn();
// printf("x1\n");
m_oG2D->InitSetting(
m_VideoMemoryPhysicalBase + (( S3C6400Surf *)(pBltParms->pDst))->OffsetInVideoMemory(),
ColorMode,
m_nScreenWidth, m_nScreenHeight,
0, 0,
m_nScreenWidth, m_nScreenHeight
);
if (pBltParms->rop4 == 0x5a5a)
{
m_oG2D->SetRopEtype(ROP_DST_XOR_PAT); // Not Supported
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -