Add codes for Dali Windows Backend 09/172009/73
authoradun <xiaohui.fang@samsung.com>
Fri, 9 Mar 2018 02:14:48 +0000 (10:14 +0800)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 12 Apr 2019 15:39:16 +0000 (15:39 +0000)
1. Add codes to adaptor Windows OS.
2. Implement some Linux's API on Windows OS.

Change-Id: Ibdc64e1167b1a85410addd9695eca94a608362c3
Signed-off-by: adun <xiaohui.fang@samsung.com>
46 files changed:
dali/devel-api/adaptor-framework/input-method-context.h
dali/internal/adaptor/windows/framework-win.cpp [new file with mode: 0755]
dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/graphics/windows-gl/egl-image-extensions.cpp [new file with mode: 0755]
dali/internal/graphics/windows/vsync-monitor-win.cpp [new file with mode: 0755]
dali/internal/imaging/windows/curl-environment-win.cpp [new file with mode: 0755]
dali/internal/imaging/windows/file-download-win.cpp [new file with mode: 0755]
dali/internal/imaging/windows/native-image-source-factory-win.cpp [new file with mode: 0755]
dali/internal/imaging/windows/native-image-source-factory-win.h [new file with mode: 0755]
dali/internal/imaging/windows/native-image-source-impl-win.cpp [new file with mode: 0755]
dali/internal/imaging/windows/native-image-source-impl-win.h [new file with mode: 0755]
dali/internal/input/windows/input-method-context-factory-win.cpp [new file with mode: 0755]
dali/internal/input/windows/input-method-context-impl-win.cpp [new file with mode: 0755]
dali/internal/input/windows/input-method-context-impl-win.h [new file with mode: 0755]
dali/internal/input/windows/key-mapping-win.cpp [new file with mode: 0755]
dali/internal/input/windows/virtual-keyboard-impl-win.cpp [new file with mode: 0755]
dali/internal/system/common/abort-handler.h [changed mode: 0644->0755]
dali/internal/system/common/file-closer.h [changed mode: 0644->0755]
dali/internal/system/file.list [changed mode: 0644->0755]
dali/internal/system/windows/callback-manager-win.cpp [new file with mode: 0755]
dali/internal/system/windows/callback-manager-win.h [new file with mode: 0755]
dali/internal/system/windows/file-closer-win.cpp [new file with mode: 0755]
dali/internal/system/windows/system-settings-win.cpp [new file with mode: 0755]
dali/internal/system/windows/timer-impl-win.cpp [new file with mode: 0755]
dali/internal/system/windows/trigger-event-factory.cpp [new file with mode: 0755]
dali/internal/system/windows/trigger-event.cpp [new file with mode: 0755]
dali/internal/system/windows/trigger-event.h [new file with mode: 0755]
dali/internal/system/windows/widget-application-impl-win.cpp [new file with mode: 0755]
dali/internal/system/windows/widget-application-impl-win.h [new file with mode: 0755]
dali/internal/system/windows/widget-controller-win.cpp [new file with mode: 0755]
dali/internal/system/windows/widget-controller-win.h [new file with mode: 0755]
dali/internal/window-system/common/event-handler.cpp
dali/internal/window-system/windows/display-connection-factory-win.cpp [new file with mode: 0755]
dali/internal/window-system/windows/display-connection-factory-win.h [new file with mode: 0755]
dali/internal/window-system/windows/display-connection-impl-win.cpp [new file with mode: 0755]
dali/internal/window-system/windows/display-connection-impl-win.h [new file with mode: 0755]
dali/internal/window-system/windows/event-system-win.h [new file with mode: 0755]
dali/internal/window-system/windows/platform-implement-win.cpp [new file with mode: 0755]
dali/internal/window-system/windows/platform-implement-win.h [new file with mode: 0755]
dali/internal/window-system/windows/render-surface-factory-win.cpp [new file with mode: 0755]
dali/internal/window-system/windows/render-surface-factory-win.h [new file with mode: 0755]
dali/internal/window-system/windows/window-base-win.cpp [new file with mode: 0755]
dali/internal/window-system/windows/window-base-win.h [new file with mode: 0755]
dali/internal/window-system/windows/window-factory-win.cpp [new file with mode: 0755]
dali/internal/window-system/windows/window-factory-win.h [new file with mode: 0755]
dali/internal/window-system/windows/window-system-win.cpp [new file with mode: 0755]

index 6775ef2..be9c81e 100755 (executable)
@@ -42,7 +42,6 @@ class InputMethodContext;
  *
  * Specifically manages the ecore input method framework which enables the virtual or hardware keyboards.
  */
-
 class DALI_ADAPTOR_API InputMethodContext : public BaseHandle
 {
 public:
diff --git a/dali/internal/adaptor/windows/framework-win.cpp b/dali/internal/adaptor/windows/framework-win.cpp
new file mode 100755 (executable)
index 0000000..1fe8890
--- /dev/null
@@ -0,0 +1,333 @@
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// CLASS HEADER\r
+#include <dali/internal/adaptor/common/framework.h>\r
+\r
+// EXTERNAL INCLUDES\r
+#include <dali/integration-api/debug.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
+#include <dali/internal/system/common/callback-manager.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+namespace\r
+{\r
+\r
+/// Application Status Enum\r
+enum\r
+{\r
+  APP_CREATE,\r
+  APP_TERMINATE,\r
+  APP_PAUSE,\r
+  APP_RESUME,\r
+  APP_RESET,\r
+  APP_LANGUAGE_CHANGE,\r
+};\r
+\r
+} // Unnamed namespace\r
+/**\r
+ * Impl to hide WindowsSystem data members\r
+ */\r
+struct Framework::Impl\r
+{\r
+  // Constructor\r
+\r
+  Impl(void* data)\r
+  : mAbortCallBack( NULL ),\r
+    mCallbackManager( CallbackManager::New() ),\r
+    mLanguage( "NOT_SUPPORTED" ),\r
+    mRegion( "NOT_SUPPORTED" )\r
+  {\r
+  }\r
+\r
+  ~Impl()\r
+  {\r
+    delete mAbortCallBack;\r
+\r
+    // we're quiting the main loop so\r
+    // mCallbackManager->RemoveAllCallBacks() does not need to be called\r
+    // to delete our abort handler\r
+    delete mCallbackManager;\r
+  }\r
+\r
+  std::string GetLanguage() const\r
+  {\r
+    return mLanguage;\r
+  }\r
+\r
+  std::string GetRegion() const\r
+  {\r
+    return mRegion;\r
+  }\r
+\r
+  // Static methods\r
+\r
+  /**\r
+   * Called by AppCore on application creation.\r
+   */\r
+  static bool AppCreate(void *data)\r
+  {\r
+    return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);\r
+  }\r
+\r
+  /**\r
+   * Called by AppCore when the application should terminate.\r
+   */\r
+  static void AppTerminate(void *data)\r
+  {\r
+    static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);\r
+  }\r
+\r
+  /**\r
+   * Called by AppCore when the application is paused.\r
+   */\r
+  static void AppPause(void *data)\r
+  {\r
+    static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);\r
+  }\r
+\r
+  /**\r
+   * Called by AppCore when the application is resumed.\r
+   */\r
+  static void AppResume(void *data)\r
+  {\r
+    static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);\r
+  }\r
+\r
+  /**\r
+   * Called by AppCore when the language changes on the device.\r
+   */\r
+  static void AppLanguageChange(void* data)\r
+  {\r
+    static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);\r
+  }\r
+\r
+  void Run()\r
+  {\r
+    WindowsPlatformImplementation::RunLoop();\r
+  }\r
+\r
+  void Quit()\r
+  {\r
+  }\r
+\r
+  void SetCallbackBase( CallbackBase *base )\r
+  {\r
+    mAbortCallBack = base;\r
+  }\r
+\r
+  bool ExcuteCallback()\r
+  {\r
+    if( NULL != mAbortCallBack )\r
+    {\r
+      CallbackBase::Execute( *mAbortCallBack );\r
+      return true;\r
+    }\r
+    else\r
+    {\r
+      return false;\r
+    }\r
+  }\r
+\r
+private:\r
+  // Undefined\r
+  Impl( const Impl& impl ) = delete;\r
+\r
+  // Undefined\r
+  Impl& operator=( const Impl& impl ) = delete;\r
+\r
+private:\r
+  // Data\r
+  CallbackBase* mAbortCallBack;\r
+  CallbackManager *mCallbackManager;\r
+  std::string mLanguage;\r
+  std::string mRegion;\r
+};\r
+\r
+Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )\r
+: mObserver(observer),\r
+  mInitialised(false),\r
+  mRunning(false),\r
+  mArgc(argc),\r
+  mArgv(argv),\r
+  mBundleName(""),\r
+  mBundleId(""),\r
+  mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),\r
+  mImpl(NULL)\r
+{\r
+    InitThreads();\r
+    mImpl = new Impl(this);\r
+}\r
+\r
+Framework::~Framework()\r
+{\r
+  if (mRunning)\r
+  {\r
+    Quit();\r
+  }\r
+\r
+  delete mImpl;\r
+}\r
+\r
+void Framework::Run()\r
+{\r
+    mRunning = true;\r
+\r
+    Impl::AppCreate(this);\r
+    mImpl->Run();\r
+    mRunning = false;\r
+}\r
+\r
+void Framework::Quit()\r
+{\r
+  Impl::AppTerminate(this);\r
+}\r
+\r
+bool Framework::IsMainLoopRunning()\r
+{\r
+  return mRunning;\r
+}\r
+\r
+void Framework::AddAbortCallback( CallbackBase* callback )\r
+{\r
+  mImpl->SetCallbackBase( callback );\r
+}\r
+\r
+std::string Framework::GetBundleName() const\r
+{\r
+  return mBundleName;\r
+}\r
+\r
+void Framework::SetBundleName(const std::string& name)\r
+{\r
+  mBundleName = name;\r
+}\r
+\r
+std::string Framework::GetBundleId() const\r
+{\r
+  return mBundleId;\r
+}\r
+\r
+std::string Framework::GetResourcePath()\r
+{\r
+  // "DALI_APPLICATION_PACKAGE" is used by Windows specifically to get the already configured Application package path.\r
+  const char* winEnvironmentVariable = "DALI_APPLICATION_PACKAGE";\r
+  char* value = getenv( winEnvironmentVariable );\r
+\r
+  std::string resourcePath;\r
+  if ( value != NULL )\r
+  {\r
+    resourcePath = value;\r
+  }\r
+\r
+  return resourcePath;\r
+}\r
+\r
+std::string Framework::GetDataPath()\r
+{\r
+  std::string result = app_get_data_path();\r
+  return result;\r
+}\r
+\r
+void Framework::SetBundleId(const std::string& id)\r
+{\r
+  mBundleId = id;\r
+}\r
+\r
+void Framework::AbortCallback( )\r
+{\r
+  // if an abort call back has been installed run it.\r
+  if( false == mImpl->ExcuteCallback() )\r
+  {\r
+    Quit();\r
+  }\r
+}\r
+\r
+bool Framework::AppStatusHandler(int type, void *bundleData)\r
+{\r
+  switch (type)\r
+  {\r
+    case APP_CREATE:\r
+    {\r
+      mInitialised = true;\r
+\r
+      mObserver.OnInit();\r
+      break;\r
+    }\r
+    case APP_RESET:\r
+    {\r
+      mObserver.OnReset();\r
+      break;\r
+    }\r
+    case APP_RESUME:\r
+    {\r
+      mObserver.OnResume();\r
+      break;\r
+    }\r
+    case APP_TERMINATE:\r
+    {\r
+      mObserver.OnTerminate();\r
+      break;\r
+    }\r
+    case APP_PAUSE:\r
+    {\r
+      mObserver.OnPause();\r
+      break;\r
+    }\r
+    case APP_LANGUAGE_CHANGE:\r
+    {\r
+      mObserver.OnLanguageChanged();\r
+      break;\r
+    }\r
+    default:\r
+    {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return true;\r
+}\r
+\r
+void Framework::InitThreads()\r
+{\r
+}\r
+\r
+std::string Framework::GetLanguage() const\r
+{\r
+  return mImpl->GetLanguage();\r
+}\r
+\r
+std::string Framework::GetRegion() const\r
+{\r
+  return mImpl->GetRegion();\r
+}\r
+\r
+} // namespace Adaptor\r
+\r
+} // namespace Internal\r
+\r
+} // namespace Dali\r
index f4673f9..6580a6f 100755 (executable)
@@ -21,7 +21,6 @@
 
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
-
 #include <dali/public-api/common/dali-vector.h>
 
 // INTERNAL INCLUDES
