2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <dali/internal/graphics/gles/egl-graphics.h>
23 #include <dali/internal/window-system/common/display-utils.h> // For Utils::MakeUnique
32 EglGraphics::EglGraphics( )
33 : mMultiSamplingLevel( 0 )
37 EglGraphics::~EglGraphics()
41 void EglGraphics::SetGlesVersion( const int32_t glesVersion )
43 mEglImplementation->SetGlesVersion( glesVersion );
44 mGLES->SetGlesVersion( glesVersion );
47 void EglGraphics::SetIsSurfacelessContextSupported( const bool isSupported )
49 mGLES->SetIsSurfacelessContextSupported( isSupported );
52 void EglGraphics::Initialize( EnvironmentOptions* environmentOptions )
54 if( environmentOptions->GetGlesCallTime() > 0 )
56 mGLES = Utils::MakeUnique< GlProxyImplementation >( *environmentOptions );
60 mGLES.reset ( new GlImplementation() );
63 mDepthBufferRequired = static_cast< Integration::DepthBufferAvailable >( environmentOptions->DepthBufferRequired() );
64 mStencilBufferRequired = static_cast< Integration::StencilBufferAvailable >( environmentOptions->StencilBufferRequired() );
65 mPartialUpdateAvailable = static_cast< Integration::PartialUpdateAvailable >( environmentOptions->PartialUpdateAvailable() );
67 mMultiSamplingLevel = environmentOptions->GetMultiSamplingLevel();
69 mEglSync = Utils::MakeUnique< EglSyncImplementation >();
71 mEglContextHelper = Utils::MakeUnique< EglContextHelperImplementation >();
74 EglInterface* EglGraphics::Create()
76 mEglImplementation = Utils::MakeUnique< EglImplementation >( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired, mPartialUpdateAvailable );
77 mEglImageExtensions = Utils::MakeUnique< EglImageExtensions >( mEglImplementation.get() );
79 mEglSync->Initialize( mEglImplementation.get() ); // The sync impl needs the EglDisplay
81 mEglContextHelper->Initialize( mEglImplementation.get() ); // The context helper impl needs the EglContext
83 return mEglImplementation.get();
86 void EglGraphics::Destroy()
90 GlImplementation& EglGraphics::GetGlesInterface()
95 Integration::GlAbstraction& EglGraphics::GetGlAbstraction() const
97 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
101 EglImplementation& EglGraphics::GetEglImplementation() const
103 DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
104 return *mEglImplementation;
107 EglInterface& EglGraphics::GetEglInterface() const
109 DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
110 EglInterface* eglInterface = mEglImplementation.get();
111 return *eglInterface;
114 EglSyncImplementation& EglGraphics::GetSyncImplementation()
116 DALI_ASSERT_DEBUG( mEglSync && "EglSyncImplementation not created" );
120 EglContextHelperImplementation& EglGraphics::GetContextHelperImplementation()
122 DALI_ASSERT_DEBUG( mEglContextHelper && "EglContextHelperImplementation not created" );
123 return *mEglContextHelper;
126 EglImageExtensions* EglGraphics::GetImageExtensions()
128 DALI_ASSERT_DEBUG( mEglImageExtensions && "EglImageExtensions not created" );
129 return mEglImageExtensions.get();