[4.0] Add NativeImageSourceQueueX
[platform/core/uifw/dali-adaptor.git] / adaptors / x11 / native-image-source-queue-impl-x.h
1 #ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H
2 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_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/devel-api/images/native-image-interface-extension.h>
23
24 // INTERNAL INCLUDES
25 #include <native-image-source-queue-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace Adaptor
34 {
35
36 class EglImageExtensions;
37
38 /**
39  * Dali internal NativeImageSourceQueue.
40  */
41 class NativeImageSourceQueueX: public Internal::Adaptor::NativeImageSourceQueue, public NativeImageInterface::Extension
42 {
43 public:
44
45   /**
46    * Create a new NativeImageSourceQueueX internally.
47    * Depending on hardware the width and height may have to be a power of two.
48    * @param[in] width The width of the image.
49    * @param[in] height The height of the image.
50    * @param[in] depth color depth of the image.
51    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
52    * @return A smart-pointer to a newly allocated image.
53    */
54   static NativeImageSourceQueueX* New(unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
55
56   /**
57    * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
58    */
59   Any GetNativeImageSourceQueue() const override;
60
61   /**
62    * @copydoc Dali::NativeImageSourceQueue::SetSource( Any source )
63    */
64   void SetSource( Any source ) override;
65
66   /**
67    * destructor
68    */
69   ~NativeImageSourceQueueX() override;
70
71   /**
72    * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
73    */
74   bool GlExtensionCreate() override;
75
76   /**
77    * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
78    */
79   void GlExtensionDestroy() override;
80
81   /**
82    * @copydoc Dali::NativeImageInterface::TargetTexture()
83    */
84   unsigned int TargetTexture() override;
85
86   /**
87    * @copydoc Dali::NativeImageInterface::PrepareTexture()
88    */
89   void PrepareTexture() override;
90
91   /**
92    * @copydoc Dali::NativeImageInterface::GetWidth()
93    */
94   unsigned int GetWidth() const override
95   {
96     return mWidth;
97   }
98
99   /**
100    * @copydoc Dali::NativeImageInterface::GetHeight()
101    */
102   unsigned int GetHeight() const override
103   {
104     return mHeight;
105   }
106
107   /**
108    * @copydoc Dali::NativeImageInterface::RequiresBlending()
109    */
110   bool RequiresBlending() const override
111   {
112     return true;
113   }
114
115   /**
116    * @copydoc Dali::NativeImageInterface::GetExtension()
117    */
118   NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
119   {
120     return this;
121   }
122
123   /**
124    * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
125    */
126   const char* GetCustomFragmentPreFix() override;
127
128   /**
129    * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
130    */
131   const char* GetCustomSamplerTypename() override;
132
133   /**
134    * @copydoc Dali::NativeImageInterface::Extension::GetEglImageTextureTarget()
135    */
136   int GetEglImageTextureTarget() override;
137
138   /**
139    * @copydoc Dali::NativeImageInterface::Extension::SetDestructorNotification(void *notification)
140    */
141   void SetDestructorNotification( void* notification ) override;
142
143 private:
144
145   /**
146    * Private constructor; @see NativeImageSourceQueue::New()
147    * @param[in] width The width of the image.
148    * @param[in] height The height of the image.
149    * @param[in] colour depth of the image.
150    * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
151    */
152   NativeImageSourceQueueX( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
153
154 private:
155
156   unsigned int    mWidth;                ///< image width
157   unsigned int    mHeight;               ///< image height
158
159 };
160
161 } // namespace Adaptor
162
163 } // namespace Internal
164
165 } // namespace Dali
166
167 #endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_X_H