Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / linux / system-factory-ecore.cpp
1 /*
2  * Copyright (c) 2023 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 // CLASS HEADER
18 #include <dali/internal/system/linux/system-factory-ecore.h>
19
20 // INTERNAL HEADERS
21 #include <dali/internal/adaptor/common/framework-factory.h>
22 #include <dali/internal/system/glib/callback-manager-glib.h>
23 #include <dali/internal/system/glib/file-descriptor-monitor-glib.h>
24 #include <dali/internal/system/glib/timer-impl-glib.h>
25 #include <dali/internal/system/linux/callback-manager-ecore.h>
26 #include <dali/internal/system/linux/file-descriptor-monitor-ecore.h>
27 #include <dali/internal/system/linux/timer-impl-ecore.h>
28 #include <dali/internal/window-system/common/display-utils.h>
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34 namespace Adaptor
35 {
36 std::unique_ptr<CallbackManager> SystemFactoryEcore::CreateCallbackManager()
37 {
38   auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
39   if(backend == FrameworkBackend::GLIB)
40   {
41     return Utils::MakeUnique<GlibCallbackManager>();
42   }
43   else
44   {
45     return Utils::MakeUnique<EcoreCallbackManager>();
46   }
47 }
48
49 std::unique_ptr<FileDescriptorMonitor> SystemFactoryEcore::CreateFileDescriptorMonitor(int fileDescriptor, CallbackBase* callback, int eventBitmask)
50 {
51   auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
52   if(backend == FrameworkBackend::GLIB)
53   {
54     return Utils::MakeUnique<FileDescriptorMonitorGlib>(fileDescriptor, callback, eventBitmask);
55   }
56   else
57   {
58     return Utils::MakeUnique<FileDescriptorMonitorEcore>(fileDescriptor, callback, eventBitmask);
59   }
60 }
61
62 TimerPtr SystemFactoryEcore::CreateTimer(uint32_t milliSec)
63 {
64   auto backend = Dali::Internal::Adaptor::GetFrameworkFactory()->GetFrameworkBackend();
65   if(backend == FrameworkBackend::GLIB)
66   {
67     return TimerGlib::New(milliSec);
68   }
69   else
70   {
71     return TimerEcore::New(milliSec);
72   }
73 }
74
75 std::unique_ptr<SystemFactory> GetSystemFactory()
76 {
77   return Utils::MakeUnique<SystemFactoryEcore>();
78 }
79
80 } // namespace Adaptor
81 } // namespace Internal
82 } // namespace Dali