utc-Dali-PinchGestureDetector.cpp
utc-Dali-Pixel.cpp
utc-Dali-PixelData.cpp
+ utc-Dali-Processors.cpp
utc-Dali-PropertyArray.cpp
utc-Dali-PropertyBuffer.cpp
utc-Dali-PropertyMap.cpp
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/integration-api/core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+
+class TestProcessor : public Integration::Processor
+{
+public:
+ TestProcessor()
+ : processRun(false)
+ {
+ }
+
+ virtual void Process()
+ {
+ processRun = true;
+ }
+
+ bool processRun;
+};
+
+
+int UtcDaliCoreProcessorP(void)
+{
+ TestApplication application;
+
+ TestProcessor testProcessor;
+ Integration::Core& core = application.GetCore();
+ core.RegisterProcessor( 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;
+
+ core.UnregisterProcessor( testProcessor );
+ application.SendNotification();
+ tet_infoline("Test that the processor has not been executed again:");
+ DALI_TEST_CHECK( testProcessor.processRun == false );
+
+ END_TEST;
+}
return mImpl->GetStereoBase();
}
+void Core::RegisterProcessor( Processor& processor )
+{
+ mImpl->RegisterProcessor( processor );
+}
+
+void Core::UnregisterProcessor( Processor& processor )
+{
+ mImpl->UnregisterProcessor( processor );
+}
+
Core::Core()
: mImpl( NULL )
{
#define DALI_INTEGRATION_CORE_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
};
/**
+ * Interface to enable classes to be processed after the event loop. Classes are processed
+ * in the order they are registered.
+ */
+class DALI_IMPORT_API Processor
+{
+public:
+ /**
+ * @brief Run the processor
+ */
+ virtual void Process() = 0;
+
+protected:
+ virtual ~Processor() { }
+};
+
+
+/**
* Integration::Core is used for integration with the native windowing system.
* The following integration tasks must be completed:
*
*/
float GetStereoBase() const;
+ /**
+ * @brief Register a processor
+ *
+ * Note, Core does not take ownership of this processor.
+ * @param[in] processor The process to register
+ */
+ void RegisterProcessor( Processor& processor );
+
+ /**
+ * @brief Unregister a processor
+ * @param[in] processor The process to unregister
+ */
+ void UnregisterProcessor( Processor& processor );
+
private:
/**
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Run the size negotiation after event processing finished signal
mRelayoutController->Relayout();
+ // Run any registered processors
+ RunProcessors();
+
// Rebuild depth tree after event processing has finished
mStage->RebuildDepthTree();
mStage->SetStereoBase( stereoBase );
}
+void Core::RegisterProcessor( Integration::Processor& processor )
+{
+ mProcessors.PushBack(&processor);
+}
+
+void Core::UnregisterProcessor( Integration::Processor& processor )
+{
+ auto iter = std::find( mProcessors.Begin(), mProcessors.End(), &processor );
+ if( iter != mProcessors.End() )
+ {
+ mProcessors.Erase( iter );
+ }
+}
+
+void Core::RunProcessors()
+{
+ // Copy processor pointers to prevent changes to vector affecting loop iterator.
+ Dali::Vector<Integration::Processor*> processors( mProcessors );
+
+ for( auto processor : processors )
+ {
+ if( processor )
+ {
+ processor->Process();
+ }
+ }
+}
+
float Core::GetStereoBase() const
{
return mStage->GetStereoBase();
#define DALI_INTERNAL_CORE_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/integration-api/context-notifier.h>
#include <dali/integration-api/core-enumerations.h>
namespace Integration
{
+class Processor;
class RenderController;
class PlatformAbstraction;
class GestureManager;
*/
float GetStereoBase() const;
-private: // for use by ThreadLocalStorage
+
+ /**
+ * @copydoc Dali::Integration::Core::RegisterProcessor
+ */
+ void RegisterProcessor( Dali::Integration::Processor& processor );
+
+ /**
+ * @copydoc Dali::Integration::Core::UnregisterProcessor
+ */
+ void UnregisterProcessor( Dali::Integration::Processor& processor );
+
+private:
+ /**
+ * Run each registered processor
+ */
+ void RunProcessors();
+
+ // for use by ThreadLocalStorage
/**
* Returns the current stage.
OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
OwnerPointer<EventProcessor> mEventProcessor; ///< The event processor
+ Dali::Vector<Integration::Processor*> mProcessors; ///< Registered processors (not owned)
friend class ThreadLocalStorage;