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