X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fecore%2Fwayland%2Fwindow-render-surface-ecore-wl.cpp;h=17c5515e4c01b8dff4396146c644e88ba82c3a6d;hb=refs%2Fchanges%2F50%2F137150%2F1;hp=a0931742d72565dca55b42b3f2d2db9278ea8385;hpb=8e190ac380649753352929a2bb66ed006c4ca4ac;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp b/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp index a093174..17c5515 100644 --- a/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp +++ b/adaptors/ecore/wayland/window-render-surface-ecore-wl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * 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. @@ -16,17 +16,19 @@ */ // CLASS HEADER -#include "window-render-surface.h" +#include // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include -#include #include #include +#include +#include namespace Dali { @@ -50,8 +52,12 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, const std::string& name, bool isTransparent) : EcoreWlRenderSurface( positionSize, surface, name, isTransparent ), + mWlWindow( NULL ), mEglWindow( NULL ), - mNeedToApproveDeiconify( false ) + mThreadSynchronization( NULL ), + mRotationTrigger( NULL ), + mRotationSupported( false ), + mRotated( false ) { DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" ); Init( surface ); @@ -69,6 +75,11 @@ WindowRenderSurface::~WindowRenderSurface() { ecore_wl_window_free( mWlWindow ); } + + if( mRotationTrigger ) + { + delete mRotationTrigger; + } } Ecore_Wl_Window* WindowRenderSurface::GetDrawable() @@ -88,9 +99,67 @@ Ecore_Wl_Window* WindowRenderSurface::GetWlWindow() return mWlWindow; } -void WindowRenderSurface::RequestToApproveDeiconify() +void WindowRenderSurface::RequestRotation( Dali::Window::WindowOrientation orientation, int width, int height ) { - mNeedToApproveDeiconify = true; + if( !mRotationSupported ) + { + DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: Rotation is not supported!\n" ); + return; + } + + DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: orientation = %d\n", orientation ); + + if( !mRotationTrigger ) + { + TriggerEventFactoryInterface& triggerFactory = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTriggerEventFactoryInterface(); + mRotationTrigger = triggerFactory.CreateTriggerEvent( MakeCallback( this, &WindowRenderSurface::ProcessRotationRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); + } + + mPosition.width = width; + mPosition.height = height; + + mRotated = true; + + int angle; + wl_egl_window_rotation rotation; + + switch( orientation ) + { + case Dali::Window::PORTRAIT: + { + angle = 0; + rotation = ROTATION_0; + break; + } + case Dali::Window::LANDSCAPE: + { + angle = 90; + rotation = ROTATION_270; + break; + } + case Dali::Window::PORTRAIT_INVERSE: + { + angle = 180; + rotation = ROTATION_180; + break; + } + case Dali::Window::LANDSCAPE_INVERSE: + { + angle = 270; + rotation = ROTATION_90; + break; + } + default: + { + angle = 0; + rotation = ROTATION_0; + break; + } + } + + ecore_wl_window_rotation_set( mWlWindow, angle ); + + wl_egl_window_set_rotation( mEglWindow, rotation ); } void WindowRenderSurface::InitializeEgl( EglInterface& eglIf ) @@ -121,7 +190,16 @@ void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf ) // create the EGL surface ecore_wl_window_surface_create(mWlWindow); mEglWindow = wl_egl_window_create(ecore_wl_window_surface_get(mWlWindow), mPosition.width, mPosition.height); - eglImpl.CreateSurfaceWindow( (EGLNativeWindowType)mEglWindow, mColorDepth ); // reinterpret_cast does not compile + EGLNativeWindowType windowType( mEglWindow ); + eglImpl.CreateSurfaceWindow( windowType, mColorDepth ); + + // Check capability + 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 ); + mRotationSupported = true; + } } void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf ) @@ -161,7 +239,8 @@ bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& egl ) mEglWindow = wl_egl_window_create(ecore_wl_window_surface_get(mWlWindow), mPosition.width, mPosition.height); Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); - return eglImpl.ReplaceSurfaceWindow( (EGLNativeWindowType)mEglWindow ); // reinterpret_cast does not compile + EGLNativeWindowType windowType( mEglWindow ); + return eglImpl.ReplaceSurfaceWindow( windowType ); } void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize ) @@ -213,6 +292,28 @@ bool WindowRenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface ) { + if( mRotated ) + { + // Check viewport size + Dali::Vector< GLint > viewportSize; + viewportSize.Resize( 4 ); + + glAbstraction.GetIntegerv( GL_VIEWPORT, &viewportSize[0] ); + + if( viewportSize[2] == mPosition.width && viewportSize[3] == mPosition.height ) + { + DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" ); + + mRotationTrigger->Trigger(); + + if( mThreadSynchronization ) + { + // Wait until the event-thread complete the rotation event processing + mThreadSynchronization->PostRenderWaitForCompletion(); + } + } + } + Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); eglImpl.SwapBuffers(); @@ -220,17 +321,6 @@ void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstract { mRenderNotification->Trigger(); } - - // When the window is deiconified, it approves the deiconify operation to window manager after rendering - if(mNeedToApproveDeiconify) - { - // SwapBuffer is desychronized. So make sure to sychronize when window is deiconified. - glAbstraction.Finish(); - - //FIXME - - mNeedToApproveDeiconify = false; - } } void WindowRenderSurface::StopRender() @@ -258,10 +348,8 @@ void WindowRenderSurface::CreateWlRenderable() if ( mWlWindow == 0 ) { - DALI_ASSERT_ALWAYS(0 && "Failed to create X window"); + DALI_ASSERT_ALWAYS(0 && "Failed to create Wayland window"); } - - //FIXME } void WindowRenderSurface::UseExistingRenderable( unsigned int surfaceId ) @@ -269,9 +357,11 @@ void WindowRenderSurface::UseExistingRenderable( unsigned int surfaceId ) mWlWindow = AnyCast< Ecore_Wl_Window* >( surfaceId ); } -void WindowRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& /* threadSynchronization */ ) +void WindowRenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) { - // Nothing to do. + DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::SetThreadSynchronization: called\n" ); + + mThreadSynchronization = &threadSynchronization; } void WindowRenderSurface::ReleaseLock() @@ -279,6 +369,20 @@ void WindowRenderSurface::ReleaseLock() // Nothing to do. } +void WindowRenderSurface::ProcessRotationRequest() +{ + mRotated = false; + + ecore_wl_window_rotation_change_done_send( mWlWindow ); + + DALI_LOG_INFO( gRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::ProcessRotationRequest: Rotation Done\n" ); + + if( mThreadSynchronization ) + { + mThreadSynchronization->PostRenderComplete(); + } +} + } // namespace ECore } // namespace Dali