[4.0] Change NativeImageSourceQueue
[platform/core/uifw/dali-adaptor.git] / adaptors / devel-api / adaptor-framework / native-image-source-queue.h
1 #ifndef DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
2 #define DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
3
4 /*
5  * Copyright (c) 2018 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 <dali/public-api/images/native-image-interface.h>
23 #include <dali/public-api/object/any.h>
24 #include <memory>
25
26 namespace Dali
27 {
28 /**
29  * @addtogroup dali_adaptor_framework
30  * @{
31  */
32
33 namespace Internal DALI_INTERNAL
34 {
35 namespace Adaptor
36 {
37 class NativeImageSourceQueue;
38 }
39 }
40
41 class NativeImageSourceQueue;
42
43 /**
44  * @brief Pointer to Dali::NativeImageSourceQueue.
45  */
46 typedef Dali::IntrusivePtr< Dali::NativeImageSourceQueue > NativeImageSourceQueuePtr;
47
48 /**
49  * @brief Used for displaying native images.
50  *
51  * NativeImageSource can be created internally or externally by native image source.
52  * NativeImage is a platform specific way of providing pixel data to the GPU for rendering,for example via an EGL image.
53  */
54 class DALI_IMPORT_API NativeImageSourceQueue : public NativeImageInterface
55 {
56 public:
57
58    /**
59     * @brief Enumeration for the instance when creating a native image, the color depth has to be specified.
60     */
61    enum ColorDepth
62    {
63      COLOR_DEPTH_DEFAULT,     ///< Uses the current screen default depth (recommended)
64      COLOR_DEPTH_24,          ///< 24 bits per pixel
65      COLOR_DEPTH_32           ///< 32 bits per pixel
66    };
67
68   /**
69    * @brief Creates a new NativeImageSourceQueue.
70    *        Depending on hardware, the width and height may have to be a power of two.
71    * @param[in] width The width of the image
72    * @param[in] height The height of the image
73    * @param[in] depth color depth of the image
74    * @return A smart-pointer to a newly allocated image
75    */
76   static NativeImageSourceQueuePtr New( uint32_t width, uint32_t height, ColorDepth depth );
77
78   /**
79    * @brief Creates a new NativeImageSourceQueue from an existing native image source.
80    *
81    * @param[in] nativeImageSourceQueue NativeImageSourceQueue must be a any handle with native image source
82    * @return A smart-pointer to a newly allocated image
83    * @see NativeImageInterface
84    */
85   static NativeImageSourceQueuePtr New( Any nativeImageSourceQueue );
86
87   /**
88    * @brief Retrieves the internal native image.
89    *
90    * @return Any object containing the internal native image source queue
91    */
92   Any GetNativeImageSourceQueue();
93
94   /**
95    * @brief Sets the size of the image.
96    *
97    * @param[in] width The width of the image
98    * @param[in] height The height of the image
99    */
100   void SetSize( uint32_t width, uint32_t height );
101
102 private:   // native image
103
104   /**
105    * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
106    */
107   virtual bool GlExtensionCreate();
108
109   /**
110    * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
111    */
112   virtual void GlExtensionDestroy();
113
114   /**
115    * @copydoc Dali::NativeImageInterface::TargetTexture()
116    */
117   virtual uint32_t TargetTexture();
118
119   /**
120    * @copydoc Dali::NativeImageInterface::PrepareTexture()
121    */
122   virtual void PrepareTexture();
123
124   /**
125    * @copydoc Dali::NativeImageInterface::GetWidth()
126    */
127   virtual uint32_t GetWidth() const;
128
129   /**
130    * @copydoc Dali::NativeImageInterface::GetHeight()
131    */
132   virtual uint32_t GetHeight() const;
133
134   /**
135    * @copydoc Dali::NativeImageInterface::RequiresBlending()
136    */
137   virtual bool RequiresBlending() const;
138
139   /**
140    * @copydoc Dali::NativeImageInterface::GetExtension()
141    */
142   NativeImageInterface::Extension* GetExtension();
143
144 private:
145
146   /// @cond internal
147   /**
148    * @brief Private constructor.
149    * @param[in] width The width of the image
150    * @param[in] height The height of the image
151    * @param[in] depth color depth of the image
152    * @param[in] nativeImageSourceQueue contains either: native image source or is empty
153    */
154   DALI_INTERNAL NativeImageSourceQueue( uint32_t width, uint32_t height, ColorDepth depth, Any nativeImageSourceQueue );
155
156   /**
157    * @brief A reference counted object may only be deleted by calling Unreference().
158    *
159    * The implementation should destroy the NativeImage resources.
160    */
161   DALI_INTERNAL virtual ~NativeImageSourceQueue();
162
163   /**
164    * @brief Undefined copy constructor.
165    *
166    * This avoids accidental calls to a default copy constructor.
167    * @param[in] nativeImageSourceQueue A reference to the object to copy
168    */
169   DALI_INTERNAL NativeImageSourceQueue( const NativeImageSourceQueue& nativeImageSourceQueue );
170
171   /**
172    * @brief Undefined assignment operator.
173    *
174    * This avoids accidental calls to a default assignment operator.
175    * @param[in] rhs A reference to the object to copy
176    */
177   DALI_INTERNAL NativeImageSourceQueue& operator=(const NativeImageSourceQueue& rhs);
178   /// @endcond
179
180 private:
181
182   /// @cond internal
183   std::unique_ptr< Internal::Adaptor::NativeImageSourceQueue > mImpl; ///< Implementation pointer
184   /// @endcond
185 };
186
187 /**
188  * @}
189  */
190 } // namespace Dali
191
192 #endif // DALI_NATIVE_IMAGE_SOURCE_QUEUE_H