/*
- * 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.
// INTERNAL INCLUDES
#include <dali/integration-api/trigger-event-factory-interface.h>
#include <dali/integration-api/thread-synchronization-interface.h>
-#include <dali/internal/graphics/gles20/egl-implementation.h>
+#include <dali/internal/graphics/gles/egl-implementation.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/adaptor-internal-services.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>
+
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 ),
{
delete mRotationTrigger;
}
+
+ if ( mEGLSurface )
+ {
+ DestroySurface();
+ }
}
void WindowRenderSurface::Initialize( Any surface )
{
- // if width or height are zero, go full screen.
- if ( (mPositionSize.width == 0) || (mPositionSize.height == 0) )
- {
- // Default window size == screen size
- mPositionSize.x = 0;
- mPositionSize.y = 0;
+ // If width or height are zero, go full screen.
+ if ( (mPositionSize.width == 0) || (mPositionSize.height == 0) )
+ {
+ // Default window size == screen size
+ mPositionSize.x = 0;
+ mPositionSize.y = 0;
- WindowSystem::GetScreenSize( mPositionSize.width, mPositionSize.height );
- }
+ WindowSystem::GetScreenSize( mPositionSize.width, mPositionSize.height );
+ }
// Create a window base
auto windowFactory = Dali::Internal::Adaptor::GetWindowFactory();
mWindowBase->GetDpi( dpiHorizontal, dpiVertical );
}
-void WindowRenderSurface::InitializeEgl( EglInterface& eglIf )
+void WindowRenderSurface::InitializeGraphics()
{
- DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
- Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
+ mGraphics = &mAdaptor->GetGraphicsInterface();
+
+ auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ mEGL = &eglGraphics->GetEglInterface();
+
+ 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 );
- eglImpl.ChooseConfig(true, mColorDepth);
+ // Create the OpenGL surface
+ CreateSurface();
+ }
}
-void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf )
+void WindowRenderSurface::CreateSurface()
{
DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
height = mPositionSize.width;
}
- // create the EGL window
+ // Create the EGL window
EGLNativeWindowType window = mWindowBase->CreateEglWindow( width, height );
- Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
- eglImpl.CreateSurfaceWindow( window, mColorDepth );
+ auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ mEGLSurface = eglImpl.CreateSurfaceWindow( window, mColorDepth );
// Check rotation capability
mRotationSupported = mWindowBase->IsEglWindowRotationSupported();
- DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, 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, "WindowRenderSurface::CreateSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle );
}
-void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf )
+void WindowRenderSurface::DestroySurface()
{
DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
- Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
- eglImpl.DestroySurface();
+ auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ eglImpl.DestroySurface( mEGLSurface );
mWindowBase->DestroyEglWindow();
}
-bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& egl )
+bool WindowRenderSurface::ReplaceGraphicsSurface()
{
DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
height = mPositionSize.width;
}
- // create the EGL window
+ // Create the EGL window
EGLNativeWindowType window = mWindowBase->CreateEglWindow( width, height );
// Set screen rotation
mScreenRotationFinished = false;
- Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
- return eglImpl.ReplaceSurfaceWindow( window );
+ auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ return eglImpl.ReplaceSurfaceWindow( window, mEGLSurface, mEGLContext );
}
void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
bool needToMove = false;
bool needToResize = false;
- // check moving
+ // Check moving
if( (fabs(positionSize.x - mPositionSize.x) > MINIMUM_DIMENSION_CHANGE) ||
(fabs(positionSize.y - mPositionSize.y) > MINIMUM_DIMENSION_CHANGE) )
{
needToMove = true;
}
- // check resizing
+ // Check resizing
if( (fabs(positionSize.width - mPositionSize.width) > MINIMUM_DIMENSION_CHANGE) ||
(fabs(positionSize.height - mPositionSize.height) > MINIMUM_DIMENSION_CHANGE) )
{
DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::MoveResize: %d, %d, %d, %d\n", mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height );
}
-void WindowRenderSurface::SetViewMode( ViewMode viewMode )
-{
- mWindowBase->SetViewMode( viewMode );
-}
-
void WindowRenderSurface::StartRender()
{
}
-bool WindowRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface )
+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);
+ if ( eglGraphics )
+ {
+ GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+ mGLES.PreRender();
+ }
+
return true;
}
-void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, Dali::DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface )
+void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
{
- if( resizingSurface )
+ // Inform the gl implementation that rendering has finished before informing the surface
+ auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+ if ( eglGraphics )
{
- if( !mRotationFinished )
- {
- DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
-
- mRotationTrigger->Trigger();
+ GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+ mGLES.PostRender();
- if( mThreadSynchronization )
+ if( renderToFbo )
+ {
+ mGLES.Flush();
+ mGLES.Finish();
+ }
+ else
+ {
+ if( resizingSurface )
{
- // Wait until the event-thread complete the rotation event processing
- mThreadSynchronization->PostRenderWaitForCompletion();
+ if( !mRotationFinished )
+ {
+ DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, 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<Internal::Adaptor::EglImplementation&>( egl );
- 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();