📄 baseroot.cpp
字号:
pBitmapInfo->biWidth,
pBitmapInfo->biHeight,
cidIn, pImageData,
pBitmapInfo->biWidth,
pBitmapInfo->biHeight, pitchIn,
0, 0, pBitmapInfo->biWidth,
pBitmapInfo->biHeight);
ScratchUnlock(pScratchBits);
// Instead of using the RGB color converter we will simply
// use OS services to BLT to the surface at this point (since
// it MAY be faster at blt-ing than we are. HOWEVER, it may
// be faster by using pixel rep to stretch. This will cause
// visually unsatisifing blts. But then again ... DO NOT
// BREAK WINDOWS. XXXAH we may want to use the color
// converter here.
if (returnVal != -1)
_BltFromScratchToComposition(rDestRect, rSrcRect);
}
else if ((IsYUV(cidIn) &&
(m_nCompositionSurfaceCID == CID_RGB565 ||
m_nCompositionSurfaceCID == CID_RGB555) &&
(dxDst > 2*dxSrc ||
dyDst > 2*dySrc))) // || bUseScratch)
{
HXxSize tempSize;
tempSize.cx = dxSrc;
tempSize.cy = dySrc;
CreateScratchSurface(m_nCompositionSurfaceCID, &tempSize);
UCHAR* pScratchBits;
INT32 nScratchPitch;
ScratchLock(&pScratchBits, &nScratchPitch);
// if somehow scratch surface creation failed
if (!pScratchBits)
{
goto regularConvert;
}
returnVal = zm_pColorAcc->ColorConvert(
m_nCompositionSurfaceCID,
pScratchBits,
m_allocatedScratchSize.cx,
m_allocatedScratchSize.cy,
nScratchPitch,
rSrcRect.left, rSrcRect.top,
dxSrc, dySrc,
cidIn, pImageData,
pBitmapInfo->biWidth,
pBitmapInfo->biHeight,
pitchIn,
rSrcRect.left, rSrcRect.top,
dxSrc, dySrc);
ScratchUnlock(pScratchBits);
if (returnVal != -1)
_BltFromScratchToComposition(rDestRect, rSrcRect);
}
else
#endif /*_WORKAROUND_YUV_RGB_16BIT_HXCOLOR_BUG*/
{
regularConvert:
int nCompPitch = m_nCompositionPitch;
returnVal = zm_pColorAcc->ColorConvert(
m_nCompositionSurfaceCID,
m_pCompositionSurface,
m_allocatedCompositionSize.cx,
m_allocatedCompositionSize.cy,
nCompPitch,
rDestRect.left, rDestRect.top,
dxDst, dyDst,
cidIn,
pImageData, pBitmapInfo->biWidth,
pBitmapInfo->biHeight, pitchIn,
rSrcRect.left, rSrcRect.top, dxSrc, dySrc);
//XXXgfw this is weird. We only want to redraw the Dest
//Rect right? The src is mostly always zero..
if( !m_pSite->IsCompositionLocked() && returnVal != -1)
_MinimalBlt(rSrcRect, rDestRect);
}
}
if (!returnVal)
{
retVal = HXR_OK;
ModifyBoundsRect(&rDestRect);
}
}
else
{
#ifndef _WINDOWS
HX_ASSERT(!"Failed to get a color convertor!!!");
#endif
}
return retVal;
}
void CBaseRootSurface::_MinimalBlt(HXxRect&, HXxRect&)
{}
void CBaseRootSurface::DrawFocusRect(int nSurfaceCID,
HXxSize *pSurfaceSize,
UCHAR *pVidMem,
CHXBaseSite* pSite)
{
// Draw the focus for this site
HXBitmapInfoHeader info;
memset(&info, 0, sizeof(info));
#ifdef _WIN32
BITMAPINFO bmiInfo;
memset(&bmiInfo, 0, sizeof(bmiInfo));
MakeBitmap(&bmiInfo, sizeof(info), nSurfaceCID,
pSurfaceSize->cx, pSurfaceSize->cy, NULL, 0);
info = *((HXBitmapInfoHeader*)&bmiInfo.bmiHeader);
#else
HXBitmapInfo bmiInfo;
memset(&bmiInfo, 0, sizeof(bmiInfo));
MakeBitmap(&bmiInfo, sizeof(info), nSurfaceCID,
pSurfaceSize->cx, pSurfaceSize->cy, NULL, 0);
info = *((HXBitmapInfoHeader*)&bmiInfo.bmiHeader);
#endif
HXxRect rc = {0,0,pSurfaceSize->cx, pSurfaceSize->cy};
pSite->_DrawFocusRect(pVidMem,
&info,
&rc);
}
HX_RESULT CBaseRootSurface::Lock(UINT32 nID)
{
m_pMutex->Lock();
HX_RESULT retVal = HXR_FAIL;
switch (m_nBLTMode)
{
case HX_WINDOWLESS_DEBUG:
retVal = HXR_OK;
break;
case HX_WINDOWLESS_MINIMAL:
retVal = MinimalLock();
break;
}
if (HXR_OK != retVal)
{
m_pMutex->Unlock();
}
return retVal;
}
HX_RESULT CBaseRootSurface::Unlock(UINT32 nID, HXxWindow* pWindow, CHXBaseSite* pSite)
{
HX_RESULT retVal = HXR_FAIL;
m_pUnlockingSite = pSite;
switch (m_nBLTMode)
{
case HX_WINDOWLESS_DEBUG:
retVal = HXR_OK;
break;
case HX_WINDOWLESS_MINIMAL:
retVal = MinimalUnlock(pWindow);
break;
}
m_pUnlockingSite = NULL;
m_pMutex->Unlock();
return retVal;
}
HX_RESULT CBaseRootSurface::MinimalUnlock(HXxWindow* pWindow)
{
// XXXAH yeah I know this sucks, but the call is ALL OS services.
HX_RESULT retVal = HXR_OK;
retVal = _MinimalUnlock(pWindow);
// m_pCompositionSurface = 0;
// m_nCompositionPitch = 0;
return retVal;
}
HX_RESULT CBaseRootSurface::MinimalLock()
{
HX_RESULT retVal = HXR_FAIL;
HXxSize size;
memcpy(&size, &m_pSite->m_size, sizeof(HXxSize)); /* Flawfinder: ignore */
if (HXR_OK == SizeChanged())
{
if (HXR_OK == _LockComposition(&m_pCompositionSurface, &m_nCompositionPitch))
{
m_boundsRect.left = 65536;
m_boundsRect.top = 65536;
m_boundsRect.right = 0;
m_boundsRect.bottom = 0;
retVal = HXR_OK;
while(m_pBltRects.GetCount())
{
HXxRect* pRect = (HXxRect*) m_pBltRects.RemoveHead();
HX_DELETE(pRect);
}
HX_ASSERT(m_pCompositionSurface);
}
}
return retVal;
}
void CBaseRootSurface::ModifyBoundsRect(HXxRect* pRect)
{
if (pRect->left < m_boundsRect.left)
{
m_boundsRect.left = pRect->left;
}
if (pRect->top < m_boundsRect.top)
{
m_boundsRect.top = pRect->top;
}
if (pRect->right > m_boundsRect.right)
{
m_boundsRect.right= pRect->right;
}
if (pRect->bottom > m_boundsRect.bottom)
{
m_boundsRect.bottom= pRect->bottom;
}
HXxRect* pTempRect = new HXxRect();
*pTempRect = *pRect;
m_pBltRects.AddHead(pTempRect);
}
HX_RESULT CBaseRootSurface::SizeChanged()
{
m_pMutex->Lock();
m_pCompMutex->Lock();
HX_RESULT retVal = HXR_FAIL;
HX_ASSERT(m_pSite);
memcpy(&m_compositionSize, &m_pSite->m_size, sizeof(HXxSize)); /* Flawfinder: ignore */
if (!m_bCompositionSurfaceCreated ||
(m_compositionSize.cx > m_allocatedCompositionSize.cx ||
m_compositionSize.cy > m_allocatedCompositionSize.cy)
)
{
if(HXR_OK == _DestroyCompositionSurface())
{
if(HXR_OK == _CreateCompositionSurface())
{
retVal = HXR_OK;
}
}
}
else
{
retVal = HXR_OK;
}
m_pCompMutex->Unlock();
m_pMutex->Unlock();
return retVal;
}
void CBaseRootSurface::LockCompMutex()
{
if( m_pCompMutex)
m_pCompMutex->Lock();
}
void CBaseRootSurface::UnlockCompMutex()
{
if(m_pCompMutex)
m_pCompMutex->Unlock();
}
void CBaseRootSurface::DestroySurfaces()
{
m_pCompMutex->Lock();
_DestroyCompositionSurface();
m_pCompMutex->Unlock();
}
void CBaseRootSurface::ReInitSurfaces()
{
m_pCompMutex->Lock();
if(HXR_OK == _DestroyCompositionSurface())
{
_CreateCompositionSurface();
}
m_pCompMutex->Unlock();
}
void CBaseRootSurface::FillBorders()
{
_FillBorders();
}
void CBaseRootSurface::SetBltLock(BOOL bSet)
{
//XXXgfw what does this do???? It just returns on windows????
}
BOOL CBaseRootSurface::IsCompositionEnabled()
{
return m_bCompositionSurfaceCreated;
}
STDMETHODIMP CBaseRootSurface::BeginOptimizedBlt(HXBitmapInfoHeader* pBitmapInfo)
{
#ifdef _DEBUG
fprintf( stderr, "CBaseRootSurface::BeginOptimizedBlt needs to be written...\n" );
#endif
return HXR_NOTIMPL;
}
BOOL CBaseRootSurface::_OptimizedSurfaceOpened()
{
return TRUE;
}
STDMETHODIMP CBaseRootSurface::OptimizedBlt( UCHAR* pImageBits,
REF(HXxRect) rDestRect,
REF(HXxRect) rSrcRect)
{
#ifdef _DEBUG
fprintf( stderr, "CBaseRootSurface::OptimizedBlt needs to be written...\n" );
#endif
return HXR_NOTIMPL;
}
STDMETHODIMP CBaseRootSurface::EndOptimizedBlt(void)
{
#ifdef _DEBUG
fprintf( stderr, "CBaseRootSurface::EndOptimizedBlt needs to be written...\n" );
#endif
return HXR_NOTIMPL;
}
STDMETHODIMP CBaseRootSurface::GetOptimizedFormat(REF(HX_COMPRESSION_TYPE) ulType)
{
#ifdef _DEBUG
fprintf( stderr, "CBaseRootSurface::GetOptimizedFormat needs to be written...\n" );
#endif
return HXR_NOTIMPL;
}
STDMETHODIMP CBaseRootSurface::GetPreferredFormat(REF(HX_COMPRESSION_TYPE) ulType)
{
#ifdef _DEBUG
fprintf( stderr, "CBaseRootSurface::GetPreferredFormat needs to be written...\n" );
#endif
return HXR_NOTIMPL;
}
void CBaseRootSurface::SetResolution( int x, int y, int depth, void* pWindow)
{
HX_ASSERT( "Must override"==NULL );
}
void CBaseRootSurface::GetDisplayModes( CModesDesc* pModesDesc, INT32* nNumModes )
{
HX_ASSERT( "Must override"==NULL );
}
BOOL CBaseRootSurface::_RectOnNthMonitor(HXxRect rect, UINT32 uMonitor, HXxRect& intersectRect)
{
// until multiple monitor support exists, simply return the original rect.
// Override, if appropriate, in the platform-specific code.
intersectRect = rect;
return TRUE;
}
BOOL CBaseRootSurface::_IsHardwareAccelerationAvail()
{
return FALSE;
}
BOOL CBaseRootSurface::_AcquireHardwareAcceleration()
{
return FALSE;
}
BOOL CBaseRootSurface::_LoseHardwareAcceleration()
{
return FALSE;
}
BOOL CBaseRootSurface::_EnableHardwareAcceleration()
{
return FALSE;
}
BOOL CBaseRootSurface::_DisableHardwareAcceleration()
{
return FALSE;
}
#ifdef _WINDOWS
IHXPlayer* CBaseRootSurface::GetPlayer()
{
if (!m_pPlayer)
{
IHXClientEngineMapper* pCleng = NULL;
m_pContext->QueryInterface(IID_IHXClientEngineMapper, (void**)&pCleng);
if (pCleng)
{
IUnknown* pUnknown = NULL;
if (HXR_OK != pCleng->GetPlayerBySite(m_pSite, pUnknown))
{
// check our children
CHXMapPtrToPtr::Iterator i = m_pSite->m_ChildrenMap.Begin();
for ( ; i != m_pSite->m_ChildrenMap.End(); ++i)
{
CHXBaseSite* pSite = (CHXBaseSite*) *i;
if (HXR_OK == pCleng->GetPlayerBySite(pSite, pUnknown))
break;
}
}
if (pUnknown)
{
pUnknown->QueryInterface(IID_IHXPlayer, (void**)&m_pPlayer);
HX_RELEASE(pUnknown);
}
}
}
return m_pPlayer;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -