smldoc.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:673k
- }
- }
- void CSmilDocumentRenderer::queueRegionForRecompute(CSmilBasicRegion* pRegion)
- {
- if (pRegion && m_pAnimRegionRecomputeMap)
- {
- m_pAnimRegionRecomputeMap->SetAt((void*) pRegion, (void*) pRegion);
- }
- }
- void CSmilDocumentRenderer::removePendingAnimationRedraw(IHXSite* pSite)
- {
- if (pSite && m_pAnimSiteRedrawMap)
- {
- // XXXMEH - TODO - right now, if we have done a SetSize()
- // or SetPostion() on a site, then we remove any pending
- // ForceRedraw() on that site. However, both SetSize and
- // SetPosition() force redraws on other sites as well,
- // like the parent and siblings. We should optimize those
- // out as well, but we need a reliable way of determining
- // if those sites are going to get redrawn.
- m_pAnimSiteRedrawMap->RemoveKey((void*) pSite);
- }
- }
- void CSmilDocumentRenderer::turnSiteCompositionModeON()
- {
- MLOG_ANIM(m_pErrorMessages,"turnSiteCompositionModeON()tm_ulCurrentTime=%luttick=%lun",
- m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- IHXSiteComposition* pSiteComp = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteComposition, (void**) &pSiteComp);
- if (pSiteComp)
- {
- pSiteComp->SetCompositionMode(TRUE);
- }
- HX_RELEASE(pSiteComp);
- }
- }
- void CSmilDocumentRenderer::turnSiteCompositionModeOFF()
- {
- MLOG_ANIM(m_pErrorMessages,"turnSiteCompositionModeOFF()tm_ulCurrentTime=%luttick=%lun",
- m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- IHXSiteComposition* pSiteComp = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteComposition, (void**) &pSiteComp);
- if (pSiteComp)
- {
- pSiteComp->SetCompositionMode(FALSE);
- }
- HX_RELEASE(pSiteComp);
- }
- }
- void CSmilDocumentRenderer::lockSiteComposition()
- {
- MLOG_ANIM(m_pErrorMessages,"lockSiteComposition()tm_ulCurrentTime=%luttick=%lun",
- m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- IHXSiteComposition* pSiteComp = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteComposition, (void**) &pSiteComp);
- if (pSiteComp)
- {
- pSiteComp->LockComposition();
- }
- HX_RELEASE(pSiteComp);
- }
- }
- void CSmilDocumentRenderer::unlockSiteComposition()
- {
- MLOG_ANIM(m_pErrorMessages,"unlockSiteComposition()tm_ulCurrentTime=%luttick=%lun",
- m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- IHXSiteComposition* pSiteComp = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteComposition, (void**) &pSiteComp);
- if (pSiteComp)
- {
- pSiteComp->UnlockComposition();
- }
- HX_RELEASE(pSiteComp);
- }
- }
- void CSmilDocumentRenderer::bltSiteComposition()
- {
- MLOG_ANIM(m_pErrorMessages,"bltSiteComposition()tm_ulCurrentTime=%luttick=%lun",
- m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- IHXSiteComposition* pSiteComp = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteComposition, (void**) &pSiteComp);
- if (pSiteComp)
- {
- pSiteComp->BltComposition();
- }
- HX_RELEASE(pSiteComp);
- }
- }
- BOOL CSmilDocumentRenderer::isSiteCompositionLocked()
- {
- BOOL bRet = FALSE;
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- IHXSiteComposition* pSiteComp = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteComposition, (void**) &pSiteComp);
- if (pSiteComp)
- {
- bRet = pSiteComp->IsCompositionLocked();
- }
- HX_RELEASE(pSiteComp);
- }
- return bRet;
- }
- BOOL CSmilDocumentRenderer::isSiteCompositionModeON()
- {
- BOOL bRet = FALSE;
- if (m_pRootLayout && m_pRootLayout->m_pSite)
- {
- IHXSiteComposition* pSiteComp = NULL;
- m_pRootLayout->m_pSite->QueryInterface(IID_IHXSiteComposition, (void**) &pSiteComp);
- if (pSiteComp)
- {
- bRet = pSiteComp->IsCompositionMode();
- }
- HX_RELEASE(pSiteComp);
- }
- return bRet;
- }
- void CSmilDocumentRenderer::GoToURLWithParamCheck(const char* pszURL,
- const char* pszTarget,
- const char* pszSendTo,
- IHXHyperNavigate* pHyper,
- CSmilElement* pElement,
- IUnknown* pContext,
- BOOL bUserInvoked,
- BOOL bHint)
- {
- if (pszURL && pHyper && pElement && pContext)
- {
- // Are there any <rn:param> children of
- // this <area> tag?
- BOOL bHasParamChildren = hasParamChildren(pElement, FALSE);
- IHXCommonClassFactory* pFact = NULL;
- pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) &pFact);
- if (pFact)
- {
- IHXValues* pParams = NULL;
- pFact->CreateInstance(CLSID_IHXValues, (void**) &pParams);
- if (pParams)
- {
- if (bHasParamChildren)
- {
- // Add the name/value pairs from all
- // <rn:param> children to the IHXValues
- addParamProperties(pElement, pParams, pContext, FALSE);
- }
- // /Add the sendTo value, if there is one:
- if (pszSendTo)
- {
- addStringProperty(pParams, pContext, "sendTo", pszSendTo);
- }
- // /Fixes open-outside-of-media-pane version of PR 84160:
- pParams->SetPropertyULONG32("AutoActivated",
- (ULONG32)(!bUserInvoked));
- if (bHint)
- {
- // Add "begin" parameter
- pParams->SetPropertyULONG32("begin", pElement->m_ulDelay);
- // QI for IHXHyperNavigateHint
- IHXHyperNavigateHint* pHint = NULL;
- pHyper->QueryInterface(IID_IHXHyperNavigateHint, (void**) &pHint);
- if (pHint)
- {
- // Now call IHXHyperNavigateHint::Hint()
- pHint->Hint(pszURL, pszTarget, pParams);
- }
- HX_RELEASE(pHint);
- }
- else
- {
- // QI for IHXHyperNavigate2
- IHXHyperNavigate2* pNav2 = NULL;
- pHyper->QueryInterface(IID_IHXHyperNavigate2, (void**) &pNav2);
- if (pNav2)
- {
- // Now call IHXHyperNavigate2::Execute()
- pNav2->Execute(pszURL, pszTarget, NULL, NULL, pParams);
- }
- else
- {
- // We couldn't get IHXHyperNavigate2, so
- // just use IHXHyperNavigate.
- pHyper->GoToURL(pszURL, pszTarget);
- }
- HX_RELEASE(pNav2);
- }
- }
- HX_RELEASE(pParams);
- }
- HX_RELEASE(pFact);
- }
- }
- UINT16 CSmilDocumentRenderer::getCurrentGroup()
- {
- UINT16 usRet = 0;
- if (m_pParent)
- {
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- if (pPlayer)
- {
- IHXGroupManager* pGroupManager = NULL;
- pPlayer->QueryInterface(IID_IHXGroupManager, (void**) &pGroupManager);
- if (pGroupManager)
- {
- pGroupManager->GetCurrentGroup(usRet);
- }
- HX_RELEASE(pGroupManager);
- }
- }
- return usRet;
- }
- void CSmilDocumentRenderer::deleteExternalMediaMarkerList()
- {
- if (m_pExternalMediaMarkerList)
- {
- LISTPOSITION pos = m_pExternalMediaMarkerList->GetHeadPosition();
- while (pos)
- {
- CExternalMediaMarkerInfo* pInfo =
- (CExternalMediaMarkerInfo*) m_pExternalMediaMarkerList->GetNext(pos);
- HX_DELETE(pInfo);
- }
- m_pExternalMediaMarkerList->RemoveAll();
- HX_DELETE(m_pExternalMediaMarkerList);
- }
- }
- CExternalMediaMarkerInfo* CSmilDocumentRenderer::getExternalMediaMarkerInfo(const char* pszURL)
- {
- CExternalMediaMarkerInfo* pRet = NULL;
- if (pszURL && m_pExternalMediaMarkerList)
- {
- LISTPOSITION pos = m_pExternalMediaMarkerList->GetHeadPosition();
- while (pos)
- {
- CExternalMediaMarkerInfo* pInfo =
- (CExternalMediaMarkerInfo*) m_pExternalMediaMarkerList->GetNext(pos);
- if (pInfo &&
- (!strcmp(pInfo->m_pszAddTrackURL, pszURL) ||
- !strcmp(pInfo->m_pszRendererURL, pszURL)))
- {
- pRet = pInfo;
- break;
- }
- }
- }
- return pRet;
- }
- BOOL CSmilDocumentRenderer::isIDMappedToExternalMediaMarkerFile(CExternalMediaMarkerInfo* pInfo,
- const char* pszID)
- {
- BOOL bRet = FALSE;
- if (pInfo && pInfo->m_pIDList && pszID)
- {
- LISTPOSITION pos = pInfo->m_pIDList->GetHeadPosition();
- while (pos)
- {
- char* pID = (char*) pInfo->m_pIDList->GetNext(pos);
- if (pID && !strcmp(pID, pszID))
- {
- bRet = TRUE;
- break;
- }
- }
- }
- return bRet;
- }
- HX_RESULT
- CSmilDocumentRenderer::closeOldRenderers(BOOL bAll)
- {
- if (m_pDelayedRendererCloseList)
- {
- LISTPOSITION pos = m_pDelayedRendererCloseList->GetHeadPosition();
- while (pos)
- {
- SMILDelayedRendererClose* pClose =
- (SMILDelayedRendererClose*)m_pDelayedRendererCloseList->GetAt(pos);
- if (bAll || pClose->m_uGroup != m_uCurrentGroupIndex)
- {
- if (bAll)
- {
- // If we are not closing all, then the Site SHOULD allready be hidden.
- CSmilBasicRegion* pRegion = getRegionByID(pClose->m_pSiteInfo->m_regionID);
- IHXSite* pRegionSite = NULL;
- if (pRegion->m_eBackgroundColorType == CSS2TypeTransparent)
- {
- pRegionSite = pClose->m_pSiteInfo->m_pRegionSite;
- }
-
- showSite(pClose->m_pSiteInfo->m_pRendererSite, FALSE);
- showSite(pRegionSite, FALSE);
- }
- actualRendererClosed(pClose->m_pRenderer, pClose->m_pInfo);
- HX_RELEASE(pClose->m_pRenderer);
- HX_RELEASE(pClose->m_pInfo);
- pos = m_pDelayedRendererCloseList->RemoveAt(pos);
- HX_DELETE(pClose);
- }
- else
- {
- m_pDelayedRendererCloseList->GetNext(pos);
- }
- }
- }
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::RendererClosed(IHXRenderer* pRenderer,
- IHXValues* pInfo)
- {
- HX_RESULT ret = HXR_OK;
- UINT32 ulGroupIndex = 0;
- UINT32 ulTrackIndex = 0;
- SMILSiteInfo* pSiteInfo = NULL;
- SMILGroupInfo* pGroupInfo = NULL;
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- pInfo->GetPropertyULONG32("GroupIndex", ulGroupIndex);
- pInfo->GetPropertyULONG32("TrackIndex", ulTrackIndex);
- IHXBuffer* pBuffer = NULL;
- if (HXR_OK == pInfo->GetPropertyCString("id", pBuffer))
- {
- pPlayToAssoc = getPlayToAssocByMedia((const char*)pBuffer->GetBuffer());
- }
- HX_RELEASE(pBuffer);
- if (!pPlayToAssoc)
- {
- // XXX HP we shouldn't be here
- HX_ASSERT(FALSE);
- pPlayToAssoc = getPlayToAssoc((UINT16)ulGroupIndex, (UINT16)ulTrackIndex);
- }
- // RemoveTrack() has been called on this track
- if (pPlayToAssoc && pPlayToAssoc->m_bRemovePending)
- {
- ret = actualRendererClosed(pRenderer, pInfo);
- }
- else if (m_pSiteInfoByRendererMap &&
- m_pSiteInfoByRendererMap->Lookup(pRenderer, (void*&)pSiteInfo))
- {
- if (!pSiteInfo->m_bNoRegion &&
- m_pGroupInfoMap &&
- m_pGroupInfoMap->Lookup(ulGroupIndex, (void*&)pGroupInfo))
- {
- // check to see if this site ended at the end of this group,
- // if it did, we will delay actually closing the renderer
- // until after the next group is started... That way we can
- // keep a site arround if there is a transition...
- if (pSiteInfo->m_ulDuration == pGroupInfo->m_ulDuration)
- {
- SMILDelayedRendererClose* pClose = new SMILDelayedRendererClose;
- if (pClose)
- {
- pClose->m_uGroup = (UINT16)ulGroupIndex;
- pClose->m_pRenderer = pRenderer;
- pClose->m_pRenderer->AddRef();
- pClose->m_pInfo = pInfo;
- pClose->m_pInfo->AddRef();
- pClose->m_pSiteInfo = pSiteInfo;
- if (!m_pDelayedRendererCloseList)
- {
- m_pDelayedRendererCloseList = new CHXSimpleList;
- }
- if (m_pDelayedRendererCloseList)
- {
- m_pDelayedRendererCloseList->AddTail(pClose);
- }
- else
- {
- ret = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- ret = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- ret = actualRendererClosed(pRenderer, pInfo);
- }
- }
- else
- {
- // if there is no group info, just close the renderer.
- ret = actualRendererClosed(pRenderer, pInfo);
- }
- }
- else
- {
- // if there is no site info, just close the renderer.
- ret = actualRendererClosed(pRenderer, pInfo);
- }
- return ret;
- }
- HX_RESULT
- CSmilDocumentRenderer::actualRendererClosed(IHXRenderer* pRenderer,
- IHXValues* pInfo)
- {
- UINT32 ulGroupIndex = 0;
- UINT32 ulTrackIndex = 0;
- UINT32 ulStreamNumber = 0;
- CHXSimpleList* pRendererList = NULL;
- SMILSiteInfo* pSiteInfo = NULL;
- SMILPlayToAssoc* pPlayToAssoc = NULL;
- pInfo->GetPropertyULONG32("GroupIndex", ulGroupIndex);
- pInfo->GetPropertyULONG32("TrackIndex", ulTrackIndex);
- pInfo->GetPropertyULONG32("StreamNumber", ulStreamNumber);
- if (m_pPlayToAssocList)
- {
- IHXBuffer* pBuffer = NULL;
- if (HXR_OK == pInfo->GetPropertyCString("id", pBuffer))
- {
- pPlayToAssoc = getPlayToAssocByMedia((const char*)pBuffer->GetBuffer());
- }
- HX_RELEASE(pBuffer);
- if (!pPlayToAssoc)
- {
- // XXX HP we shouldn't be here
- HX_ASSERT(FALSE);
- pPlayToAssoc = getPlayToAssoc((UINT16)ulGroupIndex, (UINT16)ulTrackIndex);
- }
- if (pPlayToAssoc)
- {
- pPlayToAssoc->m_sourceMap.Lookup(ulStreamNumber, (void*&) pRendererList);
- // Remove any event sinks set up on this renderer
- addRemoveEventSink((const char*) pPlayToAssoc->m_id, FALSE);
- // Remove this renderer from the map
- removeRendererFromMap((const char*) pPlayToAssoc->m_id);
- }
- }
- //{FILE* f1 = ::fopen("c:\temp\out.txt", "a+"); ::fprintf(f1, "RendererClosed pRenderer=%lun", pRenderer);::fclose(f1);}
- if (m_pSiteInfoByRendererMap &&
- m_pSiteInfoByRendererMap->Lookup(pRenderer, (void*&) pSiteInfo))
- {
- RemoveEvents(ulGroupIndex, pSiteInfo->m_pRendererSite);
-
- m_pSiteInfoByRendererMap->RemoveKey((void*)pRenderer);
- CSmilBasicRegion* pRegion = getRegionByID(pSiteInfo->m_regionID);
- IHXSite* pRegionSite = NULL;
- if (pRegion && pRegion->m_eBackgroundColorType == CSS2TypeTransparent)
- {
- pRegionSite = pSiteInfo->m_pRegionSite;
- }
- #ifdef XXX_HIDE_SITES_ON_CLOSE
- showSite(pSiteInfo->m_pRendererSite, FALSE);
- // we only want to hide the region if there is no more
- // renderer site shares the same region
- if (!pRendererList || pRendererList->GetCount() == 1)
- {
- IHXSite* pRegionSite = NULL;
- if (!pRegion->m_bBgColorSet)
- {
- pRegionSite = pSiteInfo->m_pRegionSite;
- }
- showSite(pRegionSite, FALSE);
- }
- #endif
- // Hide the site, since we're about to blow
- // it away anyway.
- showSite(pSiteInfo->m_pRendererSite, FALSE);
- m_pSiteMgr->RemoveSite(pSiteInfo->m_pRendererSite);
- pSiteInfo->m_pRendererSite->DetachWatcher();
- // Get the site watcher from the site watcher map
- if (m_pSiteWatcherMap)
- {
- void* pVoid = NULL;
- if (m_pSiteWatcherMap->Lookup((void*) pSiteInfo->m_pRendererSite, pVoid) &&
- pVoid)
- {
- // Get the CSmilSiteWatcher pointer
- CSmilSiteWatcher* pWatcher = (CSmilSiteWatcher*) pVoid;
- // Remove the site watcher from the site watcher map
- m_pSiteWatcherMap->RemoveKey((void*) pSiteInfo->m_pRendererSite);
- // Remove the site watcher from the map
- if (pPlayToAssoc)
- {
- removeRendererSiteWatcherFromMap((const char*) pPlayToAssoc->m_id);
- }
- // Release our ref on the site watcher
- HX_RELEASE(pWatcher);
- }
- }
- if(pRegion &&
- pRegion->m_pSite)
- {
- pRegion->m_pSite->DestroyChild(pSiteInfo->m_pRendererSite);
- }
- //XXXgfw this is too fix PR56050. This release deletes the
- //site but a pointer is left to it in m_pChildRendererSiteList
- //This list is iterated through inside of resetRendererSites
- //and SetSize is called a site that doesn't exist.
- //
- //So, this is my fix without knowing much about this code. :-)
- if( pRegion && pSiteInfo )
- {
- pRegion->removeRendererSiteChild(pSiteInfo->m_pRendererSite);
- }
- // Remove the site from the map
- if (pPlayToAssoc)
- {
- removeRendererSiteFromMap((const char*) pPlayToAssoc->m_id);
- }
-
- HX_RELEASE(pSiteInfo->m_pRendererSite);
- // remove the site info struct from m_pSiteInfoList
- // but *don't* delete it yet - we will do that down
- // at the bottom of this method
- removeSiteInfo(pSiteInfo);
- }
- if (pPlayToAssoc)
- {
- LISTPOSITION pos;
- SMILSourceInfo* pSMILSourceInfo = NULL;
- if (pRendererList)
- {
- CHXSimpleList::Iterator i = pRendererList->Begin();
- for (; i != pRendererList->End(); ++i)
- {
- pSMILSourceInfo = (SMILSourceInfo*) (*i);
-
- if (pSMILSourceInfo->m_pRenderer == pRenderer)
- {
- pos = pRendererList->Find(pSMILSourceInfo);
- pRendererList->RemoveAt(pos);
-
- if (pSMILSourceInfo->m_pRendererEventHook)
- {
- // get to the site manager and set an event hook
- IHXEventHookMgr* pHookMgr = NULL;
- if(HXR_OK == m_pSiteMgr->QueryInterface(IID_IHXEventHookMgr,
- (void**)&pHookMgr))
- {
- pHookMgr->RemoveHook(pSMILSourceInfo->m_pRendererEventHook,
- pSMILSourceInfo->m_pRendererEventHook->GetChannelName(), 0);
- }
- pHookMgr->Release();
- }
-
- HX_RELEASE(pSMILSourceInfo->m_pRendererEventHook);
- HX_RELEASE(pSMILSourceInfo->m_pStream);
- HX_RELEASE(pSMILSourceInfo->m_pRenderer);
- HX_DELETE(pSMILSourceInfo);
- break;
- }
- }
- if (pRendererList->GetCount())
- {
- pSMILSourceInfo = (SMILSourceInfo*)pRendererList->GetHead();
-
- pPlayToAssoc->m_tunerName = pSMILSourceInfo->m_tunerName;
- pPlayToAssoc->m_childTunerName = pSMILSourceInfo->m_childTunerName;
- pPlayToAssoc->m_ulDelay = pSMILSourceInfo->m_ulDelay;
- pPlayToAssoc->m_ulDuration = pSMILSourceInfo->m_ulDuration;
- pPlayToAssoc->m_pRendererEventHook = pSMILSourceInfo->m_pRendererEventHook;
- }
- }
- if (pPlayToAssoc->m_pSiteInfoList->GetCount() > 0 &&
- pSiteInfo)
- {
- pos = pPlayToAssoc->m_pSiteInfoList->Find(pSiteInfo);
- if (pos)
- {
- pPlayToAssoc->m_pSiteInfoList->RemoveAt(pos);
- }
- HX_DELETE(pSiteInfo);
- }
- }
- return HXR_OK;
- }
- HX_RESULT CSmilDocumentRenderer::addSiteForRenderer(SMILPlayToAssoc* pPlayToAssoc,
- SMILSourceInfo* pSMILSourceInfo,
- IHXRenderer* pRenderer,
- BOOL bNoRegion)
- {
- HX_RESULT retVal = HXR_OK;
- if (m_pRootLayout)
- {
- // We need to decide whether this renderer is playing to
- // a single region (where the <ref>'s "region" attribute
- // is a <region> id) or multiple regions (where the <ref>'s
- // "region" attribute is a <region> regionName)
- //
- // Try to get a region by regionID
- CSmilBasicRegion* pRegion = getRegionByID(pPlayToAssoc->m_playTo);
- if (pRegion)
- {
- // We got a region by region id, so use that
- retVal = addSiteForRendererByRegion(pPlayToAssoc, pSMILSourceInfo,
- pRenderer, bNoRegion, pRegion);
- }
- else
- {
- // We couldn't get a region by region id, so try
- // and get regions by regionName
- pRegion = getFirstRegionByName(pPlayToAssoc->m_playTo);
- while (pRegion && SUCCEEDED(retVal))
- {
- // We got a region by region id, so use that
- retVal = addSiteForRendererByRegion(pPlayToAssoc, pSMILSourceInfo,
- pRenderer, bNoRegion, pRegion);
- if (SUCCEEDED(retVal))
- {
- pRegion = getNextRegionByName(pPlayToAssoc->m_playTo);
- }
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::addSiteForRendererByRegion(SMILPlayToAssoc* pPlayToAssoc,
- SMILSourceInfo* pSMILSourceInfo,
- IHXRenderer* pRenderer,
- BOOL bNoRegion,
- CSmilBasicRegion* pRegion)
- {
- HX_RESULT retVal = HXR_OK;
- if(pPlayToAssoc && pSMILSourceInfo &&
- pRenderer && pRegion && pRegion->m_pSite &&
- m_pSiteMgr)
- {
- // First create a child of the region site
- IHXSite* pRendererSite = NULL;
- retVal = pRegion->m_pSite->CreateChild(pRendererSite);
- if (SUCCEEDED(retVal))
- {
- // Now decide if we need to show the renderer site
- if(pSMILSourceInfo->m_ulDelay > 0)
- {
- // show site after m_ulDelay
- showSite(pRendererSite, FALSE);
- }
- else
- {
- // show it now, don't wait for first time sync
- // unless there is a begin transition, this prevents
- // the site from being shown and then clipped back.
- if (pPlayToAssoc->m_beginTransition.GetLength() == 0)
- {
- // There is no transition, so show everything
- showSite(pRegion->m_pSite, TRUE);
- showSite(pRendererSite, TRUE);
- }
- else
- {
- // There IS a transition, so make the
- // renderer site invisible. This should stop the
- // flashing we see at the beginning of
- // crossfades.
- showSite(pRendererSite, FALSE);
- }
- }
- // Put this site into this region's list
- // of child renderer sites
- pRegion->addRendererSiteChild(pRendererSite);
- // Add to the media id to site map
- addRendererSiteToMap((const char*) pPlayToAssoc->m_id,
- pRendererSite);
- // Now create a site watcher for this renderer site
- CSmilSiteWatcher* pRendererWatch = new CSmilSiteWatcher(this,
- pRegion->m_region,
- TRUE,
- pPlayToAssoc->m_id);
- if (pRendererWatch)
- {
- // AddRef the watcher
- pRendererWatch->AddRef();
- // Get the top-level box
- CSmilBasicBox* pTopBox = getTopLevelBox(pRegion);
- if (pTopBox &&
- pTopBox->m_eResizeBehavior == ResizeZoom &&
- !m_bDoNotZoom)
- {
- // Initialize the watcher with the current zoom factor. This
- // is important if the player STARTS up in some other zoom
- // mode besides original size.
- pRendererWatch->SetZoomScaleFactors(pRegion->m_dZoomScaleFactorX,
- pRegion->m_dZoomScaleFactorY);
- // Set the resize behavior
- pRendererWatch->SetResizeBehavior(pTopBox->m_eResizeBehavior);
- }
- // Attach the watcher to the renderer site
- retVal = pRendererSite->AttachWatcher(pRendererWatch);
- if (SUCCEEDED(retVal))
- {
- // Create the site watcher map if necessary
- if (!m_pSiteWatcherMap)
- {
- m_pSiteWatcherMap = new CHXMapPtrToPtr();
- }
- if (m_pSiteWatcherMap)
- {
- // Add the site watcher to the site watcher map
- m_pSiteWatcherMap->SetAt((void*) pRendererSite,
- (void*) pRendererWatch);
- // Add to the media id to site watcher map
- addRendererSiteWatcherToMap((const char*) pPlayToAssoc->m_id,
- pRendererWatch);
- // /We need to set the "sensitivity" of the renderer
- // site (see SMIL 2.0 Interop Media test #3.1):
- if (pPlayToAssoc->m_id.GetLength() > 0 && m_pSmilParser)
- {
- CSmilElement* pElement = m_pSmilParser->findElement(pPlayToAssoc->m_id);
- HX_ASSERT(pElement);
- ULONG32 ulSensitivityStrLen = 0;
- if (pElement &&
- pElement->m_sensitivityToMouseEvents.GetLength() > 0)
- {
- setSiteProperty(pRendererSite,
- "sensitivity",
- (const char*) pElement->m_sensitivityToMouseEvents);
- }
- }
- // Set "channel" in the site's properties
- retVal = setSiteProperty(pRendererSite,
- "channel",
- pSMILSourceInfo->m_childTunerName);
- if (SUCCEEDED(retVal))
- {
- // setSiteProperty(pRendererSite,
- // "playto",
- // pSMILSourceInfo->m_childTunerName);
- // Add the site to the site manager
- retVal = m_pSiteMgr->AddSite(pRendererSite);
- if (SUCCEEDED(retVal))
- {
- // Check the showBackground property on the region. If it is
- // "always", then go ahead and show the site. If not, we'll
- // hide it and let the show event show it
- if (pRegion->m_pSmilRegion &&
- pRegion->m_pSmilRegion->m_eShowBackground == ShowBackgroundWhenActive)
- {
- // showBackground is "whenActive", so we hide
- // the site.
- showSite(pRegion->m_pSite, FALSE);
- }
- else
- {
- // showBackground is "always", so we force the
- // site to be shown
- showSite(pRegion->m_pSite, TRUE);
- }
- // in any case, stick the event on the list...
- UINT32 ulShowTime = pSMILSourceInfo->m_ulDelay;
- CSmilShowSiteEvent* pShowEvent =
- new CSmilShowSiteEvent(pPlayToAssoc->m_uGroupIndex,
- ulShowTime,
- pRendererSite,
- pRegion->m_pSite,
- TRUE,
- FALSE,
- this,
- pPlayToAssoc->m_id,
- pRegion->m_region,
- pRegion->m_eShowBackground);
- insertEvent(pShowEvent);
- // Compute the time at which to remove the element. Here
- // we take fill behavior into account.
- UINT32 ulRemoveTime = 0;
- HX_RESULT rv = m_pSmilParser->computeRemoveTime((const char*) pPlayToAssoc->m_id,
- ulRemoveTime);
- if (FAILED(rv))
- {
- // We couldn't currently compute the remove
- // time, so we set it way out, assuming it will
- // get pulled back later
- ulRemoveTime = WAY_IN_THE_FUTURE;
- }
- // Get the fill behavior for this media
- FillType eFill = getMediaFillBehavior((const char*) pPlayToAssoc->m_id);
- BOOL bIgnorHide = FALSE;
- SMILGroupInfo* pGroupInfo = 0;
- if (m_pGroupInfoMap &&
- m_pGroupInfoMap->Lookup(pPlayToAssoc->m_uGroupIndex,
- (void*&)pGroupInfo))
- {
- if (pGroupInfo->m_bDurationSet)
- {
- if (pGroupInfo->m_ulDuration == ulRemoveTime &&
- eFill != FillRemove)
- {
- bIgnorHide = TRUE;
- }
- }
- }
-
- // XXXMEH - we will go ahead and schedule the hide
- // for after the duration IF we know what the duration is.
- // This would essentially be fill="remove" behavior. Later,
- // when our parent duration gets updated in handleFillTimeUpdate()
- // we will move this event forward or backwards if necessary.
- // XXXMEH - we should also check our parent's duration here.
- // If the parent has an explicit dur, then it will already be
- // resolved and may cut off the child.
- if (!pPlayToAssoc->m_bLiveSource)
- {
- CSmilShowSiteEvent* pHideEvent =
- new CSmilShowSiteEvent(pPlayToAssoc->m_uGroupIndex,
- ulRemoveTime,
- pRendererSite,
- pRegion->m_pSite,
- FALSE,
- bIgnorHide,
- this,
- pPlayToAssoc->m_id,
- pRegion->m_region,
- pRegion->m_eShowBackground);
- insertEvent(pHideEvent);
- // Set the event time into the element
- setElementRemoveTime(pPlayToAssoc->m_id, ulRemoveTime);
- }
- SMILSiteInfo* pSiteInfo = new SMILSiteInfo;
- pSiteInfo->m_pRendererSite = pRendererSite;
- pSiteInfo->m_pRegionSite = pRegion->m_pSite;
- pSiteInfo->m_uGroupIndex = pPlayToAssoc->m_uGroupIndex;
- pSiteInfo->m_ulDelay = pSMILSourceInfo->m_ulDelay;
- pSiteInfo->m_ulDuration = pSMILSourceInfo->m_ulDuration +
- pSMILSourceInfo->m_ulDelay;
- pSiteInfo->m_ulResumeTime = 0;
- pSiteInfo->m_bRemoveSite = pPlayToAssoc->m_bRemoveSite;
- pSiteInfo->m_bNoRegion = bNoRegion;
- pSiteInfo->m_regionID = pPlayToAssoc->m_playTo;
- pSiteInfo->m_pRenderer = pRenderer;
- pSiteInfo->m_ulLexicalOrder = pPlayToAssoc->m_ulLexicalOrder;
- pSiteInfo->m_MediaID = pPlayToAssoc->m_id;
- pSiteInfo->m_lZIndex = 0;
- // Look up any z-index override on the media element
- CSmilSource* pSrc = getSource(pPlayToAssoc->m_id);
- if (pSrc &&
- pSrc->m_eZIndexType != CSS2TypeAuto)
- {
- pSiteInfo->m_lZIndex = pSrc->m_lZIndex;
- }
- pPlayToAssoc->m_pSiteInfoList->AddTail(pSiteInfo);
- insertSiteInfo(pSiteInfo);
-
- m_pSiteInfoByRendererMap->SetAt(pRenderer, pSiteInfo);
-
- // If the rn:backgroundOpacity or rn:mediaOpacity attributes
- // are set, then set those properties into the site.
- if (pSrc)
- {
- if (pSrc->m_bBackgroundOpacitySpecified)
- {
- setSitePropertyULONG32(pRendererSite,
- "backgroundOpacity",
- pSrc->m_ulBackgroundOpacity);
- }
- if (pSrc->m_bMediaOpacitySpecified)
- {
- setSitePropertyULONG32(pRendererSite,
- "mediaOpacity",
- pSrc->m_ulMediaOpacity);
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
- // schedule a start transition if there is one...
- if (pPlayToAssoc->m_beginTransition.GetLength() > 0)
- {
- // Create a begin transition event
- CSmilTransitionEvent* pTransEvent = new CSmilTransitionEvent(pSMILSourceInfo->m_ulDelay,
- pPlayToAssoc,
- pSiteInfo,
- TRUE,
- this);
- // Insert this event in the event queue
- insertEvent(pTransEvent);
- }
- // schedule an end transition if there is one.
- if (pPlayToAssoc->m_endTransition.GetLength() > 0 &&
- !pPlayToAssoc->m_bLiveSource)
- {
- CSmilTransitionInfo* pTInfo = getTransition(pPlayToAssoc->m_endTransition);
- if (pTInfo)
- {
- CSmilTransitionEvent* pTransEvent =
- new CSmilTransitionEvent(pSMILSourceInfo->m_ulDelay +
- pSMILSourceInfo->m_ulDuration -
- pTInfo->m_pTrans->m_ulDuration,
- pPlayToAssoc,
- pSiteInfo,
- FALSE,
- this);
- insertEvent(pTransEvent);
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */
- }
- }
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::setSiteProperty(IHXSite* pSite,
- const char* pszKey,
- const char* pszValue)
- {
- MLOG_LAYOUT(m_pErrorMessages,
- "setSiteProperty(0x%08x,%s,%s) m_ulCurrentTime=%lu tick=%lun",
- pSite, pszKey, pszValue, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- HX_RESULT retVal = HXR_FAIL;
- if (pSite && m_pContext && pszKey && pszValue)
- {
- IHXValues* pValues = NULL;
- pSite->QueryInterface(IID_IHXValues, (void**) &pValues);
- if (pValues)
- {
- IHXCommonClassFactory* pFactory = NULL;
- m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**) &pFactory);
- if (pFactory)
- {
- IHXBuffer* pBuffer = NULL;
- pFactory->CreateInstance(CLSID_IHXBuffer, (void**) &pBuffer);
- if (pBuffer)
- {
- retVal = pBuffer->Set((const UCHAR*) pszValue,
- strlen(pszValue) + 1);
- if (SUCCEEDED(retVal))
- {
- retVal = pValues->SetPropertyCString(pszKey,
- pBuffer);
- }
- }
- HX_RELEASE(pBuffer);
- }
- HX_RELEASE(pFactory);
- }
- HX_RELEASE(pValues);
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::setSitePropertyULONG32(IHXSite* pSite,
- const char* pszKey,
- UINT32 ulValue)
- {
- MLOG_LAYOUT(m_pErrorMessages,
- "setSitePropertyULONG32(0x%08x,%s,%lu) m_ulCurrentTime=%lu tick=%lun",
- pSite, pszKey, ulValue, m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- HX_RESULT retVal = HXR_FAIL;
- if (pSite && m_pContext && pszKey)
- {
- IHXValues* pValues = NULL;
- retVal = pSite->QueryInterface(IID_IHXValues, (void**) &pValues);
- if (SUCCEEDED(retVal))
- {
- retVal = pValues->SetPropertyULONG32(pszKey, ulValue);
- }
- HX_RELEASE(pValues);
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::getSiteProperty(IHXSite* pSite,
- const char* pszKey,
- REF(IHXBuffer*) rpValueStr)
- {
- HX_RESULT retVal = HXR_FAIL;
- if (pSite && m_pContext && pszKey)
- {
- IHXValues* pValues = NULL;
- pSite->QueryInterface(IID_IHXValues, (void**) &pValues);
- if (pValues)
- {
- HX_RELEASE(rpValueStr);
- retVal = pValues->GetPropertyCString(pszKey, rpValueStr);
- }
- HX_RELEASE(pValues);
- }
- return retVal;
- }
- HX_RESULT
- CSmilDocumentRenderer::insertIntoZOrderList(CHXSimpleList* pList,
- SMILSiteInfo* pInfo)
- {
- LISTPOSITION lPos = pList->GetHeadPosition();
- LISTPOSITION lPrev = lPos;
- // /Helps fix PR 81510 (& duplicate PR 83796): use resume time instead
- // of delay if it's more recent than delay meaning it got paused and
- // needs to come to the front when it resumes (in an excl):
- ULONG32 ulNewSiteRelevantDelay = pInfo->m_ulDelay;
- if (pInfo->m_ulResumeTime > ulNewSiteRelevantDelay)
- {
- ulNewSiteRelevantDelay = pInfo->m_ulResumeTime;
- }
- BOOL bInserted = FALSE;
- while(lPos)
- {
- SMILSiteInfo* pThisInfo = (SMILSiteInfo*)pList->GetNext(lPos);
- // /Helps fix PR 81510 (& duplicate PR 83796) by using resume time
- // in case it got paused and needs to come to the front when it
- // resumes in an excl:
- ULONG32 ulThisSiteRelevantDelay = pThisInfo->m_ulDelay;
- if (pThisInfo->m_ulResumeTime > ulThisSiteRelevantDelay)
- {
- ulThisSiteRelevantDelay = pThisInfo->m_ulResumeTime;
- }
- if (pThisInfo->m_uGroupIndex != pInfo->m_uGroupIndex)
- {
- if (pThisInfo->m_uGroupIndex > pInfo->m_uGroupIndex)
- {
- pList->InsertBefore(lPrev, pInfo);
- bInserted = TRUE;
- break;
- }
- }
- else if (ulThisSiteRelevantDelay == ulNewSiteRelevantDelay &&
- pThisInfo->m_ulLexicalOrder > pInfo->m_ulLexicalOrder)
- {
- pList->InsertBefore(lPrev, pInfo);
- bInserted = TRUE;
- break;
- }
- else if (ulThisSiteRelevantDelay > ulNewSiteRelevantDelay)
- {
- pList->InsertBefore(lPrev, pInfo);
- bInserted = TRUE;
- break;
- }
- lPrev = lPos;
- }
- if(!bInserted)
- {
- // not inserted, stick it on the end of the list
- pList->AddTail(pInfo);
- }
- return HXR_OK;
- }
- HX_RESULT CSmilDocumentRenderer::setRendererZOrder(SMILSiteInfo* pSiteInfo)
- {
- HX_RESULT retVal = HXR_OK;
- if (pSiteInfo && !pSiteInfo->m_bNoRegion && m_pSiteInfoList)
- {
- if (getNumberOfChildSites(pSiteInfo->m_pRegionSite) > 1)
- {
- // Create a list of all sites that have the same
- // region as us.
- CHXSimpleList commonRegionList;
- LISTPOSITION pos = m_pSiteInfoList->GetHeadPosition();
- while (pos)
- {
- SMILSiteInfo* pInfo = (SMILSiteInfo*) m_pSiteInfoList->GetNext(pos);
- if (pInfo && pInfo->m_pRegionSite == pSiteInfo->m_pRegionSite)
- {
- insertIntoZOrderList(&commonRegionList, pInfo);
- }
- }
- // Run through and set the z-index in increasing order
- INT32 lOrder = 0;
- pos = commonRegionList.GetHeadPosition();
- while (pos)
- {
- SMILSiteInfo* pInfo = (SMILSiteInfo*) commonRegionList.GetNext(pos);
- if (pInfo)
- {
- setSiteZIndex(pInfo->m_pRendererSite, lOrder++);
- }
- }
- }
- }
- return retVal;
- }
- /*
- * IHXGroupSink methods
- */
- STDMETHODIMP
- CSmilDocumentRenderer::GroupAdded(UINT16 uGroupIndex,
- IHXGroup* pGroup)
- {
- if(!m_pGroupInfoMap)
- {
- m_pGroupInfoMap = new CHXMapLongToObj;
- }
- // save group info
- SMILGroupInfo* pGroupInfo = 0;
- if(!m_pGroupInfoMap->Lookup(uGroupIndex, (void*&)pGroupInfo))
- {
- IHXPlayer* pPlayer = m_pParent->getPlayer();
- IHXGroupManager* pMgr = 0;
- UINT32 ulTotalTracks = 0;
- UINT32 ulDuration = 0;
- if(HXR_OK == pPlayer->QueryInterface(IID_IHXGroupManager,
- (void**)&pMgr))
- {
- IHXGroup* pGroup = NULL;
- IHXGroup2* pGroup2 = NULL;
- if (HXR_OK == pMgr->GetGroup(uGroupIndex, pGroup) &&
- HXR_OK == pGroup->QueryInterface(IID_IHXGroup2, (void**)&pGroup2))
- {
- IHXValues* pGroupProperties = NULL;
- pGroup2->GetPersistentComponentProperties(m_ulPersistentComponentID,
- pGroupProperties);
- if(pGroupProperties)
- {
- pGroupProperties->GetPropertyULONG32("total_tracks",
- ulTotalTracks);
- pGroupProperties->GetPropertyULONG32("duration",
- ulDuration);
- }
- HX_RELEASE(pGroupProperties);
- }
- HX_RELEASE(pGroup2);
- HX_RELEASE(pGroup);
- }
- HX_RELEASE(pMgr);
-
- pGroupInfo = new SMILGroupInfo;
- pGroupInfo->m_nTracks = (int)ulTotalTracks;
- pGroupInfo->m_nTracksAdded = 0;
- pGroupInfo->m_nTrackDurationsSet = 0;
- pGroupInfo->m_ulDuration = ulDuration;
- // if we have an explicit duration on the source, say that
- // we have allready got all the track durations set
- if (pGroupInfo->m_ulDuration)
- {
- pGroupInfo->m_bDurationSet = TRUE;
- pGroupInfo->m_ulDuration += m_pSmilParser->m_ulPersistentComponentDelay;
- PersistentDurationSet(pGroupInfo->m_ulDuration,
- m_pSmilParser->m_ulPersistentComponentDelay,
- FALSE);
- }
- else
- {
- pGroupInfo->m_bDurationSet = FALSE;
- }
- (*m_pGroupInfoMap)[uGroupIndex] = pGroupInfo;
- }
- else
- {
- pGroupInfo->m_nTracksAdded++;
- }
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::GroupRemoved(UINT16 uGroupIndex,
- IHXGroup* pGroup)
- {
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::AllGroupsRemoved()
- {
- return HXR_NOTIMPL;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::TrackAdded(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- MLOG_SRC(m_pErrorMessages,"TrackAdded(%u,%u,0x%08x)n",
- uGroupIndex, uTrackIndex, pTrack);
- if(pTrack)
- {
- IHXBuffer* pBuf = 0;
- const char* pID = 0;
- const char* pRepeatID = 0;
- const char* pRegionName = 0;
- const char* pBeginTransition = NULL;
- const char* pEndTransition = NULL;
- UINT32 ulDelay = 0;
- if(HXR_OK == pTrack->GetPropertyCString("id", pBuf))
- {
- pID = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- if(HXR_OK == pTrack->GetPropertyCString("repeatid", pBuf))
- {
- pRepeatID = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- if(HXR_OK == pTrack->GetPropertyCString("region", pBuf))
- {
- pRegionName = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- if(HXR_OK == pTrack->GetPropertyCString("beginTransition", pBuf))
- {
- pBeginTransition = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- if(HXR_OK == pTrack->GetPropertyCString("endTransition", pBuf))
- {
- pEndTransition = (const char*)pBuf->GetBuffer();
- pBuf->Release();
- }
- // If this is an external media marker file, then
- // save the group and track index
- BOOL bXMMSource = FALSE;
- if(HXR_OK == pTrack->GetPropertyCString("ExternalMarkerFile", pBuf))
- {
- bXMMSource = TRUE;
- pBuf->Release();
- pTrack->GetPropertyCString("url", pBuf);
- CExternalMediaMarkerInfo* pInfo = getExternalMediaMarkerInfo((const char*) pBuf->GetBuffer());
- if (pInfo)
- {
- pInfo->m_usGroupIndex = uGroupIndex;
- pInfo->m_usTrackIndex = uTrackIndex;
- }
- pBuf->Release();
- }
- UINT32 num = 0;
- pTrack->GetPropertyULONG32("lexicalNum", num);
- if(HXR_OK == pTrack->GetPropertyCString("playto", pBuf))
- {
- const char* pPlayTo = (const char*)pBuf->GetBuffer();
- setPlayToAssoc(uGroupIndex, uTrackIndex, pID, pRepeatID, pPlayTo, pRegionName,
- pBeginTransition, pEndTransition, num, bXMMSource);
- pBuf->Release();
- }
- else // non-windowed renderer
- {
- setPlayToAssoc(uGroupIndex, uTrackIndex, pID, pRepeatID, 0, pRegionName,
- pBeginTransition, pEndTransition, num, bXMMSource);
- }
- SMILPlayToAssoc* pAssoc = getPlayToAssoc(uGroupIndex, uTrackIndex);
- if(pAssoc)
- {
- if (m_pSmilParser)
- {
- CSmilElement* pElement = m_pSmilParser->findElement(pID);
- if (pElement)
- {
- if (pElement->m_eActualFill == FillFreeze ||
- pElement->m_eActualFill == FillHold ||
- pElement->m_eErase == EraseNever)
- {
- pAssoc->m_bRemoveSite = FALSE;
- }
- }
-
- }
- }
- SMILGroupInfo* pGroupInfo = 0;
- if(m_pGroupInfoMap->Lookup(uGroupIndex, (void*&)pGroupInfo))
- {
- pGroupInfo->m_nTracksAdded++;
- }
- }
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::TrackRemoved(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- HX_RESULT hr = HXR_OK;
- UINT32 ulDurationPlayed = 0;
- SMILPlayToAssoc* pPlayToAssoc = getPlayToAssoc(uGroupIndex, uTrackIndex);
- if (!pPlayToAssoc)
- {
- hr = HXR_UNEXPECTED;
- goto cleanup;
- }
- HX_ASSERT(pPlayToAssoc->m_bRemovePending);
- // caculate the actual duration this track has been played
- if (uGroupIndex == m_uCurrentGroupIndex)
- {
- if (m_ulCurrentTime > pPlayToAssoc->m_ulDelay)
- {
- ulDurationPlayed = m_ulCurrentTime - pPlayToAssoc->m_ulDelay;
- }
- }
- hr = m_pSmilParser->trackRemoved(pPlayToAssoc->m_id, ulDurationPlayed);
- removeTracksPlayToAssoc(uGroupIndex, uTrackIndex);
- // process the updated sources
- if (HXR_OK == hr)
- {
- hr = handleElements();
- }
- cleanup:
- return hr;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::TrackStarted(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- if(m_bSettingFragment)
- {
- // find out if all tracks for this group have been
- // added, then go ahead and seek
- UINT16 uFragmentGroup = m_pSmilParser->getFragmentGroup(m_pFragment);
- if(uFragmentGroup == uGroupIndex)
- {
- SMILGroupInfo* pGroupInfo = 0;
- m_nFragmentTracks++;
- if(m_pGroupInfoMap->Lookup(uFragmentGroup, (void*&)pGroupInfo))
- {
- if(pGroupInfo->m_nTracks == m_nFragmentTracks)
- {
- // /Set offset here, and then call seek on the player
- // in this's OnBegin() method which is when the player
- // is fully initialized and ready to be seeked:
- BOOL bTmp = m_bFragFoundAndResolved;
- m_ulFragmentTimeOffset =
- m_pSmilParser->getFragmentOffset(m_pFragment,
- bTmp /*<--Passed by reference.*/);
- m_bFragFoundAndResolved = bTmp;
- m_bSettingFragment = FALSE;
- }
- }
- }
- }
- // /Fire off the "beginEvent" event for the associated element:
- HX_RESULT rslt = HXR_OK;
- SMILPlayToAssoc* pPlayToAssoc =
- getPlayToAssoc(uGroupIndex, uTrackIndex);
- if (pPlayToAssoc)
- {
- // /Fixes PR 79300: need to set m_bIsDeferredInExcl to FALSE now that
- // it has started playing, otherwise siblings will calculate their
- // post-deferred begins as indefinite:
- CSmilElement* pThisElement = m_pSmilParser->findElement(
- pPlayToAssoc->m_id);
- if (pThisElement && pThisElement->m_bIsDeferredInExcl)
- {
- pThisElement->m_bIsDeferredInExcl = FALSE;
- pThisElement->m_ulTimeDeferralOccurred = (UINT32)-1;
- // /Fixes PR 86103: we need to force re-compute of end time hide
- // event since the end time, during the defer period, has been
- // treated as indefinite|unresolved:
- pThisElement->checkElementFillBehavior();
- }
- rslt = m_pSmilParser->tryToResolveBeginEndEvents("beginEvent",
- (const char*)pPlayToAssoc->m_id,
- // /XXXEH- hack until core calls us at time when track media
- // actually starts playing (which is at track's delay, not
- // at group's begin); the following hack at least gets the
- // right ballpark, but subsequent real-time adjustments to
- // this track's begin time (like if it doesn't end up playing
- // at all) will result in incorrect playback in some cases:
- pPlayToAssoc->m_ulDelay +// /XXXEH <-hack:remove w/fixed core
- // /XXXEH- ...and use m_ulCurrentTime instead of 0, below:
- 0 /*m_ulCurrentTime*/);
- if SUCCEEDED(rslt)
- {
- handleElements();
- }
- }
- return rslt;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::TrackStopped(UINT16 uGroupIndex,
- UINT16 uTrackIndex,
- IHXValues* pTrack)
- {
- HX_RESULT rslt = HXR_OK;
- SMILPlayToAssoc* pPlayToAssoc =
- getPlayToAssoc(uGroupIndex, uTrackIndex);
- if (pPlayToAssoc)
- {
- rslt = m_pSmilParser->tryToResolveBeginEndEvents("endEvent",
- (const char*)pPlayToAssoc->m_id, m_ulCurrentTime);
- // /For any paused elements in an excl awaiting this element
- // finishing, we need to call this so they know they can resume:
- HX_RESULT rsltResume =
- m_pSmilParser->tryToResolveBeginEndEvents("resumeEvent",
- (const char*)pPlayToAssoc->m_id, m_ulCurrentTime);
- HX_ASSERT(HXR_OK == rsltResume);
- // /Helps fix PR 85885: for any deferred elements that were deferred
- // while another was already deferred in an excl awaiting this element
- // finishing, we need to call this so they know they can begin:
- HX_RESULT rsltUndefer =
- m_pSmilParser->tryToResolveBeginEndEvents("undeferEvent",
- (const char*)pPlayToAssoc->m_id, m_ulCurrentTime);
- HX_ASSERT(HXR_OK == rsltUndefer);
- // /This "fixes" PR 69639 (although I have no idea why it broke in
- // the first place; perhaps the core used to call TrackRemoved() and
- // now it doesn't? If so, that would explain it. If element gets
- // played all the way through, then gets re-started, a new track is
- // created and thus a new track# is assigned, so we need to remove
- // the playToAssoc so pausing of the track happens on the correct
- // one (via element-id-based lookup of track index):
- // /Setting this flag instead of removing track's playtoAssoc fixes
- // PR 69975:
- pPlayToAssoc->m_bTrackStopped = TRUE;
- if SUCCEEDED(rslt)
- {
- if (!m_pHandlePendingSchedulingCallback)
- {
- m_pHandlePendingSchedulingCallback = new HandlePendingSchedulingCallback;
- m_pHandlePendingSchedulingCallback->m_pSmilDocumentRenderer = this;
- m_pHandlePendingSchedulingCallback->AddRef();
- }
- if (m_pHandlePendingSchedulingCallback->m_bIsCallbackPending)
- {
- m_pScheduler->Remove(m_pHandlePendingSchedulingCallback->m_PendingHandle);
- }
-
- m_pHandlePendingSchedulingCallback->m_bIsCallbackPending = TRUE;
- m_pHandlePendingSchedulingCallback->m_PendingHandle =
- m_pScheduler->RelativeEnter(m_pHandlePendingSchedulingCallback, 0);
- }
- }
- return rslt;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::CurrentGroupSet(UINT16 uGroupIndex,
- IHXGroup* pGroup)
- {
- INT16 uPrevGroupIndex = m_uCurrentGroupIndex;
- m_uCurrentGroupIndex = (INT16)uGroupIndex;
- m_ulCurrentTime = 0;
- if(uPrevGroupIndex != -1)
- {
- closeOldRenderers(FALSE);
- m_pSmilParser->resetTimeline();
- removeGroupEvents(uPrevGroupIndex);
- removeActiveTransitions();
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- removeActiveAnimations();
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
-
- removeGroupsPlayToAssoc(uPrevGroupIndex);
- m_ulEventListPosition = 0;
- if(m_pStatusMessage)
- {
- m_pStatusMessage->SetStatus(NULL);
- }
- // make hide events for sites from the last Group
- addOldRendererHideEvents(uGroupIndex);
- }
- // XXXMEH - temp remove
- #if 0
- // Schedule the animate events for this group if
- // the group index is not 0. If it is 0, then these
- // events have already been scheduled in handleAnimate()
- if (m_pAnimationMap && uGroupIndex != 0)
- {
- POSITION pos = m_pAnimationMap->GetStartPosition();
- while (pos)
- {
- const char* pszKey = NULL;
- void* pVoid = NULL;
- m_pAnimationMap->GetNextAssoc(pos, pszKey, pVoid);
- if (pszKey && pVoid)
- {
- // Cast from the void*
- CSmilAnimateElement* pAnimate = (CSmilAnimateElement*) pVoid;
- // Is this animation element in the current group?
- if (pAnimate->m_pNode &&
- pAnimate->m_pNode->m_nGroup == uGroupIndex)
- {
- // We need to schedule an animate event
- CSmilAnimateEvent* pEvent = new CSmilAnimateEvent(pAnimate->m_pNode->m_nGroup,
- pAnimate->m_ulDelay,
- FALSE,
- pAnimate,
- this,
- m_pSmilParser);
- if (pEvent)
- {
- // Put the event only the timeline
- insertEvent(pEvent);
- }
- }
- }
- }
- }
- #endif
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::PrefetchTrackAdded(UINT16 uGroupIndex,
- UINT16 uPrefetchTrackId,
- IHXValues* pTrack)
- {
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::PrefetchTrackRemoved(UINT16 uGroupIndex,
- UINT16 uPrefetchTrackId,
- IHXValues* pTrack)
- {
- return HXR_OK;
- }
- STDMETHODIMP
- CSmilDocumentRenderer::PrefetchTrackDone(UINT16 uGroupIndex,
- UINT16 uPrefetchTrackId,
- HX_RESULT status)
- {
- HX_RESULT rslt = HXR_OK;
- CHXString* pId;
- HX_ASSERT(m_pPrefetchTrackElementMap);
- if (m_pPrefetchTrackElementMap &&
- m_pPrefetchTrackElementMap->Lookup(uPrefetchTrackId,
- (void*&)pId))
- {
- // /This does nothing if duration is already a valid amount.
- // Returns HXR_FAILED if resetDuration() is not called on the element.
- HX_RESULT rsltOfDurationSetting =
- m_pSmilParser->handlePrefetchFinished(*pId,
- 0==m_ulCurrentTime? 100:m_ulCurrentTime);
- if (SUCCEEDED(rsltOfDurationSetting))
- {
- handleElements();
- }
- rslt = m_pSmilParser->tryToResolveBeginEndEvents("endEvent",
- *pId, m_ulCurrentTime);
- if SUCCEEDED(rslt)
- {
- if (!m_pHandlePendingSchedulingCallback)
- {
- m_pHandlePendingSchedulingCallback = new HandlePendingSchedulingCallback;
- m_pHandlePendingSchedulingCallback->m_pSmilDocumentRenderer = this;
- m_pHandlePendingSchedulingCallback->AddRef();
- }
- if (m_pHandlePendingSchedulingCallback->m_bIsCallbackPending)
- {
- m_pScheduler->Remove(m_pHandlePendingSchedulingCallback->m_PendingHandle);
- }
-
- m_pHandlePendingSchedulingCallback->m_bIsCallbackPending = TRUE;
- m_pHandlePendingSchedulingCallback->m_PendingHandle =
- m_pScheduler->RelativeEnter(m_pHandlePendingSchedulingCallback, 0);
- }
- }
-
- return HXR_OK;
- }
- HX_RESULT
- CSmilDocumentRenderer::addOldRendererHideEvents(UINT16 uGroupIndex)
- {
- CHXSimpleList regions;
- if (m_pDelayedRendererCloseList)
- {
- CHXSimpleList::Iterator i = m_pDelayedRendererCloseList->Begin();
- for (;i != m_pDelayedRendererCloseList->End(); ++i)
- {
- SMILDelayedRendererClose* pClose = (SMILDelayedRendererClose*)(*i);
- CSmilBasicRegion* pRegion = getRegionByID(pClose->m_pSiteInfo->m_regionID);
- regions.AddTail(pRegion);
- IHXSite* pRegionSite = NULL;
- if (pRegion->m_eBackgroundColorType == CSS2TypeTransparent)
- {
- pRegionSite = pRegion->m_pSite;
- }
- CSmilShowSiteEvent* pHideEvent =
- new CSmilShowSiteEvent(uGroupIndex,
- 0,
- pClose->m_pSiteInfo->m_pRendererSite,
- pRegionSite,
- FALSE);
-
- insertEvent(pHideEvent);
- // Set the event time into the element
- setElementRemoveTime(pHideEvent->getMediaID(), pHideEvent->m_ulEventTime);
- }
- }
-
- // hide any "transparent" sites, that are not going to be hidden at
- // the start of the next presentation.
- if(m_pRegionMap)
- {
- CHXMapStringToOb::Iterator i = m_pRegionMap->Begin();
- for(; i != m_pRegionMap->End(); ++i)
- {
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*)(*i);
- if(!pRegion->m_bNested &&
- pRegion->m_eBackgroundColorType == CSS2TypeTransparent &&
- !regions.Find(pRegion))
- {
- showSite(pRegion->m_pSite, FALSE);
- }
- }
- }
- return HXR_OK;
- }
- void
- CSmilDocumentRenderer::removeGroupEvents(UINT16 uGroupIndex)
- {
- if(m_pEventList)
- {
- LISTPOSITION lPos = m_pEventList->GetHeadPosition();
- while(lPos)
- {
- // handle all events at or before ulTimeValue
- CSmilLayoutEvent* pEvent = (CSmilLayoutEvent*)m_pEventList->GetAt(lPos);
- if(pEvent->m_uGroupIndex == uGroupIndex)
- {
- delete(pEvent);
- lPos = m_pEventList->RemoveAt(lPos);
- }
- else
- {
- m_pEventList->GetNext(lPos);
- }
- }
- }
- }
- void
- CSmilDocumentRenderer::removeActiveTransitions()
- {
- if(m_pActiveTransitions)
- {
- LISTPOSITION lPos = m_pActiveTransitions->GetHeadPosition();
- while(lPos)
- {
- SMILTransitionState* pState = (SMILTransitionState*)
- m_pActiveTransitions->GetAt(lPos);
- doTransition(lPos, pState->m_ulEndTime);
- lPos = m_pActiveTransitions->RemoveAt(lPos);
- HX_DELETE(pState);
- }
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- void CSmilDocumentRenderer::removeActiveAnimations()
- {
- if(m_pActiveAnimations)
- {
- if (atLeastOneActiveAnimation(m_ulCurrentTime))
- {
- if (!isSiteCompositionModeON())
- {
- turnSiteCompositionModeON();
- }
- }
- // m_pAnimSiteRedrawMap is a list of sites
- // which need to ForceRedraw() as a result on an
- // animation on this time sync.
- if (!m_pAnimSiteRedrawMap)
- {
- m_pAnimSiteRedrawMap = new CHXMapPtrToPtr();
- }
- if (m_pAnimSiteRedrawMap)
- {
- m_pAnimSiteRedrawMap->RemoveAll();
- }
- // m_pAnimRegionRecomputeMap is a list of sites
- // which need to ForceRedraw() as a result on an
- // animation on this time sync.
- if (!m_pAnimRegionRecomputeMap)
- {
- m_pAnimRegionRecomputeMap = new CHXMapPtrToPtr();
- }
- if (m_pAnimRegionRecomputeMap)
- {
- m_pAnimRegionRecomputeMap->RemoveAll();
- }
- // m_pAnimTopLayoutMap is a collection of topLayout's
- // which have been animated programmatically and
- // need resizing.
- if (m_pAnimTopLayoutMap)
- {
- m_pAnimTopLayoutMap->RemoveAll();
- }
- // If there is a soundlevel animation going on, then
- // we need to try to grab the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Lock();
- // Clear the animate root layout flag
- m_bAnimateRootLayout = FALSE;
- LISTPOSITION lPos = m_pActiveAnimations->GetHeadPosition();
- while(lPos)
- {
- CSmilAnimateInfo* pInfo = (CSmilAnimateInfo*)
- m_pActiveAnimations->GetNext(lPos);
- // Restore the original value
- setValue(pInfo, pInfo->m_pUnder, pInfo->m_pDepend, TRUE);
- // XXXMEH - if this is a soundLevel animation, then
- // we need to turn off the animation
- if (pInfo->m_pSandwich->GetAttributeName() == kAttrNameSoundLevel)
- {
- finishSoundLevelAnimation(pInfo);
- }
- // Now we need to delete this info object
- HX_DELETE(pInfo);
- }
- m_pActiveAnimations->RemoveAll();
- // If there was a soundlevel animation going on, then
- // we can release the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Unlock();
- // Assign any new values
- // Recompute the root-layout if necessary
- if (m_bAnimateRootLayout && m_pRootLayout && m_pRootLayout->m_pRoot)
- {
- HXxSize cNewRootSize = {0, 0};
- cNewRootSize.cx = (INT32) floor(m_pRootLayout->m_pRoot->m_dWidth + 0.5);
- cNewRootSize.cy = (INT32) floor(m_pRootLayout->m_pRoot->m_dHeight + 0.5);
- SiteSizeChanged(m_pRootLayout->m_pSite, &cNewRootSize);
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- // Animate any topLayout's
- if (m_pAnimTopLayoutMap &&
- m_pAnimTopLayoutMap->GetCount() > 0)
- {
- POSITION mpos = m_pAnimTopLayoutMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimTopLayoutMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- CSmilBasicViewport* pVP = (CSmilBasicViewport*) pKey;
- if (pVP && pVP->m_pPort)
- {
- HXxSize cNewRootSize = {0, 0};
- cNewRootSize.cx = (INT32) floor(pVP->m_pPort->m_dWidth + 0.5);
- cNewRootSize.cy = (INT32) floor(pVP->m_pPort->m_dHeight + 0.5);
- SiteSizeChanged(pVP->m_pSite, &cNewRootSize);
- }
- }
- }
- // Clear the map
- m_pAnimTopLayoutMap->RemoveAll();
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- // We've collected all the regions for which
- // we need to call recomputeBoxLayout()
- if (m_pAnimRegionRecomputeMap)
- {
- POSITION mpos = m_pAnimRegionRecomputeMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimRegionRecomputeMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) pKey;
- recomputeBoxLayout(pRegion, TRUE);
- }
- }
- // Clear the map
- m_pAnimRegionRecomputeMap->RemoveAll();
- }
- // We've collected all the sites which need
- // a ForceRedraw(), so do that now
- if (m_pAnimSiteRedrawMap)
- {
- POSITION mpos = m_pAnimSiteRedrawMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimSiteRedrawMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- IHXSite* pSite = (IHXSite*) pKey;
- forceFullRedraw(pSite);
- }
- }
- // Clear the map
- m_pAnimSiteRedrawMap->RemoveAll();
- }
- unlockSiteComposition();
- bltSiteComposition();
- lockSiteComposition();
- }
- if (isSiteCompositionModeON())
- {
- turnSiteCompositionModeOFF();
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- void CSmilDocumentRenderer::removeViewports()
- {
- if (m_pViewportList)
- {
- LISTPOSITION pos = m_pViewportList->GetHeadPosition();
- while (pos)
- {
- CSmilBasicViewport* pPort =
- (CSmilBasicViewport*) m_pViewportList->GetNext(pos);
- HX_DELETE(pPort);
- }
- m_pViewportList->RemoveAll();
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
- HX_RESULT CSmilDocumentRenderer::addAnimation(CAnimationSandwichLayer* pLayer)
- {
- MLOG_ANIM(m_pErrorMessages,"addAnimation() targEl=%s m_ulCurrentTime=%lu tick=%lun",
- (const char*) pLayer->GetTargetElementID(),
- m_ulCurrentTime, HX_GET_BETTERTICKCOUNT());
- HX_RESULT retVal = HXR_OK;
- if (pLayer)
- {
- // If there is a soundlevel animation going on, then
- // we need to try to grab the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Lock();
- // If there isn't an active animation list, then
- // create one
- if (!m_pActiveAnimations)
- {
- m_pActiveAnimations = new CHXSimpleList();
- }
- if (m_pActiveAnimations)
- {
- // Run through the list and see if there are any
- // existing animations of this element's attribute.
- CSmilAnimateInfo* pInfo = NULL;
- BOOL bNew = TRUE;
- const char* pszID = pLayer->GetTargetElementID();
- LISTPOSITION pos = m_pActiveAnimations->GetHeadPosition();
- while (pos)
- {
- CSmilAnimateInfo* pListInfo =
- (CSmilAnimateInfo*) m_pActiveAnimations->GetNext(pos);
- if (pListInfo && pListInfo->m_pSandwich)
- {
- const char* pszListID = pListInfo->m_pSandwich->GetTargetElementID();
- if (pszID && pszListID)
- {
- if (!strcmp(pszID, pszListID) &&
- pLayer->GetAttributeName() == pListInfo->m_pSandwich->GetAttributeName())
- {
- // This is the sandwich we're looking for
- pInfo = pListInfo;
- bNew = FALSE;
- break;
- }
- }
- }
- }
- // Are we already animating this attribute?
- if (bNew)
- {
- // We didn't find an existing CSmilAnimateInfo, so
- // we need to create one and put it on the list
- pInfo = new CSmilAnimateInfo();
- if (pInfo)
- {
- // Create a sandwich
- pInfo->m_pSandwich = new CAnimationSandwich(pLayer->GetTargetElementID(),
- pLayer->GetTargetElementTag(),
- pLayer->GetAttributeName());
- if (pInfo->m_pSandwich)
- {
- // Add this layer to the sandwich
- retVal = pInfo->m_pSandwich->AddLayer(pLayer);
- if (SUCCEEDED(retVal))
- {
- // Save the underlying value
- HX_DELETE(pInfo->m_pUnder);
- retVal = getUnderlyingValue(pInfo, pInfo->m_pUnder);
- if (SUCCEEDED(retVal))
- {
- HX_DELETE(pInfo->m_pDepend);
- retVal = getDependentValue(pInfo, pInfo->m_pDepend);
- if (SUCCEEDED(retVal))
- {
- // Now put this on the list
- m_pActiveAnimations->AddTail((void*) pInfo);
- // XXMEH - if this is a soundLevel animation,
- // we have to tell the core to start calling us
- if (pLayer->GetAttributeName() == kAttrNameSoundLevel)
- {
- // First we need to create the mutex
- if (!m_pSoundLevelMutex && m_pParent)
- {
- IHXCommonClassFactory* pFactory =
- m_pParent->getFactory();
- if (pFactory)
- {
- pFactory->CreateInstance(CLSID_IHXMutex,
- (void**) &m_pSoundLevelMutex);
- }
- // If we just created the mutex, the
- // we need to lock it
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Lock();
- }
- // And now we can start the animation
- startSoundLevelAnimation(pInfo);
- }
- }
- }
- }
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- if (FAILED(retVal))
- {
- HX_DELETE(pInfo);
- }
- }
- else
- {
- // There was already an existing CSmilAnimateInfo, so
- // we just need to add this layer to it
- if (pInfo && pInfo->m_pSandwich)
- {
- // Is this a soundLevel animation?
- if (pLayer->GetAttributeName() == kAttrNameSoundLevel)
- {
- // We are about to add a layer to an existing
- // soundLevel animation. Since soundLevel animations
- // get their information about 2s ahead of time, then
- // we need to stop this animation and cause another
- // rewind by starting a new animation. So first
- // we need to stop this current animation. Note
- // that we set bUseCurrentLevel to TRUE so that
- // we will end the soundLevel animation with
- // the value at the current level instead of
- // reverting to the animation's underlying value.
- finishSoundLevelAnimation(pInfo, TRUE);
- }
- retVal = pInfo->m_pSandwich->AddLayer(pLayer);
- if (SUCCEEDED(retVal))
- {
- // Is this a soundLevel animation?
- if (pLayer->GetAttributeName() == kAttrNameSoundLevel)
- {
- // If this is a soundLevel animation, then we have
- // just added an additional layer to an existing
- // soundLevel animation. Therefore, we should
- // restart a soundLevel animation.
- startSoundLevelAnimation(pInfo);
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- else
- {
- retVal = HXR_OUTOFMEMORY;
- }
- // If there is a soundlevel animation going on,
- // then release the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Unlock();
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::removeAnimation(CSmilAnimateElement* pAnimate)
- {
- HX_RESULT retVal = HXR_OK;
- if (pAnimate)
- {
- // If there is a soundlevel animation going on, then
- // we need to try to grab the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Lock();
- // Does this animation begin on an event?
- BOOL bBeginOnEvent = pAnimate->hasEventBasedBeginTime();
- // Does this animation end on an event?
- BOOL bEndOnEvent = pAnimate->hasEventBasedEndTime();
- // If we end on an event AND we have fill="freeze"
- // behavior, then we don't want to end, but rather
- // shorten the active duration to be the current time.
- // Then we will automatically go into a freeze state.
- if (bEndOnEvent &&
- pAnimate->m_eActualFill == FillFreeze)
- {
- // Find the right animation layer
- LISTPOSITION pos = m_pActiveAnimations->GetHeadPosition();
- while (pos)
- {
- CSmilAnimateInfo* pInfo =
- (CSmilAnimateInfo*) m_pActiveAnimations->GetNext(pos);
- if (pInfo &&
- pInfo->m_pSandwich &&
- pInfo->m_pSandwich->MatchingSandwich(pAnimate))
- {
- // Freeze all layers in this sandwich which come
- // from this animate element and are currently active.
- pInfo->m_pSandwich->FreezeLayers(pAnimate->m_pNode->m_id, m_ulCurrentTime);
- }
- }
- }
- else if (!bBeginOnEvent ||
- (bEndOnEvent && pAnimate->m_eActualFill == FillRemove))
- {
- if (m_pActiveAnimations &&
- m_pActiveAnimations->GetCount() > 0)
- {
- if (!isSiteCompositionModeON())
- {
- turnSiteCompositionModeON();
- }
- // m_pAnimSiteRedrawMap is a list of sites
- // which need to ForceRedraw() as a result on an
- // animation on this time sync.
- if (!m_pAnimSiteRedrawMap)
- {
- m_pAnimSiteRedrawMap = new CHXMapPtrToPtr();
- }
- if (m_pAnimSiteRedrawMap)
- {
- m_pAnimSiteRedrawMap->RemoveAll();
- }
- // m_pAnimRegionRecomputeMap is a list of sites
- // which need to ForceRedraw() as a result on an
- // animation on this time sync.
- if (!m_pAnimRegionRecomputeMap)
- {
- m_pAnimRegionRecomputeMap = new CHXMapPtrToPtr();
- }
- if (m_pAnimRegionRecomputeMap)
- {
- m_pAnimRegionRecomputeMap->RemoveAll();
- }
- // m_pAnimTopLayoutMap is a collection of topLayout's
- // which have been animated programmatically and
- // need resizing.
- if (m_pAnimTopLayoutMap)
- {
- m_pAnimTopLayoutMap->RemoveAll();
- }
- // Clear the animate root layout flag
- m_bAnimateRootLayout = FALSE;
- // Run through the active animations
- LISTPOSITION pos = m_pActiveAnimations->GetHeadPosition();
- while (pos)
- {
- CSmilAnimateInfo* pInfo =
- (CSmilAnimateInfo*) m_pActiveAnimations->GetAt(pos);
- if (pInfo && pInfo->m_pSandwich &&
- pInfo->m_pSandwich->MatchingSandwich(pAnimate))
- {
- // Remove this animate element from this sandwich.
- pInfo->m_pSandwich->RemoveLayer(pAnimate->m_pNode->m_id);
- // Are there any layers left in this sandwich?
- if (pInfo->m_pSandwich->GetNumLayers())
- {
- m_pActiveAnimations->GetNext(pos);
- }
- else
- {
- // There are no more layers left in the
- // sandwich, so this animation is done. So,
- // we need to restore whatever original values
- // were present
- setValue(pInfo, pInfo->m_pUnder, pInfo->m_pDepend, TRUE);
- // XXXMEH - if this is a soundLevel animation, then
- // we need to turn off the animation
- if (pInfo->m_pSandwich->GetAttributeName() == kAttrNameSoundLevel)
- {
- finishSoundLevelAnimation(pInfo);
- }
- // Now we need to delete this info object
- HX_DELETE(pInfo);
- // And remove it from the list
- // We have to do the following hack since
- // CHXSimpleList does not advance the position to
- // NULL if you RemoveAt() the last element in the list.
- BOOL bLast = (m_pActiveAnimations->GetAt(pos) ==
- m_pActiveAnimations->GetTail());
- pos = m_pActiveAnimations->RemoveAt(pos);
- if (bLast && pos)
- {
- m_pActiveAnimations->GetNext(pos);
- }
- }
- }
- else
- {
- m_pActiveAnimations->GetNext(pos);
- }
- }
- // Recompute the root-layout if necessary
- if (m_bAnimateRootLayout && m_pRootLayout && m_pRootLayout->m_pRoot)
- {
- HXxSize cNewRootSize = {0, 0};
- cNewRootSize.cx = (INT32) floor(m_pRootLayout->m_pRoot->m_dWidth + 0.5);
- cNewRootSize.cy = (INT32) floor(m_pRootLayout->m_pRoot->m_dHeight + 0.5);
- SiteSizeChanged(m_pRootLayout->m_pSite, &cNewRootSize);
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- // Animate any topLayout's
- if (m_pAnimTopLayoutMap &&
- m_pAnimTopLayoutMap->GetCount() > 0)
- {
- POSITION mpos = m_pAnimTopLayoutMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimTopLayoutMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- CSmilBasicViewport* pVP = (CSmilBasicViewport*) pKey;
- if (pVP && pVP->m_pPort)
- {
- HXxSize cNewRootSize = {0, 0};
- cNewRootSize.cx = (INT32) floor(pVP->m_pPort->m_dWidth + 0.5);
- cNewRootSize.cy = (INT32) floor(pVP->m_pPort->m_dHeight + 0.5);
- SiteSizeChanged(pVP->m_pSite, &cNewRootSize);
- }
- }
- }
- // Clear the map
- m_pAnimTopLayoutMap->RemoveAll();
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- // We've collected all the regions for which
- // we need to call recomputeBoxLayout()
- if (m_pAnimRegionRecomputeMap)
- {
- POSITION mpos = m_pAnimRegionRecomputeMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimRegionRecomputeMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- CSmilBasicRegion* pRegion = (CSmilBasicRegion*) pKey;
- recomputeBoxLayout(pRegion, TRUE);
- }
- }
- // Clear the map
- m_pAnimRegionRecomputeMap->RemoveAll();
- }
- // We've collected all the sites which need
- // a ForceRedraw(), so do that now
- if (m_pAnimSiteRedrawMap)
- {
- POSITION mpos = m_pAnimSiteRedrawMap->GetStartPosition();
- while (mpos)
- {
- void* pKey = NULL;
- void* pVal = NULL;
- m_pAnimSiteRedrawMap->GetNextAssoc(mpos, pKey, pVal);
- if (pKey)
- {
- IHXSite* pSite = (IHXSite*) pKey;
- forceFullRedraw(pSite);
- }
- }
- // Clear the map
- m_pAnimSiteRedrawMap->RemoveAll();
- }
- unlockSiteComposition();
- bltSiteComposition();
- lockSiteComposition();
- }
- if (!m_pActiveAnimations ||
- (m_pActiveAnimations && m_pActiveAnimations->GetCount() == 0))
- {
- if (isSiteCompositionModeON())
- {
- turnSiteCompositionModeOFF();
- }
- }
- }
- // If there is a soundlevel animation going on,
- // then release the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Unlock();
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- void CSmilDocumentRenderer::removeAnimation(CSmilAnimateInfo* pInfo)
- {
- if (pInfo && m_pActiveAnimations)
- {
- // If there is a soundlevel animation going on, then
- // we need to try to grab the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Lock();
- // Now we can remove the animation
- LISTPOSITION pos = m_pActiveAnimations->GetHeadPosition();
- while (pos)
- {
- CSmilAnimateInfo* pLInfo =
- (CSmilAnimateInfo*) m_pActiveAnimations->GetAt(pos);
- if (pInfo == pLInfo)
- {
- m_pActiveAnimations->RemoveAt(pos);
- break;
- }
- else
- {
- m_pActiveAnimations->GetNext(pos);
- }
- }
- // If there is a soundlevel animation going on,
- // then release the mutex
- if (m_pSoundLevelMutex) m_pSoundLevelMutex->Unlock();
- }
- }
- void CSmilDocumentRenderer::doAnimation(CSmilAnimateInfo* pInfo, UINT32 ulTime)
- {
- if (pInfo && pInfo->m_pSandwich && pInfo->m_pUnder)
- {
- // Compute the animation value
- CAttr cRet = pInfo->m_pSandwich->GetValue(ulTime, pInfo->m_pUnder, pInfo->m_pDepend);
- MLOG_ANIM(m_pErrorMessages,"doAnimation(,%lu) cRet=(%5.1lf,%5.1lf,%5.1lf,%5.1lf)n",
- ulTime,
- cRet.GetValueDouble(0),
- cRet.GetValueDouble(1),
- cRet.GetValueDouble(2),
- cRet.GetValueDouble(3));
- // Adjust the sandwich
- pInfo->m_pSandwich->AdjustLayers(ulTime);
- // Apply the resulting value
- setValue(pInfo, &cRet, pInfo->m_pDepend,
- (pInfo->m_pSandwich->GetNumLayers() ? FALSE : TRUE));
- }
- }
- HX_RESULT CSmilDocumentRenderer::getUnderlyingValue(CSmilAnimateInfo* pInfo,
- REF(CAttr*) rpValue)
- {
- HX_RESULT retVal = HXR_OK;
- if (pInfo && pInfo->m_pSandwich)
- {
- // Get the target element id
- const char* pszID = pInfo->m_pSandwich->GetTargetElementID();
- // Get the target element tag
- SMILNodeTag eTag = pInfo->m_pSandwich->GetTargetElementTag();
- // Get the attribute name
- UINT32 ulAttr = pInfo->m_pSandwich->GetAttributeName();
- // Depending on the type of target element, we will
- // go lookup a different object
- if (eTag == SMILRegion)
- {
- // Get the region
- CSmilBasicRegion* pRegion = getRegionByID(pszID);
- if (pRegion)
- {
- double dVal[4] = {0.0, 0.0, 0.0, 0.0};
- CSS2Type eType[4] = {CSS2TypeAuto, CSS2TypeAuto,
- CSS2TypeAuto, CSS2TypeAuto};
- switch (ulAttr)
- {
- case kAttrNameSoundLevel:
- dVal[0] = pRegion->m_dSoundLevel;
- break;
- case kAttrNameZIndex:
- dVal[0] = pRegion->m_lZIndex;
- break;
- case kAttrNameBackgroundColor:
- {
- UINT32 ulColor = pRegion->m_ulBackgroundColor;
- dVal[0] = ((ulColor & 0x00FF0000) >> 16); // R
- dVal[1] = ((ulColor & 0x0000FF00) >> 8); // G
- dVal[2] = (ulColor & 0x000000FF); // B
- dVal[3] = ((ulColor & 0xFF000000) >> 24); // A
- }
- break;
- case kAttrNameLeft:
- case kAttrNameTop:
- // Note that we have to put both left and
- // top in the same underlying value, since
- // an <animateMotion> could be inside the sandwich
- // for left or top.
- dVal[0] = pRegion->m_LayoutRect.m_dLeft;
- eType[0] = pRegion->m_LayoutRect.m_eLeftType;
- dVal[1] = pRegion->m_LayoutRect.m_dTop;
- eType[1] = pRegion->m_LayoutRect.m_eTopType;
- break;
- case kAttrNameRight:
- dVal[0] = pRegion->m_LayoutRect.m_dRight;
- eType[0] = pRegion->m_LayoutRect.m_eRightType;
- break;
- case kAttrNameBottom:
- dVal[0] = pRegion->m_LayoutRect.m_dBottom;
- eType[0] = pRegion->m_LayoutRect.m_eBottomType;
- break;
- case kAttrNameWidth:
- dVal[0] = pRegion->m_LayoutRect.m_dWidth;
- eType[0] = pRegion->m_LayoutRect.m_eWidthType;
- break;
- case kAttrNameHeight:
- dVal[0] = pRegion->m_LayoutRect.m_dHeight;
- eType[0] = pRegion->m_LayoutRect.m_eHeightType;
- break;
- }
- // Create the atttribute
- HX_DELETE(rpValue);
- rpValue = new CAttr(ulAttr,
- dVal[0], eType[0], dVal[1], eType[1],
- dVal[2], eType[2], dVal[3], eType[3]);
- if (!rpValue)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else if (eTag == SMILAnchor)
- {
- // Find the CSmilAnchorElement object
- CSmilAnchorElement* pAnchor =
- m_pSmilParser->getAnchorOrAreaElement(pInfo->m_pSandwich->GetTargetElementID());
- if (pAnchor && pAnchor->m_pNode && pAnchor->m_pNode->m_pValues)
- {
- IHXBuffer* pCoords = NULL;
- retVal = pAnchor->m_pNode->m_pValues->GetPropertyCString("coords", pCoords);
- if (SUCCEEDED(retVal))
- {
- HX_DELETE(rpValue);
- rpValue = new CAttr(kAttrNameCoords,
- (const char*) pCoords->GetBuffer());
- if (!rpValue)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- HX_RELEASE(pCoords);
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else if (eTag == SMILText ||
- eTag == SMILImg ||
- eTag == SMILRef ||
- eTag == SMILAudio ||
- eTag == SMILVideo ||
- eTag == SMILAnimation ||
- eTag == SMILTextstream ||
- eTag == SMILBrush)
- {
- // Get the source
- CSmilSource* pSource = getSource(pszID);
- if (pSource)
- {
- double dVal[4] = {0.0, 0.0, 0.0, 0.0};
- CSS2Type eType[4] = {CSS2TypeAuto, CSS2TypeAuto,
- CSS2TypeAuto, CSS2TypeAuto};
- switch (ulAttr)
- {
- case kAttrNameLeft:
- case kAttrNameTop:
- // Note that we have to put both left and
- // top in the same underlying value, since
- // an <animateMotion> could be inside the sandwich
- // for left or top.
- dVal[0] = pSource->m_Rect.m_dLeft;
- eType[0] = pSource->m_Rect.m_eLeftType;
- dVal[1] = pSource->m_Rect.m_dTop;
- eType[1] = pSource->m_Rect.m_eTopType;
- break;
- case kAttrNameRight:
- dVal[0] = pSource->m_Rect.m_dRight;
- eType[0] = pSource->m_Rect.m_eRightType;
- break;
- case kAttrNameBottom:
- dVal[0] = pSource->m_Rect.m_dBottom;
- eType[0] = pSource->m_Rect.m_eBottomType;
- break;
- case kAttrNameWidth:
- dVal[0] = pSource->m_Rect.m_dWidth;
- eType[0] = pSource->m_Rect.m_eWidthType;
- break;
- case kAttrNameHeight:
- dVal[0] = pSource->m_Rect.m_dHeight;
- eType[0] = pSource->m_Rect.m_eHeightType;
- break;
- case kAttrNameZIndex:
- dVal[0] = pSource->m_lZIndex;
- break;
- case kAttrNameBackgroundColor:
- {
- UINT32 ulColor = pSource->m_ulBackgroundColor;
- dVal[0] = ((ulColor & 0x00FF0000) >> 16); // R
- dVal[1] = ((ulColor & 0x0000FF00) >> 8); // G
- dVal[2] = (ulColor & 0x000000FF); // B
- dVal[3] = ((ulColor & 0xFF000000) >> 24); // A
- }
- break;
- case kAttrNameColor:
- {
- UINT32 ulColor = pSource->m_ulColor;
- dVal[0] = ((ulColor & 0x00FF0000) >> 16); // R
- dVal[1] = ((ulColor & 0x0000FF00) >> 8); // G
- dVal[2] = (ulColor & 0x000000FF); // B
- dVal[3] = ((ulColor & 0xFF000000) >> 24); // A
- }
- break;
- case kAttrNameMediaOpacity:
- {
- dVal[0] = (double) pSource->m_ulMediaOpacity;
- }
- break;
- case kAttrNameBackgroundOpacity:
- {
- dVal[0] = (double) pSource->m_ulBackgroundOpacity;
- }
- break;
- }
- // Create the atttribute
- HX_DELETE(rpValue);
- rpValue = new CAttr(ulAttr,
- dVal[0], eType[0], dVal[1], eType[1],
- dVal[2], eType[2], dVal[3], eType[3]);
- if (!rpValue)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else if (eTag == SMILRootLayout)
- {
- if (m_pRootLayout && m_pRootLayout->m_pRoot)
- {
- double dVal[4] = {0.0, 0.0, 0.0, 0.0};
- CSS2Type eType[4] = {CSS2TypeAuto, CSS2TypeAuto,
- CSS2TypeAuto, CSS2TypeAuto};
- switch (ulAttr)
- {
- case kAttrNameWidth:
- dVal[0] = m_pRootLayout->m_pRoot->m_dWidth;
- eType[0] = m_pRootLayout->m_pRoot->m_eWidthType;
- break;
- case kAttrNameHeight:
- dVal[0] = m_pRootLayout->m_pRoot->m_dHeight;
- eType[0] = m_pRootLayout->m_pRoot->m_eHeightType;
- break;
- }
- // Create the atttribute
- HX_DELETE(rpValue);
- rpValue = new CAttr(ulAttr,
- dVal[0], eType[0], dVal[1], eType[1],
- dVal[2], eType[2], dVal[3], eType[3]);
- if (!rpValue)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT)
- else if (eTag == SMILViewport)
- {
- CSmilBasicViewport* pPort = getViewport(pszID);
- if (pPort && pPort->m_pPort)
- {
- double dVal[4] = {0.0, 0.0, 0.0, 0.0};
- CSS2Type eType[4] = {CSS2TypeAuto, CSS2TypeAuto,
- CSS2TypeAuto, CSS2TypeAuto};
- switch (ulAttr)
- {
- case kAttrNameWidth:
- dVal[0] = pPort->m_pPort->m_dWidth;
- eType[0] = pPort->m_pPort->m_eWidthType;
- break;
- case kAttrNameHeight:
- dVal[0] = pPort->m_pPort->m_dHeight;
- eType[0] = pPort->m_pPort->m_eHeightType;
- break;
- }
- // Create the atttribute
- HX_DELETE(rpValue);
- rpValue = new CAttr(ulAttr,
- dVal[0], eType[0], dVal[1], eType[1],
- dVal[2], eType[2], dVal[3], eType[3]);
- if (!rpValue)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- #endif /* #if defined(HELIX_FEATURE_SMIL2_MULTIWINDOWLAYOUT) */
- else if (eTag == SMILParam)
- {
- if (m_pSmilParser)
- {
- CSmilElement* pEl = m_pSmilParser->findElement(pszID);
- if (pEl && pEl->m_pNode && pEl->m_pNode->m_tag == SMILParam)
- {
- // Cast to a CSmilParamElement
- CSmilParamElement* pParam = (CSmilParamElement*) pEl;
- // Make sure we have a value attribute
- if (pParam->m_pValue)
- {
- // Create the atttribute
- HX_DELETE(rpValue);
- rpValue = new CAttr(ulAttr,
- (const char*) pParam->m_pValue->GetBuffer());
- if (!rpValue)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::getDependentValue(CSmilAnimateInfo* pInfo,
- REF(CAttr*) rpDepend)
- {
- HX_RESULT retVal = HXR_OK;
- if (pInfo && pInfo->m_pSandwich)
- {
- // Clear any existing attribute
- HX_DELETE(rpDepend);
- // Get the target element id
- const char* pszID = pInfo->m_pSandwich->GetTargetElementID();
- // Get the target element tag
- SMILNodeTag eTag = pInfo->m_pSandwich->GetTargetElementTag();
- // Get the attribute name
- UINT32 ulAttr = pInfo->m_pSandwich->GetAttributeName();
- // Depending on the type of target element, we will
- // go lookup a different object
- if (eTag == SMILRegion)
- {
- // We need to compute the size of this region's parent.
- HXxSize cParentSize = {0, 0};
- CSmilBasicRegion* pRegion = getRegionByID(pszID);
- if (pRegion && pRegion->m_pParent)
- {
- cParentSize.cx = HXxRECT_WIDTH(pRegion->m_pParent->m_Rect);
- cParentSize.cy = HXxRECT_HEIGHT(pRegion->m_pParent->m_Rect);
- }
- double dVal[2] = {0.0, 0.0};
- CSS2Type eType[2] = {CSS2TypeAuto, CSS2TypeAuto};
- BOOL bCreate = TRUE;
- switch (ulAttr)
- {
- case kAttrNameLeft:
- case kAttrNameTop:
- // Note that we have to put both left and
- // top in the same depenent value, since
- // an <animateMotion> could be inside the sandwich
- // for left or top.
- dVal[0] = cParentSize.cx;
- dVal[1] = cParentSize.cy;
- eType[0] = eType[1] = CSS2TypeLength;
- break;
- case kAttrNameRight:
- case kAttrNameWidth:
- dVal[0] = cParentSize.cx;
- eType[0] = CSS2TypeLength;
- break;
- case kAttrNameBottom:
- case kAttrNameHeight:
- dVal[0] = cParentSize.cy;
- eType[0] = CSS2TypeLength;
- break;
- default:
- // We only need a dependent value for
- // position and length attributes
- bCreate = FALSE;
- break;
- }
- // Was this an attribute for which we need
- // to create a dependent value?
- if (bCreate)
- {
- // Create the atttribute
- HX_DELETE(rpDepend);
- rpDepend = new CAttr(ulAttr, dVal[0], eType[0], dVal[1], eType[1]);
- if (!rpDepend)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- }
- else if (eTag == SMILText ||
- eTag == SMILImg ||
- eTag == SMILRef ||
- eTag == SMILAudio ||
- eTag == SMILVideo ||
- eTag == SMILAnimation ||
- eTag == SMILTextstream ||
- eTag == SMILBrush)
- {
- // Get the source
- CSmilSource* pSource = getSource(pszID);
- if (pSource)
- {
- // Get the region this is playing to
- CSmilBasicRegion* pRegion = getRegionByID((const char*) pSource->m_region);
- if (pRegion)
- {
- HXxSize cRegionSize = {HXxRECT_WIDTH(pRegion->m_Rect),
- HXxRECT_HEIGHT(pRegion->m_Rect)};
- double dVal[3] = {0.0, 0.0};
- CSS2Type eType[3] = {CSS2TypeAuto, CSS2TypeAuto};
- BOOL bCreate = TRUE;
- switch (ulAttr)
- {
- case kAttrNameLeft:
- case kAttrNameTop:
- // Note that we have to put both left and
- // top in the same depenent value, since
- // an <animateMotion> could be inside the sandwich
- // for left or top.
- dVal[0] = cRegionSize.cx;
- dVal[1] = cRegionSize.cy;
- eType[0] = eType[1] = CSS2TypeLength;
- break;
- case kAttrNameRight:
- case kAttrNameWidth:
- dVal[0] = cRegionSize.cx;
- eType[0] = CSS2TypeLength;
- break;
- case kAttrNameBottom:
- case kAttrNameHeight:
- dVal[0] = cRegionSize.cy;
- eType[0] = CSS2TypeLength;
- break;
- default:
- // We only need a dependent value for
- // position and length attributes
- bCreate = FALSE;
- break;
- }
- // Was this an attribute for which we need
- // to create a dependent value?
- if (bCreate)
- {
- // Create the atttribute
- HX_DELETE(rpDepend);
- rpDepend = new CAttr(ulAttr, dVal[0], eType[0], dVal[1], eType[1]);
- if (!rpDepend)
- {
- retVal = HXR_OUTOFMEMORY;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- return retVal;
- }
- HX_RESULT CSmilDocumentRenderer::setValue(CSmilAnimateInfo* pInfo, CAttr* pValue,
- CAttr* pDepend, BOOL bUnderlyingValue)
- {
- HX_RESULT retVal = HXR_OK;
- if (pInfo && pInfo->m_pSandwich && pValue)
- {
- // Get the target element id
- const char* pszID = pInfo->m_pSandwich->GetTargetElementID();
- // Get the target element tag
- SMILNodeTag eTag = pInfo->m_pSandwich->GetTargetElementTag();
- // Get the attribute name
- UINT32 ulAttr = pInfo->m_pSandwich->GetAttributeName();
- // Depending on the type of target element, we will
- // go lookup a different object
- if (eTag == SMILRegion)
- {
- CSmilBasicRegion* pRegion = getRegionByID(pszID);
- if (pRegion)
- {
- switch (ulAttr)
- {
- case kAttrNameSoundLevel:
- {
- // XXXMEH - set the sound level - the core
- // will call us back to get this value
- pRegion->m_dSoundLevel = pValue->GetValueDouble();
- }
- break;
- case kAttrNameZIndex:
- {
- // Get the computed z-index value
- INT32 lZIndex = (INT32) (pValue->GetValueDouble() + 0.5);
- // Set the z-index value in the CSmilBasicRegion
- pRegion->m_lZIndex = lZIndex;
- // XXXMEH - animation optimization
- // Go ahead and resolve z-order here, but this
- // could be done more efficiently by collecting
- // changes until the end.
- resolveZOrder(getTopLevelBox(pRegion), m_ulCurrentTime);
- }
- break;
- case kAttrNameBackgroundColor:
- {
- // Get the color
- UINT32 ulRed = (UINT32) pValue->GetValueDouble(0);
- UINT32 ulGreen = (UINT32) pValue->GetValueDouble(1);
- UINT32 ulBlue = (UINT32) pValue->GetValueDouble(2);
- UINT32 ulAlpha = (UINT32) pValue->GetValueDouble(3);
- UINT32 ulColor = (ulAlpha << 24) | (ulRed << 16) |
- (ulGreen << 8) | ulBlue;
- // Set this color into the region
- pRegion->m_ulBackgroundColor = ulColor;
- // Set this color into the site user
- if (pRegion->m_pSiteUser)
- {
- // Get the CSmilSiteUser
- CSmilSiteUser* pUser = (CSmilSiteUser*) pRegion->m_pSiteUser;
- // Get the current background color
- UINT32 ulCurColor = pUser->GetBackgroundColor();
- // If it's different from the current color, then
- // change it
- if (ulColor != ulCurColor)
- {
- // Set the background color
- pUser->SetBackgroundColor(pRegion->m_ulBackgroundColor);
- // Queue the site for redraw
- queueSiteForAnimationRedraw(pRegion->m_pSite);
- #if 0
- // XXXMEH - TEST - this is a further optimization, but
- // doesn't seem to be working due to a site bug, so ifdef
- // it out for now
- // Check to see if the "SiteNeverBlts" property
- // of the site needs to get updated
- if (isTransparent(ulColor) &&
- !isTransparent(ulCurColor))
- {
- setSiteProperty(pRegion->m_pSite, "SiteNeverBlts", "1");
- }
- else if (!isTransparent(ulColor) &&
- isTransparent(ulCurColor))
- {
- setSiteProperty(pRegion->m_pSite, "SiteNeverBlts", "0");
- }
- #endif
- }
- }
- }
- break;
- case kAttrNameLeft:
- pRegion->m_LayoutRect.m_dLeft = pValue->GetValueDouble(0);
- pRegion->m_LayoutRect.m_eLeftType = pValue->GetCSS2Type(0);
- queueRegionForRecompute(pRegion);
- break;
- case kAttrNameTop:
- pRegion->m_LayoutRect.m_dTop = pValue->GetValueDouble(1);
- pRegion->m_LayoutRect.m_eTopType = pValue->GetCSS2Type(1);
- queueRegionForRecompute(pRegion);
- break;
- case kAttrNameRight:
- pRegion->m_LayoutRect.m_dRight = pValue->GetValueDouble(0);
- pRegion->m_LayoutRect.m_eRightType = pValue->GetCSS2Type(0);
- queueRegionForRecompute(pRegion);
- break;
- case kAttrNameBottom:
- pRegion->m_LayoutRect.m_dBottom = pValue->GetValueDouble(0);
- pRegion->m_LayoutRect.m_eBottomType = pValue->GetCSS2Type(0);
- queueRegionForRecompute(pRegion);
- break;
- case kAttrNameWidth:
- pRegion->m_LayoutRect.m_dWidth = pValue->GetValueDouble(0);
- pRegion->m_LayoutRect.m_eWidthType = pValue->GetCSS2Type(0);
- queueRegionForRecompute(pRegion);
- break;
- case kAttrNameHeight:
- pRegion->m_LayoutRect.m_dHeight = pValue->GetValueDouble(0);
- pRegion->m_LayoutRect.m_eHeightType = pValue->GetCSS2Type(0);
- queueRegionForRecompute(pRegion);
- break;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else if (eTag == SMILAnchor)
- {
- // Find the CSmilAnchorElement object
- CSmilAnchorElement* pAnchor =
- m_pSmilParser->getAnchorOrAreaElement(pInfo->m_pSandwich->GetTargetElementID());
- if (pAnchor)
- {
- // Get the string value we want to set it to
- const char* pszCoords = pValue->GetValueString();
- if (pszCoords)
- {
- // Parse this string value
- retVal = m_pSmilParser->parseAnchorCoords(pszCoords, pAnchor);
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else if (eTag == SMILText ||
- eTag == SMILImg ||
- eTag == SMILRef ||
- eTag == SMILAudio ||
- eTag == SMILVideo ||
- eTag == SMILAnimation ||
- eTag == SMILTextstream ||
- eTag == SMILBrush)
- {
- if (ulAttr == kAttrNameLeft ||
- ulAttr == kAttrNameTop ||
- ulAttr == kAttrNameRight ||
- ulAttr == kAttrNameBottom ||
- ulAttr == kAttrNameWidth ||
- ulAttr == kAttrNameHeight)
- {
- // Get the source
- CSmilSource* pSource = getSource(pszID);
- if (pSource)
- {
- // Set the attribute value
- switch (ulAttr)
- {
- case kAttrNameLeft:
- pSource->m_Rect.m_dLeft = pValue->GetValueDouble();
- pSource->m_Rect.m_eLeftType = pValue->GetCSS2Type();
- break;
- case kAttrNameTop:
- pSource->m_Rect.m_dTop = pValue->GetValueDouble(1);
- pSource->m_Rect.m_eTopType = pValue->GetCSS2Type(1);
- break;
- case kAttrNameRight:
- pSource->m_Rect.m_dRight = pValue->GetValueDouble();
- pSource->m_Rect.m_eRightType = pValue->GetCSS2Type();
- break;
- case kAttrNameBottom:
- pSource->m_Rect.m_dBottom = pValue->GetValueDouble();
- pSource->m_Rect.m_eBottomType = pValue->GetCSS2Type();
- break;
- case kAttrNameWidth:
- pSource->m_Rect.m_dWidth = pValue->GetValueDouble();
- pSource->m_Rect.m_eWidthType = pValue->GetCSS2Type();
- break;
- case kAttrNameHeight:
- pSource->m_Rect.m_dHeight = pValue->GetValueDouble();
- pSource->m_Rect.m_eHeightType = pValue->GetCSS2Type();
- break;
- }
- // XXXMEH - animation optimization
- // We will go ahead and copy the new values to the site
- // watcher, although it would be more efficient to collect
- // the changes to the end and execute them together.
- CSmilSiteWatcher* pWatcher = getRendererSiteWatcher(pszID);
- if (pWatcher)
- {
- // Set the layout rect
- pWatcher->SetSubRegionRect(pSource->m_Rect);
- // Get the renderer site
- IHXSite* pSite = NULL;
- getRendererSite(pszID, pSite);
- if (pSite)
- {
- // Re-position the site. It doesn't matter what
- // position we pass in, because the site watcher's
- // ChangingPosition() method will override it.
- HXxPoint cPos = {1, 1};
- pSite->SetPosition(cPos);
- // Re-size the site. It doesn't matter what
- // size we pass in, because the site watcher's
- // ChangingSize() method will override it.
- HXxSize cSize = {1, 1};
- pSite->SetSize(cSize);
- }
- HX_RELEASE(pSite);
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else if (ulAttr == kAttrNameZIndex ||
- ulAttr == kAttrNameBackgroundColor)
- {
- // Get the source
- CSmilSource* pSource = getSource(pszID);
- if (pSource)
- {
- // Get the region this is playing to
- CSmilBasicRegion* pRegion = getRegionByID((const char*) pSource->m_region);
- if (pRegion)
- {
- if (ulAttr == kAttrNameZIndex)
- {
- // Get the value to set
- INT32 lZIndex = (INT32) (pValue->GetValueDouble() + 0.5);
- // Set the z-index value in the CSmilBasicRegion
- pRegion->m_lZIndex = lZIndex;
- // XXXMEH - animation optimization
- // Re-evaluate all the z-indices - note that
- // we must re-evaluate from the parent of the region.
- resolveZOrder(pRegion->m_pParent, m_ulCurrentTime);
- }
- else if (ulAttr == kAttrNameBackgroundColor)
- {
- // We are setting the backgroundColor for the region
- // we are playing to
- UINT32 ulRed = (UINT32) pValue->GetValueDouble(0);
- UINT32 ulGreen = (UINT32) pValue->GetValueDouble(1);
- UINT32 ulBlue = (UINT32) pValue->GetValueDouble(2);
- UINT32 ulAlpha = (UINT32) pValue->GetValueDouble(3);
- UINT32 ulColor = (ulAlpha << 24) | (ulRed << 16) |
- (ulGreen << 8) | ulBlue;
- // Get the site user for the region site
- CSmilSiteUser* pUser = (CSmilSiteUser*) pRegion->m_pSiteUser;
- if (pUser)
- {
- // Check and make sure that a media backgroundColor
- // override did not just reset the color back to
- // the region color
- if (!bUnderlyingValue ||
- (bUnderlyingValue &&
- m_ulCurrentTime != pUser->GetLastMediaEndOverrideTime()))
- {
- // Set the background color
- pUser->SetBackgroundColor(ulColor);
- }
- }
- // XXXMEH - animation optimzation
- // We will go ahead and force redraw on the site, but
- // this can be optimized by collecting changes until
- // the end of the animation
- if (pRegion->m_pSite)
- {
- HXxSize cSize = {0, 0};
- pRegion->m_pSite->GetSize(cSize);
- HXxRect cRect = {0, 0, cSize.cx, cSize.cy};
- pRegion->m_pSite->DamageRect(cRect);
- pRegion->m_pSite->ForceRedraw();
- }
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }
- }
- else
- {
- retVal = HXR_FAIL;
- }