Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / FUi_EcoreEvasMgr.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FUi_EcoreEvasMgr.cpp
19  * @brief               This is the implementation file for the _EcoreEvasMgr class.
20  */
21 #include <new>
22 #include <FBaseErrors.h>
23 #include <FBaseSysLog.h>
24 #include "FUi_EcoreEvasMgr.h"
25 #include "FUi_EcoreEvas.h"
26
27 using namespace Tizen::Ui;
28
29 namespace
30 {
31 _EcoreEvasMgr* __pEcoreEvasMgr = null;
32 } // Anonymous
33
34 namespace Tizen { namespace Ui
35 {
36
37 _EcoreEvasMgr::_EcoreEvasMgr(void)
38         : __pEcoreEvas(null)
39 {
40 }
41
42 _EcoreEvasMgr::~_EcoreEvasMgr(void)
43 {
44 }
45
46 void
47 _EcoreEvasMgr::SetEcoreEvas(const _EcoreEvas& ecoreEvas)
48 {
49         __pEcoreEvas = &ecoreEvas;
50 }
51
52 _EcoreEvas*
53 _EcoreEvasMgr::GetEcoreEvas(void) const
54 {
55         return const_cast<_EcoreEvas*>(__pEcoreEvas);
56 }
57
58 void
59 _EcoreEvasMgr::BeginMainLoop(void)
60 {
61         ecore_main_loop_begin();
62 }
63
64 void
65 _EcoreEvasMgr::EndMainLoop(void)
66 {
67         ecore_main_loop_quit();
68 }
69
70 void
71 _EcoreEvasMgr::SetRenderBackend(int backend)
72 {
73         GetEcoreEvas()->SetRenderBackend((_RenderBackend)backend);
74 }
75
76 int
77 _EcoreEvasMgr::GetRenderBackend(void)
78 {
79         return GetEcoreEvas()->GetRenderBackend();
80 }
81
82 void
83 DestroyEcoreEvasMgr(void)
84 {
85         _EcoreEvasMgr* pEcoreEvasMgr = GetEcoreEvasMgr();
86
87         if (pEcoreEvasMgr)
88         {
89                 _EcoreEvas* pEcoreEvas = pEcoreEvasMgr->GetEcoreEvas();
90                 if (pEcoreEvas)
91                 {
92                         delete pEcoreEvas;
93                 }
94         }
95
96         delete __pEcoreEvasMgr;
97         __pEcoreEvasMgr = null;
98 }
99
100 _EcoreEvasMgr*
101 GetEcoreEvasMgr(void)
102 {
103         if (__pEcoreEvasMgr)
104         {
105                 return __pEcoreEvasMgr;
106         }
107
108         __pEcoreEvasMgr = new (std::nothrow) _EcoreEvasMgr;
109
110         return __pEcoreEvasMgr;
111 }
112
113 }} // Tizen::Ui