e13ce0b0cbc31b1aa8ebb26f172ffaf5bf0d7577
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-graphics.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18
19 // CLASS HEADER
20 #include <dali/internal/graphics/gles/egl-graphics.h>
21
22 // INTERNAL INCLUDES
23 #include <dali/internal/window-system/common/display-utils.h> // For Utils::MakeUnique
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 namespace Adaptor
30 {
31
32 EglGraphics::EglGraphics( )
33 : mMultiSamplingLevel( 0 )
34 {
35 }
36
37 EglGraphics::~EglGraphics()
38 {
39 }
40
41 void EglGraphics::SetGlesVersion( const int32_t glesVersion )
42 {
43   mEglImplementation->SetGlesVersion( glesVersion );
44   mGLES->SetGlesVersion( glesVersion );
45 }
46
47 void EglGraphics::SetIsSurfacelessContextSupported( const bool isSupported )
48 {
49   mGLES->SetIsSurfacelessContextSupported( isSupported );
50 }
51
52 void EglGraphics::Initialize( EnvironmentOptions* environmentOptions )
53 {
54   if( environmentOptions->GetGlesCallTime() > 0 )
55   {
56     mGLES = Utils::MakeUnique< GlProxyImplementation >( *environmentOptions );
57   }
58   else
59   {
60     mGLES.reset ( new GlImplementation() );
61   }
62
63   mDepthBufferRequired = static_cast< Integration::DepthBufferAvailable >( environmentOptions->DepthBufferRequired() );
64   mStencilBufferRequired = static_cast< Integration::StencilBufferAvailable >( environmentOptions->StencilBufferRequired() );
65   mPartialUpdateRequired = static_cast< Integration::PartialUpdateAvailable >( environmentOptions->PartialUpdateRequired() );
66
67   mMultiSamplingLevel = environmentOptions->GetMultiSamplingLevel();
68
69   mEglSync = Utils::MakeUnique< EglSyncImplementation >();
70
71   mEglContextHelper = Utils::MakeUnique< EglContextHelperImplementation >();
72 }
73
74 EglInterface* EglGraphics::Create()
75 {
76   mEglImplementation = Utils::MakeUnique< EglImplementation >( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired, mPartialUpdateRequired );
77   mEglImageExtensions = Utils::MakeUnique< EglImageExtensions >( mEglImplementation.get() );
78
79   mEglSync->Initialize( mEglImplementation.get() ); // The sync impl needs the EglDisplay
80
81   mEglContextHelper->Initialize( mEglImplementation.get() ); // The context helper impl needs the EglContext
82
83   return mEglImplementation.get();
84 }
85
86 void EglGraphics::Destroy()
87 {
88 }
89
90 GlImplementation& EglGraphics::GetGlesInterface()
91 {
92   return *mGLES;
93 }
94
95 Integration::GlAbstraction& EglGraphics::GetGlAbstraction() const
96 {
97   DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
98   return *mGLES;
99 }
100
101 EglImplementation& EglGraphics::GetEglImplementation() const
102 {
103   DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
104   return *mEglImplementation;
105 }
106
107 EglInterface& EglGraphics::GetEglInterface() const
108 {
109   DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
110   EglInterface* eglInterface = mEglImplementation.get();
111   return *eglInterface;
112 }
113
114 EglSyncImplementation& EglGraphics::GetSyncImplementation()
115 {
116   DALI_ASSERT_DEBUG( mEglSync && "EglSyncImplementation not created" );
117   return *mEglSync;
118 }
119
120 EglContextHelperImplementation& EglGraphics::GetContextHelperImplementation()
121 {
122   DALI_ASSERT_DEBUG( mEglContextHelper && "EglContextHelperImplementation not created" );
123   return *mEglContextHelper;
124 }
125
126 EglImageExtensions* EglGraphics::GetImageExtensions()
127 {
128   DALI_ASSERT_DEBUG( mEglImageExtensions && "EglImageExtensions not created" );
129   return mEglImageExtensions.get();
130 }
131
132 void EglGraphics::SetDamagedAreas(std::vector<Dali::Rect<int>>& areas)
133 {
134   mEglImplementation->SetDamageAreas(areas);
135 }
136
137 void EglGraphics::SetFullSwapNextFrame()
138 {
139   mEglImplementation->SetFullSwapNextFrame();
140 }
141
142 } // Adaptor
143 } // Internal
144 } // Dali