}
/**
+ * Discard visual from source to visual factory.
+ */
+void DiscardVisual(RegisteredVisualContainer::Iterator sourceIter, RegisteredVisualContainer& source)
+{
+ Toolkit::Visual::Base visual = (*sourceIter)->visual;
+ if(visual)
+ {
+ if(Stage::IsInstalled())
+ {
+ Toolkit::VisualFactory::Get().DiscardVisual(visual);
+ }
+ }
+
+ source.Erase(sourceIter);
+}
+
+/**
* Performs actions as requested using the action name.
* @param[in] object The object on which to perform the action.
* @param[in] actionName The action to perform.
mIsKeyboardNavigationSupported(false),
mIsKeyboardFocusGroup(false),
mIsEmittingResourceReadySignal(false),
- mNeedToEmitResourceReady(false),
+ mIdleCallbackRegistered(false),
mDispatchKeyEvents(true)
{
Dali::Accessibility::Accessible::RegisterExternalAccessibleGetter(&ExternalAccessibleGetter);
Control::Impl& Control::Impl::Get(Internal::Control& internalControl)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
return *internalControl.mImpl;
}
const Control::Impl& Control::Impl::Get(const Internal::Control& internalControl)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
return *internalControl.mImpl;
}
void Control::Impl::RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual, VisualState::Type enabled, DepthIndexValue::Type depthIndexValueSet, int depthIndex)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
DALI_LOG_INFO(gLogFilter, Debug::Concise, "RegisterVisual:%d \n", index);
bool visualReplaced(false);
void Control::Impl::UnregisterVisual(Property::Index index)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
RegisteredVisualContainer::Iterator iter;
if(FindVisual(index, mVisuals, iter))
{
Actor self(mControlImpl.Self());
Toolkit::GetImplementation((*iter)->visual).SetOffScene(self);
(*iter)->pending = false;
- (*iter)->visual.Reset();
- mRemoveVisuals.Erase(iter);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(iter, mRemoveVisuals);
}
}
void Control::Impl::ResourceReady()
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
// Emit signal if all enabled visuals registered by the control are ready or there are no visuals.
if(IsResourceReady())
{
- // Reset the flag
- mNeedToEmitResourceReady = false;
EmitResourceReadySignal();
}
}
{
Toolkit::GetImplementation((*visualToRemoveIter)->visual).SetOffScene(self);
}
- mRemoveVisuals.Erase(visualToRemoveIter);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(visualToRemoveIter, mRemoveVisuals);
}
// A visual is ready so control may need relayouting if staged
void Control::Impl::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
Toolkit::Control control = Toolkit::Control::DownCast(BaseHandle(object));
if(control)
Property::Value Control::Impl::GetProperty(BaseObject* object, Property::Index index)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
Property::Value value;
Toolkit::Control control = Toolkit::Control::DownCast(BaseHandle(object));
void Control::Impl::ReplaceStateVisualsAndProperties(const StylePtr oldState, const StylePtr newState, const std::string& subState)
{
+ DALI_ASSERT_ALWAYS(Stage::IsCoreThread() && "Core is not installed. Might call this API from worker thread?");
+
// Collect all old visual names
DictionaryKeys stateVisualsToRemove;
if(oldState)
// Visuals pending replacement can now be taken out of the removal list and set off scene
// Iterate through all replacement visuals and add to a move queue then set off scene
- for(auto removalIter = mRemoveVisuals.Begin(), end = mRemoveVisuals.End(); removalIter != end; removalIter++)
+
+ if(!mRemoveVisuals.Empty())
{
- Toolkit::GetImplementation((*removalIter)->visual).SetOffScene(self);
+ std::reverse(mRemoveVisuals.Begin(), mRemoveVisuals.End());
+
+ while(!mRemoveVisuals.Empty())
+ {
+ auto removalIter = mRemoveVisuals.End() - 1u;
+ Toolkit::GetImplementation((*removalIter)->visual).SetOffScene(self);
+
+ // Discard removed visual. It will be destroyed at next Idle time.
+ DiscardVisual(removalIter, mRemoveVisuals);
+ }
}
for(auto replacedIter = mVisuals.Begin(), end = mVisuals.End(); replacedIter != end; replacedIter++)
{
(*replacedIter)->pending = false;
}
-
- mRemoveVisuals.Clear();
}
void Control::Impl::SetMargin(Extents margin)
mIsEmittingResourceReadySignal = true;
// If the signal handler changes visual, it may become ready during this call & therefore this method will
- // get called again recursively. If so, mNeedToEmitResourceReady is set below, and we act on it after that secondary
+ // get called again recursively. If so, mIdleCallbackRegistered is set below, and we act on it after that secondary
// invocation has completed by notifying in an Idle callback to prevent further recursion.
Dali::Toolkit::Control handle(mControlImpl.GetOwner());
mResourceReadySignal.Emit(handle);
- if(mNeedToEmitResourceReady)
+ mIsEmittingResourceReadySignal = false;
+ }
+ else
+ {
+ if(!mIdleCallbackRegistered)
{
+ mIdleCallbackRegistered = true;
+
// Add idler to emit the signal again
if(!mIdleCallback)
{
// The callback manager takes the ownership of the callback object.
mIdleCallback = MakeCallback(this, &Control::Impl::OnIdleCallback);
- Adaptor::Get().AddIdle(mIdleCallback, false);
+ Adaptor::Get().AddIdle(mIdleCallback, true);
}
}
-
- mIsEmittingResourceReadySignal = false;
- }
- else
- {
- mNeedToEmitResourceReady = true;
}
}
-void Control::Impl::OnIdleCallback()
+bool Control::Impl::OnIdleCallback()
{
- if(mNeedToEmitResourceReady)
+ // Reset the flag
+ mIdleCallbackRegistered = false;
+
+ // A visual is ready so control may need relayouting if staged
+ if(mControlImpl.Self().GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
{
- // Reset the flag
- mNeedToEmitResourceReady = false;
+ mControlImpl.RelayoutRequest();
+ }
- // A visual is ready so control may need relayouting if staged
- if(mControlImpl.Self().GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
- {
- mControlImpl.RelayoutRequest();
- }
+ EmitResourceReadySignal();
- EmitResourceReadySignal();
+ if(!mIdleCallbackRegistered)
+ {
+ // Set the pointer to null as the callback manager deletes the callback after execute it.
+ mIdleCallback = nullptr;
}
- // Set the pointer to null as the callback manager deletes the callback after execute it.
- mIdleCallback = nullptr;
+ // Repeat idle if mIdleCallbackRegistered become true one more time.
+ return mIdleCallbackRegistered;
}
Toolkit::DevelControl::ControlAccessible* Control::Impl::GetAccessibleObject()