diff --git a/dali/internal/graphics/windows-gl/egl-image-extensions.cpp b/dali/internal/graphics/windows-gl/egl-image-extensions.cpp
new file mode 100755 (executable)
index 0000000..9b4ab64
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ *
+ */
+
+
+// CLASS HEADER
+#include <dali/internal/graphics/common/egl-image-extensions.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-implementation.h>
+
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl)
+: mEglImplementation(eglImpl),
+  mImageKHRInitialized(false),
+  mImageKHRInitializeFailed(false)
+{
+  DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" );
+}
+
+EglImageExtensions::~EglImageExtensions()
+{
+}
+
+void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
+{
+  DALI_LOG_ERROR(" does not support CreateImageKHR\n");
+  return NULL;
+}
+
+void EglImageExtensions::DestroyImageKHR(void* eglImageKHR)
+{
+  DALI_LOG_ERROR(" does not support DestroyImageKHR\n");
+}
+
+void EglImageExtensions::TargetTextureKHR(void* eglImageKHR)
+{
+  DALI_LOG_ERROR(" does not support TargetTextureKHR\n");
+}
+
+void EglImageExtensions::InitializeEglImageKHR()
+{
+  DALI_LOG_ERROR(" does not support InitializeEglImageKHR\n");
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/graphics/windows/vsync-monitor-win.cpp b/dali/internal/graphics/windows/vsync-monitor-win.cpp
new file mode 100755 (executable)
index 0000000..9ba3026
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/graphics/common/vsync-monitor.h>
+
+// EXTERNAL INCLUDES
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+// constants to keep code readability with unsigned int has to be used as boolean (due to multithreading)
+const unsigned int TRUE = 1u;
+const unsigned int FALSE = 0u;
+
+const int FD_NONE( -1 );
+
+} // unnamed namespace
+
+VSyncMonitor::VSyncMonitor()
+: mFileDescriptor( FD_NONE ),
+  mUseHardwareVSync( FALSE ),
+  mHardwareVSyncAvailable( FALSE )
+{
+}
+
+VSyncMonitor::~VSyncMonitor()
+{
+  Terminate();
+}
+
+void VSyncMonitor::SetUseHardwareVSync( bool useHardware )
+{
+  mUseHardwareVSync = useHardware;
+}
+
+void VSyncMonitor::SetHardwareVSyncAvailable( bool hardwareVSyncAvailable )
+{
+  mHardwareVSyncAvailable = hardwareVSyncAvailable;
+}
+
+void VSyncMonitor::Initialize()
+{
+  DALI_ASSERT_DEBUG( mFileDescriptor == FD_NONE && "VSyncMonitor::Initialize() called twice" );
+
+  // setup vblank request - block and wait for next vblank
+  mVBlankInfo.request.type = DRM_VBLANK_NEXTONMISS;
+  mVBlankInfo.request.sequence = 0;
+  mVBlankInfo.request.signal = 0;
+
+  // setup vblank reply - block and wait for next vblank
+  mVBlankInfo.reply.type = DRM_VBLANK_NEXTONMISS;
+  mVBlankInfo.reply.sequence = 0;
+  mVBlankInfo.reply.tval_sec = 0;
+  mVBlankInfo.reply.tval_usec = 0;
+}
+
+void VSyncMonitor::Terminate()
+{
+}
+
+bool VSyncMonitor::UseHardware()
+{
+  return mUseHardwareVSync && mHardwareVSyncAvailable && (FD_NONE != mFileDescriptor );
+}
+
+
+bool VSyncMonitor::DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds )
+{
+  DALI_ASSERT_DEBUG( mFileDescriptor != FD_NONE && "Windows::VSyncMonitor is not initialized" );
+  return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/imaging/windows/curl-environment-win.cpp b/dali/internal/imaging/windows/curl-environment-win.cpp
new file mode 100755 (executable)
index 0000000..d727848
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// EXTERNAL INCLUDES\r
+#include <string>\r
+#include <curl/curl.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/imaging/common/file-download.h>\r
+#include <dali/integration-api/debug.h>\r
+#include <dali/internal/system/common/file-closer.h>\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace TizenPlatform\r
+{\r
+\r
+const int CONNECTION_TIMEOUT_SECONDS( 30L );\r
+const long VERBOSE_MODE = 0L;                // 0 == off, 1 == on\r
+const long CLOSE_CONNECTION_ON_ERROR = 1L;   // 0 == off, 1 == on\r
+const long EXCLUDE_HEADER = 0L;\r
+const long INCLUDE_HEADER = 1L;\r
+const long INCLUDE_BODY = 0L;\r
+const long EXCLUDE_BODY = 1L;\r
+\r
+namespace Network\r
+{\r
+\r
+void CurlEnvironment::GetThreadId( CRYPTO_THREADID* tid )\r
+{\r
+  // If dali uses c++ thread, we may replace pthread_self() to this_thread::get_id()\r
+  tid->val = Internal::Adaptor::WindowsPlatformImplementation::GetCurrentThreadId();\r
+}\r
+}\r
+}\r
+}\r
diff --git a/dali/internal/imaging/windows/file-download-win.cpp b/dali/internal/imaging/windows/file-download-win.cpp
new file mode 100755 (executable)
index 0000000..a6ab471
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * 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.
+ *
+ */
+
+// HEADER
+#include <dali/internal/imaging/common/file-download.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <pthread.h>
+#include <openssl/crypto.h>
+#include <cstring>
+#include <curl/curl.h>
+#include <../ExInclude/InternalFileOperation.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/system/common/file-writer.h>
+
+#ifdef TPK_CURL_ENABLED
+#include <tpkp_curl.h>
+#endif // TPK_CURL_ENABLED
+
+using namespace Dali::Integration;
+
+namespace Dali
+{
+
+namespace TizenPlatform
+{
+
+namespace // unnamed namespace
+{
+
+const int CONNECTION_TIMEOUT_SECONDS( 30L );
+const long VERBOSE_MODE = 0L;                // 0 == off, 1 == on
+const long CLOSE_CONNECTION_ON_ERROR = 1L;   // 0 == off, 1 == on
+const long EXCLUDE_HEADER = 0L;
+const long INCLUDE_HEADER = 1L;
+const long INCLUDE_BODY = 0L;
+const long EXCLUDE_BODY = 1L;
+
+/**
+ * Curl library environment. Direct initialize ensures it's constructed before adaptor
+ * or application creates any threads.
+ */
+static Dali::TizenPlatform::Network::CurlEnvironment gCurlEnvironment;
+
+// Without a write function or a buffer (file descriptor) to write to, curl will pump out
+// header/body contents to stdout
+size_t __cdecl DummyWrite(char *ptr, size_t size, size_t nmemb, void *userdata)
+{
+  return size * nmemb;
+}
+
+struct ChunkData
+{
+  std::vector< uint8_t > data;
+};
+
+size_t __cdecl ChunkLoader(char *ptr, size_t size, size_t nmemb, void *userdata)
+{
+  std::vector<ChunkData>* chunks = static_cast<std::vector<ChunkData>*>( userdata );
+  int numBytes = size*nmemb;
+  if( chunks != nullptr )
+  {
+    chunks->push_back( ChunkData() );
+    ChunkData& chunkData = (*chunks)[chunks->size()-1];
+    chunkData.data.reserve( numBytes );
+    memcpy( chunkData.data.data(), ptr, numBytes );
+  }
+  return numBytes;
+}
+
+static size_t __cdecl WriteFunction( void *input, size_t uSize, size_t uCount, void *avg )
+{
+  fwrite( input, uSize, uCount, (FILE*)avg );
+  return uSize * uCount;
+}
+
+void InitWriteFunction( void* curlHandle )
+{
+  curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, WriteFunction );
+}
+
+CURLcode DownloadFileDataWithSize( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t dataSize )
+{
+  CURLcode result( CURLE_OK );
+
+  // create
+  Dali::Internal::Platform::FileWriter fileWriter( dataBuffer, dataSize );
+  FILE* dataBufferFilePointer = fileWriter.GetFile();
+  if( nullptr != dataBufferFilePointer )
+  {
+    // we only want the body which contains the file data
+    curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
+    curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+
+    // disable the write callback, and get curl to write directly into our data buffer
+    InitWriteFunction( curlHandle );
+
+    curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, dataBufferFilePointer );
+
+    // synchronous request of the body data
+    result = curl_easy_perform( curlHandle );
+  }
+  return result;
+}
+
+CURLcode DownloadFileDataByChunk( CURL* curlHandle, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize )
+{
+  // create
+  std::vector< ChunkData > chunks;
+
+  // we only want the body which contains the file data
+  curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER );
+  curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY );
+
+  // Enable the write callback.
+  curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, ChunkLoader );
+  curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, &chunks );
+
+  // synchronous request of the body data
+  CURLcode result = curl_easy_perform( curlHandle );
+
+  // chunks should now contain all of the chunked data. Reassemble into a single vector
+  dataSize = 0;
+  for( size_t i=0; i<chunks.size() ; ++i )
+  {
+    dataSize += chunks[i].data.capacity();
+  }
+  dataBuffer.Resize(dataSize);
+
+  size_t offset = 0;
+  for( size_t i=0; i<chunks.size() ; ++i )
+  {
+    memcpy( &dataBuffer[offset], chunks[i].data.data(), chunks[i].data.capacity() ); 
+    offset += chunks[i].data.capacity();
+  }
+
+  return result;
+}
+
+void ConfigureCurlOptions( void* curlHandle, const std::string& url )
+{
+  curl_easy_setopt( curlHandle, CURLOPT_URL, url.c_str() );
+  //curl_easy_setopt( curlHandle, CURLOPT_VERBOSE, VERBOSE_MODE );
+  curl_easy_setopt( curlHandle, CURLOPT_PROXY, "109.123.100.31:3128" );
+
+  // CURLOPT_FAILONERROR is not fail-safe especially when authentication is involved ( see manual )
+  // Removed CURLOPT_FAILONERROR option
+  curl_easy_setopt( curlHandle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT_SECONDS );
+  curl_easy_setopt( curlHandle, CURLOPT_HEADER, INCLUDE_HEADER );
+  curl_easy_setopt( curlHandle, CURLOPT_NOBODY, EXCLUDE_BODY );
+}
+
+bool DownloadFile( CURL* curlHandle,
+                   const std::string& url,
+                   Dali::Vector<uint8_t>& dataBuffer,
+                   size_t& dataSize,
+                   size_t maximumAllowedSizeBytes )
+{
+  CURLcode result( CURLE_OK );
+  double size(0);
+
+  // setup curl to download just the header so we can extract the content length
+  ConfigureCurlOptions( curlHandle, url );
+
+  curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, DummyWrite);
+
+  // perform the request to get the header
+  result = curl_easy_perform( curlHandle );
+
+  if( result != CURLE_OK)
+  {
+    DALI_LOG_ERROR( "Failed to download http header for \"%s\" with error code %d\n", url.c_str(), result );
+    return false;
+  }
+
+  // get the content length, -1 == size is not known
+  curl_easy_getinfo( curlHandle,CURLINFO_CONTENT_LENGTH_DOWNLOAD , &size );
+
+
+  if( size >= maximumAllowedSizeBytes )
+  {
+    DALI_LOG_ERROR( "File content length %f > max allowed %zu \"%s\" \n", size, maximumAllowedSizeBytes, url.c_str() );
+    return false;
+  }
+  else if( size > 0 )
+  {
+    // If we know the size up front, allocate once and avoid chunk copies.
+    dataSize = static_cast<size_t>( size );
+    result = DownloadFileDataWithSize( curlHandle, dataBuffer, dataSize );
+  }
+  else
+  {
+    result = DownloadFileDataByChunk( curlHandle, dataBuffer, dataSize );
+  }
+
+  if( result != CURLE_OK )
+  {
+    DALI_LOG_ERROR( "Failed to download image file \"%s\" with error code %d\n", url.c_str(), result );
+    return false;
+  }
+  return true;
+}
+
+
+} // unnamed namespace
+
+
+namespace Network
+{
+
+std::mutex* CurlEnvironment::mMutexs = NULL;
+
+CurlEnvironment::CurlEnvironment()
+{
+  // Must be called before we attempt any loads. e.g. by using curl_easy_init()
+  // and before we start any threads.
+  curl_global_init(CURL_GLOBAL_ALL);
+
+ // libcurl with openssl needs locking_function and thread id for threadsafe
+ // https://curl.haxx.se/libcurl/c/threadsafe.html
+ // https://www.openssl.org/docs/man1.0.2/crypto/threads.html#DESCRIPTION
+ // SetLockingFunction sets locking_function and get thread id by the guide.
+  SetLockingFunction();
+}
+
+CurlEnvironment::~CurlEnvironment()
+{
+  UnsetLockingFunction();
+
+  curl_global_cleanup();
+}
+
+// libcurl with openssl needs locking_function and thread id for threadsafe
+// https://curl.haxx.se/libcurl/c/threadsafe.html
+// https://www.openssl.org/docs/man1.0.2/crypto/threads.html#DESCRIPTION
+void CurlEnvironment::OnOpenSSLLocking( int mode, int n, const char* file, int line )
+{
+  if( mode & CRYPTO_LOCK )
+  {
+    mMutexs[n].lock();
+  }
+  else
+  {
+    mMutexs[n].unlock();
+  }
+}
+
+void CurlEnvironment::SetLockingFunction()
+{
+  if( mMutexs != NULL )
+  {
+    return;
+  }
+
+  mMutexs = new std::mutex[ CRYPTO_num_locks() ];
+
+  CRYPTO_set_id_callback( &CurlEnvironment::GetThreadId );
+  CRYPTO_set_locking_callback( &CurlEnvironment::OnOpenSSLLocking );
+}
+
+void CurlEnvironment::UnsetLockingFunction()
+{
+  if( mMutexs == NULL )
+  {
+    return;
+  }
+
+  CRYPTO_set_id_callback( NULL );
+  CRYPTO_set_locking_callback( NULL );
+
+  delete [] mMutexs;
+  mMutexs = NULL;
+}
+
+bool DownloadRemoteFileIntoMemory( const std::string& url,
+                                   Dali::Vector<uint8_t>& dataBuffer,
+                                   size_t& dataSize,
+                                   size_t maximumAllowedSizeBytes )
+{
+  if( url.empty() )
+  {
+    DALI_LOG_WARNING("empty url requested \n");
+    return false;
+  }
+
+  // start a libcurl easy session, this internally calls curl_global_init, if we ever have more than one download
+  // thread we need to explicity call curl_global_init() on startup from a single thread.
+
+  CURL* curlHandle = curl_easy_init();
+
+  bool result = DownloadFile( curlHandle, url, dataBuffer,  dataSize, maximumAllowedSizeBytes);
+
+  // clean up session
+  curl_easy_cleanup( curlHandle );
+
+#ifdef TPK_CURL_ENABLED
+  // Clean up tpkp(the module for certificate pinning) resources on Tizen
+  tpkp_curl_cleanup();
+#endif // TPK_CURL_ENABLED
+
+  return result;
+}
+
+} // namespace Network
+
+} // namespace TizenPlatform
+
+} // namespace Dali
diff --git a/dali/internal/imaging/windows/native-image-source-factory-win.cpp b/dali/internal/imaging/windows/native-image-source-factory-win.cpp
new file mode 100755 (executable)
index 0000000..aa1662f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/imaging/windows/native-image-source-factory-win.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/imaging/windows/native-image-source-impl-win.h>
+#include <dali/internal/imaging/common/native-image-source-queue-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+std::unique_ptr< NativeImageSource > NativeImageSourceFactoryWin::CreateNativeImageSource( unsigned int width, unsigned int height,
+                                                                                         Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+{
+  return std::unique_ptr< NativeImageSource >( NativeImageSourceWin::New( width, height, depth, nativeImageSource ) );
+}
+
+std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryWin::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+                                                                                                   Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+{
+  return std::unique_ptr< NativeImageSourceQueue >( nullptr );
+}
+
+// this should be created from somewhere
+std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+{
+  // returns native image source factory
+  return std::unique_ptr< NativeImageSourceFactoryWin >( new NativeImageSourceFactoryWin() );
+}
+
+} // Adaptor
+} // Internal
+} // Dali
diff --git a/dali/internal/imaging/windows/native-image-source-factory-win.h b/dali/internal/imaging/windows/native-image-source-factory-win.h
new file mode 100755 (executable)
index 0000000..d4f289a
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
+
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/imaging/common/native-image-source-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class NativeImageSourceFactoryWin : public NativeImageSourceFactory
+{
+public:
+
+  std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+                                                                Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
+
+  std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+                                                                          Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
+
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
diff --git a/dali/internal/imaging/windows/native-image-source-impl-win.cpp b/dali/internal/imaging/windows/native-image-source-impl-win.cpp
new file mode 100755 (executable)
index 0000000..eb96bb2
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2017 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/imaging/windows/native-image-source-impl-win.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/common/egl-image-extensions.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/window-system/windows/platform-implement-win.h>
+#include <dali/devel-api/adaptor-framework/bitmap-saver.h>
+#include <dali/integration-api/render-surface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+using Dali::Integration::PixelBuffer;
+
+NativeImageSourceWin* NativeImageSourceWin::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+{
+  NativeImageSourceWin* image = new NativeImageSourceWin( width, height, depth, nativeImageSource );
+  DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
+
+  // 2nd phase construction
+  if(image) //< Defensive in case we ever compile without exceptions.
+  {
+    image->Initialize();
+  }
+
+  return image;
+}
+
+NativeImageSourceWin::NativeImageSourceWin( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+: mWidth( width ),
+  mHeight( height ),
+  mOwnPixmap( true ),
+  mPixmap( 0 ),
+  mBlendingRequired( false ),
+  mColorDepth( depth ),
+  mEglImageKHR( NULL ),
+  mEglImageExtensions( NULL )
+{
+  DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+
+  GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
+  auto eglGraphics = static_cast<EglGraphics *>(graphics);
+
+  mEglImageExtensions = eglGraphics->GetImageExtensions();
+
+  DALI_ASSERT_DEBUG( mEglImageExtensions );
+
+  // assign the pixmap
+  mPixmap = GetPixmapFromAny(nativeImageSource);
+}
+
+void NativeImageSourceWin::Initialize()
+{
+  // if pixmap has been created outside of Windows Image we can return
+  if (mPixmap)
+  {
+    // we don't own the pixmap
+    mOwnPixmap = false;
+
+    // find out the pixmap width / height and color depth
+    GetPixmapDetails();
+    return;
+  }
+
+  // get the pixel depth
+  int depth = GetPixelDepth(mColorDepth);
+
+  // set whether blending is required according to pixel format based on the depth
+  /* default pixel format is RGB888
+     If depth = 8, Pixel::A8;
+     If depth = 16, Pixel::RGB565;
+     If depth = 32, Pixel::RGBA8888 */
+  mBlendingRequired = ( depth == 32 || depth == 8 );
+}
+
+NativeImageSourceWin::~NativeImageSourceWin()
+{
+}
+
+Any NativeImageSourceWin::GetNativeImageSource() const
+{
+  return Any(mPixmap);
+}
+
+bool NativeImageSourceWin::GetPixels(std::vector<uint8_t>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+{
+  DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
+  bool success = false;
+  width  = mWidth;
+  height = mHeight;
+
+  return success;
+}
+
+bool NativeImageSourceWin::EncodeToFile(const std::string& filename) const
+{
+  std::vector< uint8_t > pixbuf;
+  uint32_t width(0), height(0);
+  Pixel::Format pixelFormat;
+
+  if(GetPixels(pixbuf, width, height, pixelFormat))
+  {
+    return Dali::EncodeToFile(&pixbuf[0], filename, pixelFormat, width, height);
+  }
+  return false;
+}
+
+void NativeImageSourceWin::SetSource( Any source )
+{
+  mPixmap = GetPixmapFromAny( source );
+
+  if (mPixmap)
+  {
+    // we don't own the pixmap
+    mOwnPixmap = false;
+
+    // find out the pixmap width / height and color depth
+    GetPixmapDetails();
+  }
+}
+
+bool NativeImageSourceWin::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+{
+  return true;
+}
+
+bool NativeImageSourceWin::GlExtensionCreate()
+{
+  // if the image existed previously delete it.
+  if (mEglImageKHR != NULL)
+  {
+    GlExtensionDestroy();
+  }
+
+  // casting from an unsigned int to a void *, which should then be cast back
+  // to an unsigned int in the driver.
+  EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer > (mPixmap);
+
+  mEglImageKHR = mEglImageExtensions->CreateImageKHR( eglBuffer );
+
+  return mEglImageKHR != NULL;
+}
+
+void NativeImageSourceWin::GlExtensionDestroy()
+{
+  mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
+
+  mEglImageKHR = NULL;
+}
+
+unsigned int NativeImageSourceWin::TargetTexture()
+{
+  mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
+
+  return 0;
+}
+
+void NativeImageSourceWin::PrepareTexture()
+{
+}
+
+int NativeImageSourceWin::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
+{
+  switch (depth)
+  {
+    case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
+    {
+      return WindowsPlatformImplementation::GetColorDepth();
+    }
+    case Dali::NativeImageSource::COLOR_DEPTH_8:
+    {
+      return 8;
+    }
+    case Dali::NativeImageSource::COLOR_DEPTH_16:
+    {
+      return 16;
+    }
+    case Dali::NativeImageSource::COLOR_DEPTH_24:
+    {
+      return 24;
+    }
+    case Dali::NativeImageSource::COLOR_DEPTH_32:
+    {
+      return 32;
+    }
+    default:
+    {
+      DALI_ASSERT_DEBUG(0 && "unknown color enum");
+      return 0;
+    }
+  }
+}
+
+unsigned int NativeImageSourceWin::GetPixmapFromAny(Any pixmap) const
+{
+  if (pixmap.Empty())
+  {
+    return 0;
+  }
+
+  // see if it is of type Windows pixmap
+  if (pixmap.GetType() == typeid ( unsigned int ))
+  {
+    // get the Windows pixmap type
+    unsigned int xpixmap = AnyCast<unsigned int>(pixmap);
+
+    // cast it to a Windows pixmap type
+    return static_cast<unsigned int>(xpixmap);
+  }
+  else
+  {
+    return AnyCast<unsigned int>(pixmap);
+  }
+}
+
+void NativeImageSourceWin::GetPixmapDetails()
+{
+}
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
diff --git a/dali/internal/imaging/windows/native-image-source-impl-win.h b/dali/internal/imaging/windows/native-image-source-impl-win.h
new file mode 100755 (executable)
index 0000000..f5ba236
--- /dev/null
@@ -0,0 +1,195 @@
+#ifndef __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
+#define __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
+
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+
+#include <dali/internal/imaging/common/native-image-source-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+class EglImageExtensions;
+
+/**
+ * Dali internal NativeImageSource.
+ */
+class NativeImageSourceWin : public Internal::Adaptor::NativeImageSource
+{
+public:
+
+  /**
+   * Create a new NativeImageSource internally.
+   * Depending on hardware the width and height may have to be a power of two.
+   * @param[in] width The width of the image.
+   * @param[in] height The height of the image.
+   * @param[in] depth color depth of the image.
+   * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
+   * @return A smart-pointer to a newly allocated image.
+   */
+  static NativeImageSourceWin* New(unsigned int width,
+                          unsigned int height,
+                          Dali::NativeImageSource::ColorDepth depth,
+                          Any nativeImageSource);
+  /**
+   * @copydoc Dali::NativeImageSource::GetNativeImageSource()
+   */
+  Any GetNativeImageSource() const override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::GetPixels()
+   */
+  bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
+   */
+  bool EncodeToFile(const std::string& filename) const override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::SetSource( Any source )
+   */
+  void SetSource( Any source ) override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
+   */
+  bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
+
+  /**
+   * destructor
+   */
+  ~NativeImageSourceWin() override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::GlExtensionCreate()
+   */
+  bool GlExtensionCreate() override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
+   */
+  void GlExtensionDestroy() override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::TargetTexture()
+   */
+  unsigned int TargetTexture() override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::PrepareTexture()
+   */
+  void PrepareTexture() override;
+
+  /**
+   * @copydoc Dali::NativeImageSource::GetWidth()
+   */
+  unsigned int GetWidth() const override
+  {
+    return mWidth;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageSource::GetHeight()
+   */
+  unsigned int GetHeight() const override
+  {
+    return mHeight;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageSource::RequiresBlending()
+   */
+  bool RequiresBlending() const override
+  {
+    return mBlendingRequired;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetExtension()
+   */
+  NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
+  {
+    return nullptr;
+  }
+
+private:
+
+  /**
+   * Private constructor; @see NativeImageSource::New()
+   * @param[in] width The width of the image.
+   * @param[in] height The height of the image.
+   * @param[in] colour depth of the image.
+   * @param[in] nativeImageSource contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
+   */
+  NativeImageSourceWin(unsigned int width,
+              unsigned  int height,
+              Dali::NativeImageSource::ColorDepth depth,
+              Any nativeImageSource);
+
+  /**
+   * 2nd phase construction.
+   */
+  void Initialize();
+
+  /**
+   * Uses X11 to get the default depth.
+   * @param depth the PixelImage depth enum
+   * @return default win32 pixel depth
+   */
+  int GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const;
+
+  /**
+   * Gets the pixmap from the Any parameter
+   * @param pixmap contains either: pixmap of type Win32 Pixmap , a WinPixmap or is empty
+   * @return pixmap x11 pixmap
+   */
+  unsigned int GetPixmapFromAny(Any pixmap) const;
+
+  /**
+   * Given an existing pixmap, the function uses X to find out
+   * the width, heigth and depth of that pixmap.
+   */
+  void GetPixmapDetails();
+
+private:
+
+  unsigned int mWidth;                        ///< image width
+  unsigned int mHeight;                       ///< image heights
+  bool mOwnPixmap;                            ///< Whether we created pixmap or not
+  unsigned int mPixmap;                       ///< From Windows
+  bool mBlendingRequired;                      ///< Whether blending is required
+  Dali::NativeImageSource::ColorDepth mColorDepth;  ///< color depth of image
+  void* mEglImageKHR;                         ///< From EGL extension
+  EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
diff --git a/dali/internal/input/windows/input-method-context-factory-win.cpp b/dali/internal/input/windows/input-method-context-factory-win.cpp
new file mode 100755 (executable)
index 0000000..817dacb
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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 <memory>
+#include <dali/internal/input/common/input-method-context-factory.h>
+#include <dali/internal/input/windows/input-method-context-impl-win.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class InputMethodContext;
+
+namespace InputMethodContextFactory
+{
+
+// InputMethodContext Factory to be implemented by the platform
+InputMethodContextPtr CreateInputMethodContext()
+{
+  return Dali::Internal::Adaptor::InputMethodContextWin::New();
+}
+
+}
+
+}
+
+
+
+}
+}
\ No newline at end of file
diff --git a/dali/internal/input/windows/input-method-context-impl-win.cpp b/dali/internal/input/windows/input-method-context-impl-win.cpp
new file mode 100755 (executable)
index 0000000..16df1a5
--- /dev/null
@@ -0,0 +1,375 @@
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// CLASS HEADER\r
+#include <dali/internal/input/windows/input-method-context-impl-win.h>\r
+\r
+// EXTERNAL INCLUDES\r
+#include <dali/public-api/events/key-event.h>\r
+#include <dali/public-api/adaptor-framework/key.h>\r
+#include <dali/public-api/object/type-registry.h>\r
+#include <dali/integration-api/debug.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/integration-api/adaptor.h>\r
+#include <dali/internal/adaptor/common/adaptor-impl.h>\r
+#include <dali/internal/system/common/locale-utils.h>\r
+#include <dali/internal/system/common/singleton-service-impl.h>\r
+#include <dali/internal/input/common/virtual-keyboard-impl.h>\r
+#include <dali/internal/input/common/key-impl.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+InputMethodContextPtr InputMethodContextWin::New()\r
+{\r
+  InputMethodContextPtr manager;\r
+\r
+  if ( Adaptor::IsAvailable() )\r
+  {\r
+    // Create instance and register singleton only if the adaptor is available\r
+    Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );\r
+    Any nativeWindow = adaptorImpl.GetNativeWindowHandle();\r
+\r
+    // The Win_Window_Handle needs to use the InputMethodContext.\r
+    // Only when the render surface is window, we can get the Win_Window_Handle.\r
+    WinWindowHandle winWindow( AnyCast<WinWindowHandle>(nativeWindow) );\r
+    if ( winWindow )\r
+    {\r
+      manager = new InputMethodContextWin( winWindow );\r
+    }\r
+    else\r
+    {\r
+      DALI_LOG_ERROR("Failed to get native window handle\n");\r
+    }\r
+  }\r
+\r
+  return manager;\r
+}\r
+\r
+void InputMethodContextWin::Finalize()\r
+{\r
+}\r
+\r
+InputMethodContextWin::InputMethodContextWin( WinWindowHandle winWindow )\r
+: mWin32Window( winWindow ),\r
+  mIMFCursorPosition( 0 ),\r
+  mSurroundingText(),\r
+  mRestoreAfterFocusLost( false ),\r
+  mIdleCallbackConnected( false )\r
+{\r
+}\r
+\r
+InputMethodContextWin::~InputMethodContextWin()\r
+{\r
+  Finalize();\r
+}\r
+\r
+void InputMethodContextWin::Initialize()\r
+{\r
+  CreateContext( mWin32Window );\r
+  ConnectCallbacks();\r
+}\r
+\r
+void InputMethodContextWin::CreateContext( WinWindowHandle winHandle )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CreateContext\n" );\r
+}\r
+\r
+void InputMethodContextWin::DeleteContext()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteContext\n" );\r
+}\r
+\r
+// Callbacks for predicitive text support.\r
+void InputMethodContextWin::ConnectCallbacks()\r
+{\r
+}\r
+\r
+void InputMethodContextWin::DisconnectCallbacks()\r
+{\r
+}\r
+\r
+void InputMethodContextWin::Activate()\r
+{\r
+  // Reset mIdleCallbackConnected\r
+  mIdleCallbackConnected = false;\r
+}\r
+\r
+void InputMethodContextWin::Deactivate()\r
+{\r
+  mIdleCallbackConnected = false;\r
+}\r
+\r
+void InputMethodContextWin::Reset()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Reset\n" );\r
+}\r
+\r
+ImfContext* InputMethodContextWin::GetContext()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetContext\n" );\r
+\r
+  return NULL;\r
+}\r
+\r
+bool InputMethodContextWin::RestoreAfterFocusLost() const\r
+{\r
+  return mRestoreAfterFocusLost;\r
+}\r
+\r
+void InputMethodContextWin::SetRestoreAfterFocusLost( bool toggle )\r
+{\r
+  mRestoreAfterFocusLost = toggle;\r
+}\r
+\r
+/**\r
+ * Called when an InputMethodContext Pre-Edit changed event is received.\r
+ * We are still predicting what the user is typing.  The latest string is what the InputMethodContext module thinks\r
+ * the user wants to type.\r
+ */\r
+void InputMethodContextWin::PreEditChanged( void*, ImfContext* imfContext, void* event_info )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::PreEditChanged\n" );\r
+}\r
+\r
+void InputMethodContextWin::CommitReceived( void*, ImfContext* imfContext, void* event_info )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CommitReceived\n" );\r
+\r
+  if ( Dali::Adaptor::IsAvailable() )\r
+  {\r
+    const std::string keyString( static_cast<char*>( event_info ) );\r
+\r
+    Dali::InputMethodContext handle( this );\r
+    Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 );\r
+    Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData );\r
+\r
+    if( callbackData.update )\r
+    {\r
+      mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
+\r
+      NotifyCursorPosition();\r
+    }\r
+  }\r
+}\r
+\r
+/**\r
+ * Called when an InputMethodContext retrieve surround event is received.\r
+ * Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is\r
+ * We need to signal the application to tell us this information.\r
+ */\r
+bool InputMethodContextWin::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::RetrieveSurrounding\n" );\r
+\r
+  Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 );\r
+  Dali::InputMethodContext handle( this );\r
+  Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData );\r
+\r
+  if( callbackData.update )\r
+  {\r
+    if( text )\r
+    {\r
+      *text = strdup( callbackData.currentText.c_str() );\r
+    }\r
+\r
+    if( cursorPosition )\r
+    {\r
+      mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );\r
+      *cursorPosition = mIMFCursorPosition;\r
+    }\r
+  }\r
+\r
+  return true;\r
+}\r
+\r
+/**\r
+ * Called when an InputMethodContext delete surrounding event is received.\r
+ * Here we tell the application that it should delete a certain range.\r
+ */\r
+void InputMethodContextWin::DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteSurrounding\n" );\r
+}\r
+\r
+void InputMethodContextWin::NotifyCursorPosition()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::NotifyCursorPosition\n" );\r
+}\r
+\r
+void InputMethodContextWin::SetCursorPosition( unsigned int cursorPosition )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetCursorPosition\n" );\r
+\r
+  mIMFCursorPosition = static_cast<int>( cursorPosition );\r
+}\r
+\r
+unsigned int InputMethodContextWin::GetCursorPosition() const\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetCursorPosition\n" );\r
+\r
+  return static_cast<unsigned int>( mIMFCursorPosition );\r
+}\r
+\r
+void InputMethodContextWin::SetSurroundingText( const std::string& text )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetSurroundingText\n" );\r
+\r
+  mSurroundingText = text;\r
+}\r
+\r
+const std::string& InputMethodContextWin::GetSurroundingText() const\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetSurroundingText\n" );\r
+\r
+  return mSurroundingText;\r
+}\r
+\r
+void InputMethodContextWin::NotifyTextInputMultiLine( bool multiLine )\r
+{\r
+}\r
+\r
+Dali::InputMethodContext::TextDirection InputMethodContextWin::GetTextDirection()\r
+{\r
+  Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LeftToRight );\r
+\r
+  return direction;\r
+}\r
+\r
+Rect<int> InputMethodContextWin::GetInputMethodArea()\r
+{\r
+  int xPos, yPos, width, height;\r
+\r
+  width = height = xPos = yPos = 0;\r
+\r
+  return Rect<int>(xPos,yPos,width,height);\r
+}\r
+\r
+void InputMethodContextWin::ApplyOptions( const InputMethodOptions& options )\r
+{\r
+  using namespace Dali::InputMethod::Category;\r
+\r
+  int index;\r
+\r
+  if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )\r
+  {\r
+  }\r
+  if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) )\r
+  {\r
+  }\r
+  if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) )\r
+  {\r
+  }\r
+  if ( mOptions.CompareAndSet(VARIATION, options, index) )\r
+  {\r
+  }\r
+}\r
+\r
+void InputMethodContextWin::SetInputPanelData( const std::string& data )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelData\n" );\r
+}\r
+\r
+void InputMethodContextWin::GetInputPanelData( std::string& data )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelData\n" );\r
+}\r
+\r
+Dali::InputMethodContext::State InputMethodContextWin::GetInputPanelState()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelState\n" );\r
+  return Dali::InputMethodContext::DEFAULT;\r
+}\r
+\r
+void InputMethodContextWin::SetReturnKeyState( bool visible )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetReturnKeyState\n" );\r
+}\r
+\r
+void InputMethodContextWin::AutoEnableInputPanel( bool enabled )\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::AutoEnableInputPanel\n" );\r
+}\r
+\r
+void InputMethodContextWin::ShowInputPanel()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ShowInputPanel\n" );\r
+}\r
+\r
+void InputMethodContextWin::HideInputPanel()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::HideInputPanel\n" );\r
+}\r
+\r
+Dali::InputMethodContext::KeyboardType InputMethodContextWin::GetKeyboardType()\r
+{\r
+  return Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD;\r
+}\r
+\r
+std::string InputMethodContextWin::GetInputPanelLocale()\r
+{\r
+  DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLocale\n" );\r
+\r
+  std::string locale = "";\r
+  return locale;\r
+}\r
+\r
+bool InputMethodContextWin::FilterEventKey( const Dali::KeyEvent& keyEvent )\r
+{\r
+  bool eventHandled( false );\r
+\r
+  if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() ))\r
+  {\r
+    //check whether it's key down or key up event\r
+    if ( keyEvent.state == KeyEvent::Down )\r
+    {\r
+      eventHandled = ProcessEventKeyDown( keyEvent );\r
+    }\r
+    else if ( keyEvent.state == KeyEvent::Up )\r
+    {\r
+      eventHandled = ProcessEventKeyUp( keyEvent );\r
+    }\r
+  }\r
+\r
+  return eventHandled;\r
+}\r
+\r
+bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent )\r
+{\r
+  bool eventHandled( false );\r
+  return eventHandled;\r
+}\r
+\r
+bool InputMethodContextWin::ProcessEventKeyUp( const KeyEvent& keyEvent )\r
+{\r
+  bool eventHandled( false );\r
+  return eventHandled;\r
+}\r
+\r
+} // Adaptor\r
+\r
+} // Internal\r
+\r
+} // Dali\r
+\r
diff --git a/dali/internal/input/windows/input-method-context-impl-win.h b/dali/internal/input/windows/input-method-context-impl-win.h
new file mode 100755 (executable)
index 0000000..a2f71f3
--- /dev/null
@@ -0,0 +1,293 @@
+#ifndef DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r
+#define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r
+\r
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// EXTERNAL INCLUDES\r
+#include <dali/public-api/object/base-object.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/devel-api/adaptor-framework/input-method-context.h>\r
+#include <dali/internal/input/common/input-method-context-impl.h>\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+class RenderSurface;\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+class InputMethodContextWin : public Dali::Internal::Adaptor::InputMethodContext\r
+{\r
+public:\r
+  /**\r
+   * @brief Creates a new InputMethodContext handle\r
+   *\r
+   * @return InputMethodContext pointer\r
+   */\r
+  static InputMethodContextPtr New();\r
+\r
+  /**\r
+   * Constructor\r
+   * @param[in] win32Window, The window is created by application.\r
+   */\r
+  explicit InputMethodContextWin( WinWindowHandle win32Window );\r
+\r
+public:\r
+\r
+  /**\r
+   * @brief Initializes member data.\r
+   */\r
+  void Initialize() override;\r
+\r
+  /**\r
+   * Connect Callbacks required for InputMethodContext.\r
+   * If you don't connect InputMethodContext callbacks, you can't get the key events.\r
+   * The events are PreeditChanged, Commit and DeleteSurrounding.\r
+   */\r
+  void ConnectCallbacks() override;\r
+\r
+  /**\r
+   * Disconnect Callbacks attached to input method context.\r
+   */\r
+  void DisconnectCallbacks() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::Finalize()\r
+   */\r
+  void Finalize() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::Activate()\r
+   */\r
+  void Activate() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::Deactivate()\r
+   */\r
+  void Deactivate() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::Reset()\r
+   */\r
+  void Reset() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetContext()\r
+   */\r
+  ImfContext* GetContext() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()\r
+   */\r
+  bool RestoreAfterFocusLost() const override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()\r
+   */\r
+  void SetRestoreAfterFocusLost( bool toggle ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::PreEditChanged()\r
+   */\r
+  void PreEditChanged( void* data, ImfContext* imfContext, void* event_info ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
+   */\r
+  void CommitReceived( void* data, ImfContext* imfContext, void* event_info ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
+   */\r
+  bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::DeleteSurrounding()\r
+   */\r
+  void DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::SendPrivateCommand()\r
+   */\r
+  void SendPrivateCommand( void* data, ImfContext* imfContext, void* event_info ) override\r
+  {}\r
+\r
+  // Cursor related\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::NotifyCursorPosition()\r
+   */\r
+  void NotifyCursorPosition() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::SetCursorPosition()\r
+   */\r
+  void SetCursorPosition( unsigned int cursorPosition ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetCursorPosition()\r
+   */\r
+  unsigned int GetCursorPosition() const override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::SetSurroundingText()\r
+   */\r
+  void SetSurroundingText( const std::string& text ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetSurroundingText()\r
+   */\r
+  const std::string& GetSurroundingText() const override;\r
+\r
+  /**\r
+  * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()\r
+  */\r
+  void NotifyTextInputMultiLine( bool multiLine ) override;\r
+\r
+  /**\r
+  * @copydoc Dali::InputMethodContext::GetTextDirection()\r
+  */\r
+  Dali::InputMethodContext::TextDirection GetTextDirection() override;\r
+\r
+  /**\r
+  * @copydoc Dali::InputMethodContext::GetInputMethodArea()\r
+  */\r
+  Dali::Rect<int> GetInputMethodArea() override;\r
+\r
+  /**\r
+  * @copydoc Dali::InputMethodContext::ApplyOptions()\r
+  */\r
+  void ApplyOptions( const InputMethodOptions& options ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::SetInputPanelData()\r
+   */\r
+  void SetInputPanelData( const std::string& data ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetInputPanelData()\r
+   */\r
+  void GetInputPanelData( std::string& data ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetInputPanelState()\r
+   */\r
+  Dali::InputMethodContext::State GetInputPanelState() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::SetReturnKeyState()\r
+   */\r
+  void SetReturnKeyState( bool visible ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()\r
+   */\r
+  void AutoEnableInputPanel( bool enabled ) override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::ShowInputPanel()\r
+   */\r
+  void ShowInputPanel() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::HideInputPanel()\r
+   */\r
+  void HideInputPanel() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetKeyboardType()\r
+   */\r
+  Dali::InputMethodContext::KeyboardType GetKeyboardType() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::GetInputPanelLocale()\r
+   */\r
+  std::string GetInputPanelLocale() override;\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::FilterEventKey()\r
+   */\r
+  bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;\r
+\r
+private:\r
+  /**\r
+   * Context created the first time and kept until deleted.\r
+   * @param[in] win32Window, The window is created by application.\r
+   */\r
+  void CreateContext( WinWindowHandle win32Window );\r
+\r
+  /**\r
+   * @copydoc Dali::InputMethodContext::DeleteContext()\r
+   */\r
+  void DeleteContext();\r
+\r
+private:\r
+\r
+  /**\r
+   * @brief Process event key down, whether filter a key to isf.\r
+   *\r
+   * @param[in] keyEvent The event key to be handled.\r
+   * @return Whether the event key is handled.\r
+   */\r
+  bool ProcessEventKeyDown( const KeyEvent& keyEvent );\r
+\r
+  /**\r
+   * @brief Process event key up, whether filter a key to isf.\r
+   *\r
+   * @param[in] keyEvent The event key to be handled.\r
+   * @return Whether the event key is handled.\r
+   */\r
+  bool ProcessEventKeyUp( const KeyEvent& keyEvent );\r
+\r
+public:\r
+\r
+  /**\r
+   * Destructor.\r
+   */\r
+  virtual ~InputMethodContextWin();\r
+\r
+private:\r
+\r
+  // Undefined copy constructor\r
+  InputMethodContextWin( const InputMethodContextWin& inputMethodContext) = delete;\r
+\r
+  // Undefined assignment operator\r
+  InputMethodContextWin& operator=( const InputMethodContextWin& inputMethodContext ) = delete;\r
+\r
+private:\r
+  WinWindowHandle mWin32Window;\r
+  int mIMFCursorPosition;\r
+  std::string mSurroundingText;\r
+\r
+  bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
+  bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.\r
+  InputMethodOptions        mOptions;\r
+};\r
+\r
+} // namespace Adaptor\r
+\r
+} // namespace Internal\r
+\r
+} // namespace Dali\r
+\r
+#endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H\r
diff --git a/dali/internal/input/windows/key-mapping-win.cpp b/dali/internal/input/windows/key-mapping-win.cpp
new file mode 100755 (executable)
index 0000000..9b855bd
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/input/common/key-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace KeyLookup
+{
+
+// matches a DALI_KEY enum, to key name
+KeyLookup KeyLookupTable[]=
+{
+  // more than one key name can be assigned to a single dali-key code
+  // e.g. "Menu" and "XF86Menu" are both assigned to  DALI_KEY_MENU
+
+  { "Escape",                DALI_KEY_ESCAPE,                                            false },
+  { "Menu",                  DALI_KEY_MENU,                                              false },
+  { "Cancel",                DALI_KEY_CANCEL,                                            false },
+
+  { "BackSpace",             DALI_KEY_BACKSPACE,                                         false },
+  { "Up",                    DALI_KEY_CURSOR_UP,                                         false }, // To be removed after the key name is fixed in the platform
+  { "Left",                  DALI_KEY_CURSOR_LEFT,                                       false },
+  { "Right",                 DALI_KEY_CURSOR_RIGHT,                                      false },
+  { "Down",                  DALI_KEY_CURSOR_DOWN,                                       false }, // To be removed after the key name is fixed in the platform
+  { "Shift_L",               DALI_KEY_SHIFT_LEFT,                                        false },
+  { "Shift_R",               DALI_KEY_SHIFT_RIGHT,                                       false },
+  { "Delete",                static_cast<Dali::KEY>( DevelKey::DALI_KEY_DELETE ),        false },
+  { "Control_L",             static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_LEFT ),  false },
+  { "Control_R",             static_cast<Dali::KEY>( DevelKey::DALI_KEY_CONTROL_RIGHT ), false }
+};
+
+const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable ))/ (sizeof( KeyLookup ));
+
+} // namespace KeyLookup
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/input/windows/virtual-keyboard-impl-win.cpp b/dali/internal/input/windows/virtual-keyboard-impl-win.cpp
new file mode 100755 (executable)
index 0000000..8d4eb0a
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/input/common/virtual-keyboard-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace VirtualKeyboard
+{
+void Show()
+{
+}
+
+void Hide()
+{
+
+}
+
+bool IsVisible()
+{
+  return false;
+}
+
+void ApplySettings( const Property::Map& settingsMap )
+{
+
+}
+
+void EnablePrediction( const bool enable )
+{
+
+}
+
+bool IsPredictionEnabled()
+{
+  return false;
+}
+
+Rect<int> GetSizeAndPosition()
+{
+  Rect<int> ret;
+  return ret;
+}
+
+Dali::VirtualKeyboard::StatusSignalType& StatusChangedSignal()
+{
+  Dali::VirtualKeyboard::StatusSignalType ret;
+  return ret;
+}
+
+Dali::VirtualKeyboard::KeyboardResizedSignalType& ResizedSignal()
+{
+  Dali::VirtualKeyboard::KeyboardResizedSignalType ret;
+  return ret;
+}
+
+Dali::VirtualKeyboard::LanguageChangedSignalType& LanguageChangedSignal()
+{
+  Dali::VirtualKeyboard::LanguageChangedSignalType ret;
+  return ret;
+}
+
+Dali::VirtualKeyboard::TextDirection GetTextDirection()
+{
+  return Dali::VirtualKeyboard::LeftToRight;
+}
+
+Dali::InputMethod::ActionButton gActionButtonFunction = Dali::InputMethod::ACTION_DEFAULT;
+
+
+void RotateTo(int angle)
+{
+}
+
+void SetReturnKeyType( const InputMethod::ButtonAction::Type type )
+{
+}
+
+Dali::InputMethod::ButtonAction::Type GetReturnKeyType()
+{
+  return Dali::InputMethod::ButtonAction::DEFAULT;
+}
+
+} // namespace VirtualKeyboard
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
old mode 100644 (file)
new mode 100755 (executable)
index 90b8aef..131bd9b
@@ -86,7 +86,7 @@ private:
   AbortHandler& operator=(const AbortHandler& rhs);
 
 private:
-  typedef void (*SignalHandlerFuncPtr )( int );
+  using SignalHandlerFuncPtr = void( * )( int );
 
   // _NSIG comes from the signal.h linux system header, defining the number of signals.
   SignalHandlerFuncPtr        mSignalOldHandlers[_NSIG-1];
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/dali/internal/system/windows/callback-manager-win.cpp b/dali/internal/system/windows/callback-manager-win.cpp
new file mode 100755 (executable)
index 0000000..539daa3
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// CLASS HEADER\r
+#include <dali/internal/system/windows/callback-manager-win.h>\r
+\r
+// EXTERNAL INCLUDES\r
+#include <dali/integration-api/debug.h>\r
+#include <Windows.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+WinCallbackManager::WinCallbackManager()\r
+:mRunning(false)\r
+{\r
+}\r
+\r
+void WinCallbackManager::Start()\r
+{\r
+  DALI_ASSERT_DEBUG( mRunning == false );\r
+  mRunning = true;\r
+}\r
+\r
+void WinCallbackManager::Stop()\r
+{\r
+  // make sure we're not called twice\r
+  DALI_ASSERT_DEBUG( mRunning == true );\r
+\r
+  mRunning = false;\r
+}\r
+\r
+bool WinCallbackManager::AddIdleCallback( CallbackBase* callback, bool hasReturnValue )\r
+{\r
+  if( !mRunning )\r
+  {\r
+    return false;\r
+  }\r
+\r
+  WindowsPlatformImplementation::PostWinThreadMessage( WIN_CALLBACK_EVENT, reinterpret_cast<uint64_t>(callback), 0 );\r
+  return true;\r
+}\r
+\r
+void WinCallbackManager::RemoveIdleCallback( CallbackBase* callback )\r
+{\r
+  //Wait for deal\r
+}\r
+\r
+bool WinCallbackManager::AddIdleEntererCallback( CallbackBase* callback )\r
+{\r
+  return AddIdleCallback( callback, true );\r
+}\r
+\r
+void WinCallbackManager::RemoveIdleEntererCallback( CallbackBase* callback )\r
+{\r
+\r
+}\r
+\r
+// Creates a concrete interface for CallbackManager\r
+CallbackManager* CallbackManager::New()\r
+{\r
+  return new WinCallbackManager;\r
+}\r
+\r
+} // namespace Adaptor\r
+\r
+} // namespace Internal\r
+\r
+} // namespace Dali\r
diff --git a/dali/internal/system/windows/callback-manager-win.h b/dali/internal/system/windows/callback-manager-win.h
new file mode 100755 (executable)
index 0000000..3048036
--- /dev/null
@@ -0,0 +1,111 @@
+#ifndef DALI_WIN_CALLBACK_MANAGER_H
+#define DALI_WIN_CALLBACK_MANAGER_H
+
+/*
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <list>
+
+// INTERNAL INCLUDES
+#include <dali/internal/system/common/callback-manager.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+/**
+ * @brief LibUV callback manager used to install call backs in the applications main loop.
+ * The manager keeps track of all callbacks, so that if Stop() is called it can remove them.
+ */
+class WinCallbackManager : public CallbackManager
+{
+
+public:
+
+     /**
+     * @brief constructor
+     */
+    WinCallbackManager();
+
+    /**
+     * @brief destructor
+     */
+    ~WinCallbackManager(){}
+
+    /**
+     * @copydoc CallbackManager::AddIdleCallback()
+     */
+    virtual bool AddIdleCallback( CallbackBase* callback, bool hasReturnValue );
+
+    /**
+     * @copydoc CallbackManager::RemoveIdleCallback()
+     */
+    virtual void RemoveIdleCallback( CallbackBase* callback );
+
+    /**
+    * @brief Adds a @p callback to be run when entering an idle state.
+    * @note Must be called from the main thread only.
+    *
+    * A callback of the following type should be used:
+    * @code
+    *   bool MyFunction();
+    * @endcode
+    * This callback will be called repeatedly as long as it returns true. A return of 0 deletes this callback.
+    *
+    * @param[in] callback custom callback function.
+    *
+    * @return true on success
+    */
+    virtual bool AddIdleEntererCallback( CallbackBase* callback );
+
+    /**
+    * @brief Removes a previously added the idle enterer callback.
+    * @note Must be called from main thread only.
+    *
+    * Does nothing if the @p callback doesn't exist.
+    *
+    * @param[in] callback The callback to be removed.
+    */
+    virtual void RemoveIdleEntererCallback( CallbackBase* callback );
+
+    /**
+     * @copydoc CallbackManager::Start()
+     */
+    virtual void Start();
+
+    /**
+     * @copydoc CallbackManager::Stop()
+     */
+    virtual void Stop();
+
+private:
+    bool                           mRunning;            ///< flag is set to true if when running
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_UV_CALLBACK_MANAGER_H__
diff --git a/dali/internal/system/windows/file-closer-win.cpp b/dali/internal/system/windows/file-closer-win.cpp
new file mode 100755 (executable)
index 0000000..7cadd88
--- /dev/null
@@ -0,0 +1,119 @@
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// Internal\r
+#include <dali/integration-api/debug.h>\r
+#include <dali/public-api/common/dali-vector.h>\r
+#include <dali/internal/system/common/file-closer.h>\r
+\r
+// External\r
+#include <CustomFile.h>\r
+#include <string>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Platform\r
+{\r
+\r
+namespace InternalFile\r
+{\r
+\r
+std::string GetRealName( const char *name )\r
+{\r
+  if( NULL != name && '*' == name[0] )\r
+  {\r
+    std::string envName;\r
+\r
+    const char *p = name + 1;\r
+    \r
+    while( 0 != *p && '*' != *p )\r
+    {\r
+      envName.push_back( *p );\r
+      p++;\r
+    }\r
+\r
+    p++;\r
+\r
+    char *envValue = std::getenv( envName.c_str() );\r
+\r
+    std::string realName = envValue;\r
+    realName += p;\r
+\r
+    return realName;\r
+  }\r
+  else\r
+  {\r
+    return "";\r
+  }\r
+}\r
+\r
+FILE *FOpen( const char *name, const char *mode )\r
+{\r
+  if( NULL != name && '*' == name[0] )\r
+  {\r
+    std::string realName = GetRealName( name );\r
+    return (FILE*)CustomFile::FOpen( realName.c_str(), mode );\r
+  }\r
+  else\r
+  {\r
+    return (FILE*)CustomFile::FOpen( name, mode );\r
+  }\r
+}\r
+\r
+FILE *FMemopen( void *__s, size_t __len, const char *__modes )\r
+{\r
+  FILE *ret = (FILE*)CustomFile::FMemopen( __s, __len, __modes );\r
+  return ret;\r
+}\r
+\r
+size_t FRead( void*  _Buffer, size_t _ElementSize, size_t _ElementCount, FILE*  _Stream )\r
+{\r
+  return CustomFile::FRead( _Buffer, _ElementSize, _ElementCount, _Stream );\r
+}\r
+\r
+int FClose( FILE *__stream )\r
+{\r
+  return CustomFile::FClose( __stream );\r
+}\r
+\r
+void FWrite( void *buf, int size, int count, FILE *fp )\r
+{\r
+  CustomFile::FWrite( buf, size * count, fp );\r
+}\r
+\r
+int FSeek( FILE *fp, int offset, int origin )\r
+{\r
+  return CustomFile::FSeek( fp, offset, origin );\r
+}\r
+\r
+int FTell( FILE *fp )\r
+{\r
+  return CustomFile::FTell( fp );\r
+}\r
+\r
+bool FEof( FILE *fp )\r
+{\r
+  return CustomFile::FEof( fp );\r
+}\r
+} //InternalFile\r
+} //Platform\r
+} //Internal\r
+} //Dali\r
diff --git a/dali/internal/system/windows/system-settings-win.cpp b/dali/internal/system/windows/system-settings-win.cpp
new file mode 100755 (executable)
index 0000000..3cf5f2c
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/system/common/system-settings.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+int GetLongPressTime( int defaultTime )\r
+{\r
+  return defaultTime;\r
+}\r
+\r
+int GetElmAccessActionOver()\r
+{\r
+  return 0;\r
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/system/windows/timer-impl-win.cpp b/dali/internal/system/windows/timer-impl-win.cpp
new file mode 100755 (executable)
index 0000000..7691199
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/system/common/timer-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/windows/platform-implement-win.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+// LOCAL STUFF
+namespace
+{
+bool TimerSourceFunc (void *data)
+{
+  Timer* timer = static_cast<Timer*>(data);
+  return timer->Tick();
+}
+}
+
+/**
+ * Struct to hide away Windows implementation details
+ */
+struct Timer::Impl
+{
+  Impl( unsigned int milliSec ) :
+    mId(-1),
+    mInterval(milliSec)
+  {
+  }
+
+  int mId;
+
+  unsigned int mInterval;
+};
+
+TimerPtr Timer::New( unsigned int milliSec )
+{
+  TimerPtr timer( new Timer( milliSec ) );
+  return timer;
+}
+
+Timer::Timer( unsigned int milliSec )
+: mImpl(new Impl(milliSec))
+{
+}
+
+Timer::~Timer()
+{
+  // stop timers
+  Stop();
+
+  delete mImpl;
+  mImpl = NULL;
+}
+
+void Timer::Start()
+{
+  if( 0 > mImpl->mId )
+  {
+    mImpl->mId = WindowsPlatformImplementation::SetTimer( mImpl->mInterval, TimerSourceFunc, this );
+  }
+}
+
+void Timer::Stop()
+{
+  if( 0 <= mImpl->mId )
+  {
+    WindowsPlatformImplementation::KillTimer( mImpl->mId );
+    mImpl->mId = -1;
+  }
+}
+
+void Timer::Pause()
+{
+
+}
+
+void Timer::Resume()
+{
+
+}
+
+void Timer::SetInterval( unsigned int interval, bool restart )
+{
+  if( true == restart )
+  {
+    // stop existing timer
+    Stop();
+    mImpl->mInterval = interval;
+    // start new tick
+    Start();
+  }
+  else
+  {
+    mImpl->mInterval = interval;
+  }
+}
+
+unsigned int Timer::GetInterval() const
+{
+  return mImpl->mInterval;
+}
+
+bool Timer::Tick()
+{
+  // Guard against destruction during signal emission
+  Dali::Timer handle( this );
+
+  bool retVal( false );
+
+  // Override with new signal if used
+  if( !mTickSignal.Empty() )
+  {
+    retVal = mTickSignal.Emit();
+
+    // Timer stops if return value is false
+    if (retVal == false)
+    {
+      Stop();
+    }
+    else
+    {
+      retVal = true;   // continue emission
+    }
+  }
+  else // no callbacks registered
+  {
+    // periodic timer is started but nobody listens, continue
+    retVal = true;
+  }
+
+  return retVal;
+}
+
+Dali::Timer::TimerSignalType& Timer::TickSignal()
+{
+  return mTickSignal;
+}
+
+bool Timer::IsRunning() const
+{
+  return 0 <= mImpl->mId;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
diff --git a/dali/internal/system/windows/trigger-event-factory.cpp b/dali/internal/system/windows/trigger-event-factory.cpp
new file mode 100755 (executable)
index 0000000..7151c65
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014 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/integration-api/trigger-event-factory.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/system/windows/trigger-event.h>
+
+namespace Dali
+{
+
+TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent( CallbackBase* callback,  TriggerEventInterface::Options options )
+{
+  return new Internal::Adaptor::TriggerEvent( callback, options );
+}
+
+void TriggerEventFactory::DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface )
+{
+  Internal::Adaptor::TriggerEvent* triggerEvent( static_cast<Internal::Adaptor::TriggerEvent *>(triggerEventInterface) );
+  delete triggerEvent;
+}
+
+} // namespace Dali
diff --git a/dali/internal/system/windows/trigger-event.cpp b/dali/internal/system/windows/trigger-event.cpp
new file mode 100755 (executable)
index 0000000..cbd5b33
--- /dev/null
@@ -0,0 +1,95 @@
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// CLASS HEADER\r
+#include <dali/internal/system/windows/trigger-event.h>\r
+\r
+// EXTERNAL INCLUDES\r
+#include <unistd.h>\r
+\r
+#include <dali/integration-api/debug.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/system/common/file-descriptor-monitor.h>\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+TriggerEvent::TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options )\r
+: mCallback( callback ),\r
+  mThreadID( -1 ),\r
+  mOptions( options )\r
+{\r
+  // Create accompanying file descriptor.\r
+  mThreadID = WindowsPlatformImplementation::GetCurrentThreadId();\r
+\r
+  if ( mThreadID < 0)\r
+  {\r
+    DALI_LOG_ERROR("Unable to create TriggerEvent File descriptor\n");\r
+  }\r
+}\r
+\r
+TriggerEvent::~TriggerEvent()\r
+{\r
+  delete mCallback;\r
+\r
+  if ( mThreadID >= 0)\r
+  {\r
+    mThreadID = 0;\r
+  }\r
+}\r
+\r
+void TriggerEvent::Trigger()\r
+{\r
+  if ( mThreadID >= 0)\r
+  {\r
+    // Increment event counter by 1.\r
+    // Writing to the file descriptor triggers the Dispatch() method in the other thread\r
+    // (if in multi-threaded environment).\r
+    CallbackBase *callback = MakeCallback( this, &TriggerEvent::Triggered );\r
+    WindowsPlatformImplementation::PostWinThreadMessage( WIN_CALLBACK_EVENT, reinterpret_cast<uint64_t>( callback ), 0, mThreadID );\r
+  }\r
+  else\r
+  {\r
+    DALI_LOG_WARNING("Attempting to write to an invalid file descriptor\n");\r
+  }\r
+}\r
+\r
+void TriggerEvent::Triggered()\r
+{\r
+  // Call the connected callback\r
+  CallbackBase::Execute( *mCallback );\r
+\r
+  //check if we should delete ourselves after the trigger\r
+  if( mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER )\r
+  {\r
+    delete this;\r
+  }\r
+}\r
+\r
+} // namespace Adaptor\r
+\r
+} // namespace Internal\r
+\r
+} // namespace Dali\r
diff --git a/dali/internal/system/windows/trigger-event.h b/dali/internal/system/windows/trigger-event.h
new file mode 100755 (executable)
index 0000000..b0c198e
--- /dev/null
@@ -0,0 +1,87 @@
+#ifndef __DALI_INTERNAL_TRIGGER_EVENT_IMPL_H__
+#define __DALI_INTERNAL_TRIGGER_EVENT_IMPL_H__
+
+/*
+* 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.
+*
+*/
+
+// EXTERNAL INCLUDES\r
+#include <dali/public-api/signals/callback.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/public-api/dali-adaptor-common.h>\r
+#include <dali/integration-api/trigger-event-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class TriggerEvent : public TriggerEventInterface
+{
+public:
+
+  /**
+   * Constructor
+   * Creates an event file descriptor and starts a GSource which reads from the file
+   * descriptor when there is data.
+   *
+   * @param[in] callback The callback to call
+   * @param[in] options Trigger event options.
+   * @note The ownership of callback is taken by this class.
+   */
+  TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options );
+
+  /**
+   * Destructor
+   */
+  ~TriggerEvent();
+
+public:
+
+  /**
+   * Triggers the event.
+   *
+   * This can be called from one thread in order to wake up another thread.
+   */
+  void Trigger();
+
+private:
+
+  /**
+   * @brief Called when our event file descriptor has been written to.
+   * @param[in] eventBitMask bit mask of events that occured on the file descriptor
+   */
+  void Triggered();
+
+private:
+
+  CallbackBase* mCallback;
+  int32_t mThreadID;
+  TriggerEventInterface::Options mOptions;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_TRIGGER_EVENT_IMPL_H__
\ No newline at end of file
diff --git a/dali/internal/system/windows/widget-application-impl-win.cpp b/dali/internal/system/windows/widget-application-impl-win.cpp
new file mode 100755 (executable)
index 0000000..57c38ee
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/system/windows/widget-application-impl-win.h>
+#include <dali/integration-api/debug.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+WidgetApplicationPtr WidgetApplicationWin::New(
+  int* argc,
+  char **argv[],
+  const std::string& stylesheet)
+{
+  return new WidgetApplicationWin(argc, argv, stylesheet );
+}
+
+WidgetApplicationWin::WidgetApplicationWin( int* argc, char** argv[], const std::string& stylesheet )
+: WidgetApplication(argc, argv, stylesheet)
+{
+  DALI_LOG_ERROR("WidgetApplication is not implemented in UBUNTU profile.\n");
+}
+
+WidgetApplicationWin::~WidgetApplicationWin()
+{
+}
+
+
+void WidgetApplicationWin::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction )
+{
+}
+
+// factory function, must be implemented
+namespace WidgetApplicationFactory
+{
+/**
+ * Create a new widget application
+ * @param[in]  argc         A pointer to the number of arguments
+ * @param[in]  argv         A pointer to the argument list
+ * @param[in]  stylesheet   The path to user defined theme file
+ */
+WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet )
+{
+  return WidgetApplicationWin::New( argc, argv, stylesheet );
+}
+
+} // namespace Factory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/system/windows/widget-application-impl-win.h b/dali/internal/system/windows/widget-application-impl-win.h
new file mode 100755 (executable)
index 0000000..fd3b1ab
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef DALI_INTERNAL_WIDGET_APPLICATION_IMPL_WIN_H
+#define DALI_INTERNAL_WIDGET_APPLICATION_IMPL_WIN_H
+
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/adaptor/common/application-impl.h>
+#include <dali/internal/system/common//widget-application-impl.h>
+#include <dali/public-api/adaptor-framework/widget-application.h>
+
+namespace Dali
+{
+class Widget;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Implementation of the WidgetApplicationWin class.
+ */
+class WidgetApplicationWin : public WidgetApplication
+{
+public:
+
+  typedef std::pair<const std::string, Dali::WidgetApplication::CreateWidgetFunction >  CreateWidgetFunctionPair;
+  typedef std::vector< CreateWidgetFunctionPair >   CreateWidgetFunctionContainer;
+
+  /**
+   * Create a new widget application
+   * @param[in]  argc         A pointer to the number of arguments
+   * @param[in]  argv         A pointer to the argument list
+   * @param[in]  stylesheet   The path to user defined theme file
+   */
+  static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet );
+
+public:
+
+  /**
+   * @copydoc Dali::WidgetApplication::RegisterWidgetCreator()
+   */
+  void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction ) override;
+
+protected:
+
+  /**
+   * Private Constructor
+   * @param[in]  argc         A pointer to the number of arguments
+   * @param[in]  argv         A pointer to the argument list
+   * @param[in]  stylesheet   The path to user defined theme file
+   */
+  WidgetApplicationWin( int* argc, char **argv[], const std::string& stylesheet );
+
+  /**
+   * Destructor
+   */
+  virtual ~WidgetApplicationWin();
+
+  WidgetApplicationWin(const Application&) = delete;
+  WidgetApplicationWin& operator=(Application&) = delete;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WIDGET_APPLICATION_IMPL_UBUNTU_H
diff --git a/dali/internal/system/windows/widget-controller-win.cpp b/dali/internal/system/windows/widget-controller-win.cpp
new file mode 100755 (executable)
index 0000000..e98e29c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 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/system/windows/widget-controller-win.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+WidgetImplWin::WidgetImplWin()
+{
+}
+
+WidgetImplWin::~WidgetImplWin()
+{
+}
+
+void WidgetImplWin::SetContentInfo( const std::string& contentInfo )
+{
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/system/windows/widget-controller-win.h b/dali/internal/system/windows/widget-controller-win.h
new file mode 100755 (executable)
index 0000000..c19de62
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef DALI_WIDGET_CONTROLLER_WIN_H
+#define DALI_WIDGET_CONTROLLER_WIN_H
+
+/*
+ * 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/signals/connection-tracker.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/system/common/widget-controller.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+/**
+ * @brief Holds the Implementation for the internal WidgetImpl class
+ */
+class WidgetImplWin : public Widget::Impl
+{
+public:
+
+  /**
+   * Constructor
+   */
+  WidgetImplWin();
+
+  /**
+   * Destructor
+   */
+  ~WidgetImplWin() override;
+
+public:
+
+  /**
+   * Set content information to widget framework
+   */
+  void SetContentInfo( const std::string& contentInfo ) override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_WIDGET_CONTROLLER_UBUNTU_H
index 0c21cf4..1cfab48 100755 (executable)
@@ -120,8 +120,8 @@ EventHandler::EventHandler( Dali::Integration::Scene scene, CoreEventInterface&
     WindowBase* windowBase = windowRenderSurface->GetWindowBase();
 
     // Connect signals
-    windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
     windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged );
+    windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged );
     windowBase->RotationSignal().Connect( this, &EventHandler::SendRotationPrepareEvent );
     windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent );
     windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent );
