Fix things to support EvasPlugin 11/206811/13
authorJiyun Yang <ji.yang@samsung.com>
Mon, 27 May 2019 11:00:17 +0000 (20:00 +0900)
committerJIYUN YANG <ji.yang@samsung.com>
Fri, 21 Jun 2019 04:30:25 +0000 (04:30 +0000)
1. Expose several internal API
  * Adaptor::AddWindow
  * Adaptor::SurfaceResizePrepare, SurfaceResizeComplete
  * Adaptor::OnWindowShown, OnWindowHidden
  * KeyLookup::GetDaliKeyCode

2. InputMethodContextWl supports not only WindowRenderSurface but NativeRenderSurface

3. EglImplementation::ReplaceSurfaceWindow() seems to have a bug.
   It calls MakeContextCurrent with destroyed surface.

Change-Id: I901c34d5d4bf40a4ba0075c13cf8ebe6b60e8500
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
12 files changed:
dali/devel-api/adaptor-framework/key-devel.cpp [new file with mode: 0644]
dali/devel-api/adaptor-framework/key-devel.h
dali/devel-api/file.list
dali/integration-api/adaptor.h
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/adaptor/common/adaptor.cpp
dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/input/common/key-impl.h
dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp
dali/public-api/adaptor-framework/window.cpp

diff --git a/dali/devel-api/adaptor-framework/key-devel.cpp b/dali/devel-api/adaptor-framework/key-devel.cpp
new file mode 100644 (file)
index 0000000..9690ac2
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/input/common/key-impl.h>
+
+namespace Dali
+{
+
+namespace DevelKey
+{
+
+int GetDaliKeyCode( const char* keyName )
+{
+  return Internal::Adaptor::KeyLookup::GetDaliKeyCode( keyName );
+}
+
+} // namespace DevelKey
+
+} // namespace Dali
index f42626d..c78c21a 100644 (file)
@@ -94,6 +94,13 @@ enum Key
 
 };
 
+/**
+ * @brief Get the key code from a key name.
+ * @param[in] keyName The key name
+ * @return The key code. -1 if the daliKey does not exist in the supported key lookup table.
+ */
+DALI_ADAPTOR_API int GetDaliKeyCode( const char* keyName );
+
 } // namespace DevelKey
 
 } // namespace Dali
index d3c3265..e0495d7 100755 (executable)
@@ -18,6 +18,7 @@ devel_api_src_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/orientation.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/performance-logger.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.cpp \
+  $(adaptor_devel_api_dir)/adaptor-framework/key-devel.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/pixel-buffer.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/singleton-service.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/sound-player.cpp \
index 570ff19..3369a73 100755 (executable)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/signals/callback.h>
 #include <dali/public-api/signals/dali-signal.h>
+#include <dali/public-api/math/uint-16-pair.h>
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/events/touch-event.h>
 #include <dali/public-api/common/view-mode.h>
@@ -126,6 +127,8 @@ public:
   typedef Signal< void (Adaptor&) > AdaptorSignalType; ///< Generic Type for adaptor signals
   typedef Signal< void (Window&) > WindowCreatedSignalType;  ///< Window created signal type
 
+  using SurfaceSize = Uint16Pair; ///< Surface size type
+
 public:
   /**
    * @brief Create a new adaptor using the window.
@@ -252,6 +255,19 @@ public:
   bool AddIdle( CallbackBase* callback, bool hasReturnValue );
 
   /**
+   * @brief Adds a new Window instance to the Adaptor
+   *
+   * @param[in]  childWindow The child window instance
+   * @param[in]  childWindowName The child window title/name
+   * @param[in]  childWindowClassName The class name that the child window belongs to
+   * @param[in]  childWindowMode The mode of the child window
+   */
+  bool AddWindow( Dali::Integration::SceneHolder childWindow,
+                  const std::string& childWindowName,
+                  const std::string& childWindowClassName,
+                  bool childWindowMode );
+
+  /**
    * @brief Removes a previously added @p callback.
    * @note Function must be called from the main event thread only.
    *
@@ -406,6 +422,22 @@ public:
   void SceneCreated();
 
   /**
+   * @brief Informs core the surface size has changed.
+   *
+   * @param[in] surface The current render surface
+   * @param[in] surfaceSize The new surface size
+   */
+  void SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
+
+  /**
+   * @brief Informs ThreadController the surface size has changed.
+   *
+   * @param[in] surface The current render surface
+   * @param[in] surfaceSize The new surface size
+   */
+  void SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
+
+  /**
    * @brief Renders once more even if we're paused
    * @note Will not work if the window is hidden.
    */
@@ -436,6 +468,16 @@ public:
    */
   Dali::WindowContainer GetWindows() const;
 
