Add pepper-dali
[platform/core/uifw/pepper-dali.git] / pepper-dali / internal / compositor-impl.h
1 #ifndef __DALI_PEPPER_INTERNAL_COMPOSITOR_H__
2 #define __DALI_PEPPER_INTERNAL_COMPOSITOR_H__
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <pepper-dali/public-api/compositor/compositor.h>
23 #include <pepper-dali/internal/shell.h>
24 #include <pepper-dali/internal/input.h>
25 #include <pepper-dali/internal/output.h>
26
27 // EXTERNAL INCLUDES
28 #include <dali/public-api/object/base-object.h>
29 #include <dali/public-api/signals/connection-tracker.h>
30 #include <pepper.h>
31 #include <wayland-tbm-server.h>
32 #include <Ecore.h>
33
34 namespace Dali
35 {
36
37 namespace Pepper
38 {
39
40 namespace Internal
41 {
42
43 class Compositor;
44 typedef IntrusivePtr<Compositor> CompositorPtr;
45
46 class Compositor : public BaseObject, public ConnectionTracker
47 {
48 public:
49
50   /**
51    * @copydoc Dali::Pepper::Compositor::New()
52    */
53   static CompositorPtr New( Application application, const std::string& name );
54
55   void* GetCompositorHandle();
56
57 public: //Signals
58
59   Pepper::Compositor::CompositorSignalType& ObjectViewAddedSignal();
60   Pepper::Compositor::CompositorSignalType& ObjectViewDeletedSignal();
61
62 private:
63
64   /**
65    * Construct a new Compositor.
66    */
67   Compositor();
68
69   /**
70    * A reference counted object may only be deleted by calling Unreference()
71    */
72   virtual ~Compositor();
73
74   /**
75    * Second-phase constructor. Must be called immediately after creating a new Compositor;
76    */
77   void Initialize( Application application, const std::string& name );
78
79   int GetSocketFdFromServer();
80
81   void OnObjectViewAdded( Pepper::Output output, Pepper::ObjectView obejctView );
82   void OnObjectViewDeleted( Pepper::Output output, Pepper::ObjectView objectView );
83
84   static Eina_Bool FdReadCallback( void* data, Ecore_Fd_Handler* handler );
85   static void FdPrepareCallback( void* data, Ecore_Fd_Handler* handler );
86
87 private:
88
89   // Undefined
90   Compositor( const Compositor& );
91
92   // Undefined
93   Compositor& operator=( const Compositor& rhs );
94
95 private: // Data
96
97   pepper_compositor_t* mCompositor;
98   wl_display* mDisplay;
99   wl_event_loop* mEventLoop;
100   Ecore_Fd_Handler* mFdHandler;
101   wayland_tbm_server* mTbmServer;
102
103   Pepper::Shell mShell;
104   Pepper::Input mInput;
105   Pepper::Output mOutput;
106
107   std::string mSocketName;
108
109   // Signals
110   Pepper::Compositor::CompositorSignalType mObjectViewAddedSignal;
111   Pepper::Compositor::CompositorSignalType mObjectViewDeletedSignal;
112 };
113
114 } // namespace Internal
115
116 // Helpers for public-api forwarding methods
117
118 inline Pepper::Internal::Compositor& GetImplementation( Pepper::Compositor& compositor )
119 {
120   DALI_ASSERT_ALWAYS( compositor && "Compositor handle is empty" );
121
122   BaseObject& handle = compositor.GetBaseObject();
123
124   return static_cast< Internal::Compositor& >( handle );
125 }
126
127 inline const Pepper::Internal::Compositor& GetImplementation( const Pepper::Compositor& compositor )
128 {
129   DALI_ASSERT_ALWAYS( compositor && "Compositor handle is empty" );
130
131   const BaseObject& handle = compositor.GetBaseObject();
132
133   return static_cast< const Internal::Compositor& >( handle );
134 }
135
136 } // namespace Pepper
137
138 } // namespace Dali
139
140 #endif // __DALI_PEPPER_INTERNAL_COMPOSITOR_H__