📄 blt.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// Copyright (c) Samsung Electronics. Co. LTD. All rights reserved.
//
/*++
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 S3C6410 FIMGSE-2D
Functions:
Notes:
--*/
#include "precomp.h"
#include <ceddk.h>
#include <dispperf.h>
#define HW_PROBE 1
#if HW_PROBE // For check HW consume time, insert GPIO LED triggering code.
#include <DrvLib.h>
static volatile S3C6410_GPIO_REG *g_pGPIORegs = NULL;
#endif
/// For Support Stretched Blt using HW
#if G2D_ACCELERATE
DDGPESurf *gpScratchSurf;
GPESurf *oldSrcSurf;
#endif
SCODE AcceleratedBltSelect16( GPEBltParms *pBltParms );
#define TEMP_DEBUG (FALSE)
#define FULL_TEST_OK (0)
#define DUMP_BLTPARAM (FALSE)
#define CODEPATH_PICKUP (FALSE)
SCODE
S3C6410Disp::BltPrepare(GPEBltParms *pBltParms)
{
RECTL rectl;
int iSwapTmp;
BOOL bRotate = FALSE;
static bool bIsG2DReady = false;
#if HW_PROBE // For check HW consume time, insert GPIO LED triggering code.
// GPIO Virtual alloc
if(g_pGPIORegs == NULL)
{
g_pGPIORegs = (volatile S3C6410_GPIO_REG *)DrvLib_MapIoSpace(S3C6410_BASE_REG_PA_GPIO, sizeof(S3C6410_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("S3C6410Disp::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 ) // if screen (destination primary surface) is rotated.
{
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 screen(source primary surface) is rotated
{
bRotate = TRUE;
}
}
if (bRotate) // if source or desitnation surface is rotated.
{
pBltParms->pBlt = &GPE::EmulatedBltRotate;
}
// EmulatedBltSelect02(pBltParms);
// EmulatedBltSelect08(pBltParms);
#if (CPU_NAME == S3C6410)
#if G2D_ACCELERATE
if( (m_VideoPowerState != VideoPowerOff) && // to avoid hanging while bring up display H/W
((S3C6410Surf *)(pBltParms->pDst))->InVideoMemory() &&
(((S3C6410Surf *)(pBltParms->pDst))->Format() == gpe16Bpp)
// && pBltParms->pBlt == &GPE::EmulatedBlt // Disable Rotation Case
)
{
RETAILMSG(CODEPATH_PICKUP,(TEXT("Accel Path\r\n")));
AcceleratedBltSelect16(pBltParms);
}
else
{
#endif
#endif
RETAILMSG(CODEPATH_PICKUP,(TEXT("Emul Path\r\n")));
// EmulatedBltSelect16(pBltParms);
#if (CPU_NAME == S3C6410)
#if G2D_ACCELERATE
}
if(m_VideoPowerState != VideoPowerOff ) // to avoid hanging while bring up display H/W
{
m_oG2D->WaitForIdle(); //< Wait for Fully Empty Command Fifo for all BitBlt request
}
#endif
#endif
DEBUGMSG(GPE_ZONE_BLT_HI, (TEXT("--S3C2450DISP::BltPrepare\r\n")));
return S_OK;
}
// This function would be used to undo the setting of clip registers etc
SCODE
S3C6410Disp::BltComplete(GPEBltParms *pBltParms)
{
DEBUGMSG (GPE_ZONE_BLT_HI, (TEXT("++S3C6410Disp::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();
}
#if G2D_ACCELERATE
if(gpScratchSurf)
{
pBltParms->pSrc = oldSrcSurf;
delete gpScratchSurf;
gpScratchSurf=NULL;
}
#endif
#ifdef DO_DISPPERF
DispPerfEnd(0);
#endif
DEBUGMSG(GPE_ZONE_BLT_HI, (TEXT("--S3C6410DISP::BltComplete\r\n")));
return S_OK;
}
/**
* @fn SCODE S3C6410DISP::AcceleratedBltFIll(GPEBltParms *pBltParms)
* @brief Rectangle Solid Filling Function. Solid Fill has no Source Rectangle
* @param pBltParms Blit Parameter Information Structure
* @sa GPEBltParms
* @note ROP : 0xF0F0
* @note Using Information : DstSurface, ROP, Solidcolor
*/
#if (CPU_NAME == S3C6410)
SCODE S3C6410Disp::AcceleratedBltFill(GPEBltParms *pBltParms)
{
PRECTL prclDst = pBltParms->prclDst;
DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("++S3C6410DISP::AcceleratedBltFill\r\n")));
/**
* Prepare Source & DestinationSurface Information
*
*/
// m_oG2D->Init();
SURFACE_DESCRIPTOR descDstSurface;
// When Screen is rotated, ScreenHeight and ScreenWidth always has initial surface property.
descDstSurface.dwBaseaddr = (m_VideoMemoryPhysicalBase + (( S3C6410Surf *)(pBltParms->pDst))->OffsetInVideoMemory());
descDstSurface.dwColorMode = pBltParms->pDst->Format();
descDstSurface.dwHoriRes = pBltParms->pDst->Stride()/pBltParms->pDst->BytesPerPixel();
descDstSurface.dwVertRes = pBltParms->pDst->ScreenHeight();
m_oG2D->SetSrcSurface(&descDstSurface); // Fill dummy value
m_oG2D->SetDstSurface(&descDstSurface);
if(pBltParms->prclClip)
{
m_oG2D->SetClipWindow(pBltParms->prclClip);
}
else
{
if(pBltParms->pDst->IsRotate())
{
RotateRectl(prclDst);
RETAILMSG(0, (TEXT("AfterRotate DstRect:(L%d,T%d,R%d,B%d)\r\n"),
prclDst->left, prclDst->top, prclDst->right, prclDst->bottom ));
}
m_oG2D->SetClipWindow(prclDst);
}
m_oG2D->SetRopEtype(ROP_SRC_ONLY);
RETAILMSG(0, (TEXT("FillRectA %x\r\n"), this));
RETAILMSG(0, (TEXT("BlitFill : Dst Stride:%d, W:%d, H:%d, Screen(W:%d,H:%d), DstRect:(L%d,T%d,R%d,B%d)\r\n"),
pBltParms->pDst->Stride(), pBltParms->pDst->Width(), pBltParms->pDst->Height(),
pBltParms->pDst->ScreenWidth(), pBltParms->pDst->ScreenHeight(),
prclDst->left, prclDst->top, prclDst->right, prclDst->bottom
));
EnterCriticalSection(&m_cs2D);
m_oG2D->FillRect(prclDst, pBltParms->solidColor);
LeaveCriticalSection(&m_cs2D);
RETAILMSG(0, (TEXT("FillRectB\r\n")));
if(pBltParms->pDst->IsRotate())
{
RotateRectlBack(prclDst);
RETAILMSG(0, (TEXT("End Fill DstRect:(L%d,T%d,R%d,B%d)\r\n"),
prclDst->left, prclDst->top, prclDst->right, prclDst->bottom
));
}
DEBUGMSG(GPE_ZONE_BLT_LO, (TEXT("--S3C6410DISP::AcceleratedBltFill\r\n")));
return S_OK;
}
#elif (CPU_NAME == S3C6400)
SCODE
S3C6410Disp::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 + (( S3C6410Surf *)(pBltParms->pDst))->OffsetInVideoMemory());
// m_oG2D->SetClipRgn();
// printf("x1\n");
m_oG2D->InitSetting(
m_VideoMemoryPhysicalBase + (( S3C6410Surf *)(pBltParms->pDst))->OffsetInVideoMemory(),
ColorMode,
m_nScreenWidth, m_nScreenHeight,
0, 0,
m_nScreenWidth, m_nScreenHeight
);
if (pBltParms->rop4 == 0x5a5a)
{
/// Not Supported
m_oG2D->SetRopEtype(ROP_DST_XOR_PAT);
}
else
{
m_oG2D->SetRopEtype(ROP_SRC_ONLY);
}
/// (LONG) -> (WORD)
m_oG2D->FillRect((WORD)prcDst->left, (WORD)prcDst->top, (WORD)prcDst->right, (WORD)prcDst->bottom, pBltParms->solidColor);
return S_OK;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -