Boost::any replacement in Dali Adaptor
[platform/core/uifw/dali-adaptor.git] / capi / dali / public-api / adaptor-framework / common / render-surface.h
1 #ifndef __DALI_RENDER_SURFACE_H__
2 #define __DALI_RENDER_SURFACE_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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  * @addtogroup CAPI_DALI_ADAPTOR_MODULE
22  * @{
23  */
24
25 // EXTERNAL INCLUDES
26 #include <string>
27 #include <dali/public-api/math/rect.h>
28 #include <dali/public-api/object/any.h>
29
30 namespace Dali DALI_IMPORT_API
31 {
32
33 /**
34  * @brief The position and size of the render surface.
35  */
36 typedef Dali::Rect<int> PositionSize;
37
38 /**
39  * @brief Interface for a render surface onto which Dali draws.
40  *
41  * Dali::Adaptor requires a render surface to draw on to. This is
42  * usually a window in the native windowing system, or some other
43  * mapped pixel buffer.
44  *
45  * Dali::Application will automatically create a render surface using a window.
46  *
47  * The implementation of the factory method below should choose an appropriate
48  * implementation of RenderSurface for the given platform
49  */
50 class RenderSurface
51 {
52 public:
53   /**
54    * @brief enumeration of surface types
55    */
56   enum SurfaceType
57   {
58     NO_SURFACE,     ///< not configured
59     PIXMAP,         ///< Pixmap
60     WINDOW,         ///< Window
61     NATIVE_BUFFER   ///< Native Buffer
62   };
63
64   /**
65    * @brief When application uses pixmap surface, it can select rendering mode.
66    *
67    * RENDER_SYNC : application should call RenderSync() after posting the offscreen to onscreen
68    * RENDER_#FPS : the maximum performance will be limited designated number of frame
69    */
70   enum RenderMode
71   {
72     RENDER_DEFAULT = -1,
73     RENDER_SYNC = 0,
74     RENDER_24FPS = 24,
75     RENDER_30FPS = 30,
76     RENDER_60FPS = 60
77   };
78
79   /**
80    * @brief Constructor
81    *
82    * Application or Adaptor needs to create the appropriate concrete RenderSurface type.
83    * @see CreateDefaultSurface
84    */
85   RenderSurface();
86
87   /**
88    * @brief Virtual Destructor.
89   */
90   virtual ~RenderSurface();
91
92   /**
93    * @brief returns the surface type.
94    * @return the surface type
95    */
96   virtual SurfaceType GetType() = 0;
97
98   /**
99    * @brief Returns the window or pixmap surface.
100    * @return surface
101    */
102   virtual Any GetSurface() = 0;
103
104   /**
105    * @brief Returns the display.
106    * @return display
107    */
108   virtual Any GetDisplay() = 0;
109
110   /**
111    * @brief Return the size and position of the surface.
112    * @return The position and size
113    */
114   virtual PositionSize GetPositionSize() const = 0;
115
116   /**
117    * @brief Set frame update rate for pixmap surface type
118    */
119   virtual void SetRenderMode(RenderMode mode) = 0;
120
121   /**
122    * @brief Get current fps for pixmap surface type
123    * @return The render mode
124    */
125   virtual RenderMode GetRenderMode() const = 0;
126
127 private:
128
129   /**
130    * @brief Undefined copy constructor. RenderSurface cannot be copied
131    */
132   RenderSurface( const RenderSurface& rhs );
133
134   /**
135    * @brief Undefined assignment operator. RenderSurface cannot be copied
136    */
137   RenderSurface& operator=( const RenderSurface& rhs );
138
139 };
140
141 /**
142  * @brief Default surface factory function.
143  *
144  * A surface is created with the given type.
145  *
146  * @param [in] type the type of surface to create
147  * @param [in] positionSize the position and size of the surface to create
148  * @param [in] name optional name of surface passed in
149  * @return The render surface
150  */
151 RenderSurface* CreateDefaultSurface( RenderSurface::SurfaceType type, PositionSize positionSize, const std::string& name = "" );
152
153 } // namespace Dali
154
155 /**
156  * @}
157  */
158 #endif // __DALI_RENDER_SURFACE_H__