Previous code request UpdateOnce by each visuals.
But this don't need to spend the number of requests.
So let we just use only one single request API for it.
Change-Id: I5b11ee7ad19dc7c32945c0cfc637f7c65cfe3a77
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
{
mVectorAnimationTask->ResourceReadySignal().Connect(this, &AnimatedVectorImageVisual::OnResourceReady);
mVectorAnimationTask->SetAnimationFinishedCallback(MakeCallback(this, &AnimatedVectorImageVisual::OnAnimationFinished));
- mVectorAnimationTask->SetForceRenderOnceCallback(MakeCallback(this, &AnimatedVectorImageVisual::OnForceRendering));
EncodedImageBuffer encodedImageBuffer;
}
}
-void AnimatedVectorImageVisual::OnForceRendering(uint32_t playStateId)
-{
- if(!mCoreShutdown && Dali::Adaptor::IsAvailable())
- {
- Dali::Adaptor::Get().UpdateOnce();
- }
-}
-
void AnimatedVectorImageVisual::SendAnimationData()
{
if(mAnimationData.resendFlag)
*/
void OnAnimationFinished(uint32_t playStateId);
- /**
- * @brief Event callback from rasterize thread. This is called when we want to ensure rendering next frame.
- *
- * @param[in] argument Not using arguments
- */
- void OnForceRendering(uint32_t argument);
-
/**
* @brief Send animation data to the rasterize thread.
*/
mVectorAnimationThread.RemoveEventTriggerCallbacks(mAnimationFinishedCallback.get());
mAnimationFinishedCallback.reset();
}
- if(mForceRenderOnceCallback)
- {
- mVectorAnimationThread.RemoveEventTriggerCallbacks(mForceRenderOnceCallback.get());
- mForceRenderOnceCallback.reset();
- }
if(mLoadCompletedCallback)
{
mVectorAnimationThread.RemoveEventTriggerCallbacks(mLoadCompletedCallback.get());
mAnimationFinishedCallback = std::unique_ptr<CallbackBase>(callback);
}
-void VectorAnimationTask::SetForceRenderOnceCallback(CallbackBase* callback)
-{
- Mutex::ScopedLock lock(mMutex);
- mForceRenderOnceCallback = std::unique_ptr<CallbackBase>(callback);
-}
-
void VectorAnimationTask::SetLoopCount(int32_t count)
{
if(mLoopCount != count)
if(mNotifyAfterRasterization || mNeedForceRenderOnceTrigger)
{
Mutex::ScopedLock lock(mMutex);
- if(mForceRenderOnceCallback)
- {
- mVectorAnimationThread.AddEventTriggerCallback(mForceRenderOnceCallback.get(), mAppliedPlayStateId);
- }
+ mVectorAnimationThread.RequestForceRenderOnce();
mNeedForceRenderOnceTrigger = false;
}
*/
void SetAnimationFinishedCallback(CallbackBase* callback);
- /**
- * @brief This callback is called when we want to force render next frame.
- * @param[in] callback The force render once callback
- */
- void SetForceRenderOnceCallback(CallbackBase* callback);
-
/**
* @brief Gets the playing range in frame number.
* @param[out] startFrame The frame number to specify minimum progress.
Mutex mMutex;
ResourceReadySignalType mResourceReadySignal;
std::unique_ptr<CallbackBase> mAnimationFinishedCallback{};
- std::unique_ptr<CallbackBase> mForceRenderOnceCallback{};
std::unique_ptr<CallbackBase> mLoadCompletedCallback{};
mutable Property::Map mCachedLayerInfo;
mutable Property::Map mCachedMarkerInfo;
mSleepThread(MakeCallback(this, &VectorAnimationThread::OnAwakeFromSleep)),
mConditionalWait(),
mEventTriggerMutex(),
+ mLogFactory(Dali::Adaptor::Get().GetLogFactory()),
+ mTraceFactory(Dali::Adaptor::Get().GetTraceFactory()),
mNeedToSleep(false),
mDestroyThread(false),
- mLogFactory(Dali::Adaptor::Get().GetLogFactory()),
- mTraceFactory(Dali::Adaptor::Get().GetTraceFactory())
+ mEventTriggered(false),
+ mForceRenderOnce(false)
{
mAsyncTaskManager = Dali::AsyncTaskManager::Get();
mSleepThread.Start();
}
}
+void VectorAnimationThread::RequestForceRenderOnce()
+{
+ Mutex::ScopedLock lock(mEventTriggerMutex);
+ if(!mDestroyThread)
+ {
+ mForceRenderOnce = true;
+
+ if(!mEventTriggered)
+ {
+ mEventTrigger->Trigger();
+ mEventTriggered = true;
+ }
+ }
+}
+
void VectorAnimationThread::Run()
{
SetThreadName("VectorAnimationThread");
}
CallbackBase::Execute(*callbackPair.first, callbackPair.second);
}
+ // Request update once if we need.
+ {
+ Mutex::ScopedLock lock(mEventTriggerMutex);
+ if(!mDestroyThread && mForceRenderOnce)
+ {
+ mForceRenderOnce = false;
+ if(Dali::Adaptor::IsAvailable())
+ {
+ Dali::Adaptor::Get().UpdateOnce();
+ }
+ }
+ }
}
std::pair<CallbackBase*, uint32_t> VectorAnimationThread::GetNextEventCallback()
*/
void RemoveEventTriggerCallbacks(CallbackBase* callback);
+ /**
+ * @brief Request to event callback from rasterize thread. This is called when we want to ensure rendering next frame.
+ */
+ void RequestForceRenderOnce();
+
protected:
/**
* @brief The entry function of the animation thread.
std::chrono::time_point<std::chrono::steady_clock> mSleepTimePoint;
const Dali::LogFactoryInterface& mLogFactory;
const Dali::TraceFactoryInterface& mTraceFactory;
- bool mNeedToSleep;
- bool mDestroyThread;
+
+ bool mNeedToSleep : 1;
+ bool mDestroyThread : 1;
};
private:
ConditionalWait mConditionalWait;
Mutex mEventTriggerMutex;
std::unique_ptr<EventThreadCallback> mEventTrigger{};
- bool mNeedToSleep;
- bool mDestroyThread;
- bool mEventTriggered{false};
const Dali::LogFactoryInterface& mLogFactory;
const Dali::TraceFactoryInterface& mTraceFactory;
Dali::AsyncTaskManager mAsyncTaskManager;
+
+ bool mNeedToSleep : 1;
+ bool mDestroyThread : 1;
+ bool mEventTriggered : 1;
+ bool mForceRenderOnce : 1;
};
} // namespace Internal