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