X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Ftizen-wayland%2Fecore-wl2%2Fwindow-render-surface-ecore-wl2.cpp;h=7553402a1cd51140c350936fbf3ef311167c0939;hb=198ffaa848ba593dbefe2f9a0e25b36fe32d7d99;hp=0f576757594a98d263b7221a5f7dcdbd870d6e1a;hpb=b08a8d097f77d5e3acb07699f4971758b7219182;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.cpp b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.cpp index 0f57675..7553402 100644 --- a/dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.cpp +++ b/dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,19 +23,15 @@ #include // INTERNAL INCLUDES -#include #include #include #include namespace Dali { - -#if defined(DEBUG_ENABLED) -extern Debug::Filter* gRenderSurfaceLogFilter; -#endif - -namespace ECore +namespace Internal +{ +namespace Adaptor { namespace @@ -43,31 +39,38 @@ namespace const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved +#if defined(DEBUG_ENABLED) +Debug::Filter* gWindowRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_WINDOW_RENDER_SURFACE_ECORE_WL2"); +#endif + } // unnamed namespace -WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, - Any surface, - const std::string& name, - bool isTransparent) -: EcoreWlRenderSurface( positionSize, surface, name, isTransparent ), +WindowRenderSurfaceEcoreWl2::WindowRenderSurfaceEcoreWl2( Dali::PositionSize positionSize, + Any surface, + const std::string& name, + bool isTransparent) +: mTitle( name ), + mPositionSize( positionSize ), mWlWindow( NULL ), - mEcore_Wl2_display( NULL ), mWlSurface( NULL ), mEglWindow( NULL ), mThreadSynchronization( NULL ), + mRenderNotification( NULL ), mRotationTrigger( NULL ), + mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ), mRotationAngle( 0 ), mScreenRotationAngle( 0 ), + mOwnSurface( false ), mRotationSupported( false ), mRotationFinished( true ), mScreenRotationFinished( true ), mResizeFinished( true ) { - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" ); - Init( surface ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" ); + Initialize( surface ); } -WindowRenderSurface::~WindowRenderSurface() +WindowRenderSurfaceEcoreWl2::~WindowRenderSurfaceEcoreWl2() { if( mEglWindow != NULL ) { @@ -85,37 +88,88 @@ WindowRenderSurface::~WindowRenderSurface() delete mRotationTrigger; } + if( mOwnSurface ) + { + ecore_wl2_shutdown(); + } +} + +void WindowRenderSurfaceEcoreWl2::Initialize( Any surface ) +{ + // 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 + ecore_wl2_init(); + mOwnSurface = true; + CreateRenderable(); + } + else + { + // XLib should already be initialized so no point in calling XInitThreads + UseExistingRenderable( surfaceId ); + } } -Ecore_Wl2_Window* WindowRenderSurface::GetDrawable() +Ecore_Wl2_Window* WindowRenderSurfaceEcoreWl2::GetWlWindow() { - // already an e-core type return mWlWindow; } -Any WindowRenderSurface::GetSurface() +void WindowRenderSurfaceEcoreWl2::OutputTransformed() { - // already an e-core type - return Any( mWlWindow ); + int transform; + + if( ecore_wl2_window_ignore_output_transform_get( mWlWindow ) ) + { + transform = 0; + } + else + { + transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mWlWindow ) ); + } + + mScreenRotationAngle = transform * 90; + mScreenRotationFinished = false; + + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::OutputTransformed: angle = %d screen rotation = %d\n", mRotationAngle, mScreenRotationAngle ); } -Ecore_Wl2_Window* WindowRenderSurface::GetWlWindow() +Any WindowRenderSurfaceEcoreWl2::GetWindow() { return mWlWindow; } -void WindowRenderSurface::RequestRotation( int angle, int width, int height ) +void WindowRenderSurfaceEcoreWl2::Map() +{ + ecore_wl2_window_show( mWlWindow ); +} + +void WindowRenderSurfaceEcoreWl2::SetRenderNotification( TriggerEventInterface* renderNotification ) +{ + mRenderNotification = renderNotification; +} + +void WindowRenderSurfaceEcoreWl2::SetTransparency( bool transparent ) +{ + ecore_wl2_window_alpha_set( mWlWindow, transparent ); +} + +void WindowRenderSurfaceEcoreWl2::RequestRotation( int angle, int width, int height ) { if( !mRotationSupported ) { - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: Rotation is not supported!\n" ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::Rotate: Rotation is not supported!\n" ); return; } if( !mRotationTrigger ) { TriggerEventFactoryInterface& triggerFactory = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTriggerEventFactoryInterface(); - mRotationTrigger = triggerFactory.CreateTriggerEvent( MakeCallback( this, &WindowRenderSurface::ProcessRotationRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); + mRotationTrigger = triggerFactory.CreateTriggerEvent( MakeCallback( this, &WindowRenderSurfaceEcoreWl2::ProcessRotationRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); } mPositionSize.width = width; @@ -126,45 +180,41 @@ void WindowRenderSurface::RequestRotation( int angle, int width, int height ) ecore_wl2_window_rotation_set( mWlWindow, mRotationAngle ); - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: angle = %d screen rotation = %d\n", mRotationAngle, mScreenRotationAngle ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::Rotate: angle = %d screen rotation = %d\n", mRotationAngle, mScreenRotationAngle ); } -void WindowRenderSurface::OutputTransformed() +PositionSize WindowRenderSurfaceEcoreWl2::GetPositionSize() const { - int transform; + return mPositionSize; +} - if( ecore_wl2_window_ignore_output_transform_get( mWlWindow ) ) - { - transform = 0; - } - else - { - transform = ecore_wl2_output_transform_get( ecore_wl2_window_output_find( mWlWindow ) ); - } +void WindowRenderSurfaceEcoreWl2::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) +{ + // calculate DPI + float xres, yres; - mScreenRotationAngle = transform * 90; - mScreenRotationFinished = false; + Ecore_Wl2_Output* output = ecore_wl2_window_output_find( mWlWindow ); - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::OutputTransformed: angle = %d screen rotation = %d\n", mRotationAngle, mScreenRotationAngle ); -} + // 1 inch = 25.4 millimeters + xres = ecore_wl2_output_dpi_get( output ); + yres = ecore_wl2_output_dpi_get( output ); -void WindowRenderSurface::SetTransparency( bool transparent ) -{ - ecore_wl2_window_alpha_set( mWlWindow, transparent ); + dpiHorizontal = int( xres + 0.5f ); // rounding + dpiVertical = int( yres + 0.5f ); } -void WindowRenderSurface::InitializeEgl( EglInterface& eglIf ) +void WindowRenderSurfaceEcoreWl2::InitializeEgl( EglInterface& eglIf ) { - DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); + DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter ); Internal::Adaptor::EglImplementation& eglImpl = static_cast( eglIf ); eglImpl.ChooseConfig(true, mColorDepth); } -void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf ) +void WindowRenderSurfaceEcoreWl2::CreateEglSurface( EglInterface& eglIf ) { - DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); + DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter ); Internal::Adaptor::EglImplementation& eglImpl = static_cast( eglIf ); @@ -185,16 +235,16 @@ void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf ) wl_egl_window_capability capability = static_cast< wl_egl_window_capability >( wl_egl_window_get_capabilities( mEglWindow ) ); if( capability == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) { - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateEglSurface: capability = %d\n", capability ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::CreateEglSurface: capability = %d\n", capability ); mRotationSupported = true; } - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateEglSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::CreateEglSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle ); } -void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf ) +void WindowRenderSurfaceEcoreWl2::DestroyEglSurface( EglInterface& eglIf ) { - DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); + DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter ); Internal::Adaptor::EglImplementation& eglImpl = static_cast( eglIf ); eglImpl.DestroySurface(); @@ -206,9 +256,9 @@ void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf ) } } -bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& egl ) +bool WindowRenderSurfaceEcoreWl2::ReplaceEGLSurface( EglInterface& egl ) { - DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); + DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter ); if( mEglWindow != NULL ) { @@ -233,7 +283,7 @@ bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& egl ) return eglImpl.ReplaceSurfaceWindow( windowType ); } -void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize ) +void WindowRenderSurfaceEcoreWl2::MoveResize( Dali::PositionSize positionSize ) { bool needToMove = false; bool needToResize = false; @@ -255,7 +305,8 @@ void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize ) if( needToMove || needToResize ) { ecore_wl2_window_geometry_set( mWlWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); - if (needToResize) + + if( needToResize ) { mResizeFinished = false; } @@ -263,19 +314,18 @@ void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize ) mPositionSize = positionSize; - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::MoveResize: %d, %d, %d, %d\n", mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::MoveResize: %d, %d, %d, %d\n", mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height ); } -void WindowRenderSurface::Map() +void WindowRenderSurfaceEcoreWl2::SetViewMode( ViewMode viewMode ) { - ecore_wl2_window_show(mWlWindow); } -void WindowRenderSurface::StartRender() +void WindowRenderSurfaceEcoreWl2::StartRender() { } -bool WindowRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) +bool WindowRenderSurfaceEcoreWl2::PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) { if( resizingSurface ) { @@ -328,7 +378,7 @@ bool WindowRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstracti // Reset only screen rotation flag mScreenRotationFinished = true; - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PreRender: Set rotation [%d] [%d]\n", mRotationAngle, mScreenRotationAngle ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::PreRender: Set rotation [%d] [%d]\n", mRotationAngle, mScreenRotationAngle ); } // Only window rotate @@ -375,20 +425,20 @@ bool WindowRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstracti wl_egl_window_resize( mEglWindow, mPositionSize.width, mPositionSize.height, mPositionSize.x, mPositionSize.y ); mResizeFinished = true; - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PreRender: Set resize\n" ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::PreRender: Set resize\n" ); } } return true; } -void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) +void WindowRenderSurfaceEcoreWl2::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) { if( resizingSurface ) { if( !mRotationFinished ) { - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::PostRender: Trigger rotation event\n" ); mRotationTrigger->Trigger(); @@ -409,30 +459,33 @@ void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstract } } -void WindowRenderSurface::StopRender() +void WindowRenderSurfaceEcoreWl2::StopRender() { } -void WindowRenderSurface::SetViewMode( ViewMode viewMode ) +void WindowRenderSurfaceEcoreWl2::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) { - //FIXME + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::SetThreadSynchronization: called\n" ); + + mThreadSynchronization = &threadSynchronization; } -void WindowRenderSurface::CreateWlRenderable() +void WindowRenderSurfaceEcoreWl2::ReleaseLock() { - // TODO :: - // use default display name as getenv("WAYLAND_DISPLAY") - // If specific name is needed, - // the name will be changed and should change the code of using ecore_wl2_connected_display_get() - // Because default name is used in ecore_wl2_connected_display_get()'s use case. - if ( mEcore_Wl2_display == NULL ) - { - mEcore_Wl2_display = ecore_wl2_display_connect(NULL); - } - if ( mEcore_Wl2_display == NULL ) + // Nothing to do. +} + +RenderSurface::Type WindowRenderSurfaceEcoreWl2::GetSurfaceType() +{ + return RenderSurface::WINDOW_RENDER_SURFACE; +} + +void WindowRenderSurfaceEcoreWl2::CreateRenderable() +{ + Ecore_Wl2_Display* display = ecore_wl2_display_connect( NULL ); + if ( !display ) { - DALI_LOG_ERROR("Fail to connect ecore_wl2_display"); - return; + DALI_ASSERT_ALWAYS(0 && "Failed to get display"); } // if width or height are zero, go full screen. @@ -442,10 +495,11 @@ void WindowRenderSurface::CreateWlRenderable() mPositionSize.x = 0; mPositionSize.y = 0; - ecore_wl2_display_screen_size_get( mEcore_Wl2_display, &mPositionSize.width, &mPositionSize.height ); + ecore_wl2_display_screen_size_get( display, &mPositionSize.width, &mPositionSize.height ); } - mWlWindow = ecore_wl2_window_new( mEcore_Wl2_display, NULL, mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height ); + mWlWindow = ecore_wl2_window_new( display, NULL, mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height ); + if ( mWlWindow == 0 ) { DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window"); @@ -462,7 +516,7 @@ void WindowRenderSurface::CreateWlRenderable() ecore_wl2_window_alpha_set( mWlWindow, false ); } - ecore_wl2_window_type_set( mWlWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL); + ecore_wl2_window_type_set( mWlWindow, ECORE_WL2_WINDOW_TYPE_TOPLEVEL ); // Get output transform if( !ecore_wl2_window_ignore_output_transform_get( mWlWindow ) ) @@ -476,30 +530,33 @@ void WindowRenderSurface::CreateWlRenderable() } } -void WindowRenderSurface::UseExistingRenderable( unsigned int surfaceId ) +void WindowRenderSurfaceEcoreWl2::UseExistingRenderable( unsigned int surfaceId ) { mWlWindow = AnyCast< Ecore_Wl2_Window* >( surfaceId ); } -void WindowRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) +unsigned int WindowRenderSurfaceEcoreWl2::GetSurfaceId( Any surface ) const { - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::SetThreadSynchronization: called\n" ); + unsigned int surfaceId = 0; - mThreadSynchronization = &threadSynchronization; -} + if( surface.Empty() == false ) + { + // check we have a valid type + DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (Ecore_Wl2_Window *) ) ) + && "Surface type is invalid" ); -void WindowRenderSurface::ReleaseLock() -{ - // Nothing to do. + surfaceId = AnyCast( surface ); + } + return surfaceId; } -void WindowRenderSurface::ProcessRotationRequest() +void WindowRenderSurfaceEcoreWl2::ProcessRotationRequest() { mRotationFinished = true; ecore_wl2_window_rotation_change_done_send( mWlWindow, mRotationAngle, mPositionSize.width, mPositionSize.height ); - DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::ProcessRotationRequest: Rotation Done\n" ); + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurfaceEcoreWl2::ProcessRotationRequest: Rotation Done\n" ); if( mThreadSynchronization ) { @@ -507,6 +564,8 @@ void WindowRenderSurface::ProcessRotationRequest() } } -} // namespace ECore +} // namespace Adaptor + +} // namespace internal } // namespace Dali