Integration::Core& core;
};
+class NewTestProcessorOnce : public NewTestProcessor
+{
+public:
+ NewTestProcessorOnce(Integration::Core& core)
+ : NewTestProcessor(core)
+ {
+ }
+
+ virtual void Process(bool postProcessor)
+ {
+ processRun = true;
+ if(unregisterProcessor)
+ {
+ core.UnregisterProcessorOnce(*unregisterProcessor, postProcessor);
+ }
+ }
+
+ std::string_view GetProcessorName() const override
+ {
+ return "NewTestProcessorOnce";
+ }
+};
+
int UtcDaliCoreProcessorP(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliCoreProcessorOnceP(void)
+{
+ TestApplication application;
+
+ TestProcessor testProcessor;
+ Integration::Core& core = application.GetCore();
+ core.RegisterProcessorOnce(testProcessor);
+
+ tet_infoline("Test that the processor has not been executed yet:");
+ DALI_TEST_CHECK(testProcessor.processRun == false);
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processor has been executed:");
+ DALI_TEST_CHECK(testProcessor.processRun);
+
+ // Clear down for next part of test
+ testProcessor.processRun = false;
+
+ application.SendNotification();
+ tet_infoline("Test that the processor has not been executed:");
+ DALI_TEST_CHECK(!testProcessor.processRun);
+
+ core.RegisterProcessorOnce(testProcessor);
+ core.UnregisterProcessorOnce(testProcessor);
+ application.SendNotification();
+ tet_infoline("Test that the processor has not been executed again:");
+ DALI_TEST_CHECK(!testProcessor.processRun);
+
+ END_TEST;
+}
+
int UtcDaliCoreProcessorMultipleP(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliCoreProcessorOnceMultipleP(void)
+{
+ TestApplication application;
+
+ TestProcessor testProcessor1;
+ TestProcessor testProcessor2;
+ TestProcessor testProcessor3;
+
+ Integration::Core& core = application.GetCore();
+ core.RegisterProcessorOnce(testProcessor1);
+
+ tet_infoline("Test that the processor has not been executed yet:");
+ DALI_TEST_CHECK(testProcessor1.processRun == false);
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processor has been executed:");
+ DALI_TEST_CHECK(testProcessor1.processRun);
+
+ // Clear down for next part of test
+ testProcessor1.processRun = false;
+
+ core.RegisterProcessorOnce(testProcessor1);
+ core.RegisterProcessorOnce(testProcessor2);
+ core.RegisterProcessorOnce(testProcessor3);
+
+ tet_infoline("Test that the processors have not been executed yet:");
+ DALI_TEST_CHECK(testProcessor1.processRun == false);
+ DALI_TEST_CHECK(testProcessor2.processRun == false);
+ DALI_TEST_CHECK(testProcessor3.processRun == false);
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processors have been executed:");
+ DALI_TEST_CHECK(testProcessor1.processRun);
+ DALI_TEST_CHECK(testProcessor2.processRun);
+ DALI_TEST_CHECK(testProcessor3.processRun);
+
+ // Clear down for next part of test
+ testProcessor1.processRun = false;
+ testProcessor2.processRun = false;
+ testProcessor3.processRun = false;
+
+ core.RegisterProcessorOnce(testProcessor1);
+ core.RegisterProcessorOnce(testProcessor2);
+ core.RegisterProcessorOnce(testProcessor3);
+
+ core.UnregisterProcessorOnce(testProcessor2);
+ application.SendNotification();
+ tet_infoline("Test that the unregistered processor has not been executed again but others have");
+ DALI_TEST_CHECK(testProcessor1.processRun);
+ DALI_TEST_CHECK(testProcessor2.processRun == false);
+ DALI_TEST_CHECK(testProcessor3.processRun);
+
+ END_TEST;
+}
+
int UtcDaliCorePostProcessorP(void)
{
TestApplication application;
END_TEST;
}
+int UtcDaliCorePostProcessorOnceP(void)
+{
+ TestApplication application;
+
+ TestProcessor testProcessor;
+ Integration::Core& core = application.GetCore();
+ core.RegisterProcessorOnce(testProcessor, true);
+
+ tet_infoline("Test that the processor has not been executed yet:");
+ DALI_TEST_CHECK(testProcessor.processRun == false);
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processor has been executed:");
+ DALI_TEST_CHECK(testProcessor.processRun);
+
+ // Clear down for next part of test
+ testProcessor.processRun = false;
+
+ application.SendNotification();
+ tet_infoline("Test that the processor has not been executed:");
+ DALI_TEST_CHECK(!testProcessor.processRun);
+
+ core.RegisterProcessorOnce(testProcessor, true);
+ core.UnregisterProcessorOnce(testProcessor, true);
+ application.SendNotification();
+ tet_infoline("Test that the processor has not been executed again:");
+ DALI_TEST_CHECK(!testProcessor.processRun);
+
+ END_TEST;
+}
+
int UtcDaliCoreProcessorUnregisterDuringCallback01(void)
{
// Test pre-processor
END_TEST;
}
+int UtcDaliCoreProcessorOnceUnregisterDuringCallback01(void)
+{
+ // Test post-processor
+ TestApplication application;
+ Integration::Core& core = application.GetCore();
+
+ NewTestProcessorOnce testProcessor1(core);
+ TestProcessor testProcessor2;
+ TestProcessor testProcessor3;
+
+ core.RegisterProcessorOnce(testProcessor1);
+ core.RegisterProcessorOnce(testProcessor2);
+ core.RegisterProcessorOnce(testProcessor3);
+
+ DALI_TEST_CHECK(testProcessor1.processRun == false);
+ DALI_TEST_CHECK(testProcessor2.processRun == false);
+ DALI_TEST_CHECK(testProcessor3.processRun == false);
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processors have been executed:");
+ DALI_TEST_CHECK(testProcessor1.processRun);
+ DALI_TEST_CHECK(testProcessor2.processRun);
+ DALI_TEST_CHECK(testProcessor3.processRun);
+
+ // Clear down for next part of test
+ testProcessor1.processRun = false;
+ testProcessor2.processRun = false;
+ testProcessor3.processRun = false;
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processors have not been executed:");
+ DALI_TEST_CHECK(!testProcessor1.processRun);
+ DALI_TEST_CHECK(!testProcessor2.processRun);
+ DALI_TEST_CHECK(!testProcessor3.processRun);
+
+ core.RegisterProcessorOnce(testProcessor1);
+ core.RegisterProcessorOnce(testProcessor2);
+ core.RegisterProcessorOnce(testProcessor3);
+
+ testProcessor1.SetProcessorToUnregister(&testProcessor3);
+
+ tet_infoline("Test that the processor unregistered during the callback has not been executed");
+ application.SendNotification();
+
+ DALI_TEST_CHECK(testProcessor1.processRun);
+ DALI_TEST_CHECK(testProcessor2.processRun);
+ DALI_TEST_CHECK(!testProcessor3.processRun);
+
+ END_TEST;
+}
+
+int UtcDaliCoreProcessorOnceUnregisterDuringCallback02(void)
+{
+ // Test post-processor
+ TestApplication application;
+ Integration::Core& core = application.GetCore();
+
+ NewTestProcessorOnce testProcessor1(core);
+ TestProcessor testProcessor2;
+ TestProcessor testProcessor3;
+
+ core.RegisterProcessorOnce(testProcessor1, true);
+ core.RegisterProcessorOnce(testProcessor2, true);
+ core.RegisterProcessorOnce(testProcessor3, true);
+
+ DALI_TEST_CHECK(testProcessor1.processRun == false);
+ DALI_TEST_CHECK(testProcessor2.processRun == false);
+ DALI_TEST_CHECK(testProcessor3.processRun == false);
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processors have been executed:");
+ DALI_TEST_CHECK(testProcessor1.processRun);
+ DALI_TEST_CHECK(testProcessor2.processRun);
+ DALI_TEST_CHECK(testProcessor3.processRun);
+
+ // Clear down for next part of test
+ testProcessor1.processRun = false;
+ testProcessor2.processRun = false;
+ testProcessor3.processRun = false;
+
+ application.SendNotification();
+
+ tet_infoline("Test that the processors have not been executed:");
+ DALI_TEST_CHECK(!testProcessor1.processRun);
+ DALI_TEST_CHECK(!testProcessor2.processRun);
+ DALI_TEST_CHECK(!testProcessor3.processRun);
+
+ core.RegisterProcessorOnce(testProcessor1, true);
+ core.RegisterProcessorOnce(testProcessor2, true);
+ core.RegisterProcessorOnce(testProcessor3, true);
+
+ testProcessor1.SetProcessorToUnregister(&testProcessor3);
+
+ tet_infoline("Test that the processor unregistered during the callback has not been executed");
+ application.SendNotification();
+
+ DALI_TEST_CHECK(testProcessor1.processRun);
+ DALI_TEST_CHECK(testProcessor2.processRun);
+ DALI_TEST_CHECK(!testProcessor3.processRun);
+
+ END_TEST;
+}
+
int UtcDaliCoreProcessorGetProcessorName(void)
{
// Test post-processor
TestProcessor testProcessor1;
TestProcessor testProcessor2;
TestProcessor testProcessor3;
+ TestProcessor testProcessor4;
+ TestProcessor testProcessor5;
Integration::Core& core = application.GetCore();
core.RegisterProcessor(testProcessor1);
testProcessor2.processRun = false;
testProcessor3.processRun = false;
+ core.RegisterProcessorOnce(testProcessor4);
+ core.RegisterProcessorOnce(testProcessor5, true);
+
core.UnregisterProcessors();
application.SendNotification();
tet_infoline("Test that all processors has not been executed again");
DALI_TEST_CHECK(testProcessor1.processRun == false);
DALI_TEST_CHECK(testProcessor2.processRun == false);
DALI_TEST_CHECK(testProcessor3.processRun == false);
+ DALI_TEST_CHECK(testProcessor4.processRun == false);
+ DALI_TEST_CHECK(testProcessor5.processRun == false);
END_TEST;
: mRenderController(renderController),
mPlatform(platform),
mGraphicsController(graphicsController),
+ mProcessorOnceIndex(0u),
+ mPostProcessorOnceIndex(0u),
mProcessingEvent(false),
mProcessorUnregistered(false),
mPostProcessorUnregistered(false),
}
}
+void Core::RegisterProcessorOnce(Integration::Processor& processor, bool postProcessor)
+{
+ if(postProcessor)
+ {
+ mPostProcessorsOnce[mPostProcessorOnceIndex].PushBack(&processor);
+ }
+ else
+ {
+ mProcessorsOnce[mProcessorOnceIndex].PushBack(&processor);
+ }
+}
+
+void Core::UnregisterProcessorOnce(Integration::Processor& processor, bool postProcessor)
+{
+ if(postProcessor)
+ {
+ for(uint32_t index = 0; index < 2; ++index)
+ {
+ auto iter = std::find(mPostProcessorsOnce[index].Begin(), mPostProcessorsOnce[index].End(), &processor);
+ if(iter != mPostProcessorsOnce[index].End())
+ {
+ mPostProcessorsOnce[index].Erase(iter);
+ if(index != mPostProcessorOnceIndex)
+ {
+ // Check processor unregistered during processing.
+ mPostProcessorUnregistered = true;
+ }
+ }
+ }
+ }
+ else
+ {
+ for(uint32_t index = 0; index < 2; ++index)
+ {
+ auto iter = std::find(mProcessorsOnce[index].Begin(), mProcessorsOnce[index].End(), &processor);
+ if(iter != mProcessorsOnce[index].End())
+ {
+ mProcessorsOnce[index].Erase(iter);
+ if(index != mProcessorOnceIndex)
+ {
+ // Check processor unregistered during processing.
+ mProcessorUnregistered = true;
+ }
+ }
+ }
+ }
+}
+
void Core::UnregisterProcessors()
{
mPostProcessors.Clear();
mPostProcessorUnregistered = true;
mProcessors.Clear();
mProcessorUnregistered = true;
+
+ for(uint32_t index = 0; index < 2; ++index)
+ {
+ mPostProcessorsOnce[index].Clear();
+ mProcessorsOnce[index].Clear();
+ }
}
void Core::RunProcessors()
{
+ if(mProcessorsOnce[mProcessorOnceIndex].Count() != 0)
+ {
+ DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_PROCESSORS_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << mProcessorOnceIndex << ":" << mProcessorsOnce[mProcessorOnceIndex].Count() << "]";
+ });
+
+ // Swap processor index.
+ uint32_t currentIndex = mProcessorOnceIndex;
+ mProcessorOnceIndex ^= 1;
+
+ // Copy processor pointers to prevent changes to vector affecting loop iterator.
+ Dali::Vector<Integration::Processor*> processors(mProcessorsOnce[currentIndex]);
+
+ // To prevent accessing processor unregistered during the loop
+ mProcessorUnregistered = false;
+
+ for(auto processor : processors)
+ {
+ if(processor)
+ {
+ if(!mProcessorUnregistered)
+ {
+ DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ processor->Process(false);
+ DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ }
+ else
+ {
+ // Run processor if the processor is still in the list.
+ // It may be removed during the loop.
+ auto iter = std::find(mProcessorsOnce[currentIndex].Begin(), mProcessorsOnce[currentIndex].End(), processor);
+ if(iter != mProcessorsOnce[currentIndex].End())
+ {
+ DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ processor->Process(false);
+ DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ }
+ }
+ }
+ }
+
+ // Clear once processor.
+ mProcessorsOnce[currentIndex].Clear();
+
+ DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_PROCESSORS_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << currentIndex;
+ if(mProcessorUnregistered)
+ {
+ oss << ", processor changed";
+ }
+ oss << "]";
+ });
+ }
+
if(mProcessors.Count() != 0)
{
DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_PROCESSORS", [&](std::ostringstream& oss) {
void Core::RunPostProcessors()
{
+ if(mPostProcessorsOnce[mPostProcessorOnceIndex].Count() != 0)
+ {
+ DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSORS_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << mPostProcessorOnceIndex << ":" << mPostProcessorsOnce[mPostProcessorOnceIndex].Count() << "]";
+ });
+
+ // Swap processor index.
+ uint32_t currentIndex = mPostProcessorOnceIndex;
+ mPostProcessorOnceIndex ^= 1;
+
+ // Copy processor pointers to prevent changes to vector affecting loop iterator.
+ Dali::Vector<Integration::Processor*> processors(mPostProcessorsOnce[currentIndex]);
+
+ // To prevent accessing processor unregistered during the loop
+ mPostProcessorUnregistered = false;
+
+ for(auto processor : processors)
+ {
+ if(processor)
+ {
+ if(!mPostProcessorUnregistered)
+ {
+ DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ processor->Process(true);
+ DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ }
+ else
+ {
+ // Run processor if the processor is still in the list.
+ // It may be removed during the loop.
+ auto iter = std::find(mPostProcessorsOnce[currentIndex].Begin(), mPostProcessorsOnce[currentIndex].End(), processor);
+ if(iter != mPostProcessorsOnce[currentIndex].End())
+ {
+ DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ processor->Process(true);
+ DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSOR_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << processor->GetProcessorName() << "]";
+ });
+ }
+ }
+ }
+ }
+
+ // Clear once processor.
+ mPostProcessorsOnce[currentIndex].Clear();
+
+ DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSORS_ONCE", [&](std::ostringstream& oss) {
+ oss << "[" << currentIndex;
+ if(mPostProcessorUnregistered)
+ {
+ oss << ", processor changed";
+ }
+ oss << "]";
+ });
+ }
+
if(mPostProcessors.Count() != 0)
{
DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_CORE_RUN_POST_PROCESSORS", [&](std::ostringstream& oss) {