diff --git a/dali/internal/window-system/windows/display-connection-factory-win.cpp b/dali/internal/window-system/windows/display-connection-factory-win.cpp
new file mode 100755 (executable)
index 0000000..8a93649
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/windows/display-connection-factory-win.h>
+#include <dali/internal/window-system/windows/display-connection-impl-win.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+
+
+std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> DisplayConnectionFactoryWin::CreateDisplayConnection()
+{
+  return Utils::MakeUnique<DisplayConnectionWin>();
+}
+
+// this should be created from somewhere
+std::unique_ptr<DisplayConnectionFactory> GetDisplayConnectionFactory()
+{
+  // returns windows display factory
+  return Utils::MakeUnique<DisplayConnectionFactoryWin>();
+}
+
+}
+}
+}
\ No newline at end of file
diff --git a/dali/internal/window-system/windows/display-connection-factory-win.h b/dali/internal/window-system/windows/display-connection-factory-win.h
new file mode 100755 (executable)
index 0000000..72b73ab
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H
+#define DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H
+
+/*
+ * 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 <dali/internal/window-system/common/display-connection-factory.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class DisplayConnectionFactoryWin : public DisplayConnectionFactory
+{
+public:
+  std::unique_ptr<Dali::Internal::Adaptor::DisplayConnection> CreateDisplayConnection() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H
diff --git a/dali/internal/window-system/windows/display-connection-impl-win.cpp b/dali/internal/window-system/windows/display-connection-impl-win.cpp
new file mode 100755 (executable)
index 0000000..d4e696d
--- /dev/null
@@ -0,0 +1,105 @@
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+ // CLASS HEADER\r
+#include <dali/internal/window-system/windows/display-connection-impl-win.h>\r
+\r
+// EXTERNAL INCLUDES\r
+#include <dali/integration-api/debug.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/graphics/gles/egl-graphics.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+DisplayConnection* DisplayConnectionWin::New()\r
+{\r
+  DisplayConnection* pDisplayConnection(new DisplayConnectionWin());\r
+\r
+  return pDisplayConnection;\r
+}\r
+\r
+DisplayConnectionWin::DisplayConnectionWin()\r
+: mDisplay(NULL)\r
+{\r
+}\r
+\r
+DisplayConnectionWin::~DisplayConnectionWin()\r
+{\r
+}\r
+\r
+Any DisplayConnectionWin::GetDisplay()\r
+{\r
+  return Any(mDisplay);\r
+}\r
+\r
+void DisplayConnectionWin::ConsumeEvents()\r
+{\r
+}\r
+\r
+bool DisplayConnectionWin::InitializeEgl(EglInterface& egl)\r
+{\r
+  EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );\r
+\r
+  if( !eglImpl.InitializeGles( reinterpret_cast<EGLNativeDisplayType>( mDisplay ) ) )\r
+  {\r
+    DALI_LOG_ERROR( "Failed to initialize GLES.\n" );\r
+    return false;\r
+  }\r
+\r
+  return true;\r
+}\r
+\r
+bool DisplayConnectionWin::InitializeGraphics()\r
+{\r
+  auto eglGraphics = static_cast<EglGraphics *>( mGraphics );\r
+  EglImplementation& eglImpl = eglGraphics->GetEglImplementation();\r
+\r
+  if( !eglImpl.InitializeGles( reinterpret_cast<EGLNativeDisplayType>( mDisplay ) ) )\r
+  {\r
+    DALI_LOG_ERROR( "Failed to initialize GLES.\n" );\r
+    return false;\r
+  }\r
+\r
+  return true;\r
+}\r
+\r
+void DisplayConnectionWin::SetSurfaceType( RenderSurface::Type type )\r
+{\r
+  if( type == RenderSurface::WINDOW_RENDER_SURFACE )\r
+  {\r
+     mDisplay = GetDC( GetForegroundWindow() );\r
+  }\r
+}\r
+\r
+void DisplayConnectionWin::SetGraphicsInterface( GraphicsInterface& graphics )\r
+{\r
+  mGraphics = &graphics;\r
+}\r
+\r
+} // namespace Adaptor\r
+\r
+} // namespace Internal\r
+\r
+} // namespace Dali\r
diff --git a/dali/internal/window-system/windows/display-connection-impl-win.h b/dali/internal/window-system/windows/display-connection-impl-win.h
new file mode 100755 (executable)
index 0000000..14321bf
--- /dev/null
@@ -0,0 +1,116 @@
+#ifndef DALI_INTERNAL_WIN_DIPLAY_CONNECTION_H\r
+#define DALI_INTERNAL_WIN_DIPLAY_CONNECTION_H\r
+\r
+/*\r
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/window-system/common/display-connection-impl.h>\r
+#include <dali/public-api/object/base-object.h>\r
+#include <dali/internal/graphics/gles/egl-implementation.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+class RenderSurface;\r
+class DisplayConnection;\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+/**\r
+ * DisplayConnection implementation\r
+ */\r
+class DisplayConnectionWin : public Dali::Internal::Adaptor::DisplayConnection\r
+{\r
+public:\r
+\r
+  /**\r
+   * @brief Default constructor\r
+   */\r
+  DisplayConnectionWin();\r
+\r
+  /**\r
+   * @brief Create an initialized DisplayConnection.\r
+   *\r
+   * @return A handle to a newly allocated DisplayConnection resource.\r
+   */\r
+  static DisplayConnection* New();\r
+\r
+public:\r
+\r
+  /**\r
+   * @copydoc Dali::DisplayConnection::GetDisplay\r
+   */\r
+  Any GetDisplay();\r
+\r
+  /**\r
+   * @copydoc Dali::DisplayConnection::ConsumeEvents\r
+   */\r
+  void ConsumeEvents();\r
+\r
+  /**\r
+   * @copydoc Dali::DisplayConnection::InitializeEgl\r
+   */\r
+  bool InitializeEgl(EglInterface& egl);\r
+\r
+  /**\r
+  * @copydoc Dali::DisplayConnection::InitializeGraphics\r
+  */\r
+  bool InitializeGraphics();\r
+\r
+  /**\r
+  * @copydoc Dali::Internal::Adaptor::DisplayConnection::SetSurfaceType\r
+  */\r
+  void SetSurfaceType( RenderSurface::Type type );\r
+\r
+  /**\r
+  * @copydoc Dali::Internal::Adaptor::DisplayConnection::SetGraphicsInterface\r
+  */\r
+  void SetGraphicsInterface( GraphicsInterface& graphics );\r
+\r
+public:\r
+\r
+  /**\r
+   * Destructor\r
+   */\r
+  virtual ~DisplayConnectionWin();\r
+\r
+private:\r
+\r
+  // Undefined\r
+  DisplayConnectionWin(const DisplayConnectionWin&) = delete;\r
+\r
+  // Undefined\r
+  DisplayConnectionWin& operator=(const DisplayConnectionWin& rhs) = delete;\r
+\r
+private:\r
+\r
+  GraphicsInterface *mGraphics; ///< The graphics interface\r
+  HDC mDisplay;\r
+};\r
+\r
+} // namespace Adaptor\r
+\r
+} // namespace internal\r
+\r
+} // namespace Dali\r
+\r
+#endif // DALI_INTERNAL_WIN_DIPLAY_CONNECTION_H\r
diff --git a/dali/internal/window-system/windows/event-system-win.h b/dali/internal/window-system/windows/event-system-win.h
new file mode 100755 (executable)
index 0000000..ddd7c6c
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef _WINDOWEVENTSYSTEM_H_\r
+#define _WINDOWEVENTSYSTEM_H_\r
+\r
+/*\r
+* Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+*/\r
+#define DEVICE_MOUSE                    0\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
+\r
+namespace Dali\r
+{\r
+\r
+namespace Internal\r
+{\r
+\r
+namespace Adaptor\r
+{\r
+\r
+struct _Event_Mouse_Button\r
+{\r
+  WinWindowHandle     window; /**< The main window where event happened */\r
+\r
+  uint32_t            timestamp; /**< Time when the event occurred */\r
+\r
+  int32_t             x; /**< x coordinate relative to window where event happened */\r
+  int32_t             y; /**< y coordinate relative to window where event happened */\r
+\r
+  struct\r
+  {\r
+    int32_t       device; /**< 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */\r
+    double        radius, radius_x, radius_y; /**< radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */\r
+    double        pressure; /**< pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */\r
+    double        angle; /**< angle relative to perpendicular (0.0 == perpendicular), in degrees */\r
+    double        x, y; /**< same as x, y, but with sub-pixel precision, if available */\r
+    struct\r
+    {\r
+      double     x, y;\r
+    } root; /**< same as root.x, root.y, but with sub-pixel precision, if available */\r
+  } multi;\r
+};\r
+\r
+/**\r
+* @struct _Event_Mouse_Wheel\r
+* Contains information about an Windows mouse wheel event.\r
+*/\r
+struct _Event_Mouse_Wheel\r
+{\r
+  WinWindowHandle     window; /**< The main window where event happened */\r
+  WinWindowHandle     root_window; /**< The root window where event happened */\r
+  WinWindowHandle     event_window; /**< The child window where event happened */\r
+\r
+  uint32_t            timestamp; /**< Time when the event occurred */\r
+  uint32_t            modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/\r
+\r
+  int32_t              direction; /**< Orientation of the wheel (horizontal/vertical) */\r
+  int32_t              z; /**< Value of the wheel event (+1/-1) */\r
+\r
+  int32_t              x; /**< x coordinate relative to window where event happened */\r
+  int32_t              y; /**< y coordinate relative to window where event happened */\r
+  struct\r
+  {\r
+       int32_t           x;\r
+       int32_t           y;\r
+  } root; /**< Coordinates relative to root window */\r
+};\r
+\r
+typedef struct _Event_Mouse_Button Event_Mouse_Button;\r
+typedef struct _Event_Mouse_Wheel  Event_Mouse_Wheel;\r
+\r
+struct TWinEventInfo\r
+{\r
+  TWinEventInfo( uint64_t hWnd, uint32_t uMsg, uint64_t wParam, uint64_t lParam)\r
+  {\r
+    this->mWindow = (WinWindowHandle)hWnd;\r
+    this->uMsg = uMsg;\r
+    this->wParam = wParam;\r
+    this->lParam = lParam;\r
+  }\r
+\r
+  WinWindowHandle mWindow;\r
+  uint32_t uMsg;\r
+  uint64_t wParam;\r
+  uint64_t lParam;\r
+};\r
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali\r
+\r
+#endif\r
diff --git a/dali/internal/window-system/windows/platform-implement-win.cpp b/dali/internal/window-system/windows/platform-implement-win.cpp
new file mode 100755 (executable)
index 0000000..1d79ce8
--- /dev/null
@@ -0,0 +1,390 @@
+/*\r
+* Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+*/\r
+\r
+// CLASS HEADER\r
+#include <dali/internal/window-system/windows/platform-implement-win.h>\r
+\r
+// EXTERNAL INCLUDES\r
+#include <windows.h>\r
+\r
+// INTERNAL INCLUDES\r
+#include <dali/internal/window-system/windows/event-system-win.h>\r
+\r
+static constexpr float INCH = 25.4;\r
+\r
+using namespace std;\r
+\r
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+\r
+namespace WindowsPlatformImplementation\r
+{\r
+\r
+void RunLoop()\r
+{\r
+  MSG nMsg = { 0 };\r
+\r
+  while( GetMessage( &nMsg, 0, NULL, NULL ) )\r
+  {\r
+    if( WIN_CALLBACK_EVENT == nMsg.message )\r
+    {\r
+      Dali::CallbackBase *callback = ( Dali::CallbackBase* )nMsg.wParam;\r
+      Dali::CallbackBase::Execute( *callback );\r
+    }\r
+\r
+    TranslateMessage( &nMsg );\r
+    DispatchMessage( &nMsg );\r
+\r
+    if( WM_CLOSE == nMsg.message )\r
+    {\r
+      break;\r
+    }\r
+  }\r
+}\r
+\r
+void GetDPI( uint64_t hWnd, float &xDpi, float &yDpi )\r
+{\r
+  HDC hdcScreen = GetDC( reinterpret_cast<HWND>( hWnd ) );\r
+\r
+  int32_t iX = GetDeviceCaps( hdcScreen, HORZRES );    // pixel\r
+  int32_t iY = GetDeviceCaps( hdcScreen, VERTRES );    // pixel\r
+  int32_t iPhsX = GetDeviceCaps( hdcScreen, HORZSIZE );    // mm\r
+  int32_t iPhsY = GetDeviceCaps( hdcScreen, VERTSIZE );    // mm\r
+\r
+  xDpi = static_cast<float>( iX ) / static_cast<float>( iPhsX ) * INCH;\r
+  yDpi = static_cast<float>( iY ) / static_cast<float>( iPhsY ) * INCH;\r
+}\r
+\r
+CallbackBase *listener = NULL;\r
+\r
+LRESULT CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+{\r
+  if( NULL != listener )\r
+  {\r
+    TWinEventInfo eventInfo( reinterpret_cast<uint64_t>( hWnd ), uMsg, wParam, lParam);\r
+    CallbackBase::Execute( *listener, &eventInfo );\r
+  }\r
+\r
+  LRESULT ret = DefWindowProc( hWnd, uMsg, wParam, lParam );\r
+  return ret;\r
+}\r
+\r
+DWORD windowStyle = WS_OVERLAPPED;\r
+\r
+int32_t GetEdgeWidth()\r
+{\r
+  switch( windowStyle )\r
+  {\r
+    case WS_OVERLAPPED:\r
+    {\r
+      return 8;\r
+    }\r
+    default:\r
+    {\r
+      return 0;\r
+    }\r
+  }\r
+}\r
+\r
+int32_t GetEdgeHeight()\r
+{\r
+  switch( windowStyle )\r
+  {\r
+    case WS_OVERLAPPED:\r
+    {\r
+      return 18;\r
+    }\r
+    default:\r
+    {\r
+      return 0;\r
+    }\r
+  }\r
+}\r
+\r
+class WindowsDisplayInfo\r
+{\r
+public:\r
+  static int GetColorDepth()\r
+  {\r
+    DALI_ASSERT_DEBUG(colorDepth >= 0 && "HWND hasn't been created, no color depth");\r
+    return colorDepth;\r
+  }\r
+\r
+  static void SetHWND( HWND inHWnd )\r
+  {\r
+    if( hWnd != inHWnd )\r
+    {\r
+      hWnd = inHWnd;\r
+      hdc = GetDC( hWnd );\r
+      colorDepth = GetDeviceCaps( WindowsDisplayInfo::hdc, BITSPIXEL ) * GetDeviceCaps( WindowsDisplayInfo::hdc, PLANES );\r
+    }\r
+  }\r
+\r
+private:\r
+  static int colorDepth;\r
+  static HWND hWnd;\r
+  static HDC hdc;\r
+};\r
+\r
+int WindowsDisplayInfo::colorDepth = -1;\r
+HWND WindowsDisplayInfo::hWnd = NULL;\r
+HDC WindowsDisplayInfo::hdc = NULL;\r
+\r
+int GetColorDepth()\r
+{\r
+  return WindowsDisplayInfo::GetColorDepth();\r
+}\r
+\r
+uint64_t CreateHwnd(\r
+    _In_opt_ const char *lpClassName,\r
+    _In_opt_ const char *lpWindowName,\r
+    _In_ int X,\r
+    _In_ int Y,\r
+    _In_ int nWidth,\r
+    _In_ int nHeight,\r
+    _In_opt_ uint64_t parent)\r
+{\r
+  WNDCLASS cs = { 0 };\r
+  cs.cbClsExtra = 0;\r
+  cs.cbWndExtra = 0;\r
+  cs.hbrBackground = (HBRUSH)( COLOR_WINDOW + 2 );\r
+  cs.hCursor = NULL;\r
+  cs.hIcon = NULL;\r
+  cs.hInstance = GetModuleHandle( NULL );\r
+  cs.lpfnWndProc = (WNDPROC)WinProc;\r
+  cs.lpszClassName = lpClassName;\r
+  cs.lpszMenuName = NULL;\r
+  cs.style = CS_VREDRAW | CS_HREDRAW;\r
+  RegisterClass( &cs );\r
+\r
+  HWND hWnd = CreateWindow( lpClassName, lpWindowName, windowStyle, X, Y, nWidth + 2 * GetEdgeWidth(), nHeight + 2 * GetEdgeHeight(), NULL, NULL, cs.hInstance, NULL );\r
+  ShowWindow( hWnd, SW_SHOW );\r
+\r
+  WindowsDisplayInfo::SetHWND( hWnd );\r
+\r
+  return reinterpret_cast<uint64_t>( hWnd );\r
+}\r
+\r
+void SetListener( CallbackBase *callback )\r
+{\r
+  listener = callback;\r
+}\r
+\r
+bool PostWinMessage(\r
+    _In_ uint32_t Msg,\r
+    _In_ uint32_t wParam,\r
+    _In_ uint64_t lParam,\r
+    _In_ uint64_t hWnd)\r
+{\r
+  return (bool)PostMessage( reinterpret_cast<HWND>( hWnd ), Msg, wParam, lParam );\r
+}\r
+\r
+bool PostWinThreadMessage(\r
+    _In_ uint32_t Msg,\r
+    _In_ uint32_t wParam,\r
+    _In_ uint64_t lParam,\r
+    _In_ uint64_t threadID/* = -1*/ )\r
+{\r
+  if( -1 == threadID )\r
+  {\r
+    threadID = GetCurrentThreadId();\r
+  }\r
+\r
+  return (bool)PostThreadMessage( threadID, Msg, wParam, lParam );\r
+}\r
+\r
+void ShowWindow( uint64_t hWnd)\r
+{\r
+  ::ShowWindow( reinterpret_cast<HWND>( hWnd ), SW_SHOW);\r
+}\r
+\r
+void HideWindow( uint64_t hWnd)\r
+{\r
+  ::ShowWindow( reinterpret_cast<HWND>( hWnd ), SW_HIDE);\r
+}\r
+\r
+struct TTimerCallbackInfo\r
+{\r
+  void *data;\r
+  timerCallback callback;\r
+  HWND hWnd;\r
+};\r
+\r
+void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT_PTR nTimerid, DWORD dwTime)\r
+{\r
+  TTimerCallbackInfo *info = (TTimerCallbackInfo*)nTimerid;\r
+  info->callback( info->data );\r
+}\r
+\r
+int SetTimer(int interval, timerCallback callback, void *data)\r
+{\r
+  TTimerCallbackInfo *callbackInfo = new TTimerCallbackInfo;\r
+  callbackInfo->data = data;\r
+  callbackInfo->callback = callback;\r
+  callbackInfo->hWnd = ::GetActiveWindow();\r
+\r
+  UINT_PTR timerID = (UINT_PTR)callbackInfo;\r
+  ::SetTimer( callbackInfo->hWnd, timerID, interval, TimerProc );\r
+\r
+  return timerID;\r
+}\r
+\r
+void KillTimer(int id)\r
+{\r
+  TTimerCallbackInfo *info = (TTimerCallbackInfo*)id;\r
+  ::KillTimer( info->hWnd, id );\r
+  delete info;\r
+}\r
+\r
+const char* GetKeyName( int keyCode )\r
+{\r
+  switch( keyCode )\r
+  {\r
+    case VK_BACK:\r
+    {\r
+      return "Backspace";\r
+    }\r
+    case VK_TAB:\r
+    {\r
+      return "Tab";\r
+    }\r
+    case VK_RETURN:\r
+    {\r
+      return "Return";\r
+    }\r
+    case VK_ESCAPE:\r
+    {\r
+      return "Escape";\r
+    }\r
+    case VK_SPACE:\r
+    {\r
+      return "Space";\r
+    }\r
+    case VK_LEFT:\r
+    {\r
+      return "Left";\r
+    }\r
+    case VK_UP:\r
+    {\r
+      return "Up";\r
+    }\r
+    case VK_RIGHT:\r
+    {\r
+      return "Right";\r
+    }\r
+    case VK_DOWN:\r
+    {\r
+      return "Down";\r
+    }\r
+    case 48:\r
+    {\r
+      return "0";\r
+    }\r
+    case 49:\r
+    {\r
+      return "1";\r
+    }\r
+    case 50:\r
+    {\r
+      return "2";\r
+    }\r
+    case 51:\r
+    {\r
+      return "3";\r
+    }\r
+    case 52:\r
+    {\r
+      return "4";\r
+    }\r
+    case 53:\r
+    {\r
+      return "5";\r
+    }\r
+    case 54:\r
+    {\r
+      return "6";\r
+    }\r
+    case 55:\r
+    {\r
+      return "7";\r
+    }\r
+    case 56:\r
+    {\r
+      return "8";\r
+    }\r
+    case 57:\r
+    {\r
+      return "9";\r
+    }\r
+    default:\r
+    {\r
+      break;\r
+    }\r
+  }\r
+\r
+  return "";\r
+}\r
+
+static LARGE_INTEGER cpuFrequency;\r
+static LARGE_INTEGER *pCpuFrequency = NULL;\r
+\r
+uint64_t GetCurrentThreadId()\r
+{\r
+  return ::GetCurrentThreadId();\r
+}\r
+\r
+void GetNanoseconds( uint64_t& timeInNanoseconds )\r
+{\r
+  if( NULL == pCpuFrequency )\r
+  {\r
+    pCpuFrequency = &cpuFrequency;\r
+    QueryPerformanceFrequency( pCpuFrequency );\r
+  }\r
+\r
+  LARGE_INTEGER curTime;\r
+  QueryPerformanceCounter( &curTime );\r
+\r
+  timeInNanoseconds = static_cast<double>(curTime.QuadPart) / static_cast<double>(pCpuFrequency->QuadPart) * 1000000000;\r
+}\r
+\r
+unsigned int GetCurrentMilliSeconds( void )\r
+{\r
+  if( NULL == pCpuFrequency )\r
+  {\r
+    pCpuFrequency = &cpuFrequency;\r
+    QueryPerformanceFrequency( pCpuFrequency );\r
+  }\r
+\r
+  LARGE_INTEGER curTime;\r
+  QueryPerformanceCounter( &curTime );\r
+\r
+  return curTime.QuadPart * 1000 / pCpuFrequency->QuadPart;\r
+}\r
+
+} // namespace WindowsPlatformImplement
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali\r
diff --git a/dali/internal/window-system/windows/platform-implement-win.h b/dali/internal/window-system/windows/platform-implement-win.h
new file mode 100755 (executable)
index 0000000..18b33c1
--- /dev/null
@@ -0,0 +1,96 @@
+#ifndef PLATFORM_IMPLEMENT_WIN_INCLUDE\r
+#define PLATFORM_IMPLEMENT_WIN_INCLUDE\r
+\r
+/*
+* 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.
+*
+*/\r
+\r
+// EXTERNAL_HEADERS\r
+#include <stdint.h>\r
+#include <dali/public-api/signals/callback.h>\r
+\r
+typedef uint64_t   WinWindowHandle;\r
+typedef uint64_t   WinPixmap;\r
+\r
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+\r
+namespace WindowsPlatformImplementation\r
+{\r
+\r
+void RunLoop();\r
+\r
+int GetEdgeHeight();\r
+\r
+int GetColorDepth();\r
+\r
+uint64_t CreateHwnd(\r
+    _In_opt_ const char *lpClassName,\r
+    _In_opt_ const char *lpWindowName,\r
+    _In_ int X,\r
+    _In_ int Y,\r
+    _In_ int nWidth,\r
+    _In_ int nHeight,\r
+    _In_opt_ uint64_t parent);\r
+\r
+void SetListener( CallbackBase *callback );\r
+\r
+bool PostWinMessage(\r
+    _In_ uint32_t Msg,\r
+    _In_ uint32_t wParam,\r
+    _In_ uint64_t lParam,\r
+    _In_ uint64_t hWnd);\r
+\r
+bool PostWinThreadMessage(\r
+    _In_ uint32_t Msg,\r
+    _In_ uint32_t wParam,\r
+    _In_ uint64_t lParam,\r
+    _In_ uint64_t threadID = -1 );\r
+\r
+void ShowWindow( uint64_t hWnd );\r
+void HideWindow( uint64_t hWnd );\r
+\r
+using timerCallback = bool(*)(void *data);\r
+\r
+int SetTimer(int interval, timerCallback callback, void *data);\r
+\r
+void KillTimer(int id);\r
+\r
+void GetDPI( uint64_t hWnd, float &xDpi, float &yDpi );\r
+\r
+const char* GetKeyName( int keyCode );\r
+\r
+uint64_t GetCurrentThreadId();\r
+\r
+void GetNanoseconds( uint64_t& timeInNanoseconds );\r
+\r
+unsigned int GetCurrentMilliSeconds( void );\r
+\r
+} // namespace WindowsPlatformImplement
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // WIN32_WINDOWS_SYSTEM_INCLUDE\r
diff --git a/dali/internal/window-system/windows/render-surface-factory-win.cpp b/dali/internal/window-system/windows/render-surface-factory-win.cpp
new file mode 100755 (executable)
index 0000000..e181692
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ *
+ */
+
+// EXTERNAL HEADERS
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/native-render-surface.h>
+#include <dali/internal/window-system/windows/render-surface-factory-win.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/pixmap-render-surface.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryWin::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+{
+  return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent );
+}
+
+std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryWin::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+{
+  DALI_LOG_ERROR("Pixmap isn't been supported in Windows");
+  return nullptr;
+}
+
+std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryWin::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent )
+{
+  return std::unique_ptr< NativeRenderSurface >( nullptr );
+}
+
+// this should be created from somewhere
+std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory()
+{
+  // returns Window factory
+  return Utils::MakeUnique< RenderSurfaceFactoryWin >();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/windows/render-surface-factory-win.h b/dali/internal/window-system/windows/render-surface-factory-win.h
new file mode 100755 (executable)
index 0000000..fd05c74
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_WIN_H
+#define DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_WIN_H
+
+/*
+ * 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 <dali/internal/window-system/common/render-surface-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class RenderSurfaceFactoryWin : public RenderSurfaceFactory
+{
+public:
+  std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+
+  std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
+
+  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_WIN_H
diff --git a/dali/internal/window-system/windows/window-base-win.cpp b/dali/internal/window-system/windows/window-base-win.cpp
new file mode 100755 (executable)
index 0000000..2b75b9f
--- /dev/null
@@ -0,0 +1,572 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/windows/window-base-win.h>
+
+// EXTERNAL_HEADERS
+#include <dali/public-api/object/any.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/window-system/common/window-impl.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-system.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+
+const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE;
+const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
+
+const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
+
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" );
+#endif
+
+} // unnamed namespace
+
+WindowBaseWin::WindowBaseWin( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+: mWin32Window( 0 ),
+  mOwnSurface( false ),
+  mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
+  mRotationAppSet( false )
+{
+  Initialize( positionSize, surface, isTransparent );
+}
+
+WindowBaseWin::~WindowBaseWin()
+{
+  WindowsPlatformImplementation::PostWinMessage( WM_CLOSE, 0, 0, mWin32Window );
+}
+
+void WindowBaseWin::Initialize( PositionSize positionSize, Any surface, bool isTransparent )
+{
+  // see if there is a surface in Any surface
+  unsigned int surfaceId = GetSurfaceId( surface );
+
+  // if the surface is empty, create a new one.
+  if( surfaceId == 0 )
+  {
+    // we own the surface about to created
+    mOwnSurface = true;
+    CreateWinWindow( positionSize, isTransparent );
+  }
+  else
+  {
+    // XLib should already be initialized so no point in calling XInitThreads
+    mWin32Window = static_cast< WinWindowHandle >( surfaceId );
+  }
+
+  WindowsPlatformImplementation::SetListener( MakeCallback( this, &WindowBaseWin::EventEntry ) );
+}
+
+void WindowBaseWin::OnDeleteRequest()
+{
+  mDeleteRequestSignal.Emit();
+}
+
+void WindowBaseWin::OnFocusIn( int type, TWinEventInfo *event )
+{
+}
+
+void WindowBaseWin::OnFocusOut( int type, TWinEventInfo *event )
+{
+}
+
+void WindowBaseWin::OnWindowDamaged( int type, TWinEventInfo *event )
+{
+  Event_Mouse_Button* windowDamagedEvent( (Event_Mouse_Button*)event );\r
+\r
+  if( windowDamagedEvent->window == mWin32Window )\r
+  {\r
+    DamageArea area;\r
+    area.x = 0;\r
+    area.y = 0;\r
+    WindowSystem::GetScreenSize( area.width, area.height );\r
+\r
+    mWindowDamagedSignal.Emit( area );\r
+  }\r
+}
+
+void WindowBaseWin::OnMouseButtonDown( int type, TWinEventInfo *event )
+{
+  Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event);
+  touchEvent.timestamp = GetTickCount();
+  touchEvent.x = LOWORD( event->lParam );\r
+  touchEvent.y = HIWORD( event->lParam );\r
+  touchEvent.multi.device = DEVICE_MOUSE;
+
+  if( touchEvent.window == mWin32Window )
+  {
+    PointState::Type state ( PointState::DOWN );
+
+    Integration::Point point;
+    point.SetDeviceId( touchEvent.multi.device );
+    point.SetState( state );
+    point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) );
+    point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
+    point.SetPressure( touchEvent.multi.pressure );
+    point.SetAngle( Degree( touchEvent.multi.angle ) );
+
+    mTouchEventSignal.Emit( point, touchEvent.timestamp );
+  }
+}
+
+void WindowBaseWin::OnMouseButtonUp( int type, TWinEventInfo *event )
+{
+  Event_Mouse_Button touchEvent = *( (Event_Mouse_Button*)event );
+  touchEvent.timestamp = GetTickCount();
+  touchEvent.x = LOWORD( event->lParam );\r
+  touchEvent.y = HIWORD( event->lParam );\r
+  touchEvent.multi.device = DEVICE_MOUSE;
+
+  if( touchEvent.window == mWin32Window )
+  {
+    PointState::Type state( PointState::UP );
+
+    Integration::Point point;
+    point.SetDeviceId( touchEvent.multi.device );
+    point.SetState( state );
+    point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) );
+    point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
+    point.SetPressure( touchEvent.multi.pressure );
+    point.SetAngle( Degree( touchEvent.multi.angle ) );
+
+    mTouchEventSignal.Emit( point, touchEvent.timestamp );
+  }
+}
+
+void WindowBaseWin::OnMouseButtonMove( int type, TWinEventInfo *event )
+{
+  Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event);
+  touchEvent.timestamp = GetTickCount();
+  touchEvent.x = LOWORD( event->lParam );\r
+  touchEvent.y = HIWORD( event->lParam );\r
+  touchEvent.multi.device = DEVICE_MOUSE;
+
+  if( touchEvent.window == mWin32Window )
+  {
+    PointState::Type state( PointState::MOTION );
+
+    Integration::Point point;
+    point.SetDeviceId( touchEvent.multi.device );
+    point.SetState( state );
+    point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplementation::GetEdgeHeight() ) );
+    point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) );
+    point.SetPressure( touchEvent.multi.pressure );
+    point.SetAngle( Degree( touchEvent.multi.angle ) );
+
+    mTouchEventSignal.Emit( point, touchEvent.timestamp );
+  }
+}
+
+void WindowBaseWin::OnMouseWheel( int type, TWinEventInfo *event )
+{
+  Event_Mouse_Wheel mouseWheelEvent = *((Event_Mouse_Wheel*)( event ));
+
+  if( mouseWheelEvent.window == mWin32Window )
+  {
+    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent.direction, mouseWheelEvent.modifiers, mouseWheelEvent.x, mouseWheelEvent.y, mouseWheelEvent.z );
+
+    WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent.direction, mouseWheelEvent.modifiers, Vector2( mouseWheelEvent.x, mouseWheelEvent.y ), mouseWheelEvent.z, mouseWheelEvent.timestamp );
+
+    mWheelEventSignal.Emit( wheelEvent );
+  }
+}
+
+void WindowBaseWin::OnKeyDown( int type, TWinEventInfo *event )
+{
+  if( event->mWindow == mWin32Window )
+  {
+    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" );
+
+    int keyCode = event->wParam;
+    std::string keyName( WindowsPlatformImplementation::GetKeyName( keyCode ) );
+    std::string keyString;
+    std::string emptyString;
+
+    int modifier( 0 );
+    unsigned long time( 0 );
+
+    // Ensure key event string is not NULL as keys like SHIFT have a null string.
+    keyString.push_back( event->wParam );
+
+    Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+
+    mKeyEventSignal.Emit( keyEvent );
+  }
+}
+
+void WindowBaseWin::OnKeyUp( int type, TWinEventInfo *event )
+{
+  if( event->mWindow == mWin32Window )
+  {
+    DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" );
+
+    int keyCode = event->wParam;
+    std::string keyName( WindowsPlatformImplementation::GetKeyName( keyCode ) );
+    std::string keyString;
+    std::string emptyString;
+
+    int modifier( 0 );
+    unsigned long time( 0 );
+
+    // Ensure key event string is not NULL as keys like SHIFT have a null string.
+    keyString.push_back( event->wParam );
+
+    Integration::KeyEvent keyEvent( keyName, emptyString, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, emptyString, emptyString, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+
+    mKeyEventSignal.Emit( keyEvent );
+  }
+}
+
+Any WindowBaseWin::GetNativeWindow()
+{
+  return mWin32Window;
+}
+
+int WindowBaseWin::GetNativeWindowId()
+{
+  return mWin32Window;
+}
+
+EGLNativeWindowType WindowBaseWin::CreateEglWindow( int width, int height )
+{
+  return reinterpret_cast< EGLNativeWindowType >( mWin32Window );
+}
+
+void WindowBaseWin::DestroyEglWindow()
+{
+}
+
+void WindowBaseWin::SetEglWindowRotation( int angle )
+{
+}
+
+void WindowBaseWin::SetEglWindowBufferTransform( int angle )
+{
+}
+
+void WindowBaseWin::SetEglWindowTransform( int angle )
+{
+}
+
+void WindowBaseWin::ResizeEglWindow( PositionSize positionSize )
+{
+}
+
+bool WindowBaseWin::IsEglWindowRotationSupported()
+{
+  return false;
+}
+
+void WindowBaseWin::Move( PositionSize positionSize )
+{
+}
+
+void WindowBaseWin::Resize( PositionSize positionSize )
+{
+}
+
+void WindowBaseWin::MoveResize( PositionSize positionSize )
+{
+}
+
+void WindowBaseWin::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode )
+{
+}
+
+void WindowBaseWin::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
+{
+}
+
+void WindowBaseWin::IndicatorTypeChanged( IndicatorInterface::Type type )
+{
+}
+
+void WindowBaseWin::SetClass( const std::string& name, const std::string& className )
+{
+}
+
+void WindowBaseWin::Raise()
+{
+}
+
+void WindowBaseWin::Lower()
+{
+}
+
+void WindowBaseWin::Activate()
+{
+}
+
+void WindowBaseWin::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations )
+{
+}
+
+void WindowBaseWin::SetPreferredOrientation( Dali::Window::WindowOrientation orientation )
+{
+}
+
+void WindowBaseWin::SetAcceptFocus( bool accept )
+{
+}
+
+void WindowBaseWin::Show()
+{
+}
+
+void WindowBaseWin::Hide()
+{
+}
+
+unsigned int WindowBaseWin::GetSupportedAuxiliaryHintCount() const
+{
+  return 0;
+}
+
+std::string WindowBaseWin::GetSupportedAuxiliaryHint( unsigned int index ) const
+{
+  return std::string();
+}
+
+unsigned int WindowBaseWin::AddAuxiliaryHint( const std::string& hint, const std::string& value )
+{
+  return 0;
+}
+
+bool WindowBaseWin::RemoveAuxiliaryHint( unsigned int id )
+{
+  return false;
+}
+
+bool WindowBaseWin::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
+{
+  return false;
+}
+
+std::string WindowBaseWin::GetAuxiliaryHintValue( unsigned int id ) const
+{
+  return std::string();
+}
+
+unsigned int WindowBaseWin::GetAuxiliaryHintId( const std::string& hint ) const
+{
+  return 0;
+}
+
+void WindowBaseWin::SetInputRegion( const Rect< int >& inputRegion )
+{
+}
+
+void WindowBaseWin::SetType( Dali::Window::Type type )
+{
+}
+
+bool WindowBaseWin::SetNotificationLevel( Dali::Window::NotificationLevel::Type level )
+{
+  return false;
+}
+
+Dali::Window::NotificationLevel::Type WindowBaseWin::GetNotificationLevel() const
+{
+  return Dali::Window::NotificationLevel::NONE;
+}
+
+void WindowBaseWin::SetOpaqueState( bool opaque )
+{
+}
+
+bool WindowBaseWin::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode)
+{
+  return false;
+}
+
+Dali::Window::ScreenOffMode::Type WindowBaseWin::GetScreenOffMode() const
+{
+  return Dali::Window::ScreenOffMode::TIMEOUT;
+}
+
+bool WindowBaseWin::SetBrightness( int brightness )
+{
+  return false;
+}
+
+int WindowBaseWin::GetBrightness() const
+{
+  return 0;
+}
+
+bool WindowBaseWin::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
+{
+  return false;
+}
+
+bool WindowBaseWin::UngrabKey( Dali::KEY key )
+{
+  return false;
+}
+
+bool WindowBaseWin::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result )
+{
+  return false;
+}
+
+bool WindowBaseWin::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result )
+{
+  return false;
+}
+
+void WindowBaseWin::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
+{
+  // calculate DPI
+  float xres, yres;
+
+  //// 1 inch = 25.4 millimeters
+  WindowsPlatformImplementation::GetDPI( mWin32Window, xres, yres );
+
+  xres *= 1.5f;
+  yres *= 1.5f;
+
+  dpiHorizontal = static_cast<int>( xres + 0.5f );  // rounding
+  dpiVertical = static_cast<int>( yres + 0.5f );
+}
+
+int WindowBaseWin::GetScreenRotationAngle()
+{
+  return 0;
+}
+
+void WindowBaseWin::SetWindowRotationAngle( int degree )
+{
+}
+
+void WindowBaseWin::WindowRotationCompleted( int degree, int width, int height )
+{
+}
+
+void WindowBaseWin::SetTransparency( bool transparent )
+{
+}
+
+unsigned int WindowBaseWin::GetSurfaceId( Any surface ) const
+{
+  unsigned int surfaceId = 0;
+
+  if ( surface.Empty() == false )
+  {
+    // check we have a valid type
+    DALI_ASSERT_ALWAYS( (surface.GetType() == typeid ( WinWindowHandle ) )
+                        && "Surface type is invalid" );
+
+    surfaceId = AnyCast< WinWindowHandle >( surface );
+  }
+  return surfaceId;
+}
+
+void WindowBaseWin::CreateWinWindow( PositionSize positionSize, bool isTransparent )
+{
+  long hWnd = WindowsPlatformImplementation::CreateHwnd( "Demo", "Demo", positionSize.x, positionSize.y, positionSize.width, positionSize.height, NULL );\r
+\r
+  WindowsPlatformImplementation::ShowWindow( hWnd );\r
+\r
+  mWin32Window = (WinWindowHandle)hWnd;\r
+  DALI_ASSERT_ALWAYS( mWin32Window != 0 && "There is no Windows window" );
+}
+
+void WindowBaseWin::EventEntry( TWinEventInfo *event )
+{
+  unsigned int uMsg = event->uMsg;
+
+  switch( uMsg )\r
+  {\r
+  case WM_SETFOCUS:\r
+  {\r
+    OnFocusIn( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_KILLFOCUS:\r
+  {\r
+    OnFocusOut( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_PAINT:\r
+  {\r
+    OnWindowDamaged( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_LBUTTONDOWN:\r
+  {\r
+    OnMouseButtonDown( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_LBUTTONUP:\r
+  {\r
+    OnMouseButtonUp( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_MOUSEMOVE:\r
+  {\r
+    OnMouseButtonMove( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_MOUSEWHEEL:\r
+  {\r
+    OnMouseWheel( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_KEYDOWN:\r
+  {\r
+    OnKeyDown( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  case WM_KEYUP:\r
+  {\r
+    OnKeyUp( uMsg, event );\r
+    break;\r
+  }\r
+\r
+  default:
+    break;\r
+  }
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
diff --git a/dali/internal/window-system/windows/window-base-win.h b/dali/internal/window-system/windows/window-base-win.h
new file mode 100755 (executable)
index 0000000..e9d99bb
--- /dev/null
@@ -0,0 +1,397 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
+#define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
+
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/window-base.h>
+#include <dali/internal/window-system/windows/platform-implement-win.h>
+#include <dali/internal/window-system/windows/event-system-win.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class Window;
+class WindowRenderSurface;
+class WindowRenderSurfaceWin;
+
+/**
+ * WindowBaseWin class provides an WindowBase Win32 implementation.
+ */
+class WindowBaseWin : public WindowBase
+{
+public:
+
+  /**
+   * @brief Constructor
+   */
+  WindowBaseWin( PositionSize positionSize, Any surface, bool isTransparent );
+
+  /**
+   * @brief Destructor
+   */
+  virtual ~WindowBaseWin();
+
+public:
+
+  /**
+   * Called when the window receives a delete request
+   */
+  void OnDeleteRequest();
+
+  /**
+   * @brief Called when the window gains focus.
+   */
+  void OnFocusIn( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when the window loses focus.
+   */
+  void OnFocusOut( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when the window is damaged.
+   */
+  void OnWindowDamaged( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when a touch down is received.
+   */
+  void OnMouseButtonDown( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when a touch up is received.
+   */
+  void OnMouseButtonUp( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when a touch motion is received.
+   */
+  void OnMouseButtonMove( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when a mouse wheel is received.
+   */
+  void OnMouseWheel( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when a key down is received.
+   */
+  void OnKeyDown( int type, TWinEventInfo *event );
+
+  /**
+   * @brief Called when a key up is received.
+   */
+  void OnKeyUp( int type, TWinEventInfo *event );
+
+
+public:
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
+   */
+  virtual Any GetNativeWindow() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
+   */
+  virtual int GetNativeWindowId() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
+   */
+  virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
+   */
+  virtual void DestroyEglWindow() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
+   */
+  virtual void SetEglWindowRotation( int angle ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
+   */
+  virtual void SetEglWindowBufferTransform( int angle ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
+   */
+  virtual void SetEglWindowTransform( int angle ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
+   */
+  virtual void ResizeEglWindow( PositionSize positionSize ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
+   */
+  virtual bool IsEglWindowRotationSupported() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
+   */
+  virtual void Move( PositionSize positionSize ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
+   */
+  virtual void Resize( PositionSize positionSize ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
+   */
+  virtual void MoveResize( PositionSize positionSize ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::ShowIndicator()
+   */
+  virtual void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetIndicatorProperties()
+   */
+  virtual void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::IndicatorTypeChanged()
+   */
+  virtual void IndicatorTypeChanged( IndicatorInterface::Type type ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
+   */
+  virtual void SetClass( const std::string& name, const std::string& className ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
+   */
+  virtual void Raise() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
+   */
+  virtual void Lower() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
+   */
+  virtual void Activate() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations()
+   */
+  virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation()
+   */
+  virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
+   */
+  virtual void SetAcceptFocus( bool accept ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
+   */
+  virtual void Show() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
+   */
+  virtual void Hide() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
+   */
+  virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
+   */
+  virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
+   */
+  virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
+   */
+  virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
+   */
+  virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
+   */
+  virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
+   */
+  virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
+   */
+  virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
+   */
+  virtual void SetType( Dali::Window::Type type ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
+   */
+  virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
+   */
+  virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
+   */
+  virtual void SetOpaqueState( bool opaque ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
+   */
+  virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
+   */
+  virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
+   */
+  virtual bool SetBrightness( int brightness ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
+   */
+  virtual int GetBrightness() const override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
+   */
+  virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
+   */
+  virtual bool UngrabKey( Dali::KEY key ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
+   */
+  virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
+   */
+  virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
+   */
+  virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
+   */
+  virtual int GetScreenRotationAngle() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
+   */
+  virtual void SetWindowRotationAngle( int degree ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
+   */
+  virtual void WindowRotationCompleted( int degree, int width, int height ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
+   */
+  virtual void SetTransparency( bool transparent ) override;
+
+private:
+
+  /**
+   * Second stage initialization
+   */
+  void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
+
+  /**
+   * @brief Get the surface id if the surface parameter is not empty
+   * @param surface Any containing a surface id, or can be empty
+   * @return surface id, or zero if surface is empty
+   */
+  unsigned int GetSurfaceId( Any surface ) const;
+
+  /**
+   * @brief Create window
+   */
+  void CreateWinWindow( PositionSize positionSize, bool isTransparent );
+
+private:
+
+  // Undefined
+  WindowBaseWin(const WindowBaseWin&) = delete;
+
+  // Undefined
+  WindowBaseWin& operator=(const WindowBaseWin& rhs) = delete;
+
+private:
+  void EventEntry( TWinEventInfo *event );
+
+private:
+  WinWindowHandle                      mWin32Window;        ///< Native window handle
+  bool                                 mOwnSurface:1;       ///< Whether we own the surface (responsible for deleting it)
+  bool                                 mIsTransparent:1;    ///< Whether the window is transparent (32 bit or 24 bit)
+  bool                                 mRotationAppSet:1;
+};
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
diff --git a/dali/internal/window-system/windows/window-factory-win.cpp b/dali/internal/window-system/windows/window-factory-win.cpp
new file mode 100755 (executable)
index 0000000..7359548
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/windows/window-factory-win.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/window-system/windows/window-base-win.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+std::unique_ptr< WindowBase > WindowFactoryWin::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent )
+{
+  return Utils::MakeUnique< WindowBaseWin >( positionSize, surface, isTransparent );
+}
+
+std::unique_ptr< IndicatorInterface > WindowFactoryWin::CreateIndicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer )
+{
+  return std::unique_ptr< IndicatorInterface >( nullptr );
+}
+
+// this should be created from Window impl
+std::unique_ptr< WindowFactory > GetWindowFactory()
+{
+  // returns Window factory
+  return Utils::MakeUnique< WindowFactoryWin >();
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/windows/window-factory-win.h b/dali/internal/window-system/windows/window-factory-win.h
new file mode 100755 (executable)
index 0000000..ca88e1d
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_WINDOW_FACTORY_WIN_H
+#define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_FACTORY_WIN_H
+
+/*
+ * 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 <dali/internal/window-system/common/window-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class WindowFactoryWin : public WindowFactory
+{
+public:
+  std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override;
+
+  std::unique_ptr< IndicatorInterface > CreateIndicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer ) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_FACTORY_WIN_H
diff --git a/dali/internal/window-system/windows/window-system-win.cpp b/dali/internal/window-system/windows/window-system-win.cpp
new file mode 100755 (executable)
index 0000000..1fcbc68
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL HEADERS
+#include <dali/internal/window-system/common/window-system.h>
+
+// EXTERNAL HEADERS
+#include <Windows.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace WindowSystem
+{
+
+void Initialize()
+{
+}
+
+void GetScreenSize( int& width, int& height )
+{
+  width = GetSystemMetrics( SM_CXSCREEN );
+  height = GetSystemMetrics( SM_CYSCREEN );
+}
+
+bool SetKeyboardRepeatInfo( float rate, float delay )
+{
+  return false;
+}
+
+bool GetKeyboardRepeatInfo( float& rate, float& delay )
+{
+  return false;
+}
+
+} // namespace WindowSystem
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+