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

📄 sitewatc.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    {        return m_lRefCount;    }    delete this;    return 0;}STDMETHODIMP CSmilSiteWatcher::AttachSite(IHXSite* pSite){    HX_RESULT retVal = HXR_OK;    HX_RELEASE(m_pSite);    m_pSite = pSite;    if(m_pSite)    {        m_pSite->AddRef();    }    return retVal;}STDMETHODIMP CSmilSiteWatcher::DetachSite(){    HX_RESULT retVal = HXR_OK;    HX_RELEASE(m_pSite);    return HXR_OK;}STDMETHODIMP CSmilSiteWatcher::ChangingPosition(HXxPoint      oldPos,                                                REF(HXxPoint) newPos){    HX_RESULT retVal = HXR_OK;    if(!m_bChangingSize)    {        CSmilBasicRegion* pRegion = m_pDoc->getRegionByID(m_id);        if(pRegion && m_bMediaSizeSet)        {            // Pick the rect to use as the parent. If we             // have a ResizeBehavior of Zoom and are indeed            // zooming, then use the unzoomed parent width.            // Otherwise, use the regular zoomed parent width.            HXxRect cRect = pRegion->m_rect;            if ((m_dZoomScaleFactorX != 1.0 ||                 m_dZoomScaleFactorY != 1.0) &&                m_eResizeBehavior == ResizeZoom)            {                cRect = pRegion->m_RectNoZoom;            }            // First we need to compute the subregion rect. We can't            // do this just once, since the subregion rect parameters            // may be getting animated.            HXxRect cSubRegionRect = {0, 0, 0, 0};            CSmilBasicRegion::resolveDimension(m_Rect.m_dLeft,  m_Rect.m_eLeftType,                                               m_Rect.m_dRight, m_Rect.m_eRightType,                                               m_Rect.m_dWidth, m_Rect.m_eWidthType,                                               TRUE, HXxRECT_WIDTH(cRect),                                               cSubRegionRect.left,                                               cSubRegionRect.right);            CSmilBasicRegion::resolveDimension(m_Rect.m_dTop,    m_Rect.m_eTopType,                                               m_Rect.m_dBottom, m_Rect.m_eBottomType,                                               m_Rect.m_dHeight, m_Rect.m_eHeightType,                                               TRUE, HXxRECT_HEIGHT(cRect),                                               cSubRegionRect.top,                                               cSubRegionRect.bottom);            // The calculation above was done in the space of the            // region. The calculations below are done in the space            // of the region's parent, so we need to offset the subregion            // rect by the region's upper left corner.            cSubRegionRect.left   += cRect.left;            cSubRegionRect.top    += cRect.top;            cSubRegionRect.right  += cRect.left;            cSubRegionRect.bottom += cRect.top;            // Now we need to compute the absolute coordinates            // of the regPoint. Since the regPoint could be in            // percentage values, and the size of the region            // could be changing under animation, then we             // must recompute the absolute coordinates of the            // regPoint every time. This regPoint is in the            // space of the region's PARENT and not in the space            // of the region's rect itself.            HXxPoint cRegPoint = {0, 0};            m_pDoc->computeRegPoint(cSubRegionRect,                                    m_RegPoint,                                    cRegPoint);            // Now that we know the absolute coordinates            // of the regPoint, then we can compute the             // media layout within the region rect. Note            // that the following calculation takes place            // in the coordinate space of the region's PARENT,            // and not the region's rect itself.            HXxRect  cMediaRect = {0, 0, 0, 0};            retVal = m_pDoc->computeMediaLayout(cSubRegionRect,                                                m_eFit,                                                cRegPoint,                                                m_RegPoint.m_eRegAlign,                                                m_MediaSize,                                                cMediaRect,                                                m_bMediaIsBrush);            if (SUCCEEDED(retVal))            {                // Now since the calculation of the media size was                // done in the space of the region's PARENT, then                // and we need to set the size of the media in the                // coordinate space of the REGION, then we need                // to translate the media rect to the coordinate                // space of the region.                cMediaRect.left   -= cRect.left;                cMediaRect.top    -= cRect.top;                cMediaRect.right  -= cRect.left;                cMediaRect.bottom -= cRect.top;                // Now we can assign the new position                newPos.x = cMediaRect.left;                newPos.y = cMediaRect.top;                // If we have a resize behavior of Zoom, then                // we compute everything off of the original root-layout                // size, and then simply scale by the zoom factors.                if ((m_dZoomScaleFactorX != 1.0 ||                     m_dZoomScaleFactorY != 1.0) &&                    m_eResizeBehavior == ResizeZoom)                {                    newPos.x = (INT32) floor(m_dZoomScaleFactorX * ((double) newPos.x) + 0.5);                    newPos.y = (INT32) floor(m_dZoomScaleFactorY * ((double) newPos.y) + 0.5);                }            }        }    }    MLOG_LAYOUT(NULL,                "%lu\tChangingPosition((%ld,%ld),(%ld,%ld)) m_id=%s m_SourceID=%s\n",                HX_GET_BETTERTICKCOUNT(),                oldPos.x, oldPos.y, newPos.x, newPos.y,                (const char*) m_id,                (const char*) m_SourceID);    return retVal;}STDMETHODIMP CSmilSiteWatcher::ChangingSize(HXxSize      oldSize,                                            REF(HXxSize) newSize){    HX_RESULT retVal = HXR_OK;    if(!m_bChangingSize &&       (newSize.cx != 0 || newSize.cy != 0))    {        CSmilBasicRegion* pRegion = m_pDoc->getRegionByID(m_id);        if(pRegion)        {            // For almost all renderers, here's the sequence of            // events: the core calls them with IHXSite::AttachSite()            // and in that call, they call IHXSite::SetSize() with            // the native size of their media. Therefore, we will assume            // that the first call we get will be the native size of            // the media.            BOOL bForceSetPosition = FALSE;                        BOOL bHasSiteUser = FALSE;            IHXSiteUser* pUser = NULL;            m_pSite->GetUser(pUser);            if (pUser)            {                bHasSiteUser = TRUE;            }            HX_RELEASE(pUser);                        if (bHasSiteUser && m_bFirstSizeChange)            {                MLOG_LAYOUT(NULL,                            "Media size for %s is (%ld,%ld)\n",                            (const char*) m_SourceID,                            newSize.cx, newSize.cy);                // Save off the native media size                m_MediaSize        = newSize;                m_bMediaSizeSet    = TRUE;                m_bFirstSizeChange = FALSE;                bForceSetPosition  = TRUE;                if (m_pDoc)                {                    m_pDoc->setMediaNativeSize(m_SourceID, newSize);                }                // XXXMEH - this is legacy, which saves                // the media size into the region. However,                // this SHOULD NOT be used, since multiple media                // can play to the same region. TODO - if we                 // can, make sure this is not used and then                // delete it from the region object.                pRegion->m_originalMediaSize = newSize;                pRegion->m_bMediaSizeSet     = TRUE;            }            // Pick the rect to use as the parent. If we             // have a ResizeBehavior of Zoom and are indeed            // zooming, then use the unzoomed parent width.            // Otherwise, use the regular zoomed parent width.            HXxRect cRect = pRegion->m_rect;            if ((m_dZoomScaleFactorX != 1.0 ||                 m_dZoomScaleFactorY != 1.0) &&                m_eResizeBehavior == ResizeZoom)            {                cRect = pRegion->m_RectNoZoom;            }            // First we need to compute the subregion rect. We can't            // do this just once, since the subregion rect parameters            // may be getting animated.            HXxRect cSubRegionRect = {0, 0, 0, 0};            CSmilBasicRegion::resolveDimension(m_Rect.m_dLeft,  m_Rect.m_eLeftType,                                               m_Rect.m_dRight, m_Rect.m_eRightType,                                               m_Rect.m_dWidth, m_Rect.m_eWidthType,                                               TRUE, HXxRECT_WIDTH(cRect),                                               cSubRegionRect.left,                                               cSubRegionRect.right);            CSmilBasicRegion::resolveDimension(m_Rect.m_dTop,    m_Rect.m_eTopType,                                               m_Rect.m_dBottom, m_Rect.m_eBottomType,                                               m_Rect.m_dHeight, m_Rect.m_eHeightType,                                               TRUE, HXxRECT_HEIGHT(cRect),                                               cSubRegionRect.top,                                               cSubRegionRect.bottom);            // The calculation above was done in the space of the            // region. The calculations below are done in the space            // of the region's parent, so we need to offset the subregion            // rect by the region's upper left corner.            cSubRegionRect.left   += cRect.left;            cSubRegionRect.top    += cRect.top;            cSubRegionRect.right  += cRect.left;            cSubRegionRect.bottom += cRect.top;            // Now we need to compute the absolute coordinates            // of the regPoint. Since the regPoint could be in            // percentage values, and the size of the region            // could be changing under animation, then we             // must recompute the absolute coordinates of the            // regPoint every time. This regPoint is in the            // space of the region's PARENT and not in the space            // of the region's rect itself.            HXxPoint cRegPoint = {0, 0};            m_pDoc->computeRegPoint(cSubRegionRect,                                    m_RegPoint,                                    cRegPoint);            // Now that we know the absolute coordinates            // of the regPoint, then we can compute the             // media layout within the region rect. Note            // that the following calculation takes place            // in the coordinate space of the region's PARENT,            // and not the region's rect itself.            HXxRect  cMediaRect = {0, 0, 0, 0};            retVal = m_pDoc->computeMediaLayout(cSubRegionRect,                                                m_eFit,                                                cRegPoint,                                                m_RegPoint.m_eRegAlign,                                                m_MediaSize,                                                cMediaRect,                                                m_bMediaIsBrush);            if (SUCCEEDED(retVal))            {                // Now since the calculation of the media size was                // done in the space of the region's PARENT, then                // and we need to set the size of the media in the                // coordinate space of the REGION, then we need                // to translate the media rect to the coordinate                // space of the region.                cMediaRect.left   -= cRect.left;                cMediaRect.top    -= cRect.top;                cMediaRect.right  -= cRect.left;                cMediaRect.bottom -= cRect.top;                // So now the new width and height                // can be calculated.                newSize.cx = HXxRECT_WIDTH(cMediaRect);                newSize.cy = HXxRECT_HEIGHT(cMediaRect);                // If we have a resize behavior of Zoom, then                // we compute everything off of the original root-layout                // size, and then simply scale by the zoom factors.                if ((m_dZoomScaleFactorX != 1.0 ||                     m_dZoomScaleFactorY != 1.0) &&                    m_eResizeBehavior == ResizeZoom)                {                    newSize.cx = (INT32) floor(m_dZoomScaleFactorX * ((double) newSize.cx) + 0.5);                    newSize.cy = (INT32) floor(m_dZoomScaleFactorY * ((double) newSize.cy) + 0.5);                }                // Set the current media size to this value                // XXXMEH - TODO is this actually used anywhere? We                // should not really have a media size set into                // the region object anywhere, since multiple                // media can play to the same region                pRegion->m_mediaSize = newSize;                // As mentioned above, the renderers will usually                 // call IHXSite::SetSize() when they are FIRST called                // with IHXSite::AttachSite(). However, since renderers                // don't have an idea of relative position to other renderers,                // then they rarely call IHXSite::SetPosition(). Therefore,                // if this is the first time through, we will need to explicitly                // call IHXSite::SetPosition().                if (bForceSetPosition)                {                    // Since we have a site watcher, then it                    // doesn't matter what we pass in, the site                    // watcher will change it to what it needs to                    // be. So pass in some arbitrary position.                    HXxPoint cPos = {1, 1};                    if (m_pSite)                    {                        m_pSite->SetPosition(cPos);                    }                }                // If this is a scrolling site, then set the flag                if (m_eFit == FitScroll && m_pSite)                {                    IHXValues* pValues = NULL;                    m_pSite->QueryInterface(IID_IHXValues, (void**) &pValues);                    if (pValues)                    {                        pValues->SetPropertyULONG32("ScrollingSite", 1);                    }                    HX_RELEASE(pValues);                }            }        }    }    MLOG_LAYOUT(NULL,                "%lu\tChangingSize((%ld,%ld),(%ld,%ld)) m_id=%s m_SourceID=%s\n",                HX_GET_BETTERTICKCOUNT(),                oldSize.cx, oldSize.cy, newSize.cx, newSize.cy,                (const char*) m_id,                (const char*) m_SourceID);    return retVal;}

⌨️ 快捷键说明

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