Gesture event refactor
[platform/core/uifw/dali-core.git] / dali / internal / event / common / thread-local-storage.cpp
index 7885bc9..8ce6c11 100644 (file)
@@ -1,33 +1,27 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2019 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.
+ *
+ */
 
 // CLASS HEADER
 #include <dali/internal/event/common/thread-local-storage.h>
 
-// EXTERNAL INCLUDES
-#include <boost/thread/tss.hpp>
-#include <memory>
-
 // INTERNAL INCLUDES
 #include <dali/internal/common/core-impl.h>
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/internal/render/common/render-manager.h>
-#include <dali/integration-api/platform-abstraction.h>
 #include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/math/vector2.h>
+#include <dali/internal/event/common/event-thread-services.h>
 
 namespace Dali
 {
@@ -37,21 +31,15 @@ namespace Internal
 
 namespace
 {
-#ifdef EMSCRIPTEN
-  std::auto_ptr<ThreadLocalStorage> threadLocal;
-#else
-  boost::thread_specific_ptr<ThreadLocalStorage> threadLocal;
-#endif
+thread_local ThreadLocalStorage* threadLocal = nullptr;
 }
 
 ThreadLocalStorage::ThreadLocalStorage(Core* core)
-: mCore(core)
+: mCore( core )
 {
-  DALI_ASSERT_ALWAYS( threadLocal.get() == NULL && "Cannot create more than one ThreadLocalStorage object" );
-
-  // reset is used to store a new value associated with this thread
-  threadLocal.reset(this);
+  DALI_ASSERT_ALWAYS( threadLocal == nullptr && "Cannot create more than one ThreadLocalStorage object" );
 
+  threadLocal = this;
 }
 
 ThreadLocalStorage::~ThreadLocalStorage()
@@ -60,22 +48,25 @@ ThreadLocalStorage::~ThreadLocalStorage()
 
 void ThreadLocalStorage::Remove()
 {
-  threadLocal.reset();
+  threadLocal = nullptr;
 }
 
 ThreadLocalStorage& ThreadLocalStorage::Get()
 {
-  ThreadLocalStorage* tls = threadLocal.get();
-
-  DALI_ASSERT_ALWAYS(tls);
+  DALI_ASSERT_ALWAYS(threadLocal);
 
-  return *tls;
+  return *threadLocal;
 }
 
 bool ThreadLocalStorage::Created()
 {
   // see if the TLS has been set yet
-  return (threadLocal.get() != NULL);
+  return (threadLocal != nullptr);
+}
+
+ThreadLocalStorage* ThreadLocalStorage::GetInternal()
+{
+  return threadLocal;
 }
 
 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
@@ -93,54 +84,54 @@ NotificationManager& ThreadLocalStorage::GetNotificationManager()
   return mCore->GetNotificationManager();
 }
 
-ResourceManager& ThreadLocalStorage::GetResourceManager()
+ShaderFactory& ThreadLocalStorage::GetShaderFactory()
 {
-  return mCore->GetResourceManager();
+  return mCore->GetShaderFactory();
 }
 
-ResourceClient& ThreadLocalStorage::GetResourceClient()
+StagePtr ThreadLocalStorage::GetCurrentStage()
 {
-  return mCore->GetResourceClient();
+  return mCore->GetCurrentStage();
 }
 
-ImageFactory& ThreadLocalStorage::GetImageFactory()
+GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
 {
-  return mCore->GetImageFactory();
+  return mCore->GetGestureEventProcessor();
 }
 
-ModelFactory& ThreadLocalStorage::GetModelFactory()
+RelayoutController& ThreadLocalStorage::GetRelayoutController()
 {
-  return mCore->GetModelFactory();
+  return mCore->GetRelayoutController();
 }
 
-FontFactory& ThreadLocalStorage::GetFontFactory()
+ObjectRegistry& ThreadLocalStorage::GetObjectRegistry()
 {
-  return mCore->GetFontFactory();
+  return mCore->GetObjectRegistry();
 }
 
-ShaderFactory& ThreadLocalStorage::GetShaderFactory()
+EventThreadServices& ThreadLocalStorage::GetEventThreadServices()
 {
-  return mCore->GetShaderFactory();
+  return mCore->GetEventThreadServices();
 }
 
-StagePtr ThreadLocalStorage::GetCurrentStage()
+PropertyNotificationManager& ThreadLocalStorage::GetPropertyNotificationManager()
 {
-  return mCore->GetCurrentStage();
+  return mCore->GetPropertyNotificationManager();
 }
 
-EventToUpdate& ThreadLocalStorage::GetEventToUpdate()
+AnimationPlaylist& ThreadLocalStorage::GetAnimationPlaylist()
 {
-  return GetUpdateManager().GetEventToUpdate();
+  return mCore->GetAnimationPlaylist();
 }
 
-GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
+void ThreadLocalStorage::AddScene( Scene* scene )
 {
-  return mCore->GetGestureEventProcessor();
+  mCore->AddScene( scene );
 }
 
-EmojiFactory& ThreadLocalStorage::GetEmojiFactory()
+void ThreadLocalStorage::RemoveScene( Scene* scene )
 {
-  return mCore->GetEmojiFactory();
+  mCore->RemoveScene( scene );
 }
 
 } // namespace Internal