2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 #include <dali/internal/window-system/windows/window-render-surface-ecore-win.h>
\r
21 // EXTERNAL INCLUDES
\r
22 //#include <X11/Xatom.h>
\r
23 //#include <X11/Xlib.h>
\r
24 //#include <X11/Xutil.h>
\r
26 //#include <X11/extensions/Xfixes.h> // for damage notify
\r
27 //#include <X11/extensions/Xdamage.h> // for damage notify
\r
29 #include <dali/integration-api/gl-abstraction.h>
\r
30 #include <dali/integration-api/debug.h>
\r
32 // INTERNAL INCLUDES
\r
33 #include <dali/internal/window-system/windows/ecore-win-types.h>
\r
34 #include <dali/internal/system/common/trigger-event.h>
\r
35 #include <dali/internal/graphics/gles20/egl-implementation.h>
\r
36 #include <dali/internal/window-system/common/display-connection.h>
\r
48 const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved
\r
50 #if defined(DEBUG_ENABLED)
\r
51 Debug::Filter* gWindowRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_WINDOW_RENDER_SURFACE_ECORE_X");
\r
54 } // unnamed namespace
\r
56 WindowRenderSurfaceEcoreWin::WindowRenderSurfaceEcoreWin( Dali::PositionSize positionSize,
\r
58 const std::string& name,
\r
59 const std::string& className,
\r
62 mClassName( className ),
\r
63 mPosition( positionSize ),
\r
64 mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ),
\r
66 mOwnSurface( false ),
\r
67 mNeedToApproveDeiconify( false )
\r
69 DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
\r
70 Initialize( surface );
\r
73 WindowRenderSurfaceEcoreWin::~WindowRenderSurfaceEcoreWin()
\r
77 //ecore_x_window_free( mWinWindow );
\r
81 void WindowRenderSurfaceEcoreWin::Initialize( Any surface )
\r
83 // see if there is a surface in Any surface
\r
84 unsigned int surfaceId = GetSurfaceId( surface );
\r
86 // if the surface is empty, create a new one.
\r
87 if( surfaceId == 0 )
\r
89 // we own the surface about to created
\r
95 // XLib should already be initialized so no point in calling XInitThreads
\r
96 UseExistingRenderable( surfaceId );
\r
100 Ecore_Win_Window WindowRenderSurfaceEcoreWin::GetWinWindow()
\r
105 void WindowRenderSurfaceEcoreWin::RequestToApproveDeiconify()
\r
107 mNeedToApproveDeiconify = true;
\r
110 Any WindowRenderSurfaceEcoreWin::GetWindow()
\r
115 void WindowRenderSurfaceEcoreWin::Map()
\r
117 //ecore_x_window_show( mWinWindow );
\r
120 void WindowRenderSurfaceEcoreWin::SetRenderNotification( TriggerEventInterface* renderNotification )
\r
124 void WindowRenderSurfaceEcoreWin::SetTransparency( bool transparent )
\r
128 void WindowRenderSurfaceEcoreWin::RequestRotation( int angle, int width, int height )
\r
132 PositionSize WindowRenderSurfaceEcoreWin::GetPositionSize() const
\r
137 void WindowRenderSurfaceEcoreWin::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
\r
142 //// 1 inch = 25.4 millimeters
\r
143 Win32WindowSystem::GetDPI( xres, yres );
\r
148 dpiHorizontal = int( xres + 0.5f ); // rounding
\r
149 dpiVertical = int( yres + 0.5f );
\r
152 void WindowRenderSurfaceEcoreWin::InitializeEgl( EglInterface& eglIf )
\r
154 DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
\r
156 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
\r
158 eglImpl.ChooseConfig(true, mColorDepth);
\r
161 void WindowRenderSurfaceEcoreWin::CreateEglSurface( EglInterface& eglIf )
\r
163 DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
\r
165 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
\r
167 // create the EGL surface
\r
168 // need to create X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
\r
169 XWindow window( mWinWindow );
\r
170 eglImpl.CreateSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( window ), mColorDepth );
\r
173 void WindowRenderSurfaceEcoreWin::DestroyEglSurface( EglInterface& eglIf )
\r
175 DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
\r
177 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
\r
178 eglImpl.DestroySurface();
\r
181 bool WindowRenderSurfaceEcoreWin::ReplaceEGLSurface( EglInterface& egl )
\r
183 DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
\r
185 // need to create X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
\r
186 XWindow window( mWinWindow );
\r
187 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
\r
189 return eglImpl.ReplaceSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( window ) );
\r
192 void WindowRenderSurfaceEcoreWin::MoveResize( Dali::PositionSize positionSize )
\r
194 SetWindowPos( (HWND)mWinWindow, NULL, positionSize.x, positionSize.y, positionSize.width, positionSize.height, SWP_NOZORDER | SWP_NOACTIVATE );
\r
197 void WindowRenderSurfaceEcoreWin::SetViewMode( ViewMode viewMode )
\r
201 void WindowRenderSurfaceEcoreWin::StartRender()
\r
205 bool WindowRenderSurfaceEcoreWin::PreRender( EglInterface&, Integration::GlAbstraction&, bool )
\r
207 // nothing to do for windows
\r
211 void WindowRenderSurfaceEcoreWin::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, Dali::DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface )
\r
213 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
\r
214 eglImpl.SwapBuffers();
\r
216 // When the window is deiconified, it approves the deiconify operation to window manager after rendering
\r
217 if( mNeedToApproveDeiconify )
\r
219 // SwapBuffer is desychronized. So make sure to sychronize when window is deiconified.
\r
220 glAbstraction.Finish();
\r
222 XDisplay* display = AnyCast<XDisplay *>( displayConnection->GetDisplay() );
\r
224 mNeedToApproveDeiconify = false;
\r
228 void WindowRenderSurfaceEcoreWin::StopRender()
\r
232 void WindowRenderSurfaceEcoreWin::SetThreadSynchronization( ThreadSynchronizationInterface& /* threadSynchronization */ )
\r
237 void WindowRenderSurfaceEcoreWin::ReleaseLock()
\r
242 RenderSurface::Type WindowRenderSurfaceEcoreWin::GetSurfaceType()
\r
244 return WINDOW_RENDER_SURFACE;
\r
247 void WindowRenderSurfaceEcoreWin::CreateRenderable()
\r
249 // if width or height are zero, go full screen.
\r
250 if( ( mPosition.width == 0 ) || ( mPosition.height == 0 ) )
\r
252 // Default window size == screen size
\r
256 char *strWidth = std::getenv( "DALI_WINDOW_WIDTH" );
\r
257 if( NULL == strWidth )
\r
259 mPosition.width = 480;
\r
263 mPosition.width = atoi( strWidth );
\r
266 char *strHeight = std::getenv( "DALI_WINDOW_HEIGHT" );
\r
267 if( NULL == strHeight )
\r
269 mPosition.height = 800;
\r
273 mPosition.height = atoi( strHeight );
\r
277 long pWnd1 = Win32WindowSystem::CreateWinWindow( mTitle.c_str(), mTitle.c_str(), mPosition.x, mPosition.y, mPosition.width, mPosition.height, NULL );
\r
280 Win32WindowSystem::ShowWindow( pWnd1 );
\r
282 mWinWindow = (Ecore_Win_Window)pWnd1;
\r
283 if( mWinWindow == 0 )
\r
285 DALI_ASSERT_ALWAYS( 0 && "Failed to create X window" );
\r
289 void WindowRenderSurfaceEcoreWin::UseExistingRenderable( unsigned int surfaceId )
\r
291 mWinWindow = static_cast< Ecore_Win_Window >( surfaceId );
\r
294 unsigned int WindowRenderSurfaceEcoreWin::GetSurfaceId( Any surface ) const
\r
296 unsigned int surfaceId = 0;
298 if ( surface.Empty() == false )
300 // check we have a valid type
301 DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
302 (surface.GetType() == typeid (Ecore_Win_Window) ) )
303 && "Surface type is invalid" );
305 if ( surface.GetType() == typeid (Ecore_Win_Window) )
307 surfaceId = AnyCast<Ecore_Win_Window>( surface );
311 surfaceId = AnyCast<unsigned int>(surface);
317 } // namespace Adaptor
\r
319 } // namespace internal
\r
321 } // namespace Dali
\r