⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basesurf.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    }    if( ( m_pucLastImage &&          !m_pSite->_BordersActive() &&          !m_pSite->_FadeTransitionActive()  &&          !m_pSite->_TakesPartInAlphaChain() &&          (              m_pSite->m_AlphaBlendNotifiers.GetCount() == 0 &&              m_pSite->m_AlphaBlendSites.GetCount() == 0 ||              (IsYUV(nCID) && _IsDisplaySurfaceYuv())              )          )        )    {        //We don't need the allocated buffer. Delete it.        HX_FREE(m_pucLastImage);    }    //Save the image data. This is where all the alpha blending    //will take place.    if( m_pucLastImage &&        ( m_pSite->m_AlphaBlendNotifiers.GetCount()!=0 ||          CID_ARGB32==nCID ||          m_pSite->_BordersActive() || m_pSite->_FadeTransitionActive()          )        )    {        //Stretch or shrink, if nessecary, to make the the image        //the same size as our site. If we dont' we will get        //alpha blending artifacts...#ifdef _WINDOWS        zm_pColorAcc->SetPlayer(m_pSite->m_pRootSurface->GetPlayer());#endif        BOOL bConverter = zm_pColorAcc->CheckColorConverter(nCID, CID_ARGB32);        m_pSite->ColorConverterRequest(nCID, CID_ARGB32, bConverter);        if (bConverter )        {            int cx = m_bmiLastImage.biWidth;            int cy = m_bmiLastImage.biHeight;            int pitchIn  = GETBITMAPPITCH( pBitmapInfo );            int pitchOut = GETBITMAPPITCH( &m_bmiLastImage );            zm_pColorAcc->ColorConvert(CID_ARGB32,                                       m_pucLastImage,                                       cx, cy,                                       pitchOut,                                       rDestRect.left,  rDestRect.top,                                       rDestRect.right-rDestRect.left,                                       rDestRect.bottom-rDestRect.top,                                       nCID,                                       pImageData,                                       pBitmapInfo->biWidth,                                       pBitmapInfo->biHeight,                                       pitchIn,                                       rSrcRect.left,  rSrcRect.top,                                       rSrcRect.right-rSrcRect.left,                                       rSrcRect.bottom-rSrcRect.top                                       );        }        else        {#ifdef _DEBUG            fprintf( stderr, "Can't get color converter!\n" );#endif        }        bDoAlpha=TRUE;        //MOVE        if( !IsYUV(nCID) )            rSrcRect = rDestRect;    }    if(m_pSite->_BordersActive())    {        DrawTransitionBorders(&m_bmiLastImage,                              m_pSite->m_nTransitionBorderWidth,                              m_pSite->m_ulTransitionBorderColor,                              m_pSite->m_bTransitionBlendBorder                              );        bDoAlpha = TRUE;    }    //Do we even care about alpha blening ourselves?    if( ( nCID==CID_ARGB32 ||          m_pSite->_BlendedBordersActive() ||          m_pSite->_FadeTransitionActive() ) &&        m_pSite->GetParentSite() )    {        //Alphablend against all of our regions.        for( i=m_pSite->m_AlphaBlendSites.Begin() ;             i!=m_pSite->m_AlphaBlendSites.End()  ;             ++i)        {            CHXBaseSite* pSite = (CHXBaseSite*) i.get_key();            HXREGION* pRegion = (HXREGION*)*i;            //We need to intersect this region with the rect that we            //are actually blt'ing. SubRect support.            HXxRect TmpRect = rDestRect;            TmpRect.left   += m_pSite->m_topleft.x;            TmpRect.right  += m_pSite->m_topleft.x;            TmpRect.top    += m_pSite->m_topleft.y;            TmpRect.bottom += m_pSite->m_topleft.y;            HXREGION* pInter  = HXCreateRectRegion( TmpRect.left,                                                    TmpRect.top,                                                    TmpRect.right-TmpRect.left,                                                    TmpRect.bottom-TmpRect.top                                                    );            HXIntersectRegion( pInter, pRegion, pInter );            CBaseSurface* pTmp = pSite->m_pVideoSurface;            if( pTmp->m_pucLastImage &&                !(IsYUV(GETBITMAPCOLOR(&pTmp->m_bmiLastImage)) && pTmp->_IsDisplaySurfaceYuv())                )            {                _AlphaBlend( pInter,                             pSite->m_pVideoSurface->m_pucLastImage,                             &(pSite->m_pVideoSurface->m_bmiLastImage),                             &(pSite->m_topleft),                             m_pucLastImage,                             &m_bmiLastImage,                             &(m_pSite->m_topleft)                             );            }            HXDestroyRegion( pInter );        }        bDoAlpha = TRUE;    }    //For optimized YUV alphablending.  Create a YUVA image here, if    //we have a YUV site that we blend against, and then down-scale    //and color convert to YUVA. The YUV render's call to Blt() will    //grab this and alphablend against us.    //Clean up the old ones..    i = m_YUVAImageList.Begin();    while(i != m_YUVAImageList.End())    {        Image* pImage = (Image*)*i;        HX_DELETE(pImage->pucImage);        HX_DELETE(pImage);        ++i;    }    m_YUVAImageList.RemoveAll();    BOOL bHaveYUVBlender = FALSE;    for( i=m_pSite->m_AlphaBlendSites.Begin() ;         i!=m_pSite->m_AlphaBlendSites.End() ;         ++i)    {        //CHXBaseSite* pSite = (CHXBaseSite*) i.get_key();        CHXBaseSite* pSite = NULL;        //Do a recursive search for YUV surfaces below us.        CHXBaseSite* pSiteOrig = (CHXBaseSite*)i.get_key();        pSite = _SearchForYUV( pSiteOrig );        if( pSite && pSite->m_pVideoSurface )        {            int nCID2 = GETBITMAPCOLOR(&(pSite->m_pVideoSurface->m_bmiLastBlt));            if( IsYUV(nCID2) && pSite->m_pVideoSurface->_IsDisplaySurfaceYuv())            {                //Create a YUVA buffer to hold the last frame.                Image* pImage = new Image;                memset( pImage, 0, sizeof( Image) );                //Color convert to scaled YUVA into image struct.                double scaleX = pSite->m_pVideoSurface->m_scaleFactorX/m_scaleFactorX;                double scaleY = pSite->m_pVideoSurface->m_scaleFactorY/m_scaleFactorY;                int nSizeX = (int)(((double)(m_bmiLastImage.biWidth))/scaleX+.5);                int nSizeY = (int)(((double)(m_bmiLastImage.biHeight))/scaleY+.5);                //Fix non mod quad sizes                nSizeX = (nSizeX+3)&~3;                nSizeY = (nSizeY+1)&~1;                UCHAR*              pucDownscaledRGB = NULL;                HXBitmapInfoHeader bmiDownscaledRGB;                memset( &bmiDownscaledRGB, 0, sizeof( bmiDownscaledRGB ) );#ifdef _WIN32                MakeBitmap( (LPBITMAPINFO)&(pImage->bmiImage),                            sizeof(pImage->bmiImage),                            CID_YUVA,                            nSizeX,                            nSizeY,                            NULL,                            0);                MakeBitmap( (LPBITMAPINFO)&bmiDownscaledRGB,                            sizeof(bmiDownscaledRGB),                            CID_ARGB32,                            nSizeX,                            nSizeY,                            NULL,                            0);#else                MakeBitmap( (HXBitmapInfo*)&(pImage->bmiImage),                            sizeof(pImage->bmiImage),                            CID_YUVA,                            nSizeX,                            nSizeY,                            NULL,                            0);                MakeBitmap( (HXBitmapInfo*)&bmiDownscaledRGB,                            sizeof(bmiDownscaledRGB),                            CID_ARGB32,                            nSizeX,                            nSizeY,                            NULL,                            0);#endif                //Alloc it.                pImage->pucImage = new UCHAR[pImage->bmiImage.biSizeImage];                pucDownscaledRGB = new UCHAR[bmiDownscaledRGB.biSizeImage];                //downscale the ARGB first....                int ik = 0;                UCHAR*               pBits = pImageData;                HXBitmapInfoHeader* pBIS  = pBitmapInfo;                if( IsYUV(nCID) && bDoAlpha )                {                    pBits = m_pucLastImage;                    pBIS  = &m_bmiLastImage;                }                BOOL bConverter = zm_pColorAcc->CheckColorConverter(CID_ARGB32, CID_ARGB32);                pSite->ColorConverterRequest(CID_ARGB32, CID_ARGB32, bConverter);                if (bConverter)                {                    ik = zm_pColorAcc->ColorConvert(                        CID_ARGB32,                        pucDownscaledRGB,                        bmiDownscaledRGB.biWidth,                        bmiDownscaledRGB.biHeight,                        GETBITMAPPITCH(&bmiDownscaledRGB),                        0,                        0,                        nSizeX,                        nSizeY,                        CID_ARGB32,                        pBits,                        pBIS->biWidth,                        pBIS->biHeight,                        GETBITMAPPITCH(pBIS),                        0,                        0,                        pBitmapInfo->biWidth,                        pBitmapInfo->biHeight                        );                }                HX_ASSERT(ik==0);                //We must apply any fade transitions here......                BOOL  bFade=FALSE;                int   completeness = 0;                if( (m_pSite->m_fpTransitionEffect == Crossfade ||                     m_pSite->m_fpTransitionEffect == FadeToColor ||                     m_pSite->m_fpTransitionEffect == FadeFromColor )                    && m_pSite->m_nTransitionState!=1000 )                {                    completeness = m_pSite->m_nTransitionState;                    if(m_pSite->m_bTransitionReversed)                    {                        completeness = 1000 - completeness;                    }                    if( m_pSite->m_fpTransitionEffect== FadeFromColor)                    {                        completeness = 1000 - completeness;                    }                    //Map [0,1000] --> [0,1024] for fixed point fade math.                    completeness = (int)((float)completeness*1024.0/1000.0);                    bFade=TRUE;                    if( bFade )                    {                        int alpha     = 0;                        int alphasave = 0;                        ULONG32* pTmp = (ULONG32*)pucDownscaledRGB;                        for( UINT32 i=0 ; i< bmiDownscaledRGB.biSizeImage/4; i++, pTmp++ )                        {                            if( m_pSite->m_fpTransitionEffect == Crossfade )                            {                                //fixed point version of (comp/1000 * alpha )                                alpha = (*pTmp & 0xff000000)>>24;                                alpha = ((completeness*(255-alpha)+512))>>10;                                alphasave = (255-alpha)<<24;                                *pTmp = (*pTmp&0x00ffffff) | alphasave;                            }                            else if( m_pSite->m_fpTransitionEffect == FadeToColor ||                                     m_pSite->m_fpTransitionEffect == FadeFromColor)                            {                                //Not only affect alpha but also fading to color.                                alpha = (completeness*255+512)>>10;                                UINT32 fadeColor = (m_pSite->m_ulTransitionFadeColor&0x00ffffff)|(alpha<<24);                                int pTmpAlpha = (*pTmp&0xff000000)>>24;                                int newalpha = (((0xff-alpha)*pTmpAlpha)>>8)<<24;                                *pTmp = newalpha |                                    (((alpha*( (fadeColor&0x00ff0000)-(*pTmp&0x00ff0000))+((*pTmp&0x00ff0000)<<8))>>8)&0x00ff0000)|                                    (((alpha*( (fadeColor&0x0000ff00)-(*pTmp&0x0000ff00))+((*pTmp&0x0000ff00)<<8))>>8)&0x0000ff00)|                                    (((alpha*( (fadeColor&0x000000ff)-(*pTmp&0x000000ff))+((*pTmp&0x000000ff)<<8))>>8)&0x000000ff);                            }                        }                    }                }                //Color convert downscaled ARGB to YUVA                bConverter = zm_pColorAcc->CheckColorConverter(CID_ARGB32, CID_YUVA);                pSite->ColorConverterRequest(CID_ARGB32, CID_YUVA, bConverter);                if( bConverter )                    ik = zm_pColorAcc->ColorConvert(                        CID_YUVA,                        pImage->pucImage,                        pImage->bmiImage.biWidth,                        pImage->bmiImage.biHeight,                        GETBITMAPPITCH(&pImage->bmiImage),                        0,                        0,                        nSizeX,                        nSizeY,                        CID_ARGB32,                        pucDownscaledRGB,                        bmiDownscaledRGB.biWidth,                        bmiDownscaledRGB.biHeight,                        GETBITMAPPITCH(&bmiDownscaledRGB),                        0,                        0,                        bmiDownscaledRGB.biWidth,                        bmiDownscaledRGB.biHeight                        );                HX_ASSERT( ik==0 );                HX_VECTOR_DELETE( pucDownscaledRGB );                //Add into YUVA image map for this site.                m_pSite->_TLSLock();                m_YUVAImageList.SetAt( pSiteOrig, pImage );                pSiteOrig->m_pVideoSurface->m_bYUVBlending = TRUE;                m_pSite->_TLSUnlock();                //Remove the region from the overlapping ARGB surface                //so it doesn't blt any more unless it changes.                HXREGION* pRegion = (HXREGION*)*i;                //Wow, recursive YUV blending is not fun. If we are on                //top of an ARGB image and it is on top of a YUV image                //then we need subtract only that 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -