Merge "[macos] Prevent race condition while creating the EGL Window" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / macos / display-connection-impl-mac.cpp
1 /*
2  * Copyright (c) 2020 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  // CLASS HEADER
19 #include <EGL/egl.h>
20 #include <dali/internal/window-system/macos/display-connection-impl-mac.h>
21
22 // EXTERNAL INCLUDES
23 #include <dali/integration-api/debug.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/graphics/gles/egl-graphics.h>
27
28 namespace Dali::Internal::Adaptor
29 {
30
31 DisplayConnection* DisplayConnectionCocoa::New()
32 {
33   return new DisplayConnectionCocoa();
34 }
35
36 DisplayConnectionCocoa::DisplayConnectionCocoa()
37 : mGraphics(nullptr)
38 {
39 }
40
41 DisplayConnectionCocoa::~DisplayConnectionCocoa()
42 {
43 }
44
45 Any DisplayConnectionCocoa::GetDisplay()
46 {
47   return EGL_DEFAULT_DISPLAY;
48 }
49
50 void DisplayConnectionCocoa::ConsumeEvents()
51 {
52 }
53
54 bool DisplayConnectionCocoa::InitializeEgl(EglInterface& egl)
55 {
56   EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );
57
58   if(!eglImpl.InitializeGles(EGL_DEFAULT_DISPLAY))
59   {
60     DALI_LOG_ERROR( "Failed to initialize GLES.\n" );
61     return false;
62   }
63
64   return true;
65 }
66
67 bool DisplayConnectionCocoa::InitializeGraphics()
68 {
69   auto eglGraphics = static_cast<EglGraphics *>( mGraphics );
70   EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
71
72   if(!eglImpl.InitializeGles(EGL_DEFAULT_DISPLAY))
73   {
74     DALI_LOG_ERROR( "Failed to initialize GLES.\n" );
75     return false;
76   }
77
78   return true;
79 }
80
81 void DisplayConnectionCocoa::SetSurfaceType( Dali::RenderSurfaceInterface::Type type )
82 {
83 }
84
85 void DisplayConnectionCocoa::SetGraphicsInterface( GraphicsInterface& graphics )
86 {
87   mGraphics = &graphics;
88 }
89
90 } // namespace Dali::Internal::Adaptor