Support post render callback
[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   /**
56    * @copydoc Dali::Pepper::Compositor::GetName()
57    */
58   const std::string& GetName() const;
59
60   void* GetCompositorHandle();
61
62 public: //Signals
63
64   Pepper::Compositor::CompositorSignalType& ObjectViewAddedSignal();
65   Pepper::Compositor::CompositorSignalType& ObjectViewDeletedSignal();
66
67 private:
68
69   /**
70    * Construct a new Compositor.
71    */
72   Compositor();
73
74   /**
75    * A reference counted object may only be deleted by calling Unreference()
76    */
77   virtual ~Compositor();
78
79   /**
80    * Second-phase constructor. Must be called immediately after creating a new Compositor;
81    */
82   void Initialize( Application application, const std::string& name );
83
84   int GetSocketFdFromServer();
85
86   void OnObjectViewAdded( Pepper::Output output, Pepper::ObjectView obejctView );
87   void OnObjectViewDeleted( Pepper::Output output, Pepper::ObjectView objectView );
88
89   static Eina_Bool FdReadCallback( void* data, Ecore_Fd_Handler* handler );
90   static void FdPrepareCallback( void* data, Ecore_Fd_Handler* handler );
91
92 private:
93
94   // Undefined
95   Compositor( const Compositor& );
96
97   // Undefined
98   Compositor& operator=( const Compositor& rhs );
99
100 private: // Data
101
102   pepper_compositor_t* mCompositor;
103   wl_display* mDisplay;
104   wl_event_loop* mEventLoop;
105   Ecore_Fd_Handler* mFdHandler;
106   wayland_tbm_server* mTbmServer;
107
108   Pepper::Shell mShell;
109   Pepper::Input mInput;
110   Pepper::Output mOutput;
111
112   std::string mSocketName;
113
114   // Signals
115   Pepper::Compositor::CompositorSignalType mObjectViewAddedSignal;
116   Pepper::Compositor::CompositorSignalType mObjectViewDeletedSignal;
117 };
118
119 } // namespace Internal
120
121 // Helpers for public-api forwarding methods
122
123 inline Pepper::Internal::Compositor& GetImplementation( Pepper::Compositor& compositor )
124 {
125   DALI_ASSERT_ALWAYS( compositor && "Compositor handle is empty" );
126
127   BaseObject& handle = compositor.GetBaseObject();
128
129   return static_cast< Internal::Compositor& >( handle );
130 }
131
132 inline const Pepper::Internal::Compositor& GetImplementation( const Pepper::Compositor& compositor )
133 {
134   DALI_ASSERT_ALWAYS( compositor && "Compositor handle is empty" );
135
136   const BaseObject& handle = compositor.GetBaseObject();
137
138   return static_cast< const Internal::Compositor& >( handle );
139 }
140
141 } // namespace Pepper
142
143 } // namespace Dali
144
145 #endif // __DALI_PEPPER_INTERNAL_COMPOSITOR_H__