Added spec to build for wearable
[platform/core/uifw/dali-adaptor.git] / adaptors / mobile / mobile-native-buffer-render-surface.h
1 #ifndef __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
2 #define __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__
3
4 /*
5  * Copyright (c) 2014 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 // EXTERNAL INCLUDES
22 #include <native-buffer-pool.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24
25 // INTERNAL INCLUDES
26 #include <ecore-x-render-surface.h>
27
28 using namespace std;
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38
39 namespace ECore
40 {
41
42 /**
43  * NativeBuffer API compatible implementation of RenderSurface.
44  */
45 class NativeBufferRenderSurface : public RenderSurface
46 {
47 public:
48
49   /**
50    * Constructor
51    */
52   NativeBufferRenderSurface( native_buffer_provider* provider,
53                              native_buffer_pool* pool,
54                              unsigned int maxBufferCount,
55                              Dali::PositionSize positionSize,
56                              Any surface,
57                              Any display,
58                              const std::string& name,
59                              bool isTransparent );
60
61   /**
62    * Destructor
63    */
64   virtual ~NativeBufferRenderSurface();
65
66 public: // API
67
68   /**
69    * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::GetDrawable()
70    */
71   virtual Ecore_X_Drawable GetDrawable();
72
73 public: // from Dali::RenderSurface
74
75   /**
76    * @copydoc Dali::RenderSurface::GetType()
77    */
78   virtual Dali::RenderSurface::SurfaceType GetType();
79
80   /**
81    * @copydoc Dali::RenderSurface::GetSurface()
82    */
83   virtual Any GetSurface();
84
85 public: // from Internal::Adaptor::RenderSurface
86
87   /// @copydoc Dali::Internal::Adaptor::RenderSurface::InitializeEgl
88   virtual void InitializeEgl( EglInterface& egl );
89
90   /// @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface
91   virtual void CreateEglSurface( EglInterface& egl );
92
93   /// @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface
94   virtual void DestroyEglSurface( EglInterface& egl );
95
96   /// @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface
97   virtual bool ReplaceEGLSurface( EglInterface& egl );
98
99   /// @copydoc Dali::RenderSurface::PreRender
100   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
101
102   /// @copydoc Dali::RenderSurface::PostRender
103   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, SyncMode syncMode );
104
105 protected:
106
107   /**
108    * Create XWindow
109    */
110   virtual void CreateXRenderable();
111
112   /**
113    * @copydoc Dali::Internal::Adaptor::ECore::RenderSurface::UseExistingRenderable
114    */
115   virtual void UseExistingRenderable( unsigned int surfaceId );
116
117 private:
118   /**
119    * Create native buffer
120    */
121   native_buffer* CreateNativeBuffer();
122
123 private: // Data
124   native_buffer_provider*              mProvider;
125   native_buffer_pool*                  mPool;
126
127   typedef std::vector<native_buffer*>  NativeBufferContainer;
128   NativeBufferContainer                mBuffers;
129
130   unsigned int                         mMaxBufferCount;
131   bool                                 mIsAcquired;
132 }; // class NativeBufferRenderSurface
133
134 } // namespace ECore
135
136 } // namespace Adaptor
137
138 } // namespace internal
139
140 } // namespace Dali
141
142 #endif // __DALI_INTERNAL_NATIVE_BUFFER_RENDER_SURFACE_H__