/*
- * 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/internal/window-system/common/display-connection.h>
#include <dali/internal/window-system/common/window-system.h>
#include <dali/integration-api/thread-synchronization-interface.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/adaptor-internal-services.h>
namespace Dali
{
NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent )
: mPosition( positionSize ),
mRenderNotification( NULL ),
+ mGraphics( NULL ),
+ mEGL( nullptr ),
+ mEGLSurface( nullptr ),
+ mEGLContext( nullptr ),
mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ),
mTbmFormat( isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888 ),
mOwnSurface( false ),
NativeRenderSurfaceEcoreWl::~NativeRenderSurfaceEcoreWl()
{
+ if ( mEGLSurface )
+ {
+ DestroySurface();
+ }
+
// release the surface if we own one
if( mOwnSurface )
{
dpiVertical = int( yres + 0.5f );
}
-void NativeRenderSurfaceEcoreWl::InitializeGraphics( Internal::Adaptor::GraphicsInterface& graphics, DisplayConnection& displayConnection )
+void NativeRenderSurfaceEcoreWl::InitializeGraphics()
{
DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
unsetenv( "EGL_PLATFORM" );
- mGraphics = &graphics;
-
+ mGraphics = &mAdaptor->GetGraphicsInterface();
auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
- EglInterface* mEGL = eglGraphics->Create();
-
- // Initialize EGL & OpenGL
- displayConnection.Initialize();
-
- Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
- eglImpl.ChooseConfig(true, mColorDepth);
-
- // Create the OpenGL context
- mEGL->CreateContext();
+ 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.CreateWindowContext( mEGLContext );
- // Make it current
- mEGL->MakeContextCurrent();
+ // Create the OpenGL surface
+ CreateSurface();
+ }
}
void NativeRenderSurfaceEcoreWl::CreateSurface()
auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.CreateSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ), mColorDepth );
+ mEGLSurface = eglImpl.CreateSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ), mColorDepth );
}
void NativeRenderSurfaceEcoreWl::DestroySurface()
auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.DestroySurface();
+ eglImpl.DestroySurface( mEGLSurface );
}
bool NativeRenderSurfaceEcoreWl::ReplaceGraphicsSurface()
auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- return eglImpl.ReplaceSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ) );
+ return eglImpl.ReplaceSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ), mEGLSurface, mEGLContext );
}
void NativeRenderSurfaceEcoreWl::MoveResize( Dali::PositionSize positionSize )
{
+ tbm_surface_queue_error_e error = TBM_SURFACE_QUEUE_ERROR_NONE;
+
+ error = tbm_surface_queue_reset( mTbmQueue, positionSize.width, positionSize.height, mTbmFormat );
+
+ if( error != TBM_SURFACE_QUEUE_ERROR_NONE )
+ {
+ DALI_LOG_ERROR( "Failed to resize tbm_surface_queue" );
+ }
+
+ mPosition = positionSize;
}
void NativeRenderSurfaceEcoreWl::StartRender()
void NativeRenderSurfaceEcoreWl::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
{
auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ if ( eglGraphics )
+ {
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
- eglImpl.SwapBuffers();
+ eglImpl.SwapBuffers( mEGLSurface );
+ }
if( mThreadSynchronization )
{
mThreadSynchronization = &threadSynchronization;
}
-RenderSurface::Type NativeRenderSurfaceEcoreWl::GetSurfaceType()
+Integration::RenderSurface::Type NativeRenderSurfaceEcoreWl::GetSurfaceType()
+{
+ return Integration::RenderSurface::NATIVE_RENDER_SURFACE;
+}
+
+void NativeRenderSurfaceEcoreWl::MakeContextCurrent()
+{
+ if ( mEGL != nullptr )
+ {
+ mEGL->MakeContextCurrent( mEGLSurface, mEGLContext );
+ }
+}
+
+Integration::DepthBufferAvailable NativeRenderSurfaceEcoreWl::GetDepthBufferRequired()
+{
+ return mGraphics ? mGraphics->GetDepthBufferRequired() : Integration::DepthBufferAvailable::FALSE;
+}
+
+Integration::StencilBufferAvailable NativeRenderSurfaceEcoreWl::GetStencilBufferRequired()
{
- return RenderSurface::NATIVE_RENDER_SURFACE;
+ return mGraphics ? mGraphics->GetStencilBufferRequired() : Integration::StencilBufferAvailable::FALSE;
}
void NativeRenderSurfaceEcoreWl::ReleaseLock()