/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * 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.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali/integration-api/trigger-event-factory-interface.h>
-#include <dali/integration-api/thread-synchronization-interface.h>
-#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/integration-api/adaptor-framework/thread-synchronization-interface.h>
+#include <dali/integration-api/adaptor-framework/trigger-event-factory-interface.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/adaptor-internal-services.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/window-system/common/window-base.h>
#include <dali/internal/window-system/common/window-factory.h>
#include <dali/internal/window-system/common/window-system.h>
-#include <dali/internal/graphics/gles/egl-graphics.h>
-
+#include <dali/internal/system/common/environment-variables.h>
namespace Dali
{
} // unnamed namespace
WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent )
-: mPositionSize( positionSize ),
+: mEGL( nullptr ),
+ mDisplayConnection( nullptr ),
+ mPositionSize( positionSize ),
mWindowBase(),
mThreadSynchronization( NULL ),
mRenderNotification( NULL ),
mRotationTrigger( NULL ),
+ mGraphics( nullptr ),
+ mEGLSurface( nullptr ),
+ mEGLContext( nullptr ),
mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ),
mOutputTransformedSignal(),
mRotationAngle( 0 ),
mRotationSupported( false ),
mRotationFinished( true ),
mScreenRotationFinished( true ),
- mResizeFinished( true )
+ mResizeFinished( true ),
+ mDpiHorizontal( 0 ),
+ mDpiVertical( 0 )
{
DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" );
Initialize( surface );
{
delete mRotationTrigger;
}
+
+ if ( mEGLSurface )
+ {
+ DestroySurface();
+ }
}
void WindowRenderSurface::Initialize( Any surface )
void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
{
- mWindowBase->GetDpi( dpiHorizontal, dpiVertical );
-}
+ if( mDpiHorizontal == 0 || mDpiVertical == 0 )
+ {
+ const char* environmentDpiHorizontal = std::getenv( DALI_ENV_DPI_HORIZONTAL );
+ mDpiHorizontal = environmentDpiHorizontal ? std::atoi( environmentDpiHorizontal ) : 0;
-void WindowRenderSurface::InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection )
-{
- mGraphics = &graphics;
+ const char* environmentDpiVertical = std::getenv( DALI_ENV_DPI_VERTICAL );
+ mDpiVertical = environmentDpiVertical ? std::atoi( environmentDpiVertical ) : 0;
- auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ if( mDpiHorizontal == 0 || mDpiVertical == 0 )
+ {
+ mWindowBase->GetDpi( mDpiHorizontal, mDpiVertical );
+ }
+ }
- EglInterface* mEGL = eglGraphics->Create();
+ dpiHorizontal = mDpiHorizontal;
+ dpiVertical = mDpiVertical;
+}
- // Initialize EGL & OpenGL
- displayConnection.Initialize();
+void WindowRenderSurface::InitializeGraphics()
+{
- Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
- eglImpl.ChooseConfig(true, mColorDepth);
+ mGraphics = &mAdaptor->GetGraphicsInterface();
- // Create the OpenGL context
- mEGL->CreateContext();
+ auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ mEGL = &eglGraphics->GetEglInterface();
- // Create the OpenGL surface
- CreateSurface();
+ if ( mEGLContext == NULL )
+ {
+ // Create the OpenGL context for this window
+ Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
+ eglImpl.ChooseConfig(true, mColorDepth);
+ eglImpl.CreateWindowContext( mEGLContext );
- // Make it current
- mEGL->MakeContextCurrent();
+ // Create the OpenGL surface
+ CreateSurface();
+ }
}
void WindowRenderSurface::CreateSurface()
auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.CreateSurfaceWindow( window, mColorDepth );
+ mEGLSurface = eglImpl.CreateSurfaceWindow( window, mColorDepth );
// Check rotation capability
mRotationSupported = mWindowBase->IsEglWindowRotationSupported();
- DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle );
+ DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: w = %d h = %d angle = %d screen rotation = %d\n",
+ mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle );
}
void WindowRenderSurface::DestroySurface()
auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.DestroySurface();
+ eglImpl.DestroySurface( mEGLSurface );
mWindowBase->DestroyEglWindow();
}
auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- return eglImpl.ReplaceSurfaceWindow( window );
+ return eglImpl.ReplaceSurfaceWindow( window, mEGLSurface, mEGLContext );
}
void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
bool WindowRenderSurface::PreRender( bool resizingSurface )
{
+ MakeContextCurrent();
+
if( resizingSurface )
{
-#ifdef OVER_TIZEN_VERSION_4
// Window rotate or screen rotate
if( !mRotationFinished || !mScreenRotationFinished )
{
{
mWindowBase->SetEglWindowTransform( mRotationAngle );
}
-#endif
// Resize case
if( !mResizeFinished )
}
auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- auto mGLES = eglGraphics->GetGlesInterface();
- mGLES.PreRender();
+ if ( eglGraphics )
+ {
+ GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+ mGLES.PreRender();
+ }
return true;
}
{
// Inform the gl implementation that rendering has finished before informing the surface
auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
- auto mGLES = eglGraphics->GetGlesInterface();
- mGLES.PostRender();
-
- if( renderToFbo )
+ if ( eglGraphics )
{
- mGLES.Flush();
- mGLES.Finish();
- }
- else
- {
- if( resizingSurface )
+ GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+ mGLES.PostRender();
+
+ if( renderToFbo )
+ {
+ mGLES.Flush();
+ mGLES.Finish();
+ }
+ else
{
- if( !mRotationFinished )
+ if( resizingSurface )
{
- DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
+ if( !mRotationFinished )
+ {
+ DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
- mRotationTrigger->Trigger();
+ mRotationTrigger->Trigger();
- if( mThreadSynchronization )
- {
- // Wait until the event-thread complete the rotation event processing
- mThreadSynchronization->PostRenderWaitForCompletion();
+ if( mThreadSynchronization )
+ {
+ // Wait until the event-thread complete the rotation event processing
+ mThreadSynchronization->PostRenderWaitForCompletion();
+ }
}
}
}
- }
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.SwapBuffers();
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ eglImpl.SwapBuffers( mEGLSurface );
- if( mRenderNotification )
- {
- mRenderNotification->Trigger();
+ if( mRenderNotification )
+ {
+ mRenderNotification->Trigger();
+ }
}
}
// Nothing to do.
}
-RenderSurface::Type WindowRenderSurface::GetSurfaceType()
+Integration::RenderSurface::Type WindowRenderSurface::GetSurfaceType()
{
return RenderSurface::WINDOW_RENDER_SURFACE;
}
+void WindowRenderSurface::MakeContextCurrent()
+{
+ if ( mEGL != nullptr )
+ {
+ mEGL->MakeContextCurrent( mEGLSurface, mEGLContext );
+ }
+}
+
+Integration::DepthBufferAvailable WindowRenderSurface::GetDepthBufferRequired()
+{
+ return mGraphics ? mGraphics->GetDepthBufferRequired() : Integration::DepthBufferAvailable::FALSE;
+}
+
+Integration::StencilBufferAvailable WindowRenderSurface::GetStencilBufferRequired()
+{
+ return mGraphics ? mGraphics->GetStencilBufferRequired() : Integration::StencilBufferAvailable::FALSE;
+}
+
void WindowRenderSurface::OutputTransformed()
{
int screenRotationAngle = mWindowBase->GetScreenRotationAngle();