+  /**
+   * @brief Called when the window becomes fully or partially visible.
+   */
+  void OnWindowShown();
+
+  /**
+   * @brief Called when the window is fully hidden.
+   */
+  void OnWindowHidden();
+
 public:  // Signals
 
   /**
index 0aa9feb..b51693c 100755 (executable)
@@ -571,9 +571,9 @@ void Adaptor::SetPreRenderCallback( CallbackBase* callback )
   mThreadController->SetPreRenderCallback( callback );
 }
 
-bool Adaptor::AddWindow( Dali::Integration::SceneHolder* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode )
+bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow, const std::string& childWindowName, const std::string& childWindowClassName, bool childWindowMode )
 {
-  Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( *childWindow );
+  Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( childWindow );
   windowImpl.SetAdaptor( Get() );
 
   // Add the new Window to the container - the order is not important
index 4a77dfa..3d358d3 100755 (executable)
@@ -261,10 +261,10 @@ public: // AdaptorInternalServices implementation
    * @param[in]  childWindowClassName The class name that the child window belongs to
    * @param[in]  childWindowMode The mode of the child window
    */
-  virtual bool AddWindow( Dali::Integration::SceneHolder* childWindow,
+  virtual bool AddWindow( Dali::Integration::SceneHolder childWindow,
                           const std::string& childWindowName,
                           const std::string& childWindowClassName,
-                          const bool& childWindowMode );
+                          bool childWindowMode );
 
   /**
    * Removes an existing Window instance from the Adaptor
@@ -399,12 +399,12 @@ public:
   void GetAppId( std::string& appId );
 
   /**
-   * Informs core the surface size has changed
+   * @copydoc Dali::Adaptor::SurfaceResizePrepare
    */
   void SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
 
   /**
-   * Informs ThreadController the surface size has changed
+   * @copydoc Dali::Adaptor::SurfaceResizeComplete
    */
   void SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
 
@@ -543,7 +543,7 @@ private: // From Dali::Integration::RenderController
    */
   virtual void RequestProcessEventsOnIdle( bool forceProcess );
 
-private: // From Dali::Internal::Adaptor::WindowVisibilityObserver
+public: // From Dali::Internal::Adaptor::WindowVisibilityObserver
 
   /**
    * Called when the window becomes fully or partially visible.
index 17b0805..dd2be7f 100755 (executable)
@@ -115,6 +115,11 @@ bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
   return mImpl->AddIdle( callback, hasReturnValue, false );
 }
 
+bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow, const std::string& childWindowName, const std::string& childWindowClassName, bool childWindowMode )
+{
+  return mImpl->AddWindow( childWindow, childWindowName, childWindowClassName, childWindowMode );
+}
+
 void Adaptor::RemoveIdle( CallbackBase* callback )
 {
   mImpl->RemoveIdle( callback );
@@ -221,6 +226,16 @@ void Adaptor::SceneCreated()
   mImpl->SceneCreated();
 }
 
+void Adaptor::SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
+{
+  mImpl->SurfaceResizePrepare( surface, surfaceSize );
+}
+
+void Adaptor::SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
+{
+  mImpl->SurfaceResizeComplete( surface, surfaceSize );
+}
+
 void Adaptor::RenderOnce()
 {
   mImpl->RenderOnce();
@@ -246,6 +261,16 @@ Dali::WindowContainer Adaptor::GetWindows() const
   return mImpl->GetWindows();
 }
 
+void Adaptor::OnWindowShown()
+{
+  mImpl->OnWindowShown();
+}
+
+void Adaptor::OnWindowHidden()
+{
+  mImpl->OnWindowHidden();
+}
+
 Adaptor::Adaptor()
 : mImpl( NULL )
 {
index 2172e37..76fa78a 100755 (executable)
@@ -519,10 +519,10 @@ bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLSur
   DestroySurface( eglSurface );
 
   // create the EGL surface
-  CreateSurfaceWindow( window, mColorDepth );
+  EGLSurface newEglSurface = CreateSurfaceWindow( window, mColorDepth );
 
   // set the context to be current with the new surface
-  MakeContextCurrent( eglSurface, eglContext );
+  MakeContextCurrent( newEglSurface, eglContext );
 
   return contextLost;
 }
index 474fe1b..2bc22b6 100644 (file)
@@ -68,9 +68,7 @@ bool IsDeviceButton( const char* keyName );
 const char* GetKeyName( Dali::KEY daliKey );
 
 /**
- * @brief Get the key code from a key name.
- * @param[in] keyName The key name
- * @return The key code. -1 if the daliKey does not exist in the supported key lookup table.
+ * @copydoc Dali::DevelKey::GetDaliKeyCode()
  */
 int GetDaliKeyCode( const char* keyName );
 
index 9af492e..accf6f2 100755 (executable)
 // EXTERNAL INCLUDES
 #include <Ecore_Input.h>
 
