Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-graphics.cpp
1 /*
2  * Copyright (c) 2018 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
42 void EglGraphics::Initialize( EnvironmentOptions* environmentOptions )
43 {
44   if( environmentOptions->GetGlesCallTime() > 0 )
45   {
46     mGLES = Utils::MakeUnique< GlProxyImplementation >( *environmentOptions );
47   }
48   else
49   {
50     mGLES.reset ( new GlImplementation() );
51   }
52
53   mDepthBufferRequired = static_cast< Integration::DepthBufferAvailable >( environmentOptions->DepthBufferRequired() );
54   mStencilBufferRequired = static_cast< Integration::StencilBufferAvailable >( environmentOptions->StencilBufferRequired() );
55
56   mMultiSamplingLevel = environmentOptions->GetMultiSamplingLevel();
57
58   mEglSync = Utils::MakeUnique< EglSyncImplementation >();
59 }
60
61 EglInterface* EglGraphics::Create()
62 {
63   mEglImplementation = Utils::MakeUnique< EglImplementation >( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired );
64   mEglImageExtensions = Utils::MakeUnique< EglImageExtensions >( mEglImplementation.get() );
65
66   mEglSync->Initialize( mEglImplementation.get() ); // The sync impl needs the EglDisplay
67
68   return mEglImplementation.get();
69 }
70
71 void EglGraphics::Destroy()
72 {
73 }
74
75 GlImplementation& EglGraphics::GetGlesInterface()
76 {
77   return *mGLES;
78 }
79
80 Integration::GlAbstraction& EglGraphics::GetGlAbstraction() const
81 {
82   DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
83   return *mGLES;
84 }
85
86 EglImplementation& EglGraphics::GetEglImplementation() const
87 {
88   DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
89   return *mEglImplementation;
90 }
91
92 EglInterface& EglGraphics::GetEglInterface() const
93 {
94   DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
95   EglInterface* eglInterface = mEglImplementation.get();
96   return *eglInterface;
97 }
98
99 EglSyncImplementation& EglGraphics::GetSyncImplementation()
100 {
101   DALI_ASSERT_DEBUG( mEglSync && "EglSyncImplementation not created" );
102   return *mEglSync;
103 }
104
105 EglImageExtensions* EglGraphics::GetImageExtensions()
106 {
107   DALI_ASSERT_DEBUG( mEglImageExtensions && "EglImageExtensions not created" );
108   return mEglImageExtensions.get();
109 }
110
111 } // Adaptor
112 } // Internal
113 } // Dali