void ThreadPool::WaitWork(const StringRef& name, bool cancelPending /*= false*/) { RETURN_IF_EMPTY(name); ThreadPoolWork* work = FindWork(name); RETURN_IF_NULL(work); WaitWork(*work, cancelPending); }
void SingleLineFontModel::SetText( StringRef text ) { RETURN_IF_EMPTY(text); WHeapString wText= StringParser::ToW(text); SetText(wText); }
void ThreadPool::SubmitWork(const StringRef& name) { RETURN_IF_EMPTY(name); ThreadPoolWork* work = FindWork(name); RETURN_IF_NULL(work); SubmitWork(*work); }
void ITimelineModel::Precompute(float fps) { RETURN_IF_FALSE(SupportPrecompute()); RETURN_IF_TRUE(mIsPrecomputed); RETURN_IF(fps < 0.f); RETURN_IF_EMPTY(mFrames); mIsPrecomputed = true; mFPS = fps; int preCalculatedframeCount = (int)Math::Ceil(mDuration * fps); RETURN_IF(preCalculatedframeCount <= 0); mFrameCount = (uint)preCalculatedframeCount; OnPrecomputeBegin(); float firstTime = mFrames.First().Time; AddPrecomputedItem(Math::IsZero(firstTime), 0U, 0U, 0.f); //add zero frame const float frameInterval = 1.f / mFPS; float time = 0.f; uint outPrevFrameIndex; uint outNextFrameIndex; float outPercent; uint prevIndex = 0; FOR_EACH_SIZE(i, mFrameCount) { time += frameInterval; bool isFound = TryGetFrameHelper(time, outPrevFrameIndex, outNextFrameIndex, outPercent, prevIndex); if (isFound) { prevIndex = outPrevFrameIndex; } AddPrecomputedItem(isFound, outPrevFrameIndex, outNextFrameIndex, outPercent); }
void FontFactory::Clear() { RETURN_IF_EMPTY(mItems); SAFE_RELEASE_COLLECTION(mCacheItems); SAFE_RELEASE_DICTIONARY_VALUE(mItems); }
void FontFactory::Shrink() { RETURN_IF_EMPTY(mItems); List<FontId, EqualCompare<FontId> > unusedKeys; FOR_EACH_COLLECTION(i, mItems) { const FontId& fileId = i->Key; IFont* item = i->Value; if (!item->IsShared()) { unusedKeys.Add(fileId); } } RETURN_IF_EMPTY(unusedKeys); FOR_EACH_COLLECTION(i, unusedKeys) { Remove(*i); }
void PODNode::GetScaleMatrix( uint frameIndex,float frameBlend,Matrix4& outMatrix ) const { //first get,use = RETURN_IF_EMPTY(AnimationScales); if (MEDUSA_FLAG_HAS(AnimationFlags,PODAnimiationFlags::HasScale)) { if (!AnimationScaleIndexes.IsEmpty()) { MEDUSA_ASSERT_LESS(frameIndex,AnimationScaleIndexes.Size(),""); uint index1=AnimationScaleIndexes[frameIndex]; const PODScale& scale1= AnimationScales[index1]; if (frameIndex==AnimationScaleIndexes.Size()-1) { //last frame outMatrix=Matrix4::CreateScale(scale1.Scale); } else { uint index2=AnimationScaleIndexes[frameIndex+1]; const PODScale& scale2= AnimationScales[index2]; Scale3F resultScale=Scale3F::LinearInterpolate(scale1.Scale,scale2.Scale,frameBlend); outMatrix=Matrix4::CreateScale(resultScale); } } else { const PODScale& scale1= AnimationScales[frameIndex]; if (frameIndex==AnimationScales.Size()-1) { //last frame outMatrix=Matrix4::CreateScale(scale1.Scale); } else { const PODScale& scale2= AnimationScales[frameIndex+1]; Scale3F resultScale=Scale3F::LinearInterpolate(scale1.Scale,scale2.Scale,frameBlend); outMatrix=Matrix4::CreateScale(resultScale); } } } else { const PODScale& scale= AnimationScales[0]; outMatrix=Matrix4::CreateScale(scale.Scale); } }
void ThreadEventImp::TryRemoveExpiredWaitsWithoutLock(ThreadEventMultipleWaiter* waiter) { RETURN_IF_EMPTY(mRegisteredWaits); //has been locked outside uint waitCount = mRegisteredWaits.Count(); FOR_EACH_SIZE(i, waitCount) { ThreadEventMultipleWaiterIndex& index = mRegisteredWaits[i]; if (index.Waiter == waiter) { mRegisteredWaits.RemoveAt(i); break; } }
void IListDataSource::Commit() { RETURN_IF_EMPTY(mDirtyRange); size_t count=mDirtyRange.Count(); if (count>=Count()) { OnDataChanged(*this); } else { OnItemUpdated(mDirtyRange.Min,count); } mDirtyRange.Reset(); mIsChanging=false; }
void PODNode::GetTranslateMatrix( uint frameIndex,float frameBlend,Matrix4& outMatrix ) const { RETURN_IF_EMPTY(AnimationPositions); if (MEDUSA_FLAG_HAS(AnimationFlags,PODAnimiationFlags::HasPosition)) { if (!AnimationPositionIndexes.IsEmpty()) { MEDUSA_ASSERT_LESS(frameIndex,AnimationPositionIndexes.Size(),""); uint index1=AnimationPositionIndexes[frameIndex]; const Point3F& q1= AnimationPositions[index1]; if (frameIndex==AnimationPositionIndexes.Size()-1) { //last frame outMatrix*=Matrix4::CreateTranslate(q1); } else { uint index2=AnimationPositionIndexes[frameIndex+1]; const Point3F& q2= AnimationPositions[index2]; Point3F resultQ=Point3F::LinearInterpolate(q1,q2,frameBlend); outMatrix*=Matrix4::CreateTranslate(resultQ); } } else { const Point3F& q1= AnimationPositions[frameIndex]; if (frameIndex==AnimationPositions.Size()-1) { //last frame outMatrix*=Matrix4::CreateTranslate(q1); } else { const Point3F& q2= AnimationPositions[frameIndex+1]; Point3F resultQ=Point3F::LinearInterpolate(q1,q2,frameBlend); outMatrix*=Matrix4::CreateTranslate(resultQ); } } } else { const Point3F& q= AnimationPositions[0]; outMatrix*=Matrix4::CreateTranslate(q); } }
void PODNode::GetRotateMatrix( uint frameIndex,float frameBlend,Matrix4& outMatrix ) const { RETURN_IF_EMPTY(AnimationRotations); if (MEDUSA_FLAG_HAS(AnimationFlags,PODAnimiationFlags::HasRotation)) { if (!AnimationRotationIndexes.IsEmpty()) { MEDUSA_ASSERT_LESS(frameIndex,AnimationRotationIndexes.Size(),""); uint index1=AnimationRotationIndexes[frameIndex]; const Quaternion& q1= AnimationRotations[index1]; if (frameIndex==AnimationRotationIndexes.Size()-1) { //last frame outMatrix*=Matrix4::CreateFromQuaternion(q1); } else { uint index2=AnimationRotationIndexes[frameIndex+1]; const Quaternion& q2= AnimationRotations[index2]; Quaternion resultQ=Quaternion::Slerp(q1,q2,frameBlend); outMatrix*=Matrix4::CreateFromQuaternion(resultQ); } } else { const Quaternion& q1= AnimationRotations[frameIndex]; if (frameIndex==AnimationRotations.Size()-1) { //last frame outMatrix*=Matrix4::CreateFromQuaternion(q1); } else { const Quaternion& q2= AnimationRotations[frameIndex+1]; Quaternion resultQ=Quaternion::Slerp(q1,q2,frameBlend); outMatrix*=Matrix4::CreateFromQuaternion(resultQ); } } } else { const Quaternion& q= AnimationRotations[0]; outMatrix*=Matrix4::CreateFromQuaternion(q); } }
void SingleLineFontModel::SetText( WStringRef text ) { RETURN_IF_EQUAL(mText,text); mText=text; RemoveAllMeshes(); ResetCachedMeshes(); RETURN_IF_EMPTY(mText); Size2F outSize; List<BaseFontMesh*> meshes; List<IMaterial*> outMaterials; TextLayouter::LayoutSingleLineText(meshes, outMaterials,outSize,*mFont,mText,mAlignment,mRestrictSize); //AddMeshes(meshes); SetSize(outSize); }
void SceneRenderGroup::Draw(IRenderQueue& renderQueue, RenderingFlags renderingFlags/*=RenderingFlags::None*/) { RETURN_IF_EMPTY(mGroups); RenderingContext::Instance().ApplyRenderTargetAndCamera(mRenderTarget, mCamera); if (!MEDUSA_FLAG_HAS(renderingFlags,RenderingFlags::KeepRenderTarget)) { mRenderTarget->Clear(); } mRenderTarget->OnBeforeDraw(); for (auto group : mGroups) { group->Draw(renderQueue, renderingFlags); } mRenderTarget->OnAfterDraw(); RenderingContext::Instance().RestoreRenderTargetAndCamera(); }
void PODNode::GetMatrix( uint frameIndex,Matrix4& outMatrix ) const { //first get,use = RETURN_IF_EMPTY(AnimationMatrixes); if (MEDUSA_FLAG_HAS(AnimationFlags,PODAnimiationFlags::HasMatrix)) { if (!AnimationMatrixIndexes.IsEmpty()) { uint matrixIndex=AnimationMatrixIndexes[frameIndex]; outMatrix=AnimationMatrixes[matrixIndex]; } else { outMatrix=AnimationMatrixes[frameIndex]; } } else { outMatrix=AnimationMatrixes[0]; //use first one } }
void INode::RemoveAllChilds(NodeRemoveFlags flags /*= NodeRemoveFlags::OnlyChildren*/) { RETURN_IF_EMPTY(mNodes); if (mManagedNodes.Count() == mNodes.Count()) { flags = NodeRemoveFlags::All; } bool hasManaged = !mManagedNodes.IsEmpty(); switch (flags.ToInt()) { case NodeRemoveFlags::OnlyChildren.IntValue: if (hasManaged) { List<size_t> removedIndices; size_t count = mNodes.Count(); FOR_EACH_SIZE(i, count) { INode* node = mNodes[i]; if (!mManagedNodes.Contains(node)) { node->SetParent(nullptr); removedIndices.Add(i); StringRef name = node->Name(); if (!name.IsEmpty()) { mNodeDict.RemoveKey(name); } } } mNodes.RemoveIndexes(removedIndices); } else {
void ThreadPool::DeleteWork(const StringRef& name) { RETURN_IF_EMPTY(name); ThreadPoolWork* work = mNamedWorks.RemoveKeyWithValueReturned(name, nullptr); SAFE_RELEASE(work); }
void BaseFeatureLayer::OnRefresh(INode* sender, TapGestureEventArg& e) { RETURN_IF_EMPTY(mLayers); OnRestart(); }