+#ifdef ECORE_WAYLAND2
+#include <Ecore_Wl2.h>
+#else
+#include <Ecore_Wayland.h>
+#endif
+
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/adaptor-framework/key.h>
 #include <dali/public-api/object/type-registry.h>
@@ -269,7 +275,6 @@ InputMethodContextPtr InputMethodContextEcoreWl::New()
     Any nativeWindow = Dali::Adaptor::Get().GetNativeWindowHandle();
 
     // The window needs to use the InputMethodContext.
-    // Only when the render surface is window, we can get the window.
     if( !nativeWindow.Empty() )
     {
       inputMethodContext = new InputMethodContextEcoreWl();
@@ -325,11 +330,15 @@ void InputMethodContextEcoreWl::CreateContext()
     {
       // If we fail to get window id, we can't use the InputMethodContext correctly.
       // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
-      // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
-      Dali::RenderSurfaceInterface& renderSurface = Dali::Adaptor::Get().GetSurface();
-      WindowRenderSurface& windowRenderSurface = static_cast< WindowRenderSurface& >( renderSurface );
 
-      int windowId = windowRenderSurface.GetNativeWindowId();
+      Any nativeWindowHandle = Dali::Adaptor::Get().GetNativeWindowHandle();
+
+#ifdef ECORE_WAYLAND2
+      int windowId = ecore_wl2_window_id_get( AnyCast< Ecore_Wl2_Window* >( nativeWindowHandle ) );
+#else
+      int windowId = ecore_wl_window_id_get( AnyCast< Ecore_Wl_Window* >( nativeWindowHandle ) );
+#endif
+
       if( windowId != 0 )
       {
         ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast< void* >( windowId ) );
index 38a44b4..56fc04a 100644 (file)
@@ -51,6 +51,40 @@ namespace
 Debug::Filter* gNativeSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_NATIVE_RENDER_SURFACE");
 #endif
 
+inline void PrintTBMSurfaceQueueError( int errorCode )
+{
+  switch( errorCode )
+  {
+    case TBM_SURFACE_QUEUE_ERROR_EMPTY:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_EMPTY" );
+      break;
+    case TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE" );
+      break;
+    case TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_INVALID_SURFACE" );
+      break;
+    case TBM_SURFACE_QUEUE_ERROR_SURFACE_ALLOC_FAILED:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_SURFACE_ALLOC_FAILED" );
+      break;
+    case TBM_SURFACE_QUEUE_ERROR_ALREADY_EXIST:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_ALREADY_EXIST" );
+      break;
+    case TBM_SURFACE_QUEUE_ERROR_UNKNOWN_SURFACE:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_UNKNOWN_SURFACE" );
+      break;
+    case TBM_SURFACE_QUEUE_ERROR_INVALID_SEQUENCE:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_INVALID_SEQUENCE" );
+      break;
+    case TBM_SURFACE_QUEUE_ERROR_TIMEOUT:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_TIMEOUT" );
+      break;
+    default:
+      DALI_LOG_ERROR( "TBM_SURFACE_QUEUE_ERROR_UNKNOWN" );
+      break;
+  }
+}
+
 } // unnamed namespace
 
 NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent )
@@ -195,6 +229,18 @@ bool NativeRenderSurfaceEcoreWl::ReplaceGraphicsSurface()
 
 void NativeRenderSurfaceEcoreWl::MoveResize( Dali::PositionSize positionSize )
 {
+  tbm_surface_queue_error_e error = TBM_SURFACE_QUEUE_ERROR_NONE;
+
+  error = tbm_surface_queue_reset( mTbmQueue, positionSize.width, positionSize.height, mTbmFormat );
+
+  if( error != TBM_SURFACE_QUEUE_ERROR_NONE )
+  {
+    DALI_LOG_ERROR( "Failed to resize tbm_surface_queue" );
+
+    PrintTBMSurfaceQueueError( error );
+  }
+
+  mPosition = positionSize;
 }
 
 void NativeRenderSurfaceEcoreWl::StartRender()
index 2e6a28c..07ff286 100644 (file)
@@ -37,7 +37,7 @@ Window Window::New(PositionSize posSize, const std::string& name, bool isTranspa
 
   Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
   Integration::SceneHolder sceneHolder = Integration::SceneHolder( window );
-  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &sceneHolder, name, "", isTransparent );
+  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( sceneHolder, name, "", isTransparent );
 
   return Window(window);
 }
@@ -48,7 +48,7 @@ Window Window::New(PositionSize posSize, const std::string& name, const std::str
 
   Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
   Integration::SceneHolder sceneHolder = Integration::SceneHolder( window );
-  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &sceneHolder, name, className, isTransparent );
+  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( sceneHolder, name, className, isTransparent );
 
   return Window(window);
 }