📄 pxrend.cpp
字号:
HX_RESULT rv = m_pWireFormatManager->GetDefaultURL(pDefaultURLStr); if (SUCCEEDED(rv)) { // Give it to the hyperlink manager retVal = m_pHyperlinkManager->SetDefaultLink((const char*) pDefaultURLStr->GetBuffer()); } HX_RELEASE(pDefaultURLStr); } } } } } } } } else { retVal = HXR_UNEXPECTED; } return retVal;}HX_RESULT CRealPixRenderer::SetupCodecsAndFXPackages(){ HX_RESULT retVal = HXR_OK; IHXBuffer* pStr = NULL; BOOL bUpgrade = FALSE; if (m_pWireFormatManager && m_pCodecManager) { // Check for any missing codecs HX_RESULT rv = m_pWireFormatManager->GetFirstCodecMime(&pStr); while (SUCCEEDED(rv)) { BOOL bPresent = FALSE; retVal = m_pCodecManager->IsComponentPresent((const char*) pStr->GetBuffer(), &bPresent); if (SUCCEEDED(retVal)) { if (bPresent) { // A codec is required which we DO have - so inform the // codec manager that this codec is active retVal = m_pCodecManager->SetActiveComponent((const char*) pStr->GetBuffer()); } else { // A codec is required which is not present, so add that // mime to the upgrade list retVal = AddMimeToUpgradeCollection((const char*) pStr->GetBuffer()); if (SUCCEEDED(retVal)) { bUpgrade = TRUE; } } } if (FAILED(retVal)) { break; } HX_RELEASE(pStr); rv = m_pWireFormatManager->GetNextCodecMime(&pStr); } // Now check for any missing effects packages if (SUCCEEDED(retVal)) { HX_RELEASE(pStr); rv = m_pWireFormatManager->GetFirstFXPackageMime(&pStr); while (SUCCEEDED(rv)) { BOOL bPresent = FALSE; retVal = m_pEffectsPackageManager->IsComponentPresent((const char*) pStr->GetBuffer(), &bPresent); if (SUCCEEDED(retVal)) { if (bPresent) { // A codec is required which we DO have - so inform the // codec manager that this codec is active retVal = m_pEffectsPackageManager->SetActiveComponent((const char*) pStr->GetBuffer()); } else { // A codec is required which is not present, so add that // mime to the upgrade list retVal = AddMimeToUpgradeCollection((const char*) pStr->GetBuffer()); if (SUCCEEDED(retVal)) { // Set flag that we need to upgrade bUpgrade = TRUE; } } } if (FAILED(retVal)) { break; } HX_RELEASE(pStr); rv = m_pWireFormatManager->GetNextFXPackageMime(&pStr); } // Now we can tell the codec and package managers to release // any codecs and packages which are not going to be used // in this presentation. if (SUCCEEDED(retVal)) { retVal = m_pCodecManager->ReleaseInactiveComponents(); if (SUCCEEDED(retVal)) { retVal = m_pEffectsPackageManager->ReleaseInactiveComponents(); } } } } else { retVal = HXR_UNEXPECTED; } HX_RELEASE(pStr); // If we determined we needed to upgrade, then we should fail if (SUCCEEDED(retVal) && bUpgrade) { retVal = HXR_FAIL; } return retVal;}HX_RESULT CRealPixRenderer::UpdateDisplay(UINT32 ulTime){ HX_RESULT retVal = HXR_OK; UINT32 ulTime1 = HX_GET_TICKCOUNT(); UINT32 ulDeltaTime = ulTime1 - m_ulLastDrawTime; if (ulDeltaTime >= m_ulPerformanceAdjustedDelay) { // Save this time m_ulLastDrawTime = ulTime1; // Just pass the time sync off to the effects manager retVal = m_pEffectsManager->OnTimeSync(ulTime); if (SUCCEEDED(retVal)) { // Now we need to see if we damaged the display, // and if so, call IHXSite::ForceRedraw() if (m_pEffectsManager->IsDisplayDamaged()) { // Set the flag saying we forced this redraw m_pEffectsManager->SetRedrawForced(TRUE); // Get the size of the display HXxSize cSize = {0, 0}; cSize.cx = (INT32) m_pWireFormatManager->GetDisplayWidth(); cSize.cy = (INT32) m_pWireFormatManager->GetDisplayHeight(); // Are we able to really blt subrects to the site? HXxRect cDamageRect = {0, 0, 0, 0}; if (m_bBltSubRects) { // Get the damage rect from the effects manager m_pEffectsManager->GetDamageRect(cDamageRect); // Get the size of the site HXxSize cSiteSize = {0, 0}; m_pSite->GetSize(cSiteSize); // Do we need to scale the damage rect? if (cSize.cx > 0 && cSize.cy > 0 && (cSiteSize.cx != cSize.cx || cSiteSize.cy != cSize.cy)) { cDamageRect.left = cDamageRect.left * cSiteSize.cx / cSize.cx; cDamageRect.top = cDamageRect.top * cSiteSize.cy / cSize.cy; cDamageRect.right = cDamageRect.right * cSiteSize.cx / cSize.cx; cDamageRect.bottom = cDamageRect.bottom * cSiteSize.cy / cSize.cy; } } else { // No, the site doesn't support bltting subrects // so just damage the whole display cDamageRect.right = cSize.cx; cDamageRect.bottom = cSize.cy; } // Damage the site MLOG_BLT(m_pErrorMessages, "%lu CRealPixRenderer::UpdateDisplay(%lu) " "damaging (%ld,%ld,%ld,%ld) (%ld x %ld)\n", HX_GET_BETTERTICKCOUNT(), ulTime, cDamageRect.left, cDamageRect.top, cDamageRect.right, cDamageRect.bottom, HXxRECT_WIDTH(cDamageRect), HXxRECT_HEIGHT(cDamageRect)); m_pSite->DamageRect(cDamageRect); // Force a redraw m_pSite->ForceRedraw(); } } // Find out how long this draw took UINT32 ulTime2 = HX_GET_TICKCOUNT(); ulDeltaTime = ulTime2 - ulTime1; // Recalculate the delay, never letting it be more than 1000 ms m_ulPerformanceAdjustedDelay = ulDeltaTime * m_ulPerformanceScale; m_ulPerformanceAdjustedDelay = PXMIN(1000, m_ulPerformanceAdjustedDelay); } return retVal;}BOOL CRealPixRenderer::IsStreamLive(){ BOOL bRet = FALSE; if (m_pStream) { IHXStreamSource* pStreamSource = NULL; HX_RESULT retVal = m_pStream->GetSource(pStreamSource); if (SUCCEEDED(retVal)) { bRet = pStreamSource->IsLive(); } HX_RELEASE(pStreamSource); } return bRet;}HX_RESULT CRealPixRenderer::RMASurfaceUpdate2(IHXSubRectVideoSurface* pSurface, HXxRect* pExtents, HXxBoxRegion* pDirtyRegion){ MLOG_BLT(m_pErrorMessages, "%lu CRealPixRenderer::RMASurfaceUpdate2() this=0x%08x\n", HX_GET_BETTERTICKCOUNT(), this); HX_RESULT retVal = HXR_FAIL; if (pSurface && pDirtyRegion && m_pSite && m_pImageManager) { // Get the size of the site HXxSize cSiteSize = {0, 0}; m_pSite->GetSize(cSiteSize); if (cSiteSize.cx != 0 && cSiteSize.cy != 0) { // Get the display image PXImage* pDisplay = NULL; retVal = m_pImageManager->GetDisplayImage(&pDisplay); if (SUCCEEDED(retVal)) { // Get the size of the display image HXxSize cImgSize = {0, 0}; cImgSize.cx = (INT32) pDisplay->GetWidth(); cImgSize.cy = (INT32) pDisplay->GetHeight(); // Scale dirty rects. float fx = (float) cImgSize.cx / (float) cSiteSize.cx; float fy = (float) cImgSize.cy / (float) cSiteSize.cy; // Go through each rect in the dirty region and scale it to // generate the src rects. HXBOX* pSrcRects = new HXBOX[pDirtyRegion->numRects]; if (pSrcRects) { INT32 i = 0; for(i = 0; i < pDirtyRegion->numRects; i++) { pSrcRects[i].x1 = (float) pDirtyRegion->rects[i].x1*fx+.5; pSrcRects[i].x2 = (float) pDirtyRegion->rects[i].x2*fx+.5; pSrcRects[i].y1 = (float) pDirtyRegion->rects[i].y1*fy+.5; pSrcRects[i].y2 = (float) pDirtyRegion->rects[i].y2*fy+.5; } // Set up Src region. HXxBoxRegion srcRegion; srcRegion.numRects = pDirtyRegion->numRects; srcRegion.rects = pSrcRects; // Set the values in the bitmap info header HXBitmapInfoHeader cHeader; cHeader.biSize = 40; cHeader.biWidth = cImgSize.cx; cHeader.biHeight = cImgSize.cy; cHeader.biPlanes = 1; cHeader.biBitCount = 32; cHeader.biCompression = HX_RGB; cHeader.biSizeImage = 0; cHeader.biXPelsPerMeter = 0; cHeader.biYPelsPerMeter = 0; cHeader.biClrUsed = 0; cHeader.biClrImportant = 0; cHeader.rcolor = 0; cHeader.gcolor = 0; cHeader.bcolor = 0; // Get the image store IHXBuffer* pBuffer = NULL; retVal = pDisplay->GetImageStore(&pBuffer); if (pBuffer) { MLOG_BLT(m_pErrorMessages, " numRects=%ld\n", srcRegion.numRects); for (i = 0; i < srcRegion.numRects; i++) { MLOG_BLT(m_pErrorMessages, " rect[%ld] = (%d,%d,%d,%d)\n", i, srcRegion.rects[i].x1, srcRegion.rects[i].y1, srcRegion.rects[i].x2, srcRegion.rects[i].y2); } // Blit to the video surface pSurface->BltSubRects(pBuffer->GetBuffer(), &cHeader, pDirtyRegion, &srcRegion, 1.0/fx, 1.0/fy); } HX_RELEASE(pBuffer); } HX_VECTOR_DELETE(pSrcRects); } HX_RELEASE(pDisplay); } } return retVal;}void CRealPixRenderer::_AttachSite(){ if (m_pSite) { // Lets subscribe to the sub rect messages, HX_SURFACE_UPDATE2. IHXSubRectSite* pSubRectSite = NULL; m_pSite->QueryInterface(IID_IHXSubRectSite, (void**) &pSubRectSite); if(pSubRectSite) { //If so, since IHXSubRectSite inheirits from IHXSite, lets //just swap the pointers and sign up for the service. HX_RELEASE(m_pSite); m_pSite = pSubRectSite; pSubRectSite->SendSubRectMessages(TRUE); // Set the flag m_bBltSubRects = TRUE; } }}STDMETHODIMP CRealPixRenderer::GetName(REF(const char*) rpszName){ rpszName = m_pszName; return HXR_OK;}STDMETHODIMP CRealPixRenderer::GetDescription(REF(const char*) rpszDescription){ rpszDescription = m_pszDescription; return HXR_OK;}STDMETHODIMP CRealPixRenderer::GetMimeTypes(REF(const char**) rppszMimeType){ rppszMimeType = m_ppszMimeType; return HXR_OK;}STDMETHODIMP_(UINT32) CRealPixRenderer::GetPluginVersion(){ return TARVER_ULONG32_VERSION;}STDMETHODIMP_(UINT32) CRealPixRenderer::GetHighestSupportedContentVersion(){ return HX_ENCODE_PROD_VERSION(1, 4, 0, 0);}STDMETHODIMP_(UINT32) CRealPixRenderer::GetHighestSupportedStreamVersion(){ return HX_ENCODE_PROD_VERSION(1, 4, 0, 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -