From ac0fc35678f3700af25ade02c193e71a2184bc96 Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Mon, 27 May 2019 20:00:17 +0900 Subject: [PATCH] Fix things to support EvasPlugin 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 --- dali/devel-api/adaptor-framework/key-devel.cpp | 34 ++++++++++++++++ dali/devel-api/adaptor-framework/key-devel.h | 7 ++++ dali/devel-api/file.list | 1 + dali/integration-api/adaptor.h | 42 ++++++++++++++++++++ dali/internal/adaptor/common/adaptor-impl.cpp | 4 +- dali/internal/adaptor/common/adaptor-impl.h | 10 ++--- dali/internal/adaptor/common/adaptor.cpp | 25 ++++++++++++ dali/internal/graphics/gles/egl-implementation.cpp | 4 +- dali/internal/input/common/key-impl.h | 4 +- .../input-method-context-impl-ecore-wl.cpp | 19 ++++++--- .../native-render-surface-ecore-wl.cpp | 46 ++++++++++++++++++++++ dali/public-api/adaptor-framework/window.cpp | 4 +- 12 files changed, 181 insertions(+), 19 deletions(-) create mode 100644 dali/devel-api/adaptor-framework/key-devel.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 index 0000000..9690ac2 --- /dev/null +++ b/dali/devel-api/adaptor-framework/key-devel.cpp @@ -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 + +namespace Dali +{ + +namespace DevelKey +{ + +int GetDaliKeyCode( const char* keyName ) +{ + return Internal::Adaptor::KeyLookup::GetDaliKeyCode( keyName ); +} + +} // namespace DevelKey + +} // namespace Dali diff --git a/dali/devel-api/adaptor-framework/key-devel.h b/dali/devel-api/adaptor-framework/key-devel.h index f42626d..c78c21a 100644 --- a/dali/devel-api/adaptor-framework/key-devel.h +++ b/dali/devel-api/adaptor-framework/key-devel.h @@ -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 diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index d3c3265..e0495d7 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -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 \ diff --git a/dali/integration-api/adaptor.h b/dali/integration-api/adaptor.h index 570ff19..3369a73 100755 --- a/dali/integration-api/adaptor.h +++ b/dali/integration-api/adaptor.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include #include #include @@ -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 /** diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index 0aa9feb..b51693c 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -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 diff --git a/dali/internal/adaptor/common/adaptor-impl.h b/dali/internal/adaptor/common/adaptor-impl.h index 4a77dfa..3d358d3 100755 --- a/dali/internal/adaptor/common/adaptor-impl.h +++ b/dali/internal/adaptor/common/adaptor-impl.h @@ -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. diff --git a/dali/internal/adaptor/common/adaptor.cpp b/dali/internal/adaptor/common/adaptor.cpp index 17b0805..dd2be7f 100755 --- a/dali/internal/adaptor/common/adaptor.cpp +++ b/dali/internal/adaptor/common/adaptor.cpp @@ -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 ) { diff --git a/dali/internal/graphics/gles/egl-implementation.cpp b/dali/internal/graphics/gles/egl-implementation.cpp index 2172e37..76fa78a 100755 --- a/dali/internal/graphics/gles/egl-implementation.cpp +++ b/dali/internal/graphics/gles/egl-implementation.cpp @@ -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; } diff --git a/dali/internal/input/common/key-impl.h b/dali/internal/input/common/key-impl.h index 474fe1b..2bc22b6 100644 --- a/dali/internal/input/common/key-impl.h +++ b/dali/internal/input/common/key-impl.h @@ -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 ); diff --git a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp index 9af492e..accf6f2 100755 --- a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp +++ b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp @@ -22,6 +22,12 @@ // EXTERNAL INCLUDES #include +#ifdef ECORE_WAYLAND2 +#include +#else +#include +#endif + #include #include #include @@ -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 ) ); diff --git a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp index 38a44b4..56fc04a 100644 --- a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp @@ -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() diff --git a/dali/public-api/adaptor-framework/window.cpp b/dali/public-api/adaptor-framework/window.cpp index 2e6a28c..07ff286 100644 --- a/dali/public-api/adaptor-framework/window.cpp +++ b/dali/public-api/adaptor-framework/window.cpp @@ -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); } -- 2